From owner-p4-projects@FreeBSD.ORG Wed Jan 13 20:25:59 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 59B1C106568F; Wed, 13 Jan 2010 20:25:59 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E3B9106566B for ; Wed, 13 Jan 2010 20:25:59 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 0BBBA8FC15 for ; Wed, 13 Jan 2010 20:25:59 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o0DKPwxH012493 for ; Wed, 13 Jan 2010 20:25:58 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o0DKPw6g012491 for perforce@freebsd.org; Wed, 13 Jan 2010 20:25:58 GMT (envelope-from mav@freebsd.org) Date: Wed, 13 Jan 2010 20:25:58 GMT Message-Id: <201001132025.o0DKPw6g012491@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 173079 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2010 20:25:59 -0000 http://p4web.freebsd.org/chv.cgi?CH=173079 Change 173079 by mav@mav_mavtest on 2010/01/13 20:25:44 Clean XPT initialization a bit, preparing to boot scan refactoring. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#46 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#25 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#135 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#46 (text+ko) ==== @@ -84,6 +84,7 @@ u_int32_t *timeout); static int nperiph_drivers; +static int initialized = 0; struct periph_driver **periph_drivers; MALLOC_DEFINE(M_CAMPERIPH, "CAM periph", "CAM peripheral buffers"); @@ -99,6 +100,7 @@ void periphdriver_register(void *data) { + struct periph_driver *drv = (struct periph_driver *)data; struct periph_driver **newdrivers, **old; int ndrivers; @@ -108,13 +110,30 @@ if (periph_drivers) bcopy(periph_drivers, newdrivers, sizeof(*newdrivers) * nperiph_drivers); - newdrivers[nperiph_drivers] = (struct periph_driver *)data; + newdrivers[nperiph_drivers] = drv; newdrivers[nperiph_drivers + 1] = NULL; old = periph_drivers; periph_drivers = newdrivers; if (old) free(old, M_CAMPERIPH); nperiph_drivers++; + /* If driver marked as early or it is late now, initialize it. */ + if (((drv->flags & CAM_PERIPH_DRV_EARLY) != 0 && initialized > 0) || + initialized > 1) + (*drv->init)(); +} + +void +periphdriver_init(int level) +{ + int i, early; + + initialized = max(initialized, level); + for (i = 0; periph_drivers[i] != NULL; i++) { + early = (periph_drivers[i]->flags & CAM_PERIPH_DRV_EARLY) ? 1 : 2; + if (early == initialized) + (*periph_drivers[i]->init)(); + } } cam_status ==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#25 (text+ko) ==== @@ -42,6 +42,7 @@ extern struct periph_driver **periph_drivers; void periphdriver_register(void *); +void periphdriver_init(int level); #include #define PERIPHDRIVER_DECLARE(name, driver) \ ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#135 (text+ko) ==== @@ -939,7 +939,8 @@ path, NULL, 0, xpt_sim); xpt_free_path(path); mtx_unlock(&xsoftc.xpt_lock); - + /* Install our software interrupt handlers */ + swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih); /* * Register a callback for when interrupts are enabled. */ @@ -951,7 +952,6 @@ "- 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); @@ -959,13 +959,6 @@ "- 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); - return (0); } @@ -4736,9 +4729,6 @@ static void xpt_config(void *arg) { - struct periph_driver **p_drv; - int i; - /* * Now that interrupts are enabled, go find our devices */ @@ -4772,13 +4762,11 @@ #endif /* CAM_DEBUG_BUS */ #endif /* CAMDEBUG */ - /* Register early peripheral drivers */ - /* XXX This will have to change when we have loadable modules */ - p_drv = periph_drivers; - for (i = 0; p_drv[i] != NULL; i++) { - if ((p_drv[i]->flags & CAM_PERIPH_DRV_EARLY) != 0) - (*p_drv[i]->init)(); + /* 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"); } + periphdriver_init(1); /* * Scan all installed busses. */ @@ -4821,18 +4809,9 @@ static void xpt_finishconfig_task(void *context, int pending) { - struct periph_driver **p_drv; - int i; if (busses_to_config == 0) { - /* Register all the peripheral drivers */ - /* XXX This will have to change when we have loadable modules */ - p_drv = periph_drivers; - for (i = 0; p_drv[i] != NULL; i++) { - if ((p_drv[i]->flags & CAM_PERIPH_DRV_EARLY) == 0) - (*p_drv[i]->init)(); - } - + periphdriver_init(2); /* * Check for devices with no "standard" peripheral driver * attached. For any devices like that, announce the