diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-02-04 09:43:16 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-02-17 14:22:16 -0500 |
commit | a08a8471b7aed3d50df8e9c852dc2baa08ec8b01 (patch) | |
tree | d32473715467a46fc39b6af9b3f889666a86a98f /drivers/scsi/hpsa.c | |
parent | a23513e8413e02b7e34e96a03d6bfd1c1948ac00 (diff) |
[SCSI] hpsa: use scan_start and scan_finished entry points for scanning
use scan_start and scan_finished entry points for scanning and route
the CCISS_REGNEWD ioctl and sysfs triggering of same functionality
through hpsa_scan_start.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r-- | drivers/scsi/hpsa.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index e81df76df821..f889ec8cc481 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -131,6 +131,9 @@ static void fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, | |||
131 | 131 | ||
132 | static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, | 132 | static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, |
133 | void (*done)(struct scsi_cmnd *)); | 133 | void (*done)(struct scsi_cmnd *)); |
134 | static void hpsa_scan_start(struct Scsi_Host *); | ||
135 | static int hpsa_scan_finished(struct Scsi_Host *sh, | ||
136 | unsigned long elapsed_time); | ||
134 | 137 | ||
135 | static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd); | 138 | static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd); |
136 | static int hpsa_slave_alloc(struct scsi_device *sdev); | 139 | static int hpsa_slave_alloc(struct scsi_device *sdev); |
@@ -177,6 +180,8 @@ static struct scsi_host_template hpsa_driver_template = { | |||
177 | .name = "hpsa", | 180 | .name = "hpsa", |
178 | .proc_name = "hpsa", | 181 | .proc_name = "hpsa", |
179 | .queuecommand = hpsa_scsi_queue_command, | 182 | .queuecommand = hpsa_scsi_queue_command, |
183 | .scan_start = hpsa_scan_start, | ||
184 | .scan_finished = hpsa_scan_finished, | ||
180 | .this_id = -1, | 185 | .this_id = -1, |
181 | .sg_tablesize = MAXSGENTRIES, | 186 | .sg_tablesize = MAXSGENTRIES, |
182 | .use_clustering = ENABLE_CLUSTERING, | 187 | .use_clustering = ENABLE_CLUSTERING, |
@@ -320,7 +325,7 @@ static int hpsa_scan_func(__attribute__((unused)) void *data) | |||
320 | h->busy_scanning = 1; | 325 | h->busy_scanning = 1; |
321 | mutex_unlock(&hpsa_scan_mutex); | 326 | mutex_unlock(&hpsa_scan_mutex); |
322 | host_no = h->scsi_host ? h->scsi_host->host_no : -1; | 327 | host_no = h->scsi_host ? h->scsi_host->host_no : -1; |
323 | hpsa_update_scsi_devices(h, host_no); | 328 | hpsa_scan_start(h->scsi_host); |
324 | complete_all(&h->scan_wait); | 329 | complete_all(&h->scan_wait); |
325 | mutex_lock(&hpsa_scan_mutex); | 330 | mutex_lock(&hpsa_scan_mutex); |
326 | h->busy_scanning = 0; | 331 | h->busy_scanning = 0; |
@@ -2006,6 +2011,48 @@ static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd, | |||
2006 | return 0; | 2011 | return 0; |
2007 | } | 2012 | } |
2008 | 2013 | ||
2014 | static void hpsa_scan_start(struct Scsi_Host *sh) | ||
2015 | { | ||
2016 | struct ctlr_info *h = shost_to_hba(sh); | ||
2017 | unsigned long flags; | ||
2018 | |||
2019 | /* wait until any scan already in progress is finished. */ | ||
2020 | while (1) { | ||
2021 | spin_lock_irqsave(&h->scan_lock, flags); | ||
2022 | if (h->scan_finished) | ||
2023 | break; | ||
2024 | spin_unlock_irqrestore(&h->scan_lock, flags); | ||
2025 | wait_event(h->scan_wait_queue, h->scan_finished); | ||
2026 | /* Note: We don't need to worry about a race between this | ||
2027 | * thread and driver unload because the midlayer will | ||
2028 | * have incremented the reference count, so unload won't | ||
2029 | * happen if we're in here. | ||
2030 | */ | ||
2031 | } | ||
2032 | h->scan_finished = 0; /* mark scan as in progress */ | ||
2033 | spin_unlock_irqrestore(&h->scan_lock, flags); | ||
2034 | |||
2035 | hpsa_update_scsi_devices(h, h->scsi_host->host_no); | ||
2036 | |||
2037 | spin_lock_irqsave(&h->scan_lock, flags); | ||
2038 | h->scan_finished = 1; /* mark scan as finished. */ | ||
2039 | wake_up_all(&h->scan_wait_queue); | ||
2040 | spin_unlock_irqrestore(&h->scan_lock, flags); | ||
2041 | } | ||
2042 | |||
2043 | static int hpsa_scan_finished(struct Scsi_Host *sh, | ||
2044 | unsigned long elapsed_time) | ||
2045 | { | ||
2046 | struct ctlr_info *h = shost_to_hba(sh); | ||
2047 | unsigned long flags; | ||
2048 | int finished; | ||
2049 | |||
2050 | spin_lock_irqsave(&h->scan_lock, flags); | ||
2051 | finished = h->scan_finished; | ||
2052 | spin_unlock_irqrestore(&h->scan_lock, flags); | ||
2053 | return finished; | ||
2054 | } | ||
2055 | |||
2009 | static void hpsa_unregister_scsi(struct ctlr_info *h) | 2056 | static void hpsa_unregister_scsi(struct ctlr_info *h) |
2010 | { | 2057 | { |
2011 | /* we are being forcibly unloaded, and may not refuse. */ | 2058 | /* we are being forcibly unloaded, and may not refuse. */ |
@@ -2018,7 +2065,6 @@ static int hpsa_register_scsi(struct ctlr_info *h) | |||
2018 | { | 2065 | { |
2019 | int rc; | 2066 | int rc; |
2020 | 2067 | ||
2021 | hpsa_update_scsi_devices(h, -1); | ||
2022 | rc = hpsa_scsi_detect(h); | 2068 | rc = hpsa_scsi_detect(h); |
2023 | if (rc != 0) | 2069 | if (rc != 0) |
2024 | dev_err(&h->pdev->dev, "hpsa_register_scsi: failed" | 2070 | dev_err(&h->pdev->dev, "hpsa_register_scsi: failed" |
@@ -2619,7 +2665,7 @@ static int hpsa_ioctl(struct scsi_device *dev, int cmd, void *arg) | |||
2619 | case CCISS_DEREGDISK: | 2665 | case CCISS_DEREGDISK: |
2620 | case CCISS_REGNEWDISK: | 2666 | case CCISS_REGNEWDISK: |
2621 | case CCISS_REGNEWD: | 2667 | case CCISS_REGNEWD: |
2622 | hpsa_update_scsi_devices(h, dev->host->host_no); | 2668 | hpsa_scan_start(h->scsi_host); |
2623 | return 0; | 2669 | return 0; |
2624 | case CCISS_GETPCIINFO: | 2670 | case CCISS_GETPCIINFO: |
2625 | return hpsa_getpciinfo_ioctl(h, argp); | 2671 | return hpsa_getpciinfo_ioctl(h, argp); |
@@ -3532,6 +3578,9 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev, | |||
3532 | goto clean4; | 3578 | goto clean4; |
3533 | } | 3579 | } |
3534 | spin_lock_init(&h->lock); | 3580 | spin_lock_init(&h->lock); |
3581 | spin_lock_init(&h->scan_lock); | ||
3582 | init_waitqueue_head(&h->scan_wait_queue); | ||
3583 | h->scan_finished = 1; /* no scan currently in progress */ | ||
3535 | 3584 | ||
3536 | pci_set_drvdata(pdev, h); | 3585 | pci_set_drvdata(pdev, h); |
3537 | memset(h->cmd_pool_bits, 0, | 3586 | memset(h->cmd_pool_bits, 0, |