From 0ae4d753afb2286f52c01661964d0495b7e496eb Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Mon, 9 Jul 2012 18:04:04 +0200 Subject: [PATCH] twa(4): Request a bus scan after attaching the driver to CAM. Our CAM doesn't (yet) do this by default. This fixes disk detection upon kldload. Taken-from: FreeBSD (which has since moved it to CAM). While here, add a cam_simq_release() I forgot and remove a comment that does not apply to us. --- sys/dev/raid/twa/tw_osl_cam.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/dev/raid/twa/tw_osl_cam.c b/sys/dev/raid/twa/tw_osl_cam.c index 1f2e46d4e5..895df450e0 100644 --- a/sys/dev/raid/twa/tw_osl_cam.c +++ b/sys/dev/raid/twa/tw_osl_cam.c @@ -76,6 +76,7 @@ TW_INT32 tw_osli_cam_attach(struct twa_softc *sc) { struct cam_devq *devq; + TW_INT32 error; tw_osli_dbg_dprintf(3, sc, "entered"); @@ -103,6 +104,7 @@ tw_osli_cam_attach(struct twa_softc *sc) device_get_unit(sc->bus_dev), sc->sim_lock, TW_OSLI_MAX_NUM_IOS, 1, devq); if (sc->sim == NULL) { + cam_simq_release(devq); tw_osli_printf(sc, "error = %d", TW_CL_SEVERITY_ERROR_STRING, TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, @@ -111,6 +113,7 @@ tw_osli_cam_attach(struct twa_softc *sc) ENOMEM); return(ENOMEM); } + cam_simq_release(devq); /* * Register the bus. @@ -136,8 +139,8 @@ tw_osli_cam_attach(struct twa_softc *sc) CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { xpt_bus_deregister(cam_sim_path (sc->sim)); - /* Passing TRUE to cam_sim_free will free the devq as well. */ cam_sim_free(sc->sim); + sc->sim = NULL; /* so cam_detach will not try to free it */ tw_osli_printf(sc, "error = %d", TW_CL_SEVERITY_ERROR_STRING, TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, @@ -149,6 +152,19 @@ tw_osli_cam_attach(struct twa_softc *sc) } lockmgr(sc->sim_lock, LK_RELEASE); + tw_osli_dbg_dprintf(3, sc, "Calling tw_osli_request_bus_scan"); + /* + * Request a bus scan, so that CAM gets to know of + * the logical units that we control. + */ + if ((error = tw_osli_request_bus_scan(sc))) + tw_osli_printf(sc, "error = %d", + TW_CL_SEVERITY_ERROR_STRING, + TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, + 0x2104, + "Bus scan request to CAM failed", + error); + tw_osli_dbg_dprintf(3, sc, "exiting"); return(0); } -- 2.41.0