aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@us.ibm.com>2007-01-30 04:18:58 -0500
committerJames Bottomley <jejb@mulgrave.localdomain>2007-07-18 12:16:03 -0400
commit3a2755af37b317d47fdc3dd15178adaf5d47263e (patch)
tree1d4bca0573db7d4a19a4feac5a14855764a3f3fb /drivers/scsi/libsas
parentfe059f122fb9d1bd3a629d4215a4dde11df66f98 (diff)
[SCSI] sas_ata: Implement sas_task_abort for ATA devices
ATA devices need special handling for sas_task_abort. If the ATA command came from SCSI, then we merely need to tell SCSI to abort the scsi_cmnd. However, internal commands require a bit more work--we need to fill the qc with the appropriate error status and complete the command, and eventually post_internal will issue the actual ABORT TASK. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r--drivers/scsi/libsas/sas_ata.c47
-rw-r--r--drivers/scsi/libsas/sas_internal.h3
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c8
3 files changed, 52 insertions, 6 deletions
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index b6535b073bf1..2db258996751 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -30,6 +30,8 @@
30#include <scsi/scsi_transport.h> 30#include <scsi/scsi_transport.h>
31#include <scsi/scsi_transport_sas.h> 31#include <scsi/scsi_transport_sas.h>
32#include "../scsi_sas_internal.h" 32#include "../scsi_sas_internal.h"
33#include "../scsi_transport_api.h"
34#include <scsi/scsi_eh.h>
33 35
34static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts) 36static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)
35{ 37{
@@ -91,6 +93,7 @@ static void sas_ata_task_done(struct sas_task *task)
91 struct domain_device *dev; 93 struct domain_device *dev;
92 struct task_status_struct *stat = &task->task_status; 94 struct task_status_struct *stat = &task->task_status;
93 struct ata_task_resp *resp = (struct ata_task_resp *)stat->buf; 95 struct ata_task_resp *resp = (struct ata_task_resp *)stat->buf;
96 struct sas_ha_struct *sas_ha;
94 enum ata_completion_errors ac; 97 enum ata_completion_errors ac;
95 unsigned long flags; 98 unsigned long flags;
96 99
@@ -98,6 +101,7 @@ static void sas_ata_task_done(struct sas_task *task)
98 goto qc_already_gone; 101 goto qc_already_gone;
99 102
100 dev = qc->ap->private_data; 103 dev = qc->ap->private_data;
104 sas_ha = dev->port->ha;
101 105
102 spin_lock_irqsave(dev->sata_dev.ap->lock, flags); 106 spin_lock_irqsave(dev->sata_dev.ap->lock, flags);
103 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_GOOD) { 107 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_GOOD) {
@@ -124,6 +128,20 @@ static void sas_ata_task_done(struct sas_task *task)
124 ata_qc_complete(qc); 128 ata_qc_complete(qc);
125 spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags); 129 spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags);
126 130
131 /*
132 * If the sas_task has an ata qc, a scsi_cmnd and the aborted
133 * flag is set, then we must have come in via the libsas EH
134 * functions. When we exit this function, we need to put the
135 * scsi_cmnd on the list of finished errors. The ata_qc_complete
136 * call cleans up the libata side of things but we're protected
137 * from the scsi_cmnd going away because the scsi_cmnd is owned
138 * by the EH, making libata's call to scsi_done a NOP.
139 */
140 spin_lock_irqsave(&task->task_state_lock, flags);
141 if (qc->scsicmd && task->task_state_flags & SAS_TASK_STATE_ABORTED)
142 scsi_eh_finish_cmd(qc->scsicmd, &sas_ha->eh_done_q);
143 spin_unlock_irqrestore(&task->task_state_lock, flags);
144
127qc_already_gone: 145qc_already_gone:
128 list_del_init(&task->list); 146 list_del_init(&task->list);
129 sas_free_task(task); 147 sas_free_task(task);
@@ -259,15 +277,18 @@ static void sas_ata_post_internal(struct ata_queued_cmd *qc)
259 * ought to abort the task. 277 * ought to abort the task.
260 */ 278 */
261 struct sas_task *task = qc->lldd_task; 279 struct sas_task *task = qc->lldd_task;
262 struct domain_device *dev = qc->ap->private_data; 280 unsigned long flags;
263 281
264 qc->lldd_task = NULL; 282 qc->lldd_task = NULL;
265 if (task) { 283 if (task) {
284 /* Should this be a AT(API) device reset? */
285 spin_lock_irqsave(&task->task_state_lock, flags);
286 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
287 spin_unlock_irqrestore(&task->task_state_lock, flags);
288
266 task->uldd_task = NULL; 289 task->uldd_task = NULL;
267 __sas_task_abort(task); 290 __sas_task_abort(task);
268 } 291 }
269
270 sas_phy_reset(dev->port->phy, 1);
271 } 292 }
272} 293}
273 294
@@ -369,3 +390,23 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
369 390
370 return 0; 391 return 0;
371} 392}
393
394void sas_ata_task_abort(struct sas_task *task)
395{
396 struct ata_queued_cmd *qc = task->uldd_task;
397 struct completion *waiting;
398
399 /* Bounce SCSI-initiated commands to the SCSI EH */
400 if (qc->scsicmd) {
401 scsi_req_abort_cmd(qc->scsicmd);
402 scsi_schedule_eh(qc->scsicmd->device->host);
403 return;
404 }
405
406 /* Internal command, fake a timeout and complete. */
407 qc->flags &= ~ATA_QCFLAG_ACTIVE;
408 qc->flags |= ATA_QCFLAG_FAILED;
409 qc->err_mask |= AC_ERR_TIMEOUT;
410 waiting = qc->private_data;
411 complete(waiting);
412}
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index a78638df2018..2b8213b1832d 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -39,6 +39,9 @@
39#define SAS_DPRINTK(fmt, ...) 39#define SAS_DPRINTK(fmt, ...)
40#endif 40#endif
41 41
42#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble)
43#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0)
44
42void sas_scsi_recover_host(struct Scsi_Host *shost); 45void sas_scsi_recover_host(struct Scsi_Host *shost);
43 46
44int sas_show_class(enum sas_class class, char *buf); 47int sas_show_class(enum sas_class class, char *buf);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index ba5c91b81312..7663841eb4cf 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -47,9 +47,6 @@
47 47
48/* ---------- SCSI Host glue ---------- */ 48/* ---------- SCSI Host glue ---------- */
49 49
50#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble)
51#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0)
52
53static void sas_scsi_task_done(struct sas_task *task) 50static void sas_scsi_task_done(struct sas_task *task)
54{ 51{
55 struct task_status_struct *ts = &task->task_status; 52 struct task_status_struct *ts = &task->task_status;
@@ -1018,6 +1015,11 @@ void sas_task_abort(struct sas_task *task)
1018 return; 1015 return;
1019 } 1016 }
1020 1017
1018 if (dev_is_sata(task->dev)) {
1019 sas_ata_task_abort(task);
1020 return;
1021 }
1022
1021 scsi_req_abort_cmd(sc); 1023 scsi_req_abort_cmd(sc);
1022 scsi_schedule_eh(sc->device->host); 1024 scsi_schedule_eh(sc->device->host);
1023} 1025}