summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorjimharris <jimharris@FreeBSD.org>2012-03-23 16:28:11 +0000
committerjimharris <jimharris@FreeBSD.org>2012-03-23 16:28:11 +0000
commitaeccd8bc9c4ea46cdcd36a520c6d368002605052 (patch)
treed7df4f78bcef9fb1b6c87cd6235453e980ec9eff /sys/dev
parent6a38dcaba9004d2df7ab8d3e81ef28bc712e864a (diff)
downloadFreeBSD-src-aeccd8bc9c4ea46cdcd36a520c6d368002605052.zip
FreeBSD-src-aeccd8bc9c4ea46cdcd36a520c6d368002605052.tar.gz
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: <rpokala at panasas dot com> Reviewed by: scottl Approved by: scottl
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isci/isci.h1
-rw-r--r--sys/dev/isci/isci_controller.c41
-rw-r--r--sys/dev/isci/isci_remote_device.c13
3 files changed, 43 insertions, 12 deletions
diff --git a/sys/dev/isci/isci.h b/sys/dev/isci/isci.h
index 66a0330..70ba16a 100644
--- a/sys/dev/isci/isci.h
+++ b/sys/dev/isci/isci.h
@@ -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;
diff --git a/sys/dev/isci/isci_controller.c b/sys/dev/isci/isci_controller.c
index f240928..38d91ac 100644
--- a/sys/dev/isci/isci_controller.c
+++ b/sys/dev/isci/isci_controller.c
@@ -36,6 +36,9 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/malloc.h>
+#include <cam/cam_periph.h>
+#include <cam/cam_xpt_periph.h>
+
#include <dev/isci/scil/sci_memory_descriptor_list.h>
#include <dev/isci/scil/sci_memory_descriptor_list_decorator.h>
@@ -300,6 +303,16 @@ SCI_STATUS isci_controller_initialize(struct ISCI_CONTROLLER *controller)
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 *controller_handle)
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_complete(
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
diff --git a/sys/dev/isci/isci_remote_device.c b/sys/dev/isci/isci_remote_device.c
index 2388dae..d22b4d4 100644
--- a/sys/dev/isci/isci_remote_device.c
+++ b/sys/dev/isci/isci_remote_device.c
@@ -74,13 +74,12 @@ scif_cb_remote_device_ready(SCI_CONTROLLER_HANDLE_T controller,
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();
OpenPOWER on IntegriCloud