From owner-svn-src-stable-9@FreeBSD.ORG Fri Mar 23 16:59:04 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28C05106566B; Fri, 23 Mar 2012 16:59:04 +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 0A3CD8FC0C; Fri, 23 Mar 2012 16:59:04 +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 q2NGx3GK085337; Fri, 23 Mar 2012 16:59:03 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2NGx3D9085333; Fri, 23 Mar 2012 16:59:03 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201203231659.q2NGx3D9085333@svn.freebsd.org> From: Jim Harris Date: Fri, 23 Mar 2012 16:59:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233372 - stable/9/sys/dev/isci X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2012 16:59:04 -0000 Author: jimharris Date: Fri Mar 23 16:59:03 2012 New Revision: 233372 URL: http://svn.freebsd.org/changeset/base/233372 Log: MFC r233371: 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: stable/9/sys/dev/isci/isci.h stable/9/sys/dev/isci/isci_controller.c stable/9/sys/dev/isci/isci_remote_device.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/isci/isci.h ============================================================================== --- stable/9/sys/dev/isci/isci.h Fri Mar 23 16:28:11 2012 (r233371) +++ stable/9/sys/dev/isci/isci.h Fri Mar 23 16:59:03 2012 (r233372) @@ -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: stable/9/sys/dev/isci/isci_controller.c ============================================================================== --- stable/9/sys/dev/isci/isci_controller.c Fri Mar 23 16:28:11 2012 (r233371) +++ stable/9/sys/dev/isci/isci_controller.c Fri Mar 23 16:59:03 2012 (r233372) @@ -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: stable/9/sys/dev/isci/isci_remote_device.c ============================================================================== --- stable/9/sys/dev/isci/isci_remote_device.c Fri Mar 23 16:28:11 2012 (r233371) +++ stable/9/sys/dev/isci/isci_remote_device.c Fri Mar 23 16:59:03 2012 (r233372) @@ -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();