Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Support for SATA devices on Serial Attached SCSI (SAS) controllers |
| 3 | * |
| 4 | * Copyright (C) 2006 IBM Corporation |
| 5 | * |
| 6 | * Written by: Darrick J. Wong <djwong@us.ibm.com>, IBM Corporation |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of the |
| 11 | * License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 21 | * USA |
| 22 | */ |
| 23 | |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 24 | #include <linux/scatterlist.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 26 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 27 | #include <scsi/sas_ata.h> |
| 28 | #include "sas_internal.h" |
| 29 | #include <scsi/scsi_host.h> |
| 30 | #include <scsi/scsi_device.h> |
| 31 | #include <scsi/scsi_tcq.h> |
| 32 | #include <scsi/scsi.h> |
| 33 | #include <scsi/scsi_transport.h> |
| 34 | #include <scsi/scsi_transport_sas.h> |
| 35 | #include "../scsi_sas_internal.h" |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 36 | #include "../scsi_transport_api.h" |
| 37 | #include <scsi/scsi_eh.h> |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 38 | |
| 39 | static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts) |
| 40 | { |
| 41 | /* Cheesy attempt to translate SAS errors into ATA. Hah! */ |
| 42 | |
| 43 | /* transport error */ |
| 44 | if (ts->resp == SAS_TASK_UNDELIVERED) |
| 45 | return AC_ERR_ATA_BUS; |
| 46 | |
| 47 | /* ts->resp == SAS_TASK_COMPLETE */ |
| 48 | /* task delivered, what happened afterwards? */ |
| 49 | switch (ts->stat) { |
| 50 | case SAS_DEV_NO_RESPONSE: |
| 51 | return AC_ERR_TIMEOUT; |
| 52 | |
| 53 | case SAS_INTERRUPTED: |
| 54 | case SAS_PHY_DOWN: |
| 55 | case SAS_NAK_R_ERR: |
| 56 | return AC_ERR_ATA_BUS; |
| 57 | |
| 58 | |
| 59 | case SAS_DATA_UNDERRUN: |
| 60 | /* |
| 61 | * Some programs that use the taskfile interface |
| 62 | * (smartctl in particular) can cause underrun |
| 63 | * problems. Ignore these errors, perhaps at our |
| 64 | * peril. |
| 65 | */ |
| 66 | return 0; |
| 67 | |
| 68 | case SAS_DATA_OVERRUN: |
| 69 | case SAS_QUEUE_FULL: |
| 70 | case SAS_DEVICE_UNKNOWN: |
| 71 | case SAS_SG_ERR: |
| 72 | return AC_ERR_INVALID; |
| 73 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 74 | case SAS_OPEN_TO: |
| 75 | case SAS_OPEN_REJECT: |
| 76 | SAS_DPRINTK("%s: Saw error %d. What to do?\n", |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 77 | __func__, ts->stat); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 78 | return AC_ERR_OTHER; |
| 79 | |
James Bottomley | 75c0b38 | 2011-01-23 08:16:24 -0600 | [diff] [blame] | 80 | case SAM_STAT_CHECK_CONDITION: |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 81 | case SAS_ABORTED_TASK: |
| 82 | return AC_ERR_DEV; |
| 83 | |
| 84 | case SAS_PROTO_RESPONSE: |
| 85 | /* This means the ending_fis has the error |
| 86 | * value; return 0 here to collect it */ |
| 87 | return 0; |
| 88 | default: |
| 89 | return 0; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | static void sas_ata_task_done(struct sas_task *task) |
| 94 | { |
| 95 | struct ata_queued_cmd *qc = task->uldd_task; |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 96 | struct domain_device *dev; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 97 | struct task_status_struct *stat = &task->task_status; |
| 98 | struct ata_task_resp *resp = (struct ata_task_resp *)stat->buf; |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 99 | struct sas_ha_struct *sas_ha; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 100 | enum ata_completion_errors ac; |
Darrick J. Wong | 3eb7a51 | 2007-01-30 01:18:35 -0800 | [diff] [blame] | 101 | unsigned long flags; |
Xiangliang Yu | bb650a1 | 2011-05-08 19:27:01 +0800 | [diff] [blame] | 102 | struct ata_link *link; |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 103 | struct ata_port *ap; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 104 | |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 105 | if (!qc) |
| 106 | goto qc_already_gone; |
| 107 | |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 108 | ap = qc->ap; |
| 109 | dev = ap->private_data; |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 110 | sas_ha = dev->port->ha; |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 111 | link = &ap->link; |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 112 | |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 113 | spin_lock_irqsave(ap->lock, flags); |
| 114 | /* check if we lost the race with libata/sas_ata_post_internal() */ |
| 115 | if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) { |
| 116 | spin_unlock_irqrestore(ap->lock, flags); |
| 117 | if (qc->scsicmd) |
| 118 | goto qc_already_gone; |
| 119 | else { |
| 120 | /* if eh is not involved and the port is frozen then the |
| 121 | * ata internal abort process has taken responsibility |
| 122 | * for this sas_task |
| 123 | */ |
| 124 | return; |
| 125 | } |
| 126 | } |
| 127 | |
James Bottomley | 75c0b38 | 2011-01-23 08:16:24 -0600 | [diff] [blame] | 128 | if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD || |
| 129 | ((stat->stat == SAM_STAT_CHECK_CONDITION && |
| 130 | dev->sata_dev.command_set == ATAPI_COMMAND_SET))) { |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 131 | ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf); |
Xiangliang Yu | bb650a1 | 2011-05-08 19:27:01 +0800 | [diff] [blame] | 132 | |
| 133 | if (!link->sactive) { |
| 134 | qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command); |
| 135 | } else { |
| 136 | link->eh_info.err_mask |= ac_err_mask(dev->sata_dev.tf.command); |
| 137 | if (unlikely(link->eh_info.err_mask)) |
| 138 | qc->flags |= ATA_QCFLAG_FAILED; |
| 139 | } |
James Bottomley | 75c0b38 | 2011-01-23 08:16:24 -0600 | [diff] [blame] | 140 | } else { |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 141 | ac = sas_to_ata_err(stat); |
| 142 | if (ac) { |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 143 | SAS_DPRINTK("%s: SAS error %x\n", __func__, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 144 | stat->stat); |
| 145 | /* We saw a SAS error. Send a vague error. */ |
Xiangliang Yu | bb650a1 | 2011-05-08 19:27:01 +0800 | [diff] [blame] | 146 | if (!link->sactive) { |
| 147 | qc->err_mask = ac; |
| 148 | } else { |
| 149 | link->eh_info.err_mask |= AC_ERR_DEV; |
| 150 | qc->flags |= ATA_QCFLAG_FAILED; |
| 151 | } |
| 152 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 153 | dev->sata_dev.tf.feature = 0x04; /* status err */ |
| 154 | dev->sata_dev.tf.command = ATA_ERR; |
| 155 | } |
| 156 | } |
| 157 | |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 158 | qc->lldd_task = NULL; |
Darrick J. Wong | fe059f1 | 2007-01-30 01:18:55 -0800 | [diff] [blame] | 159 | if (qc->scsicmd) |
| 160 | ASSIGN_SAS_TASK(qc->scsicmd, NULL); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 161 | ata_qc_complete(qc); |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 162 | spin_unlock_irqrestore(ap->lock, flags); |
Darrick J. Wong | 3eb7a51 | 2007-01-30 01:18:35 -0800 | [diff] [blame] | 163 | |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 164 | qc_already_gone: |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 165 | list_del_init(&task->list); |
| 166 | sas_free_task(task); |
| 167 | } |
| 168 | |
| 169 | static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) |
| 170 | { |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 171 | unsigned long flags; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 172 | struct sas_task *task; |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 173 | struct scatterlist *sg; |
| 174 | int ret = AC_ERR_SYSTEM; |
| 175 | unsigned int si, xfer = 0; |
| 176 | struct ata_port *ap = qc->ap; |
| 177 | struct domain_device *dev = ap->private_data; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 178 | struct sas_ha_struct *sas_ha = dev->port->ha; |
| 179 | struct Scsi_Host *host = sas_ha->core.shost; |
| 180 | struct sas_internal *i = to_sas_internal(host->transportt); |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 181 | |
| 182 | /* TODO: audit callers to ensure they are ready for qc_issue to |
| 183 | * unconditionally re-enable interrupts |
| 184 | */ |
| 185 | local_irq_save(flags); |
| 186 | spin_unlock(ap->lock); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 187 | |
Darrick J. Wong | 56dd2c0 | 2010-10-01 13:55:47 -0700 | [diff] [blame] | 188 | /* If the device fell off, no sense in issuing commands */ |
Dan Williams | e139942 | 2012-01-07 08:52:39 +0000 | [diff] [blame] | 189 | if (test_bit(SAS_DEV_GONE, &dev->state)) |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 190 | goto out; |
Darrick J. Wong | 56dd2c0 | 2010-10-01 13:55:47 -0700 | [diff] [blame] | 191 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 192 | task = sas_alloc_task(GFP_ATOMIC); |
| 193 | if (!task) |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 194 | goto out; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 195 | task->dev = dev; |
| 196 | task->task_proto = SAS_PROTOCOL_STP; |
| 197 | task->task_done = sas_ata_task_done; |
| 198 | |
| 199 | if (qc->tf.command == ATA_CMD_FPDMA_WRITE || |
| 200 | qc->tf.command == ATA_CMD_FPDMA_READ) { |
| 201 | /* Need to zero out the tag libata assigned us */ |
| 202 | qc->tf.nsect = 0; |
| 203 | } |
| 204 | |
James Bottomley | 110dd8f | 2007-07-20 13:11:44 -0500 | [diff] [blame] | 205 | ata_tf_to_fis(&qc->tf, 1, 0, (u8*)&task->ata_task.fis); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 206 | task->uldd_task = qc; |
Tejun Heo | 405e66b | 2007-11-27 19:28:53 +0900 | [diff] [blame] | 207 | if (ata_is_atapi(qc->tf.protocol)) { |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 208 | memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len); |
James Bottomley | dde2020 | 2008-02-19 11:36:56 +0100 | [diff] [blame] | 209 | task->total_xfer_len = qc->nbytes; |
| 210 | task->num_scatter = qc->n_elem; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 211 | } else { |
Tejun Heo | ff2aeb1 | 2007-12-05 16:43:11 +0900 | [diff] [blame] | 212 | for_each_sg(qc->sg, sg, qc->n_elem, si) |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 213 | xfer += sg->length; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 214 | |
| 215 | task->total_xfer_len = xfer; |
Tejun Heo | ff2aeb1 | 2007-12-05 16:43:11 +0900 | [diff] [blame] | 216 | task->num_scatter = si; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | task->data_dir = qc->dma_dir; |
Tejun Heo | ff2aeb1 | 2007-12-05 16:43:11 +0900 | [diff] [blame] | 220 | task->scatter = qc->sg; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 221 | task->ata_task.retry_count = 1; |
| 222 | task->task_state_flags = SAS_TASK_STATE_PENDING; |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 223 | qc->lldd_task = task; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 224 | |
| 225 | switch (qc->tf.protocol) { |
| 226 | case ATA_PROT_NCQ: |
| 227 | task->ata_task.use_ncq = 1; |
| 228 | /* fall through */ |
Tejun Heo | 0dc3688 | 2007-12-18 16:34:43 -0500 | [diff] [blame] | 229 | case ATAPI_PROT_DMA: |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 230 | case ATA_PROT_DMA: |
| 231 | task->ata_task.dma_xfer = 1; |
| 232 | break; |
| 233 | } |
| 234 | |
Darrick J. Wong | fe059f1 | 2007-01-30 01:18:55 -0800 | [diff] [blame] | 235 | if (qc->scsicmd) |
| 236 | ASSIGN_SAS_TASK(qc->scsicmd, task); |
| 237 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 238 | if (sas_ha->lldd_max_execute_num < 2) |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 239 | ret = i->dft->lldd_execute_task(task, 1, GFP_ATOMIC); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 240 | else |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 241 | ret = sas_queue_up(task); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 242 | |
| 243 | /* Examine */ |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 244 | if (ret) { |
| 245 | SAS_DPRINTK("lldd_execute_task returned: %d\n", ret); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 246 | |
Darrick J. Wong | fe059f1 | 2007-01-30 01:18:55 -0800 | [diff] [blame] | 247 | if (qc->scsicmd) |
| 248 | ASSIGN_SAS_TASK(qc->scsicmd, NULL); |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 249 | sas_free_task(task); |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 250 | ret = AC_ERR_SYSTEM; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Dan Williams | 312d3e5 | 2011-11-17 17:59:50 -0800 | [diff] [blame] | 253 | out: |
| 254 | spin_lock(ap->lock); |
| 255 | local_irq_restore(flags); |
| 256 | return ret; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Tejun Heo | 4c9bf4e | 2008-04-07 22:47:20 +0900 | [diff] [blame] | 259 | static bool sas_ata_qc_fill_rtf(struct ata_queued_cmd *qc) |
| 260 | { |
| 261 | struct domain_device *dev = qc->ap->private_data; |
| 262 | |
| 263 | memcpy(&qc->result_tf, &dev->sata_dev.tf, sizeof(qc->result_tf)); |
| 264 | return true; |
| 265 | } |
| 266 | |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 267 | static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, |
| 268 | unsigned long deadline) |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 269 | { |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 270 | struct ata_port *ap = link->ap; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 271 | struct domain_device *dev = ap->private_data; |
| 272 | struct sas_internal *i = |
| 273 | to_sas_internal(dev->port->ha->core.shost->transportt); |
James Bottomley | a29c051 | 2008-02-23 23:38:44 -0600 | [diff] [blame] | 274 | int res = TMF_RESP_FUNC_FAILED; |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 275 | int ret = 0; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 276 | |
| 277 | if (i->dft->lldd_I_T_nexus_reset) |
| 278 | res = i->dft->lldd_I_T_nexus_reset(dev); |
| 279 | |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 280 | if (res != TMF_RESP_FUNC_COMPLETE) { |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 281 | SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __func__); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 282 | ret = -EAGAIN; |
| 283 | } |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 284 | |
| 285 | switch (dev->sata_dev.command_set) { |
| 286 | case ATA_COMMAND_SET: |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 287 | SAS_DPRINTK("%s: Found ATA device.\n", __func__); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 288 | *class = ATA_DEV_ATA; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 289 | break; |
| 290 | case ATAPI_COMMAND_SET: |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 291 | SAS_DPRINTK("%s: Found ATAPI device.\n", __func__); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 292 | *class = ATA_DEV_ATAPI; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 293 | break; |
| 294 | default: |
| 295 | SAS_DPRINTK("%s: Unknown SATA command set: %d.\n", |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 296 | __func__, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 297 | dev->sata_dev.command_set); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 298 | *class = ATA_DEV_UNKNOWN; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 299 | break; |
| 300 | } |
| 301 | |
| 302 | ap->cbl = ATA_CBL_SATA; |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 303 | return ret; |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Dave Jiang | 1ca1e43 | 2011-05-24 13:18:04 -0700 | [diff] [blame] | 306 | static int sas_ata_soft_reset(struct ata_link *link, unsigned int *class, |
| 307 | unsigned long deadline) |
| 308 | { |
| 309 | struct ata_port *ap = link->ap; |
| 310 | struct domain_device *dev = ap->private_data; |
| 311 | struct sas_internal *i = |
| 312 | to_sas_internal(dev->port->ha->core.shost->transportt); |
| 313 | int res = TMF_RESP_FUNC_FAILED; |
| 314 | int ret = 0; |
| 315 | |
| 316 | if (i->dft->lldd_ata_soft_reset) |
| 317 | res = i->dft->lldd_ata_soft_reset(dev); |
| 318 | |
| 319 | if (res != TMF_RESP_FUNC_COMPLETE) { |
| 320 | SAS_DPRINTK("%s: Unable to soft reset\n", __func__); |
| 321 | ret = -EAGAIN; |
| 322 | } |
| 323 | |
| 324 | switch (dev->sata_dev.command_set) { |
| 325 | case ATA_COMMAND_SET: |
| 326 | SAS_DPRINTK("%s: Found ATA device.\n", __func__); |
| 327 | *class = ATA_DEV_ATA; |
| 328 | break; |
| 329 | case ATAPI_COMMAND_SET: |
| 330 | SAS_DPRINTK("%s: Found ATAPI device.\n", __func__); |
| 331 | *class = ATA_DEV_ATAPI; |
| 332 | break; |
| 333 | default: |
| 334 | SAS_DPRINTK("%s: Unknown SATA command set: %d.\n", |
| 335 | __func__, dev->sata_dev.command_set); |
| 336 | *class = ATA_DEV_UNKNOWN; |
| 337 | break; |
| 338 | } |
| 339 | |
| 340 | ap->cbl = ATA_CBL_SATA; |
| 341 | return ret; |
| 342 | } |
| 343 | |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 344 | /* |
| 345 | * notify the lldd to forget the sas_task for this internal ata command |
| 346 | * that bypasses scsi-eh |
| 347 | */ |
| 348 | static void sas_ata_internal_abort(struct sas_task *task) |
| 349 | { |
| 350 | struct sas_internal *si = |
| 351 | to_sas_internal(task->dev->port->ha->core.shost->transportt); |
| 352 | unsigned long flags; |
| 353 | int res; |
| 354 | |
| 355 | spin_lock_irqsave(&task->task_state_lock, flags); |
| 356 | if (task->task_state_flags & SAS_TASK_STATE_ABORTED || |
| 357 | task->task_state_flags & SAS_TASK_STATE_DONE) { |
| 358 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
| 359 | SAS_DPRINTK("%s: Task %p already finished.\n", __func__, |
| 360 | task); |
| 361 | goto out; |
| 362 | } |
| 363 | task->task_state_flags |= SAS_TASK_STATE_ABORTED; |
| 364 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
| 365 | |
| 366 | res = si->dft->lldd_abort_task(task); |
| 367 | |
| 368 | spin_lock_irqsave(&task->task_state_lock, flags); |
| 369 | if (task->task_state_flags & SAS_TASK_STATE_DONE || |
| 370 | res == TMF_RESP_FUNC_COMPLETE) { |
| 371 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
| 372 | goto out; |
| 373 | } |
| 374 | |
| 375 | /* XXX we are not prepared to deal with ->lldd_abort_task() |
| 376 | * failures. TODO: lldds need to unconditionally forget about |
| 377 | * aborted ata tasks, otherwise we (likely) leak the sas task |
| 378 | * here |
| 379 | */ |
| 380 | SAS_DPRINTK("%s: Task %p leaked.\n", __func__, task); |
| 381 | |
| 382 | if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) |
| 383 | task->task_state_flags &= ~SAS_TASK_STATE_ABORTED; |
| 384 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
| 385 | |
| 386 | return; |
| 387 | out: |
| 388 | list_del_init(&task->list); |
| 389 | sas_free_task(task); |
| 390 | } |
| 391 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 392 | static void sas_ata_post_internal(struct ata_queued_cmd *qc) |
| 393 | { |
| 394 | if (qc->flags & ATA_QCFLAG_FAILED) |
| 395 | qc->err_mask |= AC_ERR_OTHER; |
| 396 | |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 397 | if (qc->err_mask) { |
| 398 | /* |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 399 | * Find the sas_task and kill it. By this point, libata |
| 400 | * has decided to kill the qc and has frozen the port. |
| 401 | * In this state sas_ata_task_done() will no longer free |
| 402 | * the sas_task, so we need to notify the lldd (via |
| 403 | * ->lldd_abort_task) that the task is dead and free it |
| 404 | * ourselves. |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 405 | */ |
| 406 | struct sas_task *task = qc->lldd_task; |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 407 | unsigned long flags; |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 408 | |
| 409 | qc->lldd_task = NULL; |
| 410 | if (task) { |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 411 | /* Should this be a AT(API) device reset? */ |
| 412 | spin_lock_irqsave(&task->task_state_lock, flags); |
| 413 | task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; |
| 414 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
| 415 | |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 416 | task->uldd_task = NULL; |
Dan Williams | 3dff572 | 2011-11-28 12:08:22 -0800 | [diff] [blame^] | 417 | sas_ata_internal_abort(task); |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 418 | } |
Darrick J. Wong | 1c50dc8 | 2007-01-30 01:18:41 -0800 | [diff] [blame] | 419 | } |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 422 | |
| 423 | static void sas_ata_set_dmamode(struct ata_port *ap, struct ata_device *ata_dev) |
| 424 | { |
| 425 | struct domain_device *dev = ap->private_data; |
| 426 | struct sas_internal *i = |
| 427 | to_sas_internal(dev->port->ha->core.shost->transportt); |
| 428 | |
| 429 | if (i->dft->lldd_ata_set_dmamode) |
| 430 | i->dft->lldd_ata_set_dmamode(dev); |
| 431 | } |
| 432 | |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 433 | static struct ata_port_operations sas_sata_ops = { |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 434 | .prereset = ata_std_prereset, |
Dave Jiang | 1ca1e43 | 2011-05-24 13:18:04 -0700 | [diff] [blame] | 435 | .softreset = sas_ata_soft_reset, |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 436 | .hardreset = sas_ata_hard_reset, |
| 437 | .postreset = ata_std_postreset, |
| 438 | .error_handler = ata_std_error_handler, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 439 | .post_internal_cmd = sas_ata_post_internal, |
David Milburn | f0ad30d | 2010-09-03 17:13:03 -0500 | [diff] [blame] | 440 | .qc_defer = ata_std_qc_defer, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 441 | .qc_prep = ata_noop_qc_prep, |
| 442 | .qc_issue = sas_ata_qc_issue, |
Tejun Heo | 4c9bf4e | 2008-04-07 22:47:20 +0900 | [diff] [blame] | 443 | .qc_fill_rtf = sas_ata_qc_fill_rtf, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 444 | .port_start = ata_sas_port_start, |
| 445 | .port_stop = ata_sas_port_stop, |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 446 | .set_dmamode = sas_ata_set_dmamode, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 447 | }; |
| 448 | |
| 449 | static struct ata_port_info sata_port_info = { |
Sergei Shtylyov | 9cbe056 | 2011-02-04 22:05:48 +0300 | [diff] [blame] | 450 | .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ, |
Sergei Shtylyov | 0f2e033 | 2011-01-21 20:32:01 +0300 | [diff] [blame] | 451 | .pio_mask = ATA_PIO4, |
| 452 | .mwdma_mask = ATA_MWDMA2, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 453 | .udma_mask = ATA_UDMA6, |
| 454 | .port_ops = &sas_sata_ops |
| 455 | }; |
| 456 | |
| 457 | int sas_ata_init_host_and_port(struct domain_device *found_dev, |
| 458 | struct scsi_target *starget) |
| 459 | { |
| 460 | struct Scsi_Host *shost = dev_to_shost(&starget->dev); |
| 461 | struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost); |
| 462 | struct ata_port *ap; |
| 463 | |
| 464 | ata_host_init(&found_dev->sata_dev.ata_host, |
Jeff Garzik | 1d1bbee | 2007-07-26 09:28:37 -0400 | [diff] [blame] | 465 | ha->dev, |
Darrick J. Wong | 338ec57 | 2006-10-18 14:43:37 -0700 | [diff] [blame] | 466 | sata_port_info.flags, |
| 467 | &sas_sata_ops); |
| 468 | ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host, |
| 469 | &sata_port_info, |
| 470 | shost); |
| 471 | if (!ap) { |
| 472 | SAS_DPRINTK("ata_sas_port_alloc failed.\n"); |
| 473 | return -ENODEV; |
| 474 | } |
| 475 | |
| 476 | ap->private_data = found_dev; |
| 477 | ap->cbl = ATA_CBL_SATA; |
| 478 | ap->scsi_host = shost; |
| 479 | found_dev->sata_dev.ap = ap; |
| 480 | |
| 481 | return 0; |
| 482 | } |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 483 | |
| 484 | void sas_ata_task_abort(struct sas_task *task) |
| 485 | { |
| 486 | struct ata_queued_cmd *qc = task->uldd_task; |
| 487 | struct completion *waiting; |
| 488 | |
| 489 | /* Bounce SCSI-initiated commands to the SCSI EH */ |
| 490 | if (qc->scsicmd) { |
James Bottomley | 1b4d0d8 | 2010-05-13 09:31:54 -0500 | [diff] [blame] | 491 | struct request_queue *q = qc->scsicmd->device->request_queue; |
| 492 | unsigned long flags; |
| 493 | |
Tejun Heo | 70b25f8 | 2010-04-15 09:00:08 +0900 | [diff] [blame] | 494 | spin_lock_irqsave(q->queue_lock, flags); |
Jens Axboe | 242f9dc | 2008-09-14 05:55:09 -0700 | [diff] [blame] | 495 | blk_abort_request(qc->scsicmd->request); |
Tejun Heo | 70b25f8 | 2010-04-15 09:00:08 +0900 | [diff] [blame] | 496 | spin_unlock_irqrestore(q->queue_lock, flags); |
Darrick J. Wong | 3a2755a | 2007-01-30 01:18:58 -0800 | [diff] [blame] | 497 | scsi_schedule_eh(qc->scsicmd->device->host); |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | /* Internal command, fake a timeout and complete. */ |
| 502 | qc->flags &= ~ATA_QCFLAG_ACTIVE; |
| 503 | qc->flags |= ATA_QCFLAG_FAILED; |
| 504 | qc->err_mask |= AC_ERR_TIMEOUT; |
| 505 | waiting = qc->private_data; |
| 506 | complete(waiting); |
| 507 | } |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 508 | |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 509 | static void sas_get_ata_command_set(struct domain_device *dev) |
| 510 | { |
| 511 | struct dev_to_host_fis *fis = |
| 512 | (struct dev_to_host_fis *) dev->frame_rcvd; |
| 513 | |
| 514 | if ((fis->sector_count == 1 && /* ATA */ |
| 515 | fis->lbal == 1 && |
| 516 | fis->lbam == 0 && |
| 517 | fis->lbah == 0 && |
| 518 | fis->device == 0) |
| 519 | || |
| 520 | (fis->sector_count == 0 && /* CE-ATA (mATA) */ |
| 521 | fis->lbal == 0 && |
| 522 | fis->lbam == 0xCE && |
| 523 | fis->lbah == 0xAA && |
| 524 | (fis->device & ~0x10) == 0)) |
| 525 | |
| 526 | dev->sata_dev.command_set = ATA_COMMAND_SET; |
| 527 | |
| 528 | else if ((fis->interrupt_reason == 1 && /* ATAPI */ |
| 529 | fis->lbal == 1 && |
| 530 | fis->byte_count_low == 0x14 && |
| 531 | fis->byte_count_high == 0xEB && |
| 532 | (fis->device & ~0x10) == 0)) |
| 533 | |
| 534 | dev->sata_dev.command_set = ATAPI_COMMAND_SET; |
| 535 | |
| 536 | else if ((fis->sector_count == 1 && /* SEMB */ |
| 537 | fis->lbal == 1 && |
| 538 | fis->lbam == 0x3C && |
| 539 | fis->lbah == 0xC3 && |
| 540 | fis->device == 0) |
| 541 | || |
| 542 | (fis->interrupt_reason == 1 && /* SATA PM */ |
| 543 | fis->lbal == 1 && |
| 544 | fis->byte_count_low == 0x69 && |
| 545 | fis->byte_count_high == 0x96 && |
| 546 | (fis->device & ~0x10) == 0)) |
| 547 | |
| 548 | /* Treat it as a superset? */ |
| 549 | dev->sata_dev.command_set = ATAPI_COMMAND_SET; |
| 550 | } |
| 551 | |
Dan Williams | 87c8331 | 2011-11-17 17:59:51 -0800 | [diff] [blame] | 552 | void sas_probe_sata(struct work_struct *work) |
| 553 | { |
| 554 | struct domain_device *dev, *n; |
| 555 | struct sas_discovery_event *ev = |
| 556 | container_of(work, struct sas_discovery_event, work); |
| 557 | struct asd_sas_port *port = ev->port; |
| 558 | |
| 559 | clear_bit(DISCE_PROBE, &port->disc.pending); |
| 560 | |
| 561 | list_for_each_entry_safe(dev, n, &port->disco_list, disco_list_node) { |
| 562 | int err; |
| 563 | |
| 564 | spin_lock_irq(&port->dev_list_lock); |
| 565 | list_add_tail(&dev->dev_list_node, &port->dev_list); |
| 566 | spin_unlock_irq(&port->dev_list_lock); |
| 567 | |
| 568 | err = sas_rphy_add(dev->rphy); |
| 569 | |
| 570 | if (err) { |
| 571 | SAS_DPRINTK("%s: for %s device %16llx returned %d\n", |
| 572 | __func__, dev->parent ? "exp-attached" : |
| 573 | "direct-attached", |
| 574 | SAS_ADDR(dev->sas_addr), err); |
| 575 | sas_unregister_dev(port, dev); |
| 576 | } else |
| 577 | list_del_init(&dev->disco_list_node); |
| 578 | } |
| 579 | } |
| 580 | |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 581 | /** |
| 582 | * sas_discover_sata -- discover an STP/SATA domain device |
| 583 | * @dev: pointer to struct domain_device of interest |
| 584 | * |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 585 | * Devices directly attached to a HA port, have no parents. All other |
| 586 | * devices do, and should have their "parent" pointer set appropriately |
| 587 | * before calling this function. |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 588 | */ |
| 589 | int sas_discover_sata(struct domain_device *dev) |
| 590 | { |
| 591 | int res; |
| 592 | |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 593 | if (dev->dev_type == SATA_PM) |
| 594 | return -ENODEV; |
| 595 | |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 596 | sas_get_ata_command_set(dev); |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 597 | sas_fill_in_rphy(dev, dev->rphy); |
Dan Williams | 87c8331 | 2011-11-17 17:59:51 -0800 | [diff] [blame] | 598 | |
| 599 | res = sas_notify_lldd_dev_found(dev); |
| 600 | if (res) |
| 601 | return res; |
| 602 | |
| 603 | sas_discover_event(dev->port, DISCE_PROBE); |
Dan Williams | b91bb29 | 2011-11-17 17:59:52 -0800 | [diff] [blame] | 604 | return 0; |
James Bottomley | b914217 | 2007-07-22 13:15:55 -0500 | [diff] [blame] | 605 | } |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 606 | |
| 607 | void sas_ata_strategy_handler(struct Scsi_Host *shost) |
| 608 | { |
| 609 | struct scsi_device *sdev; |
Dan Williams | 87c8331 | 2011-11-17 17:59:51 -0800 | [diff] [blame] | 610 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); |
| 611 | |
| 612 | /* it's ok to defer revalidation events during ata eh, these |
| 613 | * disks are in one of three states: |
| 614 | * 1/ present for initial domain discovery, and these |
| 615 | * resets will cause bcn flutters |
| 616 | * 2/ hot removed, we'll discover that after eh fails |
| 617 | * 3/ hot added after initial discovery, lost the race, and need |
| 618 | * to catch the next train. |
| 619 | */ |
| 620 | sas_disable_revalidation(sas_ha); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 621 | |
| 622 | shost_for_each_device(sdev, shost) { |
| 623 | struct domain_device *ddev = sdev_to_domain_dev(sdev); |
| 624 | struct ata_port *ap = ddev->sata_dev.ap; |
| 625 | |
| 626 | if (!dev_is_sata(ddev)) |
| 627 | continue; |
James Bottomley | c299190 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 628 | |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 629 | ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata port error handler"); |
| 630 | ata_scsi_port_error_handler(shost, ap); |
| 631 | } |
Dan Williams | 87c8331 | 2011-11-17 17:59:51 -0800 | [diff] [blame] | 632 | |
| 633 | sas_enable_revalidation(sas_ha); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | int sas_ata_timed_out(struct scsi_cmnd *cmd, struct sas_task *task, |
| 637 | enum blk_eh_timer_return *rtn) |
| 638 | { |
| 639 | struct domain_device *ddev = cmd_to_domain_dev(cmd); |
| 640 | |
| 641 | if (!dev_is_sata(ddev) || task) |
| 642 | return 0; |
| 643 | |
| 644 | /* we're a sata device with no task, so this must be a libata |
| 645 | * eh timeout. Ideally should hook into libata timeout |
| 646 | * handling, but there's no point, it just wants to activate |
| 647 | * the eh thread */ |
| 648 | *rtn = BLK_EH_NOT_HANDLED; |
| 649 | return 1; |
| 650 | } |
| 651 | |
| 652 | int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, |
| 653 | struct list_head *done_q) |
| 654 | { |
| 655 | int rtn = 0; |
| 656 | struct scsi_cmnd *cmd, *n; |
| 657 | struct ata_port *ap; |
| 658 | |
| 659 | do { |
| 660 | LIST_HEAD(sata_q); |
| 661 | |
| 662 | ap = NULL; |
James Bottomley | c299190 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 663 | |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 664 | list_for_each_entry_safe(cmd, n, work_q, eh_entry) { |
| 665 | struct domain_device *ddev = cmd_to_domain_dev(cmd); |
| 666 | |
| 667 | if (!dev_is_sata(ddev) || TO_SAS_TASK(cmd)) |
| 668 | continue; |
James Bottomley | c299190 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 669 | if (ap && ap != ddev->sata_dev.ap) |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 670 | continue; |
| 671 | ap = ddev->sata_dev.ap; |
| 672 | rtn = 1; |
| 673 | list_move(&cmd->eh_entry, &sata_q); |
| 674 | } |
| 675 | |
| 676 | if (!list_empty(&sata_q)) { |
James Bottomley | c299190 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 677 | ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata cmd error handler\n"); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 678 | ata_scsi_cmd_error_handler(shost, ap, &sata_q); |
James Bottomley | a82058a | 2011-03-10 17:13:18 -0600 | [diff] [blame] | 679 | /* |
| 680 | * ata's error handler may leave the cmd on the list |
| 681 | * so make sure they don't remain on a stack list |
| 682 | * about to go out of scope. |
| 683 | * |
| 684 | * This looks strange, since the commands are |
| 685 | * now part of no list, but the next error |
| 686 | * action will be ata_port_error_handler() |
| 687 | * which takes no list and sweeps them up |
| 688 | * anyway from the ata tag array. |
| 689 | */ |
| 690 | while (!list_empty(&sata_q)) |
| 691 | list_del_init(sata_q.next); |
James Bottomley | 00dd499 | 2011-01-23 09:44:12 -0600 | [diff] [blame] | 692 | } |
| 693 | } while (ap); |
| 694 | |
| 695 | return rtn; |
| 696 | } |