Commit c59d04f3 authored by Don Brace's avatar Don Brace Committed by Martin K. Petersen

scsi: hpsa: cleanup reset handler

- mark device state sooner.
Reviewed-by: default avatarScott Benesh <scott.benesh@microsemi.com>
Reviewed-by: default avatarScott Teel <scott.teel@microsemi.com>
Reviewed-by: default avatarKevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: default avatarDon Brace <don.brace@microsemi.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d2315ce6
...@@ -1859,10 +1859,13 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, ...@@ -1859,10 +1859,13 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
* A reset can cause a device status to change * A reset can cause a device status to change
* re-schedule the scan to see what happened. * re-schedule the scan to see what happened.
*/ */
spin_lock_irqsave(&h->reset_lock, flags);
if (h->reset_in_progress) { if (h->reset_in_progress) {
h->drv_req_rescan = 1; h->drv_req_rescan = 1;
spin_unlock_irqrestore(&h->reset_lock, flags);
return; return;
} }
spin_unlock_irqrestore(&h->reset_lock, flags);
added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
...@@ -5618,11 +5621,14 @@ static void hpsa_scan_start(struct Scsi_Host *sh) ...@@ -5618,11 +5621,14 @@ static void hpsa_scan_start(struct Scsi_Host *sh)
/* /*
* Do the scan after a reset completion * Do the scan after a reset completion
*/ */
spin_lock_irqsave(&h->reset_lock, flags);
if (h->reset_in_progress) { if (h->reset_in_progress) {
h->drv_req_rescan = 1; h->drv_req_rescan = 1;
spin_unlock_irqrestore(&h->reset_lock, flags);
hpsa_scan_complete(h); hpsa_scan_complete(h);
return; return;
} }
spin_unlock_irqrestore(&h->reset_lock, flags);
hpsa_update_scsi_devices(h); hpsa_update_scsi_devices(h);
...@@ -5834,28 +5840,38 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h, ...@@ -5834,28 +5840,38 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h,
*/ */
static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
{ {
int rc; int rc = SUCCESS;
struct ctlr_info *h; struct ctlr_info *h;
struct hpsa_scsi_dev_t *dev; struct hpsa_scsi_dev_t *dev;
u8 reset_type; u8 reset_type;
char msg[48]; char msg[48];
unsigned long flags;
/* find the controller to which the command to be aborted was sent */ /* find the controller to which the command to be aborted was sent */
h = sdev_to_hba(scsicmd->device); h = sdev_to_hba(scsicmd->device);
if (h == NULL) /* paranoia */ if (h == NULL) /* paranoia */
return FAILED; return FAILED;
if (lockup_detected(h)) spin_lock_irqsave(&h->reset_lock, flags);
return FAILED; h->reset_in_progress = 1;
spin_unlock_irqrestore(&h->reset_lock, flags);
if (lockup_detected(h)) {
rc = FAILED;
goto return_reset_status;
}
dev = scsicmd->device->hostdata; dev = scsicmd->device->hostdata;
if (!dev) { if (!dev) {
dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__); dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__);
return FAILED; rc = FAILED;
goto return_reset_status;
} }
if (dev->devtype == TYPE_ENCLOSURE) if (dev->devtype == TYPE_ENCLOSURE) {
return SUCCESS; rc = SUCCESS;
goto return_reset_status;
}
/* if controller locked up, we can guarantee command won't complete */ /* if controller locked up, we can guarantee command won't complete */
if (lockup_detected(h)) { if (lockup_detected(h)) {
...@@ -5863,7 +5879,8 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) ...@@ -5863,7 +5879,8 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
"cmd %d RESET FAILED, lockup detected", "cmd %d RESET FAILED, lockup detected",
hpsa_get_cmd_index(scsicmd)); hpsa_get_cmd_index(scsicmd));
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
return FAILED; rc = FAILED;
goto return_reset_status;
} }
/* this reset request might be the result of a lockup; check */ /* this reset request might be the result of a lockup; check */
...@@ -5872,12 +5889,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) ...@@ -5872,12 +5889,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
"cmd %d RESET FAILED, new lockup detected", "cmd %d RESET FAILED, new lockup detected",
hpsa_get_cmd_index(scsicmd)); hpsa_get_cmd_index(scsicmd));
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
return FAILED; rc = FAILED;
goto return_reset_status;
} }
/* Do not attempt on controller */ /* Do not attempt on controller */
if (is_hba_lunid(dev->scsi3addr)) if (is_hba_lunid(dev->scsi3addr)) {
return SUCCESS; rc = SUCCESS;
goto return_reset_status;
}
if (is_logical_dev_addr_mode(dev->scsi3addr)) if (is_logical_dev_addr_mode(dev->scsi3addr))
reset_type = HPSA_DEVICE_RESET_MSG; reset_type = HPSA_DEVICE_RESET_MSG;
...@@ -5888,17 +5908,24 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) ...@@ -5888,17 +5908,24 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical "); reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ");
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
h->reset_in_progress = 1;
/* send a reset to the SCSI LUN which the command was sent to */ /* send a reset to the SCSI LUN which the command was sent to */
rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type, rc = hpsa_do_reset(h, dev, dev->scsi3addr, reset_type,
DEFAULT_REPLY_QUEUE); DEFAULT_REPLY_QUEUE);
if (rc == 0)
rc = SUCCESS;
else
rc = FAILED;
sprintf(msg, "reset %s %s", sprintf(msg, "reset %s %s",
reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ", reset_type == HPSA_DEVICE_RESET_MSG ? "logical " : "physical ",
rc == 0 ? "completed successfully" : "failed"); rc == SUCCESS ? "completed successfully" : "failed");
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
return_reset_status:
spin_lock_irqsave(&h->reset_lock, flags);
h->reset_in_progress = 0; h->reset_in_progress = 0;
return rc == 0 ? SUCCESS : FAILED; spin_unlock_irqrestore(&h->reset_lock, flags);
return rc;
} }
static void swizzle_abort_tag(u8 *tag) static void swizzle_abort_tag(u8 *tag)
...@@ -8649,10 +8676,13 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work) ...@@ -8649,10 +8676,13 @@ static void hpsa_rescan_ctlr_worker(struct work_struct *work)
/* /*
* Do the scan after the reset * Do the scan after the reset
*/ */
spin_lock_irqsave(&h->reset_lock, flags);
if (h->reset_in_progress) { if (h->reset_in_progress) {
h->drv_req_rescan = 1; h->drv_req_rescan = 1;
spin_unlock_irqrestore(&h->reset_lock, flags);
return; return;
} }
spin_unlock_irqrestore(&h->reset_lock, flags);
if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) { if (hpsa_ctlr_needs_rescan(h) || hpsa_offline_devices_ready(h)) {
scsi_host_get(h->scsi_host); scsi_host_get(h->scsi_host);
...@@ -8759,6 +8789,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -8759,6 +8789,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
spin_lock_init(&h->lock); spin_lock_init(&h->lock);
spin_lock_init(&h->offline_device_lock); spin_lock_init(&h->offline_device_lock);
spin_lock_init(&h->scan_lock); spin_lock_init(&h->scan_lock);
spin_lock_init(&h->reset_lock);
atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS);
atomic_set(&h->abort_cmds_available, HPSA_CMDS_RESERVED_FOR_ABORTS); atomic_set(&h->abort_cmds_available, HPSA_CMDS_RESERVED_FOR_ABORTS);
......
...@@ -301,6 +301,7 @@ struct ctlr_info { ...@@ -301,6 +301,7 @@ struct ctlr_info {
struct mutex reset_mutex; struct mutex reset_mutex;
u8 reset_in_progress; u8 reset_in_progress;
struct hpsa_sas_node *sas_host; struct hpsa_sas_node *sas_host;
spinlock_t reset_lock;
}; };
struct offline_device_entry { struct offline_device_entry {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment