Date: Fri, 29 Apr 2011 21:09:03 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r221226 - projects/altix/sys/ia64/ia64 Message-ID: <201104292109.p3TL93LI015640@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Fri Apr 29 21:09:03 2011 New Revision: 221226 URL: http://svn.freebsd.org/changeset/base/221226 Log: Complete the AP wake-up revamp. Modified: projects/altix/sys/ia64/ia64/mp_locore.S projects/altix/sys/ia64/ia64/mp_machdep.c Modified: projects/altix/sys/ia64/ia64/mp_locore.S ============================================================================== --- projects/altix/sys/ia64/ia64/mp_locore.S Fri Apr 29 21:02:47 2011 (r221225) +++ projects/altix/sys/ia64/ia64/mp_locore.S Fri Apr 29 21:09:03 2011 (r221226) @@ -43,62 +43,81 @@ .align 32 ENTRY_NOPROFILE(os_boot_rendez,0) { .mmi + st8 [gp] = gp // trace = 0x00 mov r8 = cr.ivr // clear IRR bit + add r2 = 8, gp ;; - srlz.d - mov r16 = (IA64_PBVM_RR << 8) | (IA64_PBVM_PAGE_SHIFT << 2) } { .mmi + srlz.d mov cr.eoi = r0 // ACK the wake-up + add r3 = 16, gp ;; +} +{ .mmi srlz.d - dep.z r17 = IA64_PBVM_RR, 61, 3 + rsm IA64_PSR_IC | IA64_PSR_I + mov r16 = (IA64_PBVM_RR << 8) | (IA64_PBVM_PAGE_SHIFT << 2) ;; } { .mmi - rsm IA64_PSR_IC | IA64_PSR_I - mov rr[r17] = r16 - add r2 = 8, r1 + srlz.d + st8 [gp] = r2 // trace = 0x08 + dep.z r17 = IA64_PBVM_RR, 61, 3 ;; } { .mlx + mov rr[r17] = r16 + movl r18 = IA64_PBVM_PGTBL + ;; +} +{ .mmi srlz.i - movl r16 = IA64_PBVM_PGTBL + ;; + st8 [gp] = r3 // trace = 0x10 + nop 0 ;; } { .mmi - ld8 r17 = [r1], 16 // as_pgtbl_pte - ld8 r18 = [r2], 16 // as_pgtbl_itir - mov r8 = r0 + ld8 r16 = [r2], 16 // as_pgtbl_pte + ld8 r17 = [r3], 16 // as_pgtbl_itir + nop 0 ;; } { .mmi - mov cr.ifa = r16 - mov cr.itir = r18 - mov r9 = r0 + mov cr.itir = r17 + mov cr.ifa = r18 + nop 0 ;; } { .mmi srlz.d - ptr.d r16, r18 + ptr.d r18, r17 nop 0 ;; } { .mmi srlz.d - itr.d dtr[r8] = r17 - nop 0 + st8 [gp] = r2 // trace = 0x18 + mov r8 = r0 ;; } { .mmi + itr.d dtr[r8] = r16 + ;; srlz.d - ld8 r16 = [r1], 16 // as_text_va + mov r9 = r0 + ;; +} +{ .mmi + ld8 r16 = [r2], 16 // as_text_va + st8 [gp] = r3 // trace = 0x20 add r8 = 1, r8 ;; } { .mmi - ld8 r17 = [r2], 16 // as_text_pte - ld8 r18 = [r1], 16 // as_text_itir + ld8 r17 = [r3], 16 // as_text_pte + ld8 r18 = [r2], 16 // as_text_itir nop 0 ;; } @@ -116,12 +135,18 @@ ENTRY_NOPROFILE(os_boot_rendez,0) } { .mmi srlz.d - itr.d dtr[r8] = r17 + st8 [gp] = r3 // trace = 0x30 nop 0 ;; } { .mmi + itr.d dtr[r8] = r17 + ;; srlz.d + nop 0 +} +{ .mmi + st8 [gp] = r2 // trace = 0x38 ptr.i r16, r18 add r8 = 1, r8 ;; @@ -136,42 +161,51 @@ ENTRY_NOPROFILE(os_boot_rendez,0) { .mmi srlz.i ;; - ld8 r16 = [r2], 16 // as_data_va + ld8 r16 = [r3], 16 // as_data_va add r9 = 1, r9 ;; } { .mmi - ld8 r17 = [r1], 16 // as_data_pte - ld8 r18 = [r2], 16 // as_data_itir + st8 [gp] = r3 // trace = 0x40 + ld8 r17 = [r2], 16 // as_data_pte nop 0 ;; } { .mmi mov cr.ifa = r16 - mov cr.itir = r18 + ld8 r18 = [r3], 16 // as_data_itir nop 0 ;; } { .mmi + mov cr.itir = r18 + ;; srlz.d - ptr.d r16, r18 nop 0 ;; } { .mmi + ptr.d r16, r18 + ;; srlz.d - itr.d dtr[r8] = r17 mov r19 = IA64_DCR_DEFAULT ;; } { .mmi + itr.d dtr[r8] = r17 + ;; srlz.d - ld8 r16 = [r1], 16 // as_kstack add r8 = 1, r8 ;; } { .mmi - ld8 r17 = [r2], 16 // as_kstack_top + st8 [gp] = r2 // trace = 0x48 + ;; + ld8 r16 = [r2], 16 // as_kstack + nop 0 +} +{ .mmi + ld8 r17 = [r3], 16 // as_kstack_top mov cr.dcr = r19 nop 0 ;; @@ -182,52 +216,50 @@ ENTRY_NOPROFILE(os_boot_rendez,0) IA64_PSR_RT | IA64_PSR_DFH ;; } -1: -{ .mii +{ .mlx mov cr.ipsr = r18 - mov r19 = ip + movl r19 = ia64_vector_table // set up IVT early ;; - add r19 = 2f-1b, r19 +} +{ .mlx + mov cr.iva = r19 + movl r18 = 1f ;; } { .mmi + mov cr.iip = r18 mov cr.ifs = r0 - mov cr.iip = r19 nop 0 ;; } - +{ .mmb + srlz.d + st8 [gp] = r2 // trace = 0x58 rfi ;; +} .align 32 -2: +1: { .mlx - mov ar.rsc = 0 - movl r18 = ia64_vector_table // set up IVT early + mov ar.bspstore = r16 + movl gp = __gp ;; } { .mmi - mov cr.iva = r18 - ;; - srlz.i + loadrs + add sp = -16, r17 nop 0 ;; } -{ .mlx - mov ar.bspstore = r16 - movl gp = __gp - ;; -} { .mmi - loadrs + mov ar.rsc = 3 ;; alloc r18 = ar.pfs, 0, 0, 0, 0 - add sp = -16, r17 ;; } { .mib - mov ar.rsc = 3 + nop 0 nop 0 br.call.sptk.few rp = ia64_ap_startup ;; Modified: projects/altix/sys/ia64/ia64/mp_machdep.c ============================================================================== --- projects/altix/sys/ia64/ia64/mp_machdep.c Fri Apr 29 21:02:47 2011 (r221225) +++ projects/altix/sys/ia64/ia64/mp_machdep.c Fri Apr 29 21:09:03 2011 (r221226) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <sys/uuid.h> #include <machine/atomic.h> +#include <machine/bootinfo.h> #include <machine/cpu.h> #include <machine/fpu.h> #include <machine/intr.h> @@ -62,6 +63,8 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_extern.h> #include <vm/vm_kern.h> +extern uint64_t bdata[]; + MALLOC_DEFINE(M_SMP, "SMP", "SMP related allocations"); void ia64_ap_startup(void); @@ -81,6 +84,21 @@ int ia64_ipi_rndzvs; int ia64_ipi_stop; static u_int +sz2shft(uint64_t sz) +{ + uint64_t s; + u_int shft; + + shft = 12; /* Start with 4K */ + s = 1 << shft; + while (s < sz) { + shft++; + s <<= 1; + } + return (shft); +} + +static u_int ia64_ih_ast(struct thread *td, u_int xiv, struct trapframe *tf) { @@ -174,14 +192,25 @@ ia64_ap_startup(void) { uint64_t vhpt; + ia64_ap_state.as_trace = 0x100; + + ia64_set_rr(IA64_RR_BASE(5), (5 << 8) | (PAGE_SHIFT << 2) | 1); + ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (PAGE_SHIFT << 2)); + ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (PAGE_SHIFT << 2)); + ia64_srlz_d(); + pcpup = ia64_ap_state.as_pcpu; ia64_set_k4((intptr_t)pcpup); + ia64_ap_state.as_trace = 0x108; + vhpt = PCPU_GET(md.vhpt); map_vhpt(vhpt); ia64_set_pta(vhpt + (1 << 8) + (pmap_vhpt_log2size << 2) + 1); ia64_srlz_i(); + ia64_ap_state.as_trace = 0x110; + ia64_ap_state.as_awake = 1; ia64_ap_state.as_delay = 0; @@ -301,48 +330,73 @@ cpu_mp_start() struct ia64_sal_result result; struct ia64_fdesc *fd; struct pcpu *pc; + uintptr_t state; u_char *stp; - ia64_ap_state.as_spin = 1; - + state = ia64_tpa((uintptr_t)&ia64_ap_state); fd = (struct ia64_fdesc *) os_boot_rendez; result = ia64_sal_entry(SAL_SET_VECTORS, SAL_OS_BOOT_RENDEZ, - ia64_tpa(fd->func), ia64_tpa((uintptr_t)&ia64_ap_state), - 0, 0, 0, 0); + ia64_tpa(fd->func), state, 0, 0, 0, 0); + + ia64_ap_state.as_pgtbl_pte = PTE_PRESENT | PTE_MA_WB | + PTE_ACCESSED | PTE_DIRTY | PTE_PL_KERN | PTE_AR_RW | + (bootinfo->bi_pbvm_pgtbl & PTE_PPN_MASK); + ia64_ap_state.as_pgtbl_itir = sz2shft(bootinfo->bi_pbvm_pgtblsz) << 2; + ia64_ap_state.as_text_va = IA64_PBVM_BASE; + ia64_ap_state.as_text_pte = PTE_PRESENT | PTE_MA_WB | + PTE_ACCESSED | PTE_DIRTY | PTE_PL_KERN | PTE_AR_RX | + (ia64_tpa(IA64_PBVM_BASE) & PTE_PPN_MASK); + ia64_ap_state.as_text_itir = bootinfo->bi_text_mapped << 2; + ia64_ap_state.as_data_va = (uintptr_t)bdata; + ia64_ap_state.as_data_pte = PTE_PRESENT | PTE_MA_WB | + PTE_ACCESSED | PTE_DIRTY | PTE_PL_KERN | PTE_AR_RW | + (ia64_tpa((uintptr_t)bdata) & PTE_PPN_MASK); + ia64_ap_state.as_data_itir = bootinfo->bi_data_mapped << 2; + + /* Keep 'em spinning until we unleash them... */ + ia64_ap_state.as_spin = 1; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { pc->pc_md.current_pmap = kernel_pmap; pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask; - if (pc->pc_cpuid > 0) { - ia64_ap_state.as_pcpu = pc; - pc->pc_md.vhpt = pmap_alloc_vhpt(); - if (pc->pc_md.vhpt == 0) { - printf("SMP: WARNING: unable to allocate VHPT" - " for cpu%d", pc->pc_cpuid); - continue; - } - stp = malloc(KSTACK_PAGES * PAGE_SIZE, M_SMP, M_WAITOK); - ia64_ap_state.as_kstack = stp; - ia64_ap_state.as_kstack_top = stp + KSTACK_PAGES * - PAGE_SIZE - 16; - ia64_ap_state.as_delay = 2000; - ia64_ap_state.as_awake = 0; - - if (bootverbose) - printf("SMP: waking up cpu%d\n", pc->pc_cpuid); - - ipi_send(pc, ia64_ipi_wakeup); - - do { - DELAY(1000); - } while (--ia64_ap_state.as_delay > 0); - pc->pc_md.awake = ia64_ap_state.as_awake; - - if (!ia64_ap_state.as_awake) - printf("SMP: WARNING: cpu%d did not wake up\n", - pc->pc_cpuid); - } else + /* The BSP is obviously running already. */ + if (pc->pc_cpuid == 0) { pc->pc_md.awake = 1; + continue; + } + + ia64_ap_state.as_pcpu = pc; + pc->pc_md.vhpt = pmap_alloc_vhpt(); + if (pc->pc_md.vhpt == 0) { + printf("SMP: WARNING: unable to allocate VHPT" + " for cpu%d", pc->pc_cpuid); + continue; + } + + stp = malloc(KSTACK_PAGES * PAGE_SIZE, M_SMP, M_WAITOK); + ia64_ap_state.as_kstack = stp; + ia64_ap_state.as_kstack_top = stp + KSTACK_PAGES * PAGE_SIZE; + + ia64_ap_state.as_trace = 0; + ia64_ap_state.as_delay = 2000; + ia64_ap_state.as_awake = 0; + + if (bootverbose) + printf("SMP: waking up cpu%d\n", pc->pc_cpuid); + + /* Here she goes... */ + ipi_send(pc, ia64_ipi_wakeup); + do { + DELAY(1000); + } while (--ia64_ap_state.as_delay > 0); + + pc->pc_md.awake = ia64_ap_state.as_awake; + + if (!ia64_ap_state.as_awake) { + printf("SMP: WARNING: cpu%d did not wake up (code " + "%#lx)\n", pc->pc_cpuid, + ia64_ap_state.as_trace - state); + } } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104292109.p3TL93LI015640>