]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sparc64/sparc64/mp_machdep.c
add -n option to suppress clearing the build tree and add -DNO_CLEAN
[FreeBSD/FreeBSD.git] / sys / sparc64 / sparc64 / mp_machdep.c
1 /*-
2  * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  * 3. Berkeley Software Design Inc's name may not be used to endorse or
13  *    promote products derived from this software without specific prior
14  *    written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * from BSDI: locore.s,v 1.36.2.15 1999/08/23 22:34:41 cp Exp
29  */
30 /*-
31  * Copyright (c) 2002 Jake Burkholder.
32  * Copyright (c) 2007 Marius Strobl <marius@FreeBSD.org>
33  * All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  * 1. Redistributions of source code must retain the above copyright
39  *    notice, this list of conditions and the following disclaimer.
40  * 2. Redistributions in binary form must reproduce the above copyright
41  *    notice, this list of conditions and the following disclaimer in the
42  *    documentation and/or other materials provided with the distribution.
43  *
44  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
45  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  */
56
57 #include <sys/cdefs.h>
58 __FBSDID("$FreeBSD$");
59
60 #include <sys/param.h>
61 #include <sys/systm.h>
62 #include <sys/lock.h>
63 #include <sys/kdb.h>
64 #include <sys/kernel.h>
65 #include <sys/ktr.h>
66 #include <sys/mutex.h>
67 #include <sys/pcpu.h>
68 #include <sys/proc.h>
69 #include <sys/sched.h>
70 #include <sys/smp.h>
71
72 #include <vm/vm.h>
73 #include <vm/vm_param.h>
74 #include <vm/pmap.h>
75 #include <vm/vm_kern.h>
76 #include <vm/vm_extern.h>
77 #include <vm/vm_map.h>
78
79 #include <dev/ofw/openfirm.h>
80
81 #include <machine/asi.h>
82 #include <machine/atomic.h>
83 #include <machine/bus.h>
84 #include <machine/cpu.h>
85 #include <machine/md_var.h>
86 #include <machine/metadata.h>
87 #include <machine/ofw_machdep.h>
88 #include <machine/pcb.h>
89 #include <machine/smp.h>
90 #include <machine/tick.h>
91 #include <machine/tlb.h>
92 #include <machine/tte.h>
93 #include <machine/ver.h>
94
95 #define SUNW_STARTCPU           "SUNW,start-cpu"
96 #define SUNW_STOPSELF           "SUNW,stop-self"
97
98 static ih_func_t cpu_ipi_ast;
99 static ih_func_t cpu_ipi_preempt;
100 static ih_func_t cpu_ipi_stop;
101
102 /*
103  * Argument area used to pass data to non-boot processors as they start up.
104  * This must be statically initialized with a known invalid CPU module ID,
105  * since the other processors will use it before the boot CPU enters the
106  * kernel.
107  */
108 struct  cpu_start_args cpu_start_args = { 0, -1, -1, 0, 0, 0 };
109 struct  ipi_cache_args ipi_cache_args;
110 struct  ipi_tlb_args ipi_tlb_args;
111 struct  pcb stoppcbs[MAXCPU];
112
113 struct  mtx ipi_mtx;
114
115 cpu_ipi_selected_t *cpu_ipi_selected;
116
117 static vm_offset_t mp_tramp;
118 static u_int cpuid_to_mid[MAXCPU];
119 static int has_stopself;
120 static int isjbus;
121 static volatile u_int shutdown_cpus;
122
123 static void cpu_mp_unleash(void *v);
124 static void spitfire_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2);
125 static void sun4u_startcpu(phandle_t cpu, void *func, u_long arg);
126 static void sun4u_stopself(void);
127
128 static cpu_ipi_selected_t cheetah_ipi_selected;
129 static cpu_ipi_selected_t spitfire_ipi_selected;
130
131 SYSINIT(cpu_mp_unleash, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL);
132
133 CTASSERT(MAXCPU <= IDR_CHEETAH_MAX_BN_PAIRS);
134 CTASSERT(MAXCPU <= sizeof(u_int) * NBBY);
135 CTASSERT(MAXCPU <= sizeof(int) * NBBY);
136
137 void
138 mp_init(void)
139 {
140         struct tte *tp;
141         int i;
142
143         mp_tramp = (vm_offset_t)OF_claim(NULL, PAGE_SIZE, PAGE_SIZE);
144         if (mp_tramp == (vm_offset_t)-1)
145                 panic("%s", __func__);
146         bcopy(mp_tramp_code, (void *)mp_tramp, mp_tramp_code_len);
147         *(vm_offset_t *)(mp_tramp + mp_tramp_tlb_slots) = kernel_tlb_slots;
148         *(vm_offset_t *)(mp_tramp + mp_tramp_func) = (vm_offset_t)mp_startup;
149         tp = (struct tte *)(mp_tramp + mp_tramp_code_len);
150         for (i = 0; i < kernel_tlb_slots; i++) {
151                 tp[i].tte_vpn = TV_VPN(kernel_tlbs[i].te_va, TS_4M);
152                 tp[i].tte_data = TD_V | TD_4M | TD_PA(kernel_tlbs[i].te_pa) |
153                     TD_L | TD_CP | TD_CV | TD_P | TD_W;
154         }
155         for (i = 0; i < PAGE_SIZE; i += sizeof(vm_offset_t))
156                 flush(mp_tramp + i);
157
158         /*
159          * On UP systems cpu_ipi_selected() can be called while
160          * cpu_mp_start() wasn't so initialize these here.
161          */
162         if (cpu_impl == CPU_IMPL_ULTRASPARCIIIi ||
163             cpu_impl == CPU_IMPL_ULTRASPARCIIIip)
164                 isjbus = 1;
165         if (cpu_impl >= CPU_IMPL_ULTRASPARCIII)
166                 cpu_ipi_selected = cheetah_ipi_selected;
167         else
168                 cpu_ipi_selected = spitfire_ipi_selected;
169 }
170
171 /*
172  * Probe for other CPUs.
173  */
174 void
175 cpu_mp_setmaxid(void)
176 {
177         char buf[128];
178         phandle_t child;
179         u_int cpus;
180
181         all_cpus = 1 << curcpu;
182         mp_ncpus = 1;
183
184         cpus = 0;
185         for (child = OF_child(OF_peer(0)); child != 0; child = OF_peer(child))
186                 if (OF_getprop(child, "device_type", buf, sizeof(buf)) > 0 &&
187                     strcmp(buf, "cpu") == 0)
188                         cpus++;
189         mp_maxid = cpus - 1;
190 }
191
192 int
193 cpu_mp_probe(void)
194 {
195
196         return (mp_maxid > 0);
197 }
198
199 struct cpu_group *
200 cpu_topo(void)
201 {
202
203         return (smp_topo_none());
204 }
205
206 static void
207 sun4u_startcpu(phandle_t cpu, void *func, u_long arg)
208 {
209         static struct {
210                 cell_t  name;
211                 cell_t  nargs;
212                 cell_t  nreturns;
213                 cell_t  cpu;
214                 cell_t  func;
215                 cell_t  arg;
216         } args = {
217                 (cell_t)SUNW_STARTCPU,
218                 3,
219         };
220
221         args.cpu = cpu;
222         args.func = (cell_t)func;
223         args.arg = (cell_t)arg;
224         openfirmware(&args);
225 }
226
227 /*
228  * Stop the calling CPU.
229  */
230 static void
231 sun4u_stopself(void)
232 {
233         static struct {
234                 cell_t  name;
235                 cell_t  nargs;
236                 cell_t  nreturns;
237         } args = {
238                 (cell_t)SUNW_STOPSELF,
239         };
240
241         openfirmware_exit(&args);
242         panic("%s: failed.", __func__);
243 }
244
245 /*
246  * Fire up any non-boot processors.
247  */
248 void
249 cpu_mp_start(void)
250 {
251         char buf[128];
252         volatile struct cpu_start_args *csa;
253         struct pcpu *pc;
254         register_t s;
255         vm_offset_t va;
256         phandle_t child;
257         u_int mid;
258         u_int clock;
259         u_int cpuid;
260
261         mtx_init(&ipi_mtx, "ipi", NULL, MTX_SPIN);
262
263         if (OF_test(SUNW_STOPSELF) == 0)
264                 has_stopself = 1;
265
266         intr_setup(PIL_AST, cpu_ipi_ast, -1, NULL, NULL);
267         intr_setup(PIL_RENDEZVOUS, (ih_func_t *)smp_rendezvous_action,
268             -1, NULL, NULL);
269         intr_setup(PIL_STOP, cpu_ipi_stop, -1, NULL, NULL);
270         intr_setup(PIL_PREEMPT, cpu_ipi_preempt, -1, NULL, NULL);
271
272         cpuid_to_mid[curcpu] = PCPU_GET(mid);
273
274         csa = &cpu_start_args;
275         for (child = OF_child(OF_peer(0)); child != 0 && mp_ncpus <= MAXCPU;
276             child = OF_peer(child)) {
277                 if (OF_getprop(child, "device_type", buf, sizeof(buf)) <= 0 ||
278                     strcmp(buf, "cpu") != 0)
279                         continue;
280                 if (OF_getprop(child, cpu_impl < CPU_IMPL_ULTRASPARCIII ?
281                     "upa-portid" : "portid", &mid, sizeof(mid)) <= 0)
282                         panic("%s: can't get module ID", __func__);
283                 if (mid == PCPU_GET(mid))
284                         continue;
285                 if (OF_getprop(child, "clock-frequency", &clock,
286                     sizeof(clock)) <= 0)
287                         panic("%s: can't get clock", __func__);
288                 if (clock != PCPU_GET(clock))
289                         hardclock_use_stick = 1;
290
291                 csa->csa_state = 0;
292                 sun4u_startcpu(child, (void *)mp_tramp, 0);
293                 s = intr_disable();
294                 while (csa->csa_state != CPU_TICKSYNC)
295                         ;
296                 membar(StoreLoad);
297                 csa->csa_tick = rd(tick);
298                 if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) {
299                         while (csa->csa_state != CPU_STICKSYNC)
300                                 ;
301                         membar(StoreLoad);
302                         csa->csa_stick = rdstick();
303                 }
304                 while (csa->csa_state != CPU_INIT)
305                         ;
306                 csa->csa_tick = csa->csa_stick = 0;
307                 intr_restore(s);
308
309                 cpuid = mp_ncpus++;
310                 cpuid_to_mid[cpuid] = mid;
311                 cpu_identify(csa->csa_ver, clock, cpuid);
312
313                 va = kmem_alloc(kernel_map, PCPU_PAGES * PAGE_SIZE);
314                 pc = (struct pcpu *)(va + (PCPU_PAGES * PAGE_SIZE)) - 1;
315                 pcpu_init(pc, cpuid, sizeof(*pc));
316                 pc->pc_addr = va;
317                 pc->pc_clock = clock;
318                 pc->pc_mid = mid;
319                 pc->pc_node = child;
320
321                 cache_init(pc);
322
323                 all_cpus |= 1 << cpuid;
324                 intr_add_cpu(cpuid);
325         }
326         KASSERT(!isjbus || mp_ncpus <= IDR_JALAPENO_MAX_BN_PAIRS,
327             ("%s: can only IPI a maximum of %d JBus-CPUs",
328             __func__, IDR_JALAPENO_MAX_BN_PAIRS));
329         PCPU_SET(other_cpus, all_cpus & ~(1 << curcpu));
330         smp_active = 1;
331 }
332
333 void
334 cpu_mp_announce(void)
335 {
336
337 }
338
339 static void
340 cpu_mp_unleash(void *v)
341 {
342         volatile struct cpu_start_args *csa;
343         struct pcpu *pc;
344         register_t s;
345         vm_offset_t va;
346         vm_paddr_t pa;
347         u_int ctx_inc;
348         u_int ctx_min;
349         int i;
350
351         ctx_min = TLB_CTX_USER_MIN;
352         ctx_inc = (TLB_CTX_USER_MAX - 1) / mp_ncpus;
353         csa = &cpu_start_args;
354         csa->csa_count = mp_ncpus;
355         SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
356                 pc->pc_tlb_ctx = ctx_min;
357                 pc->pc_tlb_ctx_min = ctx_min;
358                 pc->pc_tlb_ctx_max = ctx_min + ctx_inc;
359                 ctx_min += ctx_inc;
360
361                 if (pc->pc_cpuid == curcpu)
362                         continue;
363                 KASSERT(pc->pc_idlethread != NULL,
364                     ("%s: idlethread", __func__));
365                 pc->pc_curthread = pc->pc_idlethread;
366                 pc->pc_curpcb = pc->pc_curthread->td_pcb;
367                 for (i = 0; i < PCPU_PAGES; i++) {
368                         va = pc->pc_addr + i * PAGE_SIZE;
369                         pa = pmap_kextract(va);
370                         if (pa == 0)
371                                 panic("%s: pmap_kextract", __func__);
372                         csa->csa_ttes[i].tte_vpn = TV_VPN(va, TS_8K);
373                         csa->csa_ttes[i].tte_data = TD_V | TD_8K | TD_PA(pa) |
374                             TD_L | TD_CP | TD_CV | TD_P | TD_W;
375                 }
376                 csa->csa_state = 0;
377                 csa->csa_pcpu = pc->pc_addr;
378                 csa->csa_mid = pc->pc_mid;
379                 s = intr_disable();
380                 while (csa->csa_state != CPU_BOOTSTRAP)
381                         ;
382                 intr_restore(s);
383         }
384
385         membar(StoreLoad);
386         csa->csa_count = 0;
387         smp_started = 1;
388 }
389
390 void
391 cpu_mp_bootstrap(struct pcpu *pc)
392 {
393         volatile struct cpu_start_args *csa;
394
395         csa = &cpu_start_args;
396         if (cpu_impl >= CPU_IMPL_ULTRASPARCIII)
397                 cheetah_init();
398         cache_enable();
399         pmap_map_tsb();
400         /*
401          * Flush all non-locked TLB entries possibly left over by the
402          * firmware.
403          */
404         tlb_flush_nonlocked();
405         cpu_setregs(pc);
406         tick_start();
407
408         smp_cpus++;
409         KASSERT(curthread != NULL, ("%s: curthread", __func__));
410         PCPU_SET(other_cpus, all_cpus & ~(1 << curcpu));
411         printf("SMP: AP CPU #%d Launched!\n", curcpu);
412
413         csa->csa_count--;
414         membar(StoreLoad);
415         csa->csa_state = CPU_BOOTSTRAP;
416         while (csa->csa_count != 0)
417                 ;
418
419         /* Ok, now enter the scheduler. */
420         sched_throw(NULL);
421 }
422
423 void
424 cpu_mp_shutdown(void)
425 {
426         int i;
427
428         critical_enter();
429         shutdown_cpus = PCPU_GET(other_cpus);
430         if (stopped_cpus != PCPU_GET(other_cpus))       /* XXX */
431                 stop_cpus(stopped_cpus ^ PCPU_GET(other_cpus));
432         i = 0;
433         while (shutdown_cpus != 0) {
434                 if (i++ > 100000) {
435                         printf("timeout shutting down CPUs.\n");
436                         break;
437                 }
438         }
439         /* XXX: delay a bit to allow the CPUs to actually enter the PROM. */
440         DELAY(100000);
441         critical_exit();
442 }
443
444 static void
445 cpu_ipi_ast(struct trapframe *tf)
446 {
447
448 }
449
450 static void
451 cpu_ipi_stop(struct trapframe *tf)
452 {
453
454         CTR2(KTR_SMP, "%s: stopped %d", __func__, curcpu);
455         savectx(&stoppcbs[curcpu]);
456         atomic_set_acq_int(&stopped_cpus, PCPU_GET(cpumask));
457         while ((started_cpus & PCPU_GET(cpumask)) == 0) {
458                 if ((shutdown_cpus & PCPU_GET(cpumask)) != 0) {
459                         atomic_clear_int(&shutdown_cpus, PCPU_GET(cpumask));
460                         if (has_stopself != 0)
461                                 sun4u_stopself();
462                         (void)intr_disable();
463                         for (;;)
464                                 ;
465                 }
466         }
467         atomic_clear_rel_int(&started_cpus, PCPU_GET(cpumask));
468         atomic_clear_rel_int(&stopped_cpus, PCPU_GET(cpumask));
469         CTR2(KTR_SMP, "%s: restarted %d", __func__, curcpu);
470 }
471
472 static void
473 cpu_ipi_preempt(struct trapframe *tf)
474 {
475
476         sched_preempt(curthread);
477 }
478
479 static void
480 spitfire_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2)
481 {
482         u_int cpu;
483
484         KASSERT((cpus & (1 << curcpu)) == 0,
485             ("%s: CPU can't IPI itself", __func__));
486         while (cpus) {
487                 cpu = ffs(cpus) - 1;
488                 cpus &= ~(1 << cpu);
489                 spitfire_ipi_send(cpuid_to_mid[cpu], d0, d1, d2);
490         }
491 }
492
493 static void
494 spitfire_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2)
495 {
496         register_t s;
497         u_long ids;
498         int i;
499
500         KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & IDR_BUSY) == 0,
501             ("%s: outstanding dispatch", __func__));
502         for (i = 0; i < IPI_RETRIES; i++) {
503                 s = intr_disable();
504                 stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0);
505                 stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1);
506                 stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2);
507                 membar(Sync);
508                 stxa(AA_INTR_SEND | (mid << IDC_ITID_SHIFT),
509                     ASI_SDB_INTR_W, 0);
510                 /*
511                  * Workaround for SpitFire erratum #54; do a dummy read
512                  * from a SDB internal register before the MEMBAR #Sync
513                  * for the write to ASI_SDB_INTR_W (requiring another
514                  * MEMBAR #Sync in order to make sure the write has
515                  * occurred before the load).
516                  */
517                 membar(Sync);
518                 (void)ldxa(AA_SDB_CNTL_HIGH, ASI_SDB_CONTROL_R);
519                 membar(Sync);
520                 while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) &
521                     IDR_BUSY) != 0)
522                         ;
523                 intr_restore(s);
524                 if ((ids & (IDR_BUSY | IDR_NACK)) == 0)
525                         return;
526                 /*
527                  * Leave interrupts enabled for a bit before retrying
528                  * in order to avoid deadlocks if the other CPU is also
529                  * trying to send an IPI.
530                  */
531                 DELAY(2);
532         }
533         if (
534 #ifdef KDB
535             kdb_active ||
536 #endif
537             panicstr != NULL)
538                 printf("%s: couldn't send IPI to module 0x%u\n",
539                     __func__, mid);
540         else
541                 panic("%s: couldn't send IPI", __func__);
542 }
543
544 static void
545 cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2)
546 {
547         register_t s;
548         u_long ids;
549         u_int bnp;
550         u_int cpu;
551         int i;
552
553         KASSERT((cpus & (1 << curcpu)) == 0,
554             ("%s: CPU can't IPI itself", __func__));
555         KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) &
556             IDR_CHEETAH_ALL_BUSY) == 0,
557             ("%s: outstanding dispatch", __func__));
558         if (cpus == 0)
559                 return;
560         ids = 0;
561         for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) {
562                 s = intr_disable();
563                 stxa(AA_SDB_INTR_D0, ASI_SDB_INTR_W, d0);
564                 stxa(AA_SDB_INTR_D1, ASI_SDB_INTR_W, d1);
565                 stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2);
566                 membar(Sync);
567                 bnp = 0;
568                 for (cpu = 0; cpu < mp_ncpus; cpu++) {
569                         if ((cpus & (1 << cpu)) != 0) {
570                                 stxa(AA_INTR_SEND |
571                                     (cpuid_to_mid[cpu] << IDC_ITID_SHIFT) |
572                                     (isjbus ? 0 : bnp << IDC_BN_SHIFT),
573                                     ASI_SDB_INTR_W, 0);
574                                 membar(Sync);
575                                 bnp++;
576                         }
577                 }
578                 while (((ids = ldxa(0, ASI_INTR_DISPATCH_STATUS)) &
579                     IDR_CHEETAH_ALL_BUSY) != 0)
580                         ;
581                 intr_restore(s);
582                 if ((ids & (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0)
583                         return;
584                 bnp = 0;
585                 for (cpu = 0; cpu < mp_ncpus; cpu++) {
586                         if ((cpus & (1 << cpu)) != 0) {
587                                 if ((ids & (IDR_NACK << (isjbus ?
588                                     (2 * cpuid_to_mid[cpu]) :
589                                     (2 * bnp)))) == 0)
590                                         cpus &= ~(1 << cpu);
591                                 bnp++;
592                         }
593                 }
594                 /*
595                  * Leave interrupts enabled for a bit before retrying
596                  * in order to avoid deadlocks if the other CPUs are
597                  * also trying to send IPIs.
598                  */
599                 DELAY(2 * bnp);
600         }
601         if (
602 #ifdef KDB
603             kdb_active ||
604 #endif
605             panicstr != NULL)
606                 printf("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)\n",
607                     __func__, cpus, ids);
608         else
609                 panic("%s: couldn't send IPI", __func__);
610 }