Index: dev/nvme/nvme_ctrlr.c =================================================================== --- dev/nvme/nvme_ctrlr.c (revision 335853) +++ dev/nvme/nvme_ctrlr.c (working copy) @@ -955,7 +955,7 @@ } /* - * Poll the single-vector intertrupt case: num_io_queues will be 1 and + * Poll the single-vector interrupt case: num_io_queues will be 1 and * there's only a single vector. While we're polling, we mask further * interrupts in the controller. */ Index: dev/nvme/nvme_private.h =================================================================== --- dev/nvme/nvme_private.h (revision 335853) +++ dev/nvme/nvme_private.h (working copy) @@ -1,4 +1,4 @@ -/*- +/* * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (C) 2012-2014 Intel Corporation @@ -93,9 +93,9 @@ #define NVME_MAX_NAMESPACES (16) #define NVME_MAX_CONSUMERS (2) -#define NVME_MAX_ASYNC_EVENTS (8) +#define NVME_MAX_ASYNC_EVENTS (4) /* samsung */ -#define NVME_DEFAULT_TIMEOUT_PERIOD (30) /* in seconds */ +#define NVME_DEFAULT_TIMEOUT_PERIOD (10) /* in seconds */ #define NVME_MIN_TIMEOUT_PERIOD (5) #define NVME_MAX_TIMEOUT_PERIOD (120) @@ -209,6 +209,7 @@ bus_dma_tag_t dma_tag_payload; bus_dmamap_t queuemem_map; + uint64_t cmd_bus_addr; uint64_t cpl_bus_addr; Index: dev/nvme/nvme_qpair.c =================================================================== --- dev/nvme/nvme_qpair.c (revision 335853) +++ dev/nvme/nvme_qpair.c (working copy) @@ -387,6 +387,8 @@ nvme_qpair_print_completion(qpair, cpl); } + //if (!atomic_cmpset_ptr(qpair->act_tr[cpl->cid], tr, NULL)) +// panic("Mismatched act_tr\n"); qpair->act_tr[cpl->cid] = NULL; KASSERT(cpl->cid == req->cmd.cid, ("cpl cid does not match cmd cid\n")); @@ -488,6 +490,7 @@ return (false); while (1) { + /* Copy completion */ cpl = qpair->cpl[qpair->cq_head]; /* Convert to host endian */ @@ -496,10 +499,12 @@ if (NVME_STATUS_GET_P(cpl.status) != qpair->phase) break; + tr = NULL; tr = qpair->act_tr[cpl.cid]; if (tr != NULL) { nvme_qpair_complete_tracker(qpair, tr, &cpl, TRUE); + /* For sysctl readout only */ qpair->sq_head = cpl.sqhd; done++; } else { @@ -595,7 +600,7 @@ } if (bus_dmamem_alloc(qpair->dma_tag, (void **)&queuemem, - BUS_DMA_NOWAIT, &qpair->queuemem_map)) { + BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &qpair->queuemem_map)) { nvme_printf(ctrlr, "failed to alloc qpair memory\n"); goto out; } @@ -810,6 +815,8 @@ req = tr->req; req->cmd.cid = tr->cid; +// if(!atomic_cmpset_ptr(qpair->act_tr[tr->cid], NULL, tr)) +// panic("Transaction fence error\n"); qpair->act_tr[tr->cid] = tr; ctrlr = qpair->ctrlr; Index: dev/ofw/ofwbus.c =================================================================== --- dev/ofw/ofwbus.c (revision 335853) +++ dev/ofw/ofwbus.c (working copy) @@ -100,7 +100,7 @@ DEFINE_CLASS_1(ofwbus, ofwbus_driver, ofwbus_methods, sizeof(struct ofwbus_softc), simplebus_driver); static devclass_t ofwbus_devclass; -EARLY_DRIVER_MODULE(ofwbus, nexus, ofwbus_driver, ofwbus_devclass, 0, 0, +EARLY_BUS_DRIVER_MODULE(ofwbus, nexus, ofwbus_driver, ofwbus_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); MODULE_VERSION(ofwbus, 1); Index: kern/kern_shutdown.c =================================================================== --- kern/kern_shutdown.c (revision 335853) +++ kern/kern_shutdown.c (working copy) @@ -716,6 +716,10 @@ void kassert_panic(const char *fmt, ...) { + // HACK to prevent parallel print + //while (curcpu != 1) + //;; + static char buf[256]; va_list ap; Index: kern/sched_ule.c =================================================================== --- kern/sched_ule.c (revision 335853) +++ kern/sched_ule.c (working copy) @@ -1080,9 +1080,13 @@ if (tdq->tdq_ipipending) return; +printf("xA"); cpu = td_get_sched(td)->ts_cpu; +printf("xB"); pri = td->td_priority; +printf("xC"); ctd = pcpu_find(cpu)->pc_curthread; +printf("xD"); if (!sched_shouldpreempt(pri, ctd->td_priority, 1)) return; @@ -1091,9 +1095,12 @@ * globally visible before we read tdq_cpu_idle. Idle thread * accesses both of them without locks, and the order is important. */ +printf("xE"); atomic_thread_fence_seq_cst(); +printf("xF"); if (TD_IS_IDLETHREAD(ctd)) { +printf("xG"); /* * If the MD code has an idle wakeup routine try that before * falling back to IPI. @@ -1101,8 +1108,11 @@ if (!tdq->tdq_cpu_idle || cpu_idle_wakeup(cpu)) return; } +printf("xH"); tdq->tdq_ipipending = 1; +printf("xI"); ipi_cpu(cpu, IPI_PREEMPT); +printf("xJ"); } /* @@ -2541,6 +2551,8 @@ int cpu; #endif +printf("1"); + KTR_STATE2(KTR_SCHED, "thread", sched_tdname(td), "runq add", "prio:%d", td->td_priority, KTR_ATTR_LINKED, sched_tdname(curthread)); @@ -2549,22 +2561,31 @@ SDT_PROBE4(sched, , , enqueue, td, td->td_proc, NULL, flags & SRQ_PREEMPTED); THREAD_LOCK_ASSERT(td, MA_OWNED); +printf("2"); /* * Recalculate the priority before we select the target cpu or * run-queue. */ - if (PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) + if (PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) { +printf("3"); sched_priority(td); + } #ifdef SMP /* * Pick the destination cpu and if it isn't ours transfer to the * target cpu. */ +printf("4"); cpu = sched_pickcpu(td, flags); +printf("5"); tdq = sched_setcpu(td, cpu, flags); +printf("6"); tdq_add(tdq, td, flags); +printf("7"); if (cpu != PCPU_GET(cpuid)) { +printf("8"); tdq_notify(tdq, td); +printf("9"); return; } #else @@ -2577,8 +2598,12 @@ thread_lock_set(td, TDQ_LOCKPTR(tdq)); tdq_add(tdq, td, flags); #endif - if (!(flags & SRQ_YIELDING)) +printf("_10_"); + if (!(flags & SRQ_YIELDING)) { +printf("_11_"); sched_setpreempt(td); +printf("_12_"); + } } /* Index: kern/subr_bus.c =================================================================== --- kern/subr_bus.c (revision 335853) +++ kern/subr_bus.c (working copy) @@ -431,13 +431,20 @@ static void devinit(void) { +printf("11"); devctl_dev = make_dev_credf(MAKEDEV_ETERNAL, &dev_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0600, "devctl"); +printf("22"); mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF); +printf("33"); cv_init(&devsoftc.cv, "dev cv"); +printf("44"); TAILQ_INIT(&devsoftc.devq); +printf("55"); knlist_init_mtx(&devsoftc.sel.si_note, &devsoftc.mtx); +printf("66"); devctl2_init(); +printf("77"); } static int @@ -4928,15 +4935,25 @@ { switch (what) { case MOD_LOAD: +printf("aa"); TAILQ_INIT(&bus_data_devices); +printf("bb"); kobj_class_compile((kobj_class_t) &root_driver); +printf("cc"); root_bus = make_device(NULL, "root", 0); +printf("dd"); root_bus->desc = "System root bus"; +printf("ee"); kobj_init((kobj_t) root_bus, (kobj_class_t) &root_driver); +printf("ff"); root_bus->driver = &root_driver; +printf("gg"); root_bus->state = DS_ATTACHED; +printf("hh"); root_devclass = devclass_find_internal("root", NULL, FALSE); +printf("ii"); devinit(); +printf("jj"); return (0); case MOD_SHUTDOWN: @@ -4954,7 +4971,7 @@ root_bus_module_handler, NULL }; -DECLARE_MODULE(rootbus, root_bus_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +DECLARE_MODULE(rootbus, root_bus_mod, SI_SUB_EARLY_BUS, SI_ORDER_FIRST); /** * @brief Automatically configure devices Index: kern/subr_gtaskqueue.c =================================================================== --- kern/subr_gtaskqueue.c (revision 335853) +++ kern/subr_gtaskqueue.c (working copy) @@ -408,6 +408,7 @@ _gtaskqueue_start_threads(struct gtaskqueue **tqp, int count, int pri, cpuset_t *mask, const char *name, va_list ap) { +printf("\nGTQ %d %d %s\n", count, pri, name); char ktname[MAXCOMLEN + 1]; struct thread *td; struct gtaskqueue *tq; @@ -415,25 +416,32 @@ if (count <= 0) return (EINVAL); +printf("a"); vsnprintf(ktname, sizeof(ktname), name, ap); +printf("b"); tq = *tqp; - +printf("c"); tq->tq_threads = malloc(sizeof(struct thread *) * count, M_GTASKQUEUE, M_NOWAIT | M_ZERO); +printf("d"); if (tq->tq_threads == NULL) { printf("%s: no memory for %s threads\n", __func__, ktname); return (ENOMEM); } - for (i = 0; i < count; i++) { - if (count == 1) +printf("e"); + if (count == 1) { error = kthread_add(gtaskqueue_thread_loop, tqp, NULL, &tq->tq_threads[i], RFSTOPPED, 0, "%s", ktname); - else +printf("f"); + } + else { error = kthread_add(gtaskqueue_thread_loop, tqp, NULL, &tq->tq_threads[i], RFSTOPPED, 0, "%s_%d", ktname, i); +printf("g"); + } if (error) { /* should be ok to continue, taskqueue_free will dtrt */ printf("%s: kthread_add(%s): error %d", __func__, @@ -443,27 +451,40 @@ tq->tq_tcount++; } for (i = 0; i < count; i++) { - if (tq->tq_threads[i] == NULL) +printf("h"); + if (tq->tq_threads[i] == NULL) { +printf("i"); continue; + } td = tq->tq_threads[i]; +printf("j"); if (mask) { +printf("k"); error = cpuset_setthread(td->td_tid, mask); +printf("l"); /* * Failing to pin is rarely an actual fatal error; * it'll just affect performance. */ - if (error) + if (error) { printf("%s: curthread=%llu: can't pin; " "error=%d\n", __func__, (unsigned long long) td->td_tid, error); + } } +printf("m"); thread_lock(td); +printf("n"); sched_prio(td, pri); +printf("o"); sched_add(td, SRQ_BORING); +printf("p"); thread_unlock(td); +printf("q"); } +printf("r"); return (0); } @@ -576,14 +597,20 @@ taskqgroup_cpu_create(struct taskqgroup *qgroup, int idx, int cpu) { struct taskqgroup_cpu *qcpu; +printf("A"); qcpu = &qgroup->tqg_queue[idx]; +printf("B"); LIST_INIT(&qcpu->tgc_tasks); +printf("C"); qcpu->tgc_taskq = gtaskqueue_create_fast(NULL, M_WAITOK, taskqueue_thread_enqueue, &qcpu->tgc_taskq); +printf("D"); gtaskqueue_start_threads(&qcpu->tgc_taskq, 1, PI_SOFT, "%s_%d", qgroup->tqg_name, idx); +printf("E"); qcpu->tgc_cpu = cpu; +printf("F"); } static void @@ -655,6 +682,7 @@ static void tqg_record_smp_started(void *arg) { + printf("TQG_RECORD_SMP_STARTED\n"); tqg_smp_started = 1; } @@ -860,11 +888,13 @@ static int _taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride) { + printf("TASKQGROUP_ADJUST\n"); LIST_HEAD(, grouptask) gtask_head = LIST_HEAD_INITIALIZER(NULL); struct grouptask *gtask; int i, k, old_cnt, old_cpu, cpu; mtx_assert(&qgroup->tqg_lock, MA_OWNED); +printf("1"); if (cnt < 1 || cnt * stride > mp_ncpus || !tqg_smp_started) { printf("%s: failed cnt: %d stride: %d " @@ -872,10 +902,12 @@ __func__, cnt, stride, mp_ncpus, tqg_smp_started); return (EINVAL); } +printf("2"); if (qgroup->tqg_adjusting) { printf("%s failed: adjusting\n", __func__); return (EBUSY); } +printf("3"); qgroup->tqg_adjusting = 1; old_cnt = qgroup->tqg_cnt; old_cpu = 0; @@ -885,10 +917,14 @@ /* * Set up queue for tasks added before boot. */ +printf("4"); if (old_cnt == 0) { +printf("a"); LIST_SWAP(>ask_head, &qgroup->tqg_queue[0].tgc_tasks, grouptask, gt_list); +printf("b"); qgroup->tqg_queue[0].tgc_cnt = 0; +printf("c"); } /* @@ -895,12 +931,19 @@ * If new taskq threads have been added. */ cpu = old_cpu; +printf("d"); for (i = old_cnt; i < cnt; i++) { +printf("e"); taskqgroup_cpu_create(qgroup, i, cpu); - - for (k = 0; k < stride; k++) +printf("f"); + for (k = 0; k < stride; k++) { + printf("g"); cpu = CPU_NEXT(cpu); + printf("j"); + } +printf("i"); } +printf("5"); mtx_lock(&qgroup->tqg_lock); qgroup->tqg_cnt = cnt; qgroup->tqg_stride = stride; @@ -915,6 +958,7 @@ LIST_INSERT_HEAD(>ask_head, gtask, gt_list); } } +printf("6"); mtx_unlock(&qgroup->tqg_lock); while ((gtask = LIST_FIRST(>ask_head))) { @@ -924,6 +968,7 @@ else if (taskqgroup_attach_cpu_deferred(qgroup, gtask)) taskqgroup_attach_deferred(qgroup, gtask); } +printf("7"); #ifdef INVARIANTS mtx_lock(&qgroup->tqg_lock); @@ -934,17 +979,21 @@ } mtx_unlock(&qgroup->tqg_lock); #endif +printf("8noreally"); /* * If taskq thread count has been reduced. */ +printf("cnt %d old_cnt %d", cnt, old_cnt); for (i = cnt; i < old_cnt; i++) taskqgroup_cpu_remove(qgroup, i); +printf("x9"); taskqgroup_bind(qgroup); - +printf("x10"); mtx_lock(&qgroup->tqg_lock); +printf("x11"); qgroup->tqg_adjusting = 0; - +printf("\nOKAY\n"); return (0); } @@ -954,6 +1003,7 @@ int error; mtx_lock(&qgroup->tqg_lock); +printf("TASKQGROUP_ADJUST2 %s\n", qgroup->tqg_name); error = _taskqgroup_adjust(qgroup, cnt, stride); mtx_unlock(&qgroup->tqg_lock); Index: kern/subr_intr.c =================================================================== --- kern/subr_intr.c (revision 335853) +++ kern/subr_intr.c (working copy) @@ -1203,6 +1203,7 @@ return; mtx_lock(&isrc_table_lock); +printf("IRQSHUF\n"); irq_assign_cpu = TRUE; for (i = 0; i < NIRQ; i++) { isrc = irq_sources[i]; Index: libkern/arc4random.c =================================================================== --- libkern/arc4random.c (revision 335853) +++ libkern/arc4random.c (working copy) @@ -98,8 +98,9 @@ explicit_bzero(data, size); if (bootverbose) printf("arc4random: read %zu bytes from preloaded cache\n", size); - } else - printf("arc4random: no preloaded entropy cache\n"); + } else { + //printf("arc4random: no preloaded entropy cache\n"); + } chacha20->first_time_done = 1; } getmicrouptime(&tv_now); Index: netinet/in_mcast.c =================================================================== --- netinet/in_mcast.c (revision 335853) +++ netinet/in_mcast.c (working copy) @@ -231,8 +231,13 @@ taskqgroup_config_gtask_init(NULL, &free_gtask, inm_release_task, "inm release task"); } +#ifdef EARLY_AP_STARTUP SYSINIT(inm_init, SI_SUB_SMP + 1, SI_ORDER_FIRST, inm_init, NULL); +#else +SYSINIT(inm_init, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_SECOND, + inm_init, NULL); +#endif void Index: powerpc/powerpc/autoconf.c =================================================================== --- powerpc/powerpc/autoconf.c (revision 335853) +++ powerpc/powerpc/autoconf.c (working copy) @@ -51,7 +51,11 @@ static void configure(void *); static void configure_final(void *); +#ifdef EARLY_AP_STARTUP +SYSINIT(configure1, SI_SUB_EARLY_BUS, SI_ORDER_SECOND, configure_first, NULL); +#else SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL); +#endif /* SI_ORDER_SECOND is hookable */ SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL); /* SI_ORDER_MIDDLE is hookable */ @@ -63,8 +67,14 @@ static void configure_first(void *dummy) { - +printf("AAA"); + bus_set_pass(BUS_PASS_CPU-1); + /* Root bus has just attached, attach the nexus */ +printf("BBB"); nexusdev = device_add_child(root_bus, "nexus", 0); +printf("CCC"); + bus_set_pass(BUS_PASS_INTERRUPT); +printf("DDD"); } static void Index: powerpc/powerpc/clock.c =================================================================== --- powerpc/powerpc/clock.c (revision 335853) +++ powerpc/powerpc/clock.c (working copy) @@ -62,10 +62,13 @@ #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -159,7 +162,27 @@ { decr_tc_init(); +#ifdef EARLY_AP_STARTUP + struct thread *td; + int i; + + td = curthread; + cpu_initclocks_bsp(); + CPU_FOREACH(i) { + if (i == 0) + continue; + thread_lock(td); + sched_bind(td, i); + thread_unlock(td); + cpu_initclocks_ap(); + } + thread_lock(td); + if (sched_is_bound(td)) + sched_unbind(td); + thread_unlock(td); +#else cpu_initclocks_bsp(); +#endif } /* Index: powerpc/powerpc/intr_machdep.c =================================================================== --- powerpc/powerpc/intr_machdep.c (revision 335853) +++ powerpc/powerpc/intr_machdep.c (working copy) @@ -152,17 +152,73 @@ static void smp_intr_init(void *dummy __unused) { + printf("SMP_INTR_INIT!\n"); + printf("nvectors %d", nvectors); struct powerpc_intr *i; int vector; for (vector = 0; vector < nvectors; vector++) { i = powerpc_intrs[vector]; - if (i != NULL && i->event != NULL && i->pic == root_pic) + if (i != NULL && i->event != NULL && i->pic == root_pic) { + printf("INTRBIND %d\n", i->intline); PIC_BIND(i->pic, i->intline, i->cpu); + } } } -SYSINIT(smp_intr_init, SI_SUB_SMP, SI_ORDER_ANY, smp_intr_init, NULL); +SYSINIT(smp_intr_init, SI_SUB_INT_CONFIG_HOOKS + 1, SI_ORDER_FIRST, smp_intr_init, NULL); +/*SYSINIT(smp_intr_init, SI_SUB_SMP, SI_ORDER_SECOND, smp_intr_init, NULL); */ +/*SYSINIT(smp_intr_init, SI_SUB_EARLY_BUS, SI_ORDER_ANY, smp_intr_init, NULL); */ + +#ifdef EARLY_AP_STARTUP + +static struct powerpc_intr * intr_lookup(u_int irq); + +static void +smp_intr_ipi_init(void *dummy __unused) +{ + struct powerpc_intr *i; + int error; + + int n; + printf("IPI startup! Hold onto yer butts!\n"); + if (npics == 0) + panic("no PIC detected\n"); + + if (root_pic == NULL) + root_pic = piclist[0].dev; + + /* Install an IPI handler. */ + if (mp_ncpus > 1) { + for (n = 0; n < npics; n++) { + if (piclist[n].dev != root_pic) + continue; + + KASSERT(piclist[n].ipis != 0, + ("%s: SMP root PIC does not supply any IPIs", + __func__)); + error = powerpc_setup_intr("IPI", + MAP_IRQ(piclist[n].node, piclist[n].irqs), + powerpc_ipi_handler, NULL, NULL, + INTR_TYPE_MISC | INTR_EXCL, &ipi_cookie); + if (error) { + panic("unable to setup IPI handler\n"); + } + + /* + * Some subterfuge: disable late EOI and mark this + * as an IPI to the dispatch layer. + */ + i = intr_lookup(MAP_IRQ(piclist[n].node, + piclist[n].irqs)); + i->event->ie_post_filter = NULL; + i->ipi = 1; + } + } +} +SYSINIT(smp_intr_ipi_init, SI_SUB_EARLY_BUS, SI_ORDER_ANY, smp_intr_ipi_init, NULL); + #endif +#endif static void intrcnt_setname(const char *name, int index) @@ -325,6 +381,7 @@ powerpc_register_pic(device_t dev, uint32_t node, u_int irqs, u_int ipis, u_int atpic) { +printf("powerpc_register_pic()\n"); struct pic *p; u_int irq; int idx; @@ -408,8 +465,10 @@ struct powerpc_intr *i; int error, vector; #ifdef SMP +#ifndef EARLY_AP_STARTUP int n; #endif +#endif if (npics == 0) panic("no PIC detected\n"); @@ -418,6 +477,7 @@ root_pic = piclist[0].dev; #ifdef SMP +#ifndef EARLY_AP_STARTUP /* Install an IPI handler. */ if (mp_ncpus > 1) { for (n = 0; n < npics; n++) { @@ -447,6 +507,7 @@ } } #endif +#endif for (vector = 0; vector < nvectors; vector++) { i = powerpc_intrs[vector]; Index: powerpc/powerpc/mp_machdep.c =================================================================== --- powerpc/powerpc/mp_machdep.c (revision 335853) +++ powerpc/powerpc/mp_machdep.c (working copy) @@ -106,8 +106,16 @@ while(smp_started == 0) ; +/* + mtx_lock_spin(&ap_boot_mtx); + printf("RELEASE THE HOUNDS!\n"); + mtx_unlock_spin(&ap_boot_mtx); +*/ + +#ifndef EARLY_AP_STARTUP /* Start per-CPU event timers. */ cpu_initclocks_ap(); +#endif /* Announce ourselves awake, and enter the scheduler */ sched_throw(NULL); @@ -248,13 +256,16 @@ } ap_awake = 1; +printf("Back to init processor.\n"); /* Provide our current DEC and TB values for APs */ ap_timebase = mftb() + 10; __asm __volatile("msync; isync"); +printf("About to let go!\n"); /* Let APs continue */ atomic_store_rel_int(&ap_letgo, 1); +printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); platform_smp_timebase_sync(ap_timebase, 0); Index: powerpc/powerpc/nexus.c =================================================================== --- powerpc/powerpc/nexus.c (revision 335853) +++ powerpc/powerpc/nexus.c (working copy) @@ -99,7 +99,7 @@ static devclass_t nexus_devclass; DEFINE_CLASS_0(nexus, nexus_driver, nexus_methods, 1); -EARLY_DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0, +EARLY_BUS_DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0, BUS_PASS_BUS); MODULE_VERSION(nexus, 1); @@ -106,8 +106,9 @@ static int nexus_probe(device_t dev) { +printf("NEXUS PROBE\n"); - device_quiet(dev); /* suppress attach message for neatness */ +// device_quiet(dev); /* suppress attach message for neatness */ return (BUS_PROBE_DEFAULT); } @@ -115,6 +116,7 @@ static int nexus_attach(device_t dev) { +printf("NEXUS ATTACH\n"); bus_generic_probe(dev); bus_generic_attach(dev); Index: powerpc/pseries/xics.c =================================================================== --- powerpc/pseries/xics.c (revision 335853) +++ powerpc/pseries/xics.c (working copy) @@ -117,6 +117,10 @@ int ibm_get_xive; int ibm_set_xive; +#ifdef POWERNV + int ipi_irq[MAXCPU]; +#endif + /* XXX: inefficient -- hash table? tree? */ struct { int irq; @@ -205,6 +209,7 @@ static int xicp_attach(device_t dev) { +printf("XICP_ATTACH!\n"); struct xicp_softc *sc = device_get_softc(dev); phandle_t phandle = ofw_bus_get_node(dev); @@ -247,11 +252,13 @@ int i; if (sc->xics_emu) { +//#ifndef EARLY_AP_STARTUP opal_call(OPAL_INT_SET_CPPR, 0xff); for (i = 0; i < mp_ncpus; i++) { opal_call(OPAL_INT_SET_MFRR, pcpu_find(i)->pc_hwref, 0xff); } +//#endif } else { for (i = 0; i < sc->cpu_range[1] - sc->cpu_range[0]; i++) { sc->mem[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, @@ -283,6 +290,7 @@ static int xics_attach(device_t dev) { +printf("XICS_ATTACH!\n"); phandle_t phandle = ofw_bus_get_node(dev); /* The XICP (root PIC) will handle all our interrupts */ @@ -351,6 +359,7 @@ static void xicp_dispatch(device_t dev, struct trapframe *tf) { +printf("XICP_DISPATCH!"); struct xicp_softc *sc; struct resource *regs = NULL; uint64_t xirr, junk; @@ -565,12 +574,14 @@ void xicp_smp_cpu_startup(void) { - struct xicp_softc *sc; +printf("$"); +/* struct xicp_softc *sc; */ if (mfmsr() & PSL_HV) { +/* sc = device_get_softc(root_pic); - if (sc->xics_emu) + if (sc->xics_emu) */ opal_call(OPAL_INT_SET_CPPR, 0xff); } } Index: sys/bus.h =================================================================== --- sys/bus.h (revision 335853) +++ sys/bus.h (working copy) @@ -751,7 +751,7 @@ }; #define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ - evh, arg, order, pass) \ + evh, arg, sub, order, pass) \ \ static struct driver_module_data name##_##busname##_driver_mod = { \ evh, arg, \ @@ -767,16 +767,20 @@ &name##_##busname##_driver_mod \ }; \ DECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ - SI_SUB_DRIVERS, order) + sub, order) #define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ - evh, arg, SI_ORDER_MIDDLE, pass) + evh, arg, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, pass) +#define EARLY_BUS_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ + EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ + evh, arg, SI_SUB_EARLY_BUS, SI_ORDER_MIDDLE, pass) + #define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\ order) \ EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ - evh, arg, order, BUS_PASS_DEFAULT) + evh, arg, SI_SUB_DRIVERS, order, BUS_PASS_DEFAULT) #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \ Index: sys/kernel.h =================================================================== --- sys/kernel.h (revision 335853) +++ sys/kernel.h (working copy) @@ -124,16 +124,20 @@ SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ SI_SUB_TASKQ = 0x2880000, /* task queues */ + SI_SUB_DEVFS = 0x28A0000, /* devfs ready for devices */ #ifdef EARLY_AP_STARTUP - SI_SUB_SMP = 0x2900000, /* start the APs*/ + SI_SUB_EARLY_BUS = 0x28B0000, /* Attach root bus and interrupt controller */ + SI_SUB_SMP = 0x2900000, /* start the APs */ #endif SI_SUB_SOFTINTR = 0x2A00000, /* start soft interrupt thread */ - SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ SI_SUB_NETGRAPH = 0x3010000, /* Let Netgraph initialize */ SI_SUB_DTRACE = 0x3020000, /* DTrace subsystem */ SI_SUB_DTRACE_PROVIDER = 0x3048000, /* DTrace providers */ SI_SUB_DTRACE_ANON = 0x308C000, /* DTrace anon enabling */ +#ifndef EARLY_AP_STARTUP + SI_SUB_EARLY_BUS = 0x30C0000, /* Attach root bus and interrupt controller */ +#endif SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ SI_SUB_VFS = 0x4000000, /* virtual filesystem*/