From owner-svn-src-all@FreeBSD.ORG Fri Mar 23 16:28:12 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1CD2C1065674; Fri, 23 Mar 2012 16:28:12 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1BB58FC1F; Fri, 23 Mar 2012 16:28:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2NGSBoD084227; Fri, 23 Mar 2012 16:28:11 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2NGSBmj084223; Fri, 23 Mar 2012 16:28:11 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201203231628.q2NGSBmj084223@svn.freebsd.org> From: Jim Harris Date: Fri, 23 Mar 2012 16:28:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233371 - head/sys/dev/isci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2012 16:28:12 -0000 Author: jimharris Date: Fri Mar 23 16:28:11 2012 New Revision: 233371 URL: http://svn.freebsd.org/changeset/base/233371 Log: Call xpt_bus_register during attach context, then freeze and do not release until domain discovery is complete. This fixes an isci(4) bug on FreeBSD 7.x where devices weren't always appearing after boot without an explicit rescan. Sponsored by: Intel Reported and tested by: Reviewed by: scottl Approved by: scottl Modified: head/sys/dev/isci/isci.h head/sys/dev/isci/isci_controller.c head/sys/dev/isci/isci_remote_device.c Modified: head/sys/dev/isci/isci.h ============================================================================== --- head/sys/dev/isci/isci.h Fri Mar 23 16:24:07 2012 (r233370) +++ head/sys/dev/isci/isci.h Fri Mar 23 16:28:11 2012 (r233371) @@ -122,6 +122,7 @@ struct ISCI_CONTROLLER SCI_CONTROLLER_HANDLE_T scif_controller_handle; struct ISCI_DOMAIN domain[SCI_MAX_DOMAINS]; BOOL is_started; + BOOL has_been_scanned; uint32_t initial_discovery_mask; BOOL is_frozen; uint8_t *remote_device_memory; Modified: head/sys/dev/isci/isci_controller.c ============================================================================== --- head/sys/dev/isci/isci_controller.c Fri Mar 23 16:24:07 2012 (r233370) +++ head/sys/dev/isci/isci_controller.c Fri Mar 23 16:28:11 2012 (r233371) @@ -36,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include #include @@ -300,6 +303,16 @@ SCI_STATUS isci_controller_initialize(st TUNABLE_INT_FETCH("hw.isci.io_shortage", &io_shortage); controller->sim_queue_depth += io_shortage; + /* Attach to CAM using xpt_bus_register now, then immediately freeze + * the simq. It will get released later when initial domain discovery + * is complete. + */ + controller->has_been_scanned = FALSE; + mtx_lock(&controller->lock); + isci_controller_attach_to_cam(controller); + xpt_freeze_simq(controller->sim, 1); + mtx_unlock(&controller->lock); + return (scif_controller_initialize(controller->scif_controller_handle)); } @@ -441,13 +454,13 @@ void isci_controller_start(void *control void isci_controller_domain_discovery_complete( struct ISCI_CONTROLLER *isci_controller, struct ISCI_DOMAIN *isci_domain) { - if (isci_controller->sim == NULL) + if (!isci_controller->has_been_scanned) { - /* Controller has not been attached to CAM yet. We'll clear + /* Controller has not been scanned yet. We'll clear * the discovery bit for this domain, then check if all bits * are now clear. That would indicate that all domains are - * done with discovery and we can then attach the controller - * to CAM. + * done with discovery and we can then proceed with initial + * scan. */ isci_controller->initial_discovery_mask &= @@ -457,7 +470,25 @@ void isci_controller_domain_discovery_co struct isci_softc *driver = isci_controller->isci; uint8_t next_index = isci_controller->index + 1; - isci_controller_attach_to_cam(isci_controller); + isci_controller->has_been_scanned = TRUE; + + /* Unfreeze simq to allow initial scan to proceed. */ + xpt_release_simq(isci_controller->sim, TRUE); + +#if __FreeBSD_version < 800000 + /* When driver is loaded after boot, we need to + * explicitly rescan here for versions <8.0, because + * CAM only automatically scans new buses at boot + * time. + */ + union ccb *ccb = xpt_alloc_ccb_nowait(); + + xpt_create_path(&ccb->ccb_h.path, xpt_periph, + cam_sim_path(isci_controller->sim), + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); + + xpt_rescan(ccb); +#endif if (next_index < driver->controller_count) { /* There are more controllers that need to Modified: head/sys/dev/isci/isci_remote_device.c ============================================================================== --- head/sys/dev/isci/isci_remote_device.c Fri Mar 23 16:24:07 2012 (r233370) +++ head/sys/dev/isci/isci_remote_device.c Fri Mar 23 16:28:11 2012 (r233371) @@ -74,13 +74,12 @@ scif_cb_remote_device_ready(SCI_CONTROLL isci_controller->remote_device[device_index] = isci_remote_device; - if (isci_controller->sim != NULL) { - /* The sim object is not NULL, meaning we have attached - * the controller to CAM already. In that case, create - * a CCB to instruct CAM to rescan this device. - * If the sim object is NULL, this device will get - * scanned as part of the initial scan when the - * controller is attached to CAM. + if (isci_controller->has_been_scanned) { + /* The sim object has been scanned at least once + * already. In that case, create a CCB to instruct + * CAM to rescan this device. + * If the sim object has not been scanned, this device + * will get scanned as part of the initial scan. */ union ccb *ccb = xpt_alloc_ccb_nowait();