summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Brace <don.brace@microsemi.com>2017-05-04 18:51:49 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2017-06-12 20:48:01 -0400
commit08ec46f673369f65dfc6fc52fb7fadb39776e81f (patch)
tree09681df625093c7afd143cc4814838f147b4b831
parentb63c64ac5a5ccb6ee56e0d906f2f5d2b7e54cbd9 (diff)
scsi: hpsa: remove abort handler
- simplify the driver - there are a lot of quirky racy conditions not handled - causes more aborts/resets when the number of commands to be aborted is large, such as in multi-path fail-overs. - has been turned off in our internal driver since 8/31/2015 Reviewed-by: Scott Benesh <scott.benesh@microsemi.com> Reviewed-by: Scott Teel <scott.teel@microsemi.com> Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com> Signed-off-by: Don Brace <don.brace@microsemi.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/hpsa.c621
-rw-r--r--drivers/scsi/hpsa.h1
2 files changed, 8 insertions, 614 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ea778cc453dc..9a631e399169 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -258,7 +258,6 @@ static int hpsa_scan_finished(struct Scsi_Host *sh,
258static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth); 258static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth);
259 259
260static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd); 260static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd);
261static int hpsa_eh_abort_handler(struct scsi_cmnd *scsicmd);
262static int hpsa_slave_alloc(struct scsi_device *sdev); 261static int hpsa_slave_alloc(struct scsi_device *sdev);
263static int hpsa_slave_configure(struct scsi_device *sdev); 262static int hpsa_slave_configure(struct scsi_device *sdev);
264static void hpsa_slave_destroy(struct scsi_device *sdev); 263static void hpsa_slave_destroy(struct scsi_device *sdev);
@@ -326,7 +325,7 @@ static inline bool hpsa_is_cmd_idle(struct CommandList *c)
326 325
327static inline bool hpsa_is_pending_event(struct CommandList *c) 326static inline bool hpsa_is_pending_event(struct CommandList *c)
328{ 327{
329 return c->abort_pending || c->reset_pending; 328 return c->reset_pending;
330} 329}
331 330
332/* extract sense key, asc, and ascq from sense data. -1 means invalid. */ 331/* extract sense key, asc, and ascq from sense data. -1 means invalid. */
@@ -581,12 +580,6 @@ static u32 soft_unresettable_controller[] = {
581 0x409D0E11, /* Smart Array 6400 EM */ 580 0x409D0E11, /* Smart Array 6400 EM */
582}; 581};
583 582
584static u32 needs_abort_tags_swizzled[] = {
585 0x323D103C, /* Smart Array P700m */
586 0x324a103C, /* Smart Array P712m */
587 0x324b103C, /* SmartArray P711m */
588};
589
590static int board_id_in_array(u32 a[], int nelems, u32 board_id) 583static int board_id_in_array(u32 a[], int nelems, u32 board_id)
591{ 584{
592 int i; 585 int i;
@@ -615,12 +608,6 @@ static int ctlr_is_resettable(u32 board_id)
615 ctlr_is_soft_resettable(board_id); 608 ctlr_is_soft_resettable(board_id);
616} 609}
617 610
618static int ctlr_needs_abort_tags_swizzled(u32 board_id)
619{
620 return board_id_in_array(needs_abort_tags_swizzled,
621 ARRAY_SIZE(needs_abort_tags_swizzled), board_id);
622}
623
624static ssize_t host_show_resettable(struct device *dev, 611static ssize_t host_show_resettable(struct device *dev,
625 struct device_attribute *attr, char *buf) 612 struct device_attribute *attr, char *buf)
626{ 613{
@@ -928,8 +915,8 @@ static struct device_attribute *hpsa_shost_attrs[] = {
928 NULL, 915 NULL,
929}; 916};
930 917
931#define HPSA_NRESERVED_CMDS (HPSA_CMDS_RESERVED_FOR_ABORTS + \ 918#define HPSA_NRESERVED_CMDS (HPSA_CMDS_RESERVED_FOR_DRIVER +\
932 HPSA_CMDS_RESERVED_FOR_DRIVER + HPSA_MAX_CONCURRENT_PASSTHRUS) 919 HPSA_MAX_CONCURRENT_PASSTHRUS)
933 920
934static struct scsi_host_template hpsa_driver_template = { 921static struct scsi_host_template hpsa_driver_template = {
935 .module = THIS_MODULE, 922 .module = THIS_MODULE,
@@ -941,7 +928,6 @@ static struct scsi_host_template hpsa_driver_template = {
941 .change_queue_depth = hpsa_change_queue_depth, 928 .change_queue_depth = hpsa_change_queue_depth,
942 .this_id = -1, 929 .this_id = -1,
943 .use_clustering = ENABLE_CLUSTERING, 930 .use_clustering = ENABLE_CLUSTERING,
944 .eh_abort_handler = hpsa_eh_abort_handler,
945 .eh_device_reset_handler = hpsa_eh_device_reset_handler, 931 .eh_device_reset_handler = hpsa_eh_device_reset_handler,
946 .ioctl = hpsa_ioctl, 932 .ioctl = hpsa_ioctl,
947 .slave_alloc = hpsa_slave_alloc, 933 .slave_alloc = hpsa_slave_alloc,
@@ -2361,26 +2347,12 @@ static void hpsa_cmd_resolve_events(struct ctlr_info *h,
2361 bool do_wake = false; 2347 bool do_wake = false;
2362 2348
2363 /* 2349 /*
2364 * Prevent the following race in the abort handler: 2350 * Reset c->scsi_cmd here so that the reset handler will know
2365 *
2366 * 1. LLD is requested to abort a SCSI command
2367 * 2. The SCSI command completes
2368 * 3. The struct CommandList associated with step 2 is made available
2369 * 4. New I/O request to LLD to another LUN re-uses struct CommandList
2370 * 5. Abort handler follows scsi_cmnd->host_scribble and
2371 * finds struct CommandList and tries to aborts it
2372 * Now we have aborted the wrong command.
2373 *
2374 * Reset c->scsi_cmd here so that the abort or reset handler will know
2375 * this command has completed. Then, check to see if the handler is 2351 * this command has completed. Then, check to see if the handler is
2376 * waiting for this command, and, if so, wake it. 2352 * waiting for this command, and, if so, wake it.
2377 */ 2353 */
2378 c->scsi_cmd = SCSI_CMD_IDLE; 2354 c->scsi_cmd = SCSI_CMD_IDLE;
2379 mb(); /* Declare command idle before checking for pending events. */ 2355 mb(); /* Declare command idle before checking for pending events. */
2380 if (c->abort_pending) {
2381 do_wake = true;
2382 c->abort_pending = false;
2383 }
2384 if (c->reset_pending) { 2356 if (c->reset_pending) {
2385 unsigned long flags; 2357 unsigned long flags;
2386 struct hpsa_scsi_dev_t *dev; 2358 struct hpsa_scsi_dev_t *dev;
@@ -2423,20 +2395,6 @@ static void hpsa_retry_cmd(struct ctlr_info *h, struct CommandList *c)
2423 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work); 2395 queue_work_on(raw_smp_processor_id(), h->resubmit_wq, &c->work);
2424} 2396}
2425 2397
2426static void hpsa_set_scsi_cmd_aborted(struct scsi_cmnd *cmd)
2427{
2428 cmd->result = DID_ABORT << 16;
2429}
2430
2431static void hpsa_cmd_abort_and_free(struct ctlr_info *h, struct CommandList *c,
2432 struct scsi_cmnd *cmd)
2433{
2434 hpsa_set_scsi_cmd_aborted(cmd);
2435 dev_warn(&h->pdev->dev, "CDB %16phN was aborted with status 0x%x\n",
2436 c->Request.CDB, c->err_info->ScsiStatus);
2437 hpsa_cmd_resolve_and_free(h, c);
2438}
2439
2440static void process_ioaccel2_completion(struct ctlr_info *h, 2398static void process_ioaccel2_completion(struct ctlr_info *h,
2441 struct CommandList *c, struct scsi_cmnd *cmd, 2399 struct CommandList *c, struct scsi_cmnd *cmd,
2442 struct hpsa_scsi_dev_t *dev) 2400 struct hpsa_scsi_dev_t *dev)
@@ -2561,12 +2519,9 @@ static void complete_scsi_command(struct CommandList *cp)
2561 return hpsa_cmd_free_and_done(h, cp, cmd); 2519 return hpsa_cmd_free_and_done(h, cp, cmd);
2562 } 2520 }
2563 2521
2564 if ((unlikely(hpsa_is_pending_event(cp)))) { 2522 if ((unlikely(hpsa_is_pending_event(cp))))
2565 if (cp->reset_pending) 2523 if (cp->reset_pending)
2566 return hpsa_cmd_free_and_done(h, cp, cmd); 2524 return hpsa_cmd_free_and_done(h, cp, cmd);
2567 if (cp->abort_pending)
2568 return hpsa_cmd_abort_and_free(h, cp, cmd);
2569 }
2570 2525
2571 if (cp->cmd_type == CMD_IOACCEL2) 2526 if (cp->cmd_type == CMD_IOACCEL2)
2572 return process_ioaccel2_completion(h, cp, cmd, dev); 2527 return process_ioaccel2_completion(h, cp, cmd, dev);
@@ -2686,8 +2641,8 @@ static void complete_scsi_command(struct CommandList *cp)
2686 cp->Request.CDB); 2641 cp->Request.CDB);
2687 break; 2642 break;
2688 case CMD_ABORTED: 2643 case CMD_ABORTED:
2689 /* Return now to avoid calling scsi_done(). */ 2644 cmd->result = DID_ABORT << 16;
2690 return hpsa_cmd_abort_and_free(h, cp, cmd); 2645 break;
2691 case CMD_ABORT_FAILED: 2646 case CMD_ABORT_FAILED:
2692 cmd->result = DID_ERROR << 16; 2647 cmd->result = DID_ERROR << 16;
2693 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n", 2648 dev_warn(&h->pdev->dev, "CDB %16phN : abort failed\n",
@@ -3793,53 +3748,6 @@ static unsigned char hpsa_volume_offline(struct ctlr_info *h,
3793 return HPSA_LV_OK; 3748 return HPSA_LV_OK;
3794} 3749}
3795 3750
3796/*
3797 * Find out if a logical device supports aborts by simply trying one.
3798 * Smart Array may claim not to support aborts on logical drives, but
3799 * if a MSA2000 * is connected, the drives on that will be presented
3800 * by the Smart Array as logical drives, and aborts may be sent to
3801 * those devices successfully. So the simplest way to find out is
3802 * to simply try an abort and see how the device responds.
3803 */
3804static int hpsa_device_supports_aborts(struct ctlr_info *h,
3805 unsigned char *scsi3addr)
3806{
3807 struct CommandList *c;
3808 struct ErrorInfo *ei;
3809 int rc = 0;
3810
3811 u64 tag = (u64) -1; /* bogus tag */
3812
3813 /* Assume that physical devices support aborts */
3814 if (!is_logical_dev_addr_mode(scsi3addr))
3815 return 1;
3816
3817 c = cmd_alloc(h);
3818
3819 (void) fill_cmd(c, HPSA_ABORT_MSG, h, &tag, 0, 0, scsi3addr, TYPE_MSG);
3820 (void) hpsa_scsi_do_simple_cmd(h, c, DEFAULT_REPLY_QUEUE,
3821 DEFAULT_TIMEOUT);
3822 /* no unmap needed here because no data xfer. */
3823 ei = c->err_info;
3824 switch (ei->CommandStatus) {
3825 case CMD_INVALID:
3826 rc = 0;
3827 break;
3828 case CMD_UNABORTABLE:
3829 case CMD_ABORT_FAILED:
3830 rc = 1;
3831 break;
3832 case CMD_TMF_STATUS:
3833 rc = hpsa_evaluate_tmf_status(h, c);
3834 break;
3835 default:
3836 rc = 0;
3837 break;
3838 }
3839 cmd_free(h, c);
3840 return rc;
3841}
3842
3843static int hpsa_update_device_info(struct ctlr_info *h, 3751static int hpsa_update_device_info(struct ctlr_info *h,
3844 unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device, 3752 unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device,
3845 unsigned char *is_OBDR_device) 3753 unsigned char *is_OBDR_device)
@@ -3939,31 +3847,6 @@ bail_out:
3939 return rc; 3847 return rc;
3940} 3848}
3941 3849
3942static void hpsa_update_device_supports_aborts(struct ctlr_info *h,
3943 struct hpsa_scsi_dev_t *dev, u8 *scsi3addr)
3944{
3945 unsigned long flags;
3946 int rc, entry;
3947 /*
3948 * See if this device supports aborts. If we already know
3949 * the device, we already know if it supports aborts, otherwise
3950 * we have to find out if it supports aborts by trying one.
3951 */
3952 spin_lock_irqsave(&h->devlock, flags);
3953 rc = hpsa_scsi_find_entry(dev, h->dev, h->ndevices, &entry);
3954 if ((rc == DEVICE_SAME || rc == DEVICE_UPDATED) &&
3955 entry >= 0 && entry < h->ndevices) {
3956 dev->supports_aborts = h->dev[entry]->supports_aborts;
3957 spin_unlock_irqrestore(&h->devlock, flags);
3958 } else {
3959 spin_unlock_irqrestore(&h->devlock, flags);
3960 dev->supports_aborts =
3961 hpsa_device_supports_aborts(h, scsi3addr);
3962 if (dev->supports_aborts < 0)
3963 dev->supports_aborts = 0;
3964 }
3965}
3966
3967/* 3850/*
3968 * Helper function to assign bus, target, lun mapping of devices. 3851 * Helper function to assign bus, target, lun mapping of devices.
3969 * Logical drive target and lun are assigned at this time, but 3852 * Logical drive target and lun are assigned at this time, but
@@ -4001,35 +3884,6 @@ static void figure_bus_target_lun(struct ctlr_info *h,
4001 0, lunid & 0x3fff); 3884 0, lunid & 0x3fff);
4002} 3885}
4003 3886
4004
4005/*
4006 * Get address of physical disk used for an ioaccel2 mode command:
4007 * 1. Extract ioaccel2 handle from the command.
4008 * 2. Find a matching ioaccel2 handle from list of physical disks.
4009 * 3. Return:
4010 * 1 and set scsi3addr to address of matching physical
4011 * 0 if no matching physical disk was found.
4012 */
4013static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h,
4014 struct CommandList *ioaccel2_cmd_to_abort, unsigned char *scsi3addr)
4015{
4016 struct io_accel2_cmd *c2 =
4017 &h->ioaccel2_cmd_pool[ioaccel2_cmd_to_abort->cmdindex];
4018 unsigned long flags;
4019 int i;
4020
4021 spin_lock_irqsave(&h->devlock, flags);
4022 for (i = 0; i < h->ndevices; i++)
4023 if (h->dev[i]->ioaccel_handle == le32_to_cpu(c2->scsi_nexus)) {
4024 memcpy(scsi3addr, h->dev[i]->scsi3addr,
4025 sizeof(h->dev[i]->scsi3addr));
4026 spin_unlock_irqrestore(&h->devlock, flags);
4027 return 1;
4028 }
4029 spin_unlock_irqrestore(&h->devlock, flags);
4030 return 0;
4031}
4032
4033static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position, 3887static int figure_external_status(struct ctlr_info *h, int raid_ctlr_position,
4034 int i, int nphysicals, int nlocal_logicals) 3888 int i, int nphysicals, int nlocal_logicals)
4035{ 3889{
@@ -4394,7 +4248,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
4394 } 4248 }
4395 4249
4396 figure_bus_target_lun(h, lunaddrbytes, tmpdevice); 4250 figure_bus_target_lun(h, lunaddrbytes, tmpdevice);
4397 hpsa_update_device_supports_aborts(h, tmpdevice, lunaddrbytes);
4398 this_device = currentsd[ncurrent]; 4251 this_device = currentsd[ncurrent];
4399 4252
4400 /* Turn on discovery_polling if there are ext target devices. 4253 /* Turn on discovery_polling if there are ext target devices.
@@ -5528,8 +5381,6 @@ static void hpsa_command_resubmit_worker(struct work_struct *work)
5528 } 5381 }
5529 if (c->reset_pending) 5382 if (c->reset_pending)
5530 return hpsa_cmd_free_and_done(c->h, c, cmd); 5383 return hpsa_cmd_free_and_done(c->h, c, cmd);
5531 if (c->abort_pending)
5532 return hpsa_cmd_abort_and_free(c->h, c, cmd);
5533 if (c->cmd_type == CMD_IOACCEL2) { 5384 if (c->cmd_type == CMD_IOACCEL2) {
5534 struct ctlr_info *h = c->h; 5385 struct ctlr_info *h = c->h;
5535 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; 5386 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex];
@@ -5987,433 +5838,6 @@ return_reset_status:
5987 return rc; 5838 return rc;
5988} 5839}
5989 5840
5990static void swizzle_abort_tag(u8 *tag)
5991{
5992 u8 original_tag[8];
5993
5994 memcpy(original_tag, tag, 8);
5995 tag[0] = original_tag[3];
5996 tag[1] = original_tag[2];
5997 tag[2] = original_tag[1];
5998 tag[3] = original_tag[0];
5999 tag[4] = original_tag[7];
6000 tag[5] = original_tag[6];
6001 tag[6] = original_tag[5];
6002 tag[7] = original_tag[4];
6003}
6004
6005static void hpsa_get_tag(struct ctlr_info *h,
6006 struct CommandList *c, __le32 *taglower, __le32 *tagupper)
6007{
6008 u64 tag;
6009 if (c->cmd_type == CMD_IOACCEL1) {
6010 struct io_accel1_cmd *cm1 = (struct io_accel1_cmd *)
6011 &h->ioaccel_cmd_pool[c->cmdindex];
6012 tag = le64_to_cpu(cm1->tag);
6013 *tagupper = cpu_to_le32(tag >> 32);
6014 *taglower = cpu_to_le32(tag);
6015 return;
6016 }
6017 if (c->cmd_type == CMD_IOACCEL2) {
6018 struct io_accel2_cmd *cm2 = (struct io_accel2_cmd *)
6019 &h->ioaccel2_cmd_pool[c->cmdindex];
6020 /* upper tag not used in ioaccel2 mode */
6021 memset(tagupper, 0, sizeof(*tagupper));
6022 *taglower = cm2->Tag;
6023 return;
6024 }
6025 tag = le64_to_cpu(c->Header.tag);
6026 *tagupper = cpu_to_le32(tag >> 32);
6027 *taglower = cpu_to_le32(tag);
6028}
6029
6030static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,
6031 struct CommandList *abort, int reply_queue)
6032{
6033 int rc = IO_OK;
6034 struct CommandList *c;
6035 struct ErrorInfo *ei;
6036 __le32 tagupper, taglower;
6037
6038 c = cmd_alloc(h);
6039
6040 /* fill_cmd can't fail here, no buffer to map */
6041 (void) fill_cmd(c, HPSA_ABORT_MSG, h, &abort->Header.tag,
6042 0, 0, scsi3addr, TYPE_MSG);
6043 if (h->needs_abort_tags_swizzled)
6044 swizzle_abort_tag(&c->Request.CDB[4]);
6045 (void) hpsa_scsi_do_simple_cmd(h, c, reply_queue, DEFAULT_TIMEOUT);
6046 hpsa_get_tag(h, abort, &taglower, &tagupper);
6047 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: do_simple_cmd(abort) completed.\n",
6048 __func__, tagupper, taglower);
6049 /* no unmap needed here because no data xfer. */
6050
6051 ei = c->err_info;
6052 switch (ei->CommandStatus) {
6053 case CMD_SUCCESS:
6054 break;
6055 case CMD_TMF_STATUS:
6056 rc = hpsa_evaluate_tmf_status(h, c);
6057 break;
6058 case CMD_UNABORTABLE: /* Very common, don't make noise. */
6059 rc = -1;
6060 break;
6061 default:
6062 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: interpreting error.\n",
6063 __func__, tagupper, taglower);
6064 hpsa_scsi_interpret_error(h, c);
6065 rc = -1;
6066 break;
6067 }
6068 cmd_free(h, c);
6069 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: Finished.\n",
6070 __func__, tagupper, taglower);
6071 return rc;
6072}
6073
6074static void setup_ioaccel2_abort_cmd(struct CommandList *c, struct ctlr_info *h,
6075 struct CommandList *command_to_abort, int reply_queue)
6076{
6077 struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex];
6078 struct hpsa_tmf_struct *ac = (struct hpsa_tmf_struct *) c2;
6079 struct io_accel2_cmd *c2a =
6080 &h->ioaccel2_cmd_pool[command_to_abort->cmdindex];
6081 struct scsi_cmnd *scmd = command_to_abort->scsi_cmd;
6082 struct hpsa_scsi_dev_t *dev = scmd->device->hostdata;
6083
6084 if (!dev)
6085 return;
6086
6087 /*
6088 * We're overlaying struct hpsa_tmf_struct on top of something which
6089 * was allocated as a struct io_accel2_cmd, so we better be sure it
6090 * actually fits, and doesn't overrun the error info space.
6091 */
6092 BUILD_BUG_ON(sizeof(struct hpsa_tmf_struct) >
6093 sizeof(struct io_accel2_cmd));
6094 BUG_ON(offsetof(struct io_accel2_cmd, error_data) <
6095 offsetof(struct hpsa_tmf_struct, error_len) +
6096 sizeof(ac->error_len));
6097
6098 c->cmd_type = IOACCEL2_TMF;
6099 c->scsi_cmd = SCSI_CMD_BUSY;
6100
6101 /* Adjust the DMA address to point to the accelerated command buffer */
6102 c->busaddr = (u32) h->ioaccel2_cmd_pool_dhandle +
6103 (c->cmdindex * sizeof(struct io_accel2_cmd));
6104 BUG_ON(c->busaddr & 0x0000007F);
6105
6106 memset(ac, 0, sizeof(*c2)); /* yes this is correct */
6107 ac->iu_type = IOACCEL2_IU_TMF_TYPE;
6108 ac->reply_queue = reply_queue;
6109 ac->tmf = IOACCEL2_TMF_ABORT;
6110 ac->it_nexus = cpu_to_le32(dev->ioaccel_handle);
6111 memset(ac->lun_id, 0, sizeof(ac->lun_id));
6112 ac->tag = cpu_to_le64(c->cmdindex << DIRECT_LOOKUP_SHIFT);
6113 ac->abort_tag = cpu_to_le64(le32_to_cpu(c2a->Tag));
6114 ac->error_ptr = cpu_to_le64(c->busaddr +
6115 offsetof(struct io_accel2_cmd, error_data));
6116 ac->error_len = cpu_to_le32(sizeof(c2->error_data));
6117}
6118
6119/* ioaccel2 path firmware cannot handle abort task requests.
6120 * Change abort requests to physical target reset, and send to the
6121 * address of the physical disk used for the ioaccel 2 command.
6122 * Return 0 on success (IO_OK)
6123 * -1 on failure
6124 */
6125
6126static int hpsa_send_reset_as_abort_ioaccel2(struct ctlr_info *h,
6127 unsigned char *scsi3addr, struct CommandList *abort, int reply_queue)
6128{
6129 int rc = IO_OK;
6130 struct scsi_cmnd *scmd; /* scsi command within request being aborted */
6131 struct hpsa_scsi_dev_t *dev; /* device to which scsi cmd was sent */
6132 unsigned char phys_scsi3addr[8]; /* addr of phys disk with volume */
6133 unsigned char *psa = &phys_scsi3addr[0];
6134
6135 /* Get a pointer to the hpsa logical device. */
6136 scmd = abort->scsi_cmd;
6137 dev = (struct hpsa_scsi_dev_t *)(scmd->device->hostdata);
6138 if (dev == NULL) {
6139 dev_warn(&h->pdev->dev,
6140 "Cannot abort: no device pointer for command.\n");
6141 return -1; /* not abortable */
6142 }
6143
6144 if (h->raid_offload_debug > 0)
6145 dev_info(&h->pdev->dev,
6146 "scsi %d:%d:%d:%d %s scsi3addr 0x%8phN\n",
6147 h->scsi_host->host_no, dev->bus, dev->target, dev->lun,
6148 "Reset as abort", scsi3addr);
6149
6150 if (!dev->offload_enabled) {
6151 dev_warn(&h->pdev->dev,
6152 "Can't abort: device is not operating in HP SSD Smart Path mode.\n");
6153 return -1; /* not abortable */
6154 }
6155
6156 /* Incoming scsi3addr is logical addr. We need physical disk addr. */
6157 if (!hpsa_get_pdisk_of_ioaccel2(h, abort, psa)) {
6158 dev_warn(&h->pdev->dev, "Can't abort: Failed lookup of physical address.\n");
6159 return -1; /* not abortable */
6160 }
6161
6162 /* send the reset */
6163 if (h->raid_offload_debug > 0)
6164 dev_info(&h->pdev->dev,
6165 "Reset as abort: Resetting physical device at scsi3addr 0x%8phN\n",
6166 psa);
6167 rc = hpsa_do_reset(h, dev, psa, HPSA_PHYS_TARGET_RESET, reply_queue);
6168 if (rc != 0) {
6169 dev_warn(&h->pdev->dev,
6170 "Reset as abort: Failed on physical device at scsi3addr 0x%8phN\n",
6171 psa);
6172 return rc; /* failed to reset */
6173 }
6174
6175 /* wait for device to recover */
6176 if (wait_for_device_to_become_ready(h, psa, reply_queue) != 0) {
6177 dev_warn(&h->pdev->dev,
6178 "Reset as abort: Failed: Device never recovered from reset: 0x%8phN\n",
6179 psa);
6180 return -1; /* failed to recover */
6181 }
6182
6183 /* device recovered */
6184 dev_info(&h->pdev->dev,
6185 "Reset as abort: Device recovered from reset: scsi3addr 0x%8phN\n",
6186 psa);
6187
6188 return rc; /* success */
6189}
6190
6191static int hpsa_send_abort_ioaccel2(struct ctlr_info *h,
6192 struct CommandList *abort, int reply_queue)
6193{
6194 int rc = IO_OK;
6195 struct CommandList *c;
6196 __le32 taglower, tagupper;
6197 struct hpsa_scsi_dev_t *dev;
6198 struct io_accel2_cmd *c2;
6199
6200 dev = abort->scsi_cmd->device->hostdata;
6201 if (!dev)
6202 return -1;
6203
6204 if (!dev->offload_enabled && !dev->hba_ioaccel_enabled)
6205 return -1;
6206
6207 c = cmd_alloc(h);
6208 setup_ioaccel2_abort_cmd(c, h, abort, reply_queue);
6209 c2 = &h->ioaccel2_cmd_pool[c->cmdindex];
6210 (void) hpsa_scsi_do_simple_cmd(h, c, reply_queue, DEFAULT_TIMEOUT);
6211 hpsa_get_tag(h, abort, &taglower, &tagupper);
6212 dev_dbg(&h->pdev->dev,
6213 "%s: Tag:0x%08x:%08x: do_simple_cmd(ioaccel2 abort) completed.\n",
6214 __func__, tagupper, taglower);
6215 /* no unmap needed here because no data xfer. */
6216
6217 dev_dbg(&h->pdev->dev,
6218 "%s: Tag:0x%08x:%08x: abort service response = 0x%02x.\n",
6219 __func__, tagupper, taglower, c2->error_data.serv_response);
6220 switch (c2->error_data.serv_response) {
6221 case IOACCEL2_SERV_RESPONSE_TMF_COMPLETE:
6222 case IOACCEL2_SERV_RESPONSE_TMF_SUCCESS:
6223 rc = 0;
6224 break;
6225 case IOACCEL2_SERV_RESPONSE_TMF_REJECTED:
6226 case IOACCEL2_SERV_RESPONSE_FAILURE:
6227 case IOACCEL2_SERV_RESPONSE_TMF_WRONG_LUN:
6228 rc = -1;
6229 break;
6230 default:
6231 dev_warn(&h->pdev->dev,
6232 "%s: Tag:0x%08x:%08x: unknown abort service response 0x%02x\n",
6233 __func__, tagupper, taglower,
6234 c2->error_data.serv_response);
6235 rc = -1;
6236 }
6237 cmd_free(h, c);
6238 dev_dbg(&h->pdev->dev, "%s: Tag:0x%08x:%08x: Finished.\n", __func__,
6239 tagupper, taglower);
6240 return rc;
6241}
6242
6243static int hpsa_send_abort_both_ways(struct ctlr_info *h,
6244 struct hpsa_scsi_dev_t *dev, struct CommandList *abort, int reply_queue)
6245{
6246 /*
6247 * ioccelerator mode 2 commands should be aborted via the
6248 * accelerated path, since RAID path is unaware of these commands,
6249 * but not all underlying firmware can handle abort TMF.
6250 * Change abort to physical device reset when abort TMF is unsupported.
6251 */
6252 if (abort->cmd_type == CMD_IOACCEL2) {
6253 if ((HPSATMF_IOACCEL_ENABLED & h->TMFSupportFlags) ||
6254 dev->physical_device)
6255 return hpsa_send_abort_ioaccel2(h, abort,
6256 reply_queue);
6257 else
6258 return hpsa_send_reset_as_abort_ioaccel2(h,
6259 dev->scsi3addr,
6260 abort, reply_queue);
6261 }
6262 return hpsa_send_abort(h, dev->scsi3addr, abort, reply_queue);
6263}
6264
6265/* Find out which reply queue a command was meant to return on */
6266static int hpsa_extract_reply_queue(struct ctlr_info *h,
6267 struct CommandList *c)
6268{
6269 if (c->cmd_type == CMD_IOACCEL2)
6270 return h->ioaccel2_cmd_pool[c->cmdindex].reply_queue;
6271 return c->Header.ReplyQueue;
6272}
6273
6274/*
6275 * Limit concurrency of abort commands to prevent
6276 * over-subscription of commands
6277 */
6278static inline int wait_for_available_abort_cmd(struct ctlr_info *h)
6279{
6280#define ABORT_CMD_WAIT_MSECS 5000
6281 return !wait_event_timeout(h->abort_cmd_wait_queue,
6282 atomic_dec_if_positive(&h->abort_cmds_available) >= 0,
6283 msecs_to_jiffies(ABORT_CMD_WAIT_MSECS));
6284}
6285
6286/* Send an abort for the specified command.
6287 * If the device and controller support it,
6288 * send a task abort request.
6289 */
6290static int hpsa_eh_abort_handler(struct scsi_cmnd *sc)
6291{
6292
6293 int rc;
6294 struct ctlr_info *h;
6295 struct hpsa_scsi_dev_t *dev;
6296 struct CommandList *abort; /* pointer to command to be aborted */
6297 struct scsi_cmnd *as; /* ptr to scsi cmd inside aborted command. */
6298 char msg[256]; /* For debug messaging. */
6299 int ml = 0;
6300 __le32 tagupper, taglower;
6301 int refcount, reply_queue;
6302
6303 if (sc == NULL)
6304 return FAILED;
6305
6306 if (sc->device == NULL)
6307 return FAILED;
6308
6309 /* Find the controller of the command to be aborted */
6310 h = sdev_to_hba(sc->device);
6311 if (h == NULL)
6312 return FAILED;
6313
6314 /* Find the device of the command to be aborted */
6315 dev = sc->device->hostdata;
6316 if (!dev) {
6317 dev_err(&h->pdev->dev, "%s FAILED, Device lookup failed.\n",
6318 msg);
6319 return FAILED;
6320 }
6321
6322 /* If controller locked up, we can guarantee command won't complete */
6323 if (lockup_detected(h)) {
6324 hpsa_show_dev_msg(KERN_WARNING, h, dev,
6325 "ABORT FAILED, lockup detected");
6326 return FAILED;
6327 }
6328
6329 /* This is a good time to check if controller lockup has occurred */
6330 if (detect_controller_lockup(h)) {
6331 hpsa_show_dev_msg(KERN_WARNING, h, dev,
6332 "ABORT FAILED, new lockup detected");
6333 return FAILED;
6334 }
6335
6336 /* Check that controller supports some kind of task abort */
6337 if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags) &&
6338 !(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags))
6339 return FAILED;
6340
6341 memset(msg, 0, sizeof(msg));
6342 ml += sprintf(msg+ml, "scsi %d:%d:%d:%llu %s %p",
6343 h->scsi_host->host_no, sc->device->channel,
6344 sc->device->id, sc->device->lun,
6345 "Aborting command", sc);
6346
6347 /* Get SCSI command to be aborted */
6348 abort = (struct CommandList *) sc->host_scribble;
6349 if (abort == NULL) {
6350 /* This can happen if the command already completed. */
6351 return SUCCESS;
6352 }
6353 refcount = atomic_inc_return(&abort->refcount);
6354 if (refcount == 1) { /* Command is done already. */
6355 cmd_free(h, abort);
6356 return SUCCESS;
6357 }
6358
6359 /* Don't bother trying the abort if we know it won't work. */
6360 if (abort->cmd_type != CMD_IOACCEL2 &&
6361 abort->cmd_type != CMD_IOACCEL1 && !dev->supports_aborts) {
6362 cmd_free(h, abort);
6363 return FAILED;
6364 }
6365
6366 /*
6367 * Check that we're aborting the right command.
6368 * It's possible the CommandList already completed and got re-used.
6369 */
6370 if (abort->scsi_cmd != sc) {
6371 cmd_free(h, abort);
6372 return SUCCESS;
6373 }
6374
6375 abort->abort_pending = true;
6376 hpsa_get_tag(h, abort, &taglower, &tagupper);
6377 reply_queue = hpsa_extract_reply_queue(h, abort);
6378 ml += sprintf(msg+ml, "Tag:0x%08x:%08x ", tagupper, taglower);
6379 as = abort->scsi_cmd;
6380 if (as != NULL)
6381 ml += sprintf(msg+ml,
6382 "CDBLen: %d CDB: 0x%02x%02x... SN: 0x%lx ",
6383 as->cmd_len, as->cmnd[0], as->cmnd[1],
6384 as->serial_number);
6385 dev_warn(&h->pdev->dev, "%s BEING SENT\n", msg);
6386 hpsa_show_dev_msg(KERN_WARNING, h, dev, "Aborting command");
6387
6388 /*
6389 * Command is in flight, or possibly already completed
6390 * by the firmware (but not to the scsi mid layer) but we can't
6391 * distinguish which. Send the abort down.
6392 */
6393 if (wait_for_available_abort_cmd(h)) {
6394 dev_warn(&h->pdev->dev,
6395 "%s FAILED, timeout waiting for an abort command to become available.\n",
6396 msg);
6397 cmd_free(h, abort);
6398 return FAILED;
6399 }
6400 rc = hpsa_send_abort_both_ways(h, dev, abort, reply_queue);
6401 atomic_inc(&h->abort_cmds_available);
6402 wake_up_all(&h->abort_cmd_wait_queue);
6403 if (rc != 0) {
6404 dev_warn(&h->pdev->dev, "%s SENT, FAILED\n", msg);
6405 hpsa_show_dev_msg(KERN_WARNING, h, dev,
6406 "FAILED to abort command");
6407 cmd_free(h, abort);
6408 return FAILED;
6409 }
6410 dev_info(&h->pdev->dev, "%s SENT, SUCCESS\n", msg);
6411 wait_event(h->event_sync_wait_queue,
6412 abort->scsi_cmd != sc || lockup_detected(h));
6413 cmd_free(h, abort);
6414 return !lockup_detected(h) ? SUCCESS : FAILED;
6415}
6416
6417/* 5841/*
6418 * For operations with an associated SCSI command, a command block is allocated 5842 * For operations with an associated SCSI command, a command block is allocated
6419 * at init, and managed by cmd_tagged_alloc() and cmd_tagged_free() using the 5843 * at init, and managed by cmd_tagged_alloc() and cmd_tagged_free() using the
@@ -6459,9 +5883,7 @@ static void cmd_tagged_free(struct ctlr_info *h, struct CommandList *c)
6459{ 5883{
6460 /* 5884 /*
6461 * Release our reference to the block. We don't need to do anything 5885 * Release our reference to the block. We don't need to do anything
6462 * else to free it, because it is accessed by index. (There's no point 5886 * else to free it, because it is accessed by index.
6463 * in checking the result of the decrement, since we cannot guarantee
6464 * that there isn't a concurrent abort which is also accessing it.)
6465 */ 5887 */
6466 (void)atomic_dec(&c->refcount); 5888 (void)atomic_dec(&c->refcount);
6467} 5889}
@@ -7000,7 +6422,6 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
7000 int cmd_type) 6422 int cmd_type)
7001{ 6423{
7002 int pci_dir = XFER_NONE; 6424 int pci_dir = XFER_NONE;
7003 u64 tag; /* for commands to be aborted */
7004 6425
7005 c->cmd_type = CMD_IOCTL_PEND; 6426 c->cmd_type = CMD_IOCTL_PEND;
7006 c->scsi_cmd = SCSI_CMD_BUSY; 6427 c->scsi_cmd = SCSI_CMD_BUSY;
@@ -7184,27 +6605,6 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,
7184 c->Request.CDB[6] = 0x00; 6605 c->Request.CDB[6] = 0x00;
7185 c->Request.CDB[7] = 0x00; 6606 c->Request.CDB[7] = 0x00;
7186 break; 6607 break;
7187 case HPSA_ABORT_MSG:
7188 memcpy(&tag, buff, sizeof(tag));
7189 dev_dbg(&h->pdev->dev,
7190 "Abort Tag:0x%016llx using rqst Tag:0x%016llx",
7191 tag, c->Header.tag);
7192 c->Request.CDBLen = 16;
7193 c->Request.type_attr_dir =
7194 TYPE_ATTR_DIR(cmd_type,
7195 ATTR_SIMPLE, XFER_WRITE);
7196 c->Request.Timeout = 0; /* Don't time out */
7197 c->Request.CDB[0] = HPSA_TASK_MANAGEMENT;
7198 c->Request.CDB[1] = HPSA_TMF_ABORT_TASK;
7199 c->Request.CDB[2] = 0x00; /* reserved */
7200 c->Request.CDB[3] = 0x00; /* reserved */
7201 /* Tag to abort goes in CDB[4]-CDB[11] */
7202 memcpy(&c->Request.CDB[4], &tag, sizeof(tag));
7203 c->Request.CDB[12] = 0x00; /* reserved */
7204 c->Request.CDB[13] = 0x00; /* reserved */
7205 c->Request.CDB[14] = 0x00; /* reserved */
7206 c->Request.CDB[15] = 0x00; /* reserved */
7207 break;
7208 default: 6608 default:
7209 dev_warn(&h->pdev->dev, "unknown message type %d\n", 6609 dev_warn(&h->pdev->dev, "unknown message type %d\n",
7210 cmd); 6610 cmd);
@@ -8162,9 +7562,6 @@ static int hpsa_pci_init(struct ctlr_info *h)
8162 h->product_name = products[prod_index].product_name; 7562 h->product_name = products[prod_index].product_name;
8163 h->access = *(products[prod_index].access); 7563 h->access = *(products[prod_index].access);
8164 7564
8165 h->needs_abort_tags_swizzled =
8166 ctlr_needs_abort_tags_swizzled(h->board_id);
8167
8168 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S | 7565 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
8169 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM); 7566 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
8170 7567
@@ -8885,7 +8282,6 @@ reinit_after_soft_reset:
8885 spin_lock_init(&h->scan_lock); 8282 spin_lock_init(&h->scan_lock);
8886 spin_lock_init(&h->reset_lock); 8283 spin_lock_init(&h->reset_lock);
8887 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS); 8284 atomic_set(&h->passthru_cmds_avail, HPSA_MAX_CONCURRENT_PASSTHRUS);
8888 atomic_set(&h->abort_cmds_available, HPSA_CMDS_RESERVED_FOR_ABORTS);
8889 8285
8890 /* Allocate and clear per-cpu variable lockup_detected */ 8286 /* Allocate and clear per-cpu variable lockup_detected */
8891 h->lockup_detected = alloc_percpu(u32); 8287 h->lockup_detected = alloc_percpu(u32);
@@ -8937,7 +8333,6 @@ reinit_after_soft_reset:
8937 if (rc) 8333 if (rc)
8938 goto clean5; /* cmd, irq, shost, pci, lu, aer/h */ 8334 goto clean5; /* cmd, irq, shost, pci, lu, aer/h */
8939 init_waitqueue_head(&h->scan_wait_queue); 8335 init_waitqueue_head(&h->scan_wait_queue);
8940 init_waitqueue_head(&h->abort_cmd_wait_queue);
8941 init_waitqueue_head(&h->event_sync_wait_queue); 8336 init_waitqueue_head(&h->event_sync_wait_queue);
8942 mutex_init(&h->reset_mutex); 8337 mutex_init(&h->reset_mutex);
8943 h->scan_finished = 1; /* no scan currently in progress */ 8338 h->scan_finished = 1; /* no scan currently in progress */
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index c9c4927f5d0e..1c49741bc639 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -298,7 +298,6 @@ struct ctlr_info {
298 struct workqueue_struct *resubmit_wq; 298 struct workqueue_struct *resubmit_wq;
299 struct workqueue_struct *rescan_ctlr_wq; 299 struct workqueue_struct *rescan_ctlr_wq;
300 atomic_t abort_cmds_available; 300 atomic_t abort_cmds_available;
301 wait_queue_head_t abort_cmd_wait_queue;
302 wait_queue_head_t event_sync_wait_queue; 301 wait_queue_head_t event_sync_wait_queue;
303 struct mutex reset_mutex; 302 struct mutex reset_mutex;
304 u8 reset_in_progress; 303 u8 reset_in_progress;