--- sys/sys/kernel.h 2009/07/23 20:50:15 +++ sys/sys/kernel.h 2009/10/01 18:45:12 @@ -154,6 +154,7 @@ SI_SUB_KPROF = 0x9000000, /* kernel profiling*/ SI_SUB_KICK_SCHEDULER = 0xa000000, /* start the timeout events*/ SI_SUB_INT_CONFIG_HOOKS = 0xa800000, /* Interrupts enabled config */ + SI_SUB_CONFIG_CAM = 0xa900000, /* CAM bus scan */ SI_SUB_ROOT_CONF = 0xb000000, /* Find root devices */ SI_SUB_DUMP_CONF = 0xb200000, /* Find dump devices */ SI_SUB_RAID = 0xb380000, /* Configure GEOM classes */ --- sys/cam/cam_xpt.c 2009/09/15 00:20:41 +++ sys/cam/cam_xpt.c 2009/10/02 05:00:03 @@ -107,8 +107,6 @@ TAILQ_HEAD(,cam_eb) xpt_busses; u_int bus_generation; - struct intr_config_hook *xpt_config_hook; - struct mtx xpt_topo_lock; struct mtx xpt_lock; }; @@ -910,35 +908,19 @@ xpt_free_path(path); mtx_unlock(&xsoftc.xpt_lock); - /* - * Register a callback for when interrupts are enabled. - */ - xsoftc.xpt_config_hook = - (struct intr_config_hook *)malloc(sizeof(struct intr_config_hook), - M_CAMXPT, M_NOWAIT | M_ZERO); - if (xsoftc.xpt_config_hook == NULL) { - printf("xpt_init: Cannot malloc config hook " - "- failing attach\n"); - return (ENOMEM); - } - - xsoftc.xpt_config_hook->ich_func = xpt_config; - if (config_intrhook_establish(xsoftc.xpt_config_hook) != 0) { - free (xsoftc.xpt_config_hook, M_CAMXPT); - printf("xpt_init: config_intrhook_establish failed " - "- failing attach\n"); - } - /* fire up rescan thread */ if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { printf("xpt_init: failed to create rescan thread\n"); } /* Install our software interrupt handlers */ - swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih); + swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, + &cambio_ih); return (0); } +SYSINIT(cam_config, SI_SUB_CONFIG_CAM, SI_ORDER_FIRST, xpt_config, NULL); + static cam_status xptregister(struct cam_periph *periph, void *arg) { @@ -4646,9 +4628,13 @@ return(1); } +#define CAM_WARN_INTERVAL_SECS 60 + static void xpt_config(void *arg) { + u_int warned = 0; + /* * Now that interrupts are enabled, go find our devices */ @@ -4697,6 +4683,17 @@ } xpt_for_all_busses(xptconfigfunc, NULL); } + + mtx_lock(&xsoftc.xpt_lock); + while (msleep(xpt_config, &xsoftc.xpt_lock, PCONFIG, "camhk", + CAM_WARN_INTERVAL_SECS * hz) == EWOULDBLOCK) { + if (++warned < 6) + printf("xpt_config: still waiting after %d seconds " + "for CAM buses to respond\n", + warned * CAM_WARN_INTERVAL_SECS); + KASSERT(warned < 6, ("xpt_config: waited too long")); + } + mtx_unlock(&xsoftc.xpt_lock); } /* @@ -4743,9 +4740,9 @@ xpt_for_all_devices(xptpassannouncefunc, NULL); /* Release our hook so that the boot can continue. */ - config_intrhook_disestablish(xsoftc.xpt_config_hook); - free(xsoftc.xpt_config_hook, M_CAMXPT); - xsoftc.xpt_config_hook = NULL; + mtx_lock(&xsoftc.xpt_lock); + wakeup(xpt_config); + mtx_unlock(&xsoftc.xpt_lock); } free(context, M_CAMXPT);