blob: dbc2a912114f1880b0172055d703b0c9553bfbd4 [file] [log] [blame]
James Bottomley2908d772006-08-29 09:22:51 -05001/*
2 * Serial Attached SCSI (SAS) class SCSI Host glue.
3 *
4 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
5 * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
6 *
7 * This file is licensed under GPLv2.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 */
25
Christoph Hellwigd7a54e32007-04-26 09:38:01 -040026#include <linux/kthread.h>
27
James Bottomley2908d772006-08-29 09:22:51 -050028#include "sas_internal.h"
29
30#include <scsi/scsi_host.h>
31#include <scsi/scsi_device.h>
32#include <scsi/scsi_tcq.h>
33#include <scsi/scsi.h>
Darrick J. Wongf4563932006-10-30 15:18:39 -080034#include <scsi/scsi_eh.h>
James Bottomley2908d772006-08-29 09:22:51 -050035#include <scsi/scsi_transport.h>
36#include <scsi/scsi_transport_sas.h>
Darrick J. Wong338ec572006-10-18 14:43:37 -070037#include <scsi/sas_ata.h>
James Bottomley2908d772006-08-29 09:22:51 -050038#include "../scsi_sas_internal.h"
Darrick J. Wong79a5eb62006-10-30 15:18:50 -080039#include "../scsi_transport_api.h"
Darrick J. Wongad689232007-01-26 14:08:52 -080040#include "../scsi_priv.h"
James Bottomley2908d772006-08-29 09:22:51 -050041
42#include <linux/err.h>
43#include <linux/blkdev.h>
Rafael J. Wysocki83144182007-07-17 04:03:35 -070044#include <linux/freezer.h>
James Bottomley2908d772006-08-29 09:22:51 -050045#include <linux/scatterlist.h>
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -070046#include <linux/libata.h>
James Bottomley2908d772006-08-29 09:22:51 -050047
48/* ---------- SCSI Host glue ---------- */
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)
54{
55 struct task_status_struct *ts = &task->task_status;
56 struct scsi_cmnd *sc = task->uldd_task;
Darrick J. Wongf4563932006-10-30 15:18:39 -080057 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(sc->device->host);
James Bottomley2908d772006-08-29 09:22:51 -050058 unsigned ts_flags = task->task_state_flags;
59 int hs = 0, stat = 0;
60
61 if (unlikely(!sc)) {
62 SAS_DPRINTK("task_done called with non existing SCSI cmnd!\n");
63 list_del_init(&task->list);
64 sas_free_task(task);
65 return;
66 }
67
68 if (ts->resp == SAS_TASK_UNDELIVERED) {
69 /* transport error */
70 hs = DID_NO_CONNECT;
71 } else { /* ts->resp == SAS_TASK_COMPLETE */
72 /* task delivered, what happened afterwards? */
73 switch (ts->stat) {
74 case SAS_DEV_NO_RESPONSE:
75 case SAS_INTERRUPTED:
76 case SAS_PHY_DOWN:
77 case SAS_NAK_R_ERR:
78 case SAS_OPEN_TO:
79 hs = DID_NO_CONNECT;
80 break;
81 case SAS_DATA_UNDERRUN:
FUJITA Tomonoric13e5562007-05-26 02:46:37 +090082 scsi_set_resid(sc, ts->residual);
83 if (scsi_bufflen(sc) - scsi_get_resid(sc) < sc->underflow)
James Bottomley2908d772006-08-29 09:22:51 -050084 hs = DID_ERROR;
85 break;
86 case SAS_DATA_OVERRUN:
87 hs = DID_ERROR;
88 break;
89 case SAS_QUEUE_FULL:
90 hs = DID_SOFT_ERROR; /* retry */
91 break;
92 case SAS_DEVICE_UNKNOWN:
93 hs = DID_BAD_TARGET;
94 break;
95 case SAS_SG_ERR:
96 hs = DID_PARITY;
97 break;
98 case SAS_OPEN_REJECT:
99 if (ts->open_rej_reason == SAS_OREJ_RSVD_RETRY)
100 hs = DID_SOFT_ERROR; /* retry */
101 else
102 hs = DID_ERROR;
103 break;
104 case SAS_PROTO_RESPONSE:
105 SAS_DPRINTK("LLDD:%s sent SAS_PROTO_RESP for an SSP "
106 "task; please report this\n",
107 task->dev->port->ha->sas_ha_name);
108 break;
109 case SAS_ABORTED_TASK:
110 hs = DID_ABORT;
111 break;
112 case SAM_CHECK_COND:
113 memcpy(sc->sense_buffer, ts->buf,
114 max(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
115 stat = SAM_CHECK_COND;
116 break;
117 default:
118 stat = ts->stat;
119 break;
120 }
121 }
122 ASSIGN_SAS_TASK(sc, NULL);
123 sc->result = (hs << 16) | stat;
124 list_del_init(&task->list);
125 sas_free_task(task);
126 /* This is very ugly but this is how SCSI Core works. */
127 if (ts_flags & SAS_TASK_STATE_ABORTED)
Darrick J. Wongf4563932006-10-30 15:18:39 -0800128 scsi_eh_finish_cmd(sc, &sas_ha->eh_done_q);
James Bottomley2908d772006-08-29 09:22:51 -0500129 else
130 sc->scsi_done(sc);
131}
132
133static enum task_attribute sas_scsi_get_task_attr(struct scsi_cmnd *cmd)
134{
135 enum task_attribute ta = TASK_ATTR_SIMPLE;
136 if (cmd->request && blk_rq_tagged(cmd->request)) {
137 if (cmd->device->ordered_tags &&
Jeff Garzik1bdfd552006-09-30 21:28:22 -0400138 (cmd->request->cmd_flags & REQ_HARDBARRIER))
FUJITA Tomonori63bb1bf2007-01-28 01:19:41 +0900139 ta = TASK_ATTR_ORDERED;
James Bottomley2908d772006-08-29 09:22:51 -0500140 }
141 return ta;
142}
143
144static struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
145 struct domain_device *dev,
Al Viro3cc27542006-09-25 02:55:40 +0100146 gfp_t gfp_flags)
James Bottomley2908d772006-08-29 09:22:51 -0500147{
148 struct sas_task *task = sas_alloc_task(gfp_flags);
149 struct scsi_lun lun;
150
151 if (!task)
152 return NULL;
153
154 *(u32 *)cmd->sense_buffer = 0;
155 task->uldd_task = cmd;
156 ASSIGN_SAS_TASK(cmd, task);
157
158 task->dev = dev;
159 task->task_proto = task->dev->tproto; /* BUG_ON(!SSP) */
160
161 task->ssp_task.retry_count = 1;
162 int_to_scsilun(cmd->device->lun, &lun);
163 memcpy(task->ssp_task.LUN, &lun.scsi_lun, 8);
164 task->ssp_task.task_attr = sas_scsi_get_task_attr(cmd);
165 memcpy(task->ssp_task.cdb, cmd->cmnd, 16);
166
FUJITA Tomonoric13e5562007-05-26 02:46:37 +0900167 task->scatter = scsi_sglist(cmd);
168 task->num_scatter = scsi_sg_count(cmd);
169 task->total_xfer_len = scsi_bufflen(cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500170 task->data_dir = cmd->sc_data_direction;
171
172 task->task_done = sas_scsi_task_done;
173
174 return task;
175}
176
Darrick J. Wong338ec572006-10-18 14:43:37 -0700177int sas_queue_up(struct sas_task *task)
James Bottomley2908d772006-08-29 09:22:51 -0500178{
179 struct sas_ha_struct *sas_ha = task->dev->port->ha;
180 struct scsi_core *core = &sas_ha->core;
181 unsigned long flags;
182 LIST_HEAD(list);
183
184 spin_lock_irqsave(&core->task_queue_lock, flags);
185 if (sas_ha->lldd_queue_size < core->task_queue_size + 1) {
186 spin_unlock_irqrestore(&core->task_queue_lock, flags);
187 return -SAS_QUEUE_FULL;
188 }
189 list_add_tail(&task->list, &core->task_queue);
190 core->task_queue_size += 1;
191 spin_unlock_irqrestore(&core->task_queue_lock, flags);
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400192 wake_up_process(core->queue_thread);
James Bottomley2908d772006-08-29 09:22:51 -0500193
194 return 0;
195}
196
197/**
198 * sas_queuecommand -- Enqueue a command for processing
199 * @parameters: See SCSI Core documentation
200 *
201 * Note: XXX: Remove the host unlock/lock pair when SCSI Core can
202 * call us without holding an IRQ spinlock...
203 */
204int sas_queuecommand(struct scsi_cmnd *cmd,
205 void (*scsi_done)(struct scsi_cmnd *))
206{
207 int res = 0;
208 struct domain_device *dev = cmd_to_domain_dev(cmd);
209 struct Scsi_Host *host = cmd->device->host;
210 struct sas_internal *i = to_sas_internal(host->transportt);
211
212 spin_unlock_irq(host->host_lock);
213
214 {
215 struct sas_ha_struct *sas_ha = dev->port->ha;
216 struct sas_task *task;
217
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700218 if (dev_is_sata(dev)) {
219 res = ata_sas_queuecmd(cmd, scsi_done,
220 dev->sata_dev.ap);
221 goto out;
222 }
223
James Bottomley2908d772006-08-29 09:22:51 -0500224 res = -ENOMEM;
225 task = sas_create_task(cmd, dev, GFP_ATOMIC);
226 if (!task)
227 goto out;
228
229 cmd->scsi_done = scsi_done;
230 /* Queue up, Direct Mode or Task Collector Mode. */
231 if (sas_ha->lldd_max_execute_num < 2)
232 res = i->dft->lldd_execute_task(task, 1, GFP_ATOMIC);
233 else
234 res = sas_queue_up(task);
235
236 /* Examine */
237 if (res) {
238 SAS_DPRINTK("lldd_execute_task returned: %d\n", res);
239 ASSIGN_SAS_TASK(cmd, NULL);
240 sas_free_task(task);
241 if (res == -SAS_QUEUE_FULL) {
242 cmd->result = DID_SOFT_ERROR << 16; /* retry */
243 res = 0;
244 scsi_done(cmd);
245 }
246 goto out;
247 }
248 }
249out:
250 spin_lock_irq(host->host_lock);
251 return res;
252}
253
254static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd)
255{
256 struct scsi_cmnd *cmd, *n;
257
258 list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
259 if (cmd == my_cmd)
260 list_del_init(&cmd->eh_entry);
261 }
262}
263
264static void sas_scsi_clear_queue_I_T(struct list_head *error_q,
265 struct domain_device *dev)
266{
267 struct scsi_cmnd *cmd, *n;
268
269 list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
270 struct domain_device *x = cmd_to_domain_dev(cmd);
271
272 if (x == dev)
273 list_del_init(&cmd->eh_entry);
274 }
275}
276
277static void sas_scsi_clear_queue_port(struct list_head *error_q,
278 struct asd_sas_port *port)
279{
280 struct scsi_cmnd *cmd, *n;
281
282 list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
283 struct domain_device *dev = cmd_to_domain_dev(cmd);
284 struct asd_sas_port *x = dev->port;
285
286 if (x == port)
287 list_del_init(&cmd->eh_entry);
288 }
289}
290
291enum task_disposition {
292 TASK_IS_DONE,
293 TASK_IS_ABORTED,
294 TASK_IS_AT_LU,
295 TASK_IS_NOT_AT_LU,
Darrick J. Wong02cd7432007-01-11 14:15:46 -0800296 TASK_ABORT_FAILED,
James Bottomley2908d772006-08-29 09:22:51 -0500297};
298
299static enum task_disposition sas_scsi_find_task(struct sas_task *task)
300{
301 struct sas_ha_struct *ha = task->dev->port->ha;
302 unsigned long flags;
303 int i, res;
304 struct sas_internal *si =
305 to_sas_internal(task->dev->port->ha->core.shost->transportt);
306
307 if (ha->lldd_max_execute_num > 1) {
308 struct scsi_core *core = &ha->core;
309 struct sas_task *t, *n;
310
311 spin_lock_irqsave(&core->task_queue_lock, flags);
312 list_for_each_entry_safe(t, n, &core->task_queue, list) {
313 if (task == t) {
314 list_del_init(&t->list);
315 spin_unlock_irqrestore(&core->task_queue_lock,
316 flags);
317 SAS_DPRINTK("%s: task 0x%p aborted from "
318 "task_queue\n",
319 __FUNCTION__, task);
320 return TASK_IS_ABORTED;
321 }
322 }
323 spin_unlock_irqrestore(&core->task_queue_lock, flags);
324 }
325
326 for (i = 0; i < 5; i++) {
327 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task);
328 res = si->dft->lldd_abort_task(task);
329
330 spin_lock_irqsave(&task->task_state_lock, flags);
331 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
332 spin_unlock_irqrestore(&task->task_state_lock, flags);
333 SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__,
334 task);
335 return TASK_IS_DONE;
336 }
337 spin_unlock_irqrestore(&task->task_state_lock, flags);
338
339 if (res == TMF_RESP_FUNC_COMPLETE) {
340 SAS_DPRINTK("%s: task 0x%p is aborted\n",
341 __FUNCTION__, task);
342 return TASK_IS_ABORTED;
343 } else if (si->dft->lldd_query_task) {
344 SAS_DPRINTK("%s: querying task 0x%p\n",
345 __FUNCTION__, task);
346 res = si->dft->lldd_query_task(task);
Darrick J. Wong02cd7432007-01-11 14:15:46 -0800347 switch (res) {
348 case TMF_RESP_FUNC_SUCC:
James Bottomley2908d772006-08-29 09:22:51 -0500349 SAS_DPRINTK("%s: task 0x%p at LU\n",
350 __FUNCTION__, task);
351 return TASK_IS_AT_LU;
Darrick J. Wong02cd7432007-01-11 14:15:46 -0800352 case TMF_RESP_FUNC_COMPLETE:
James Bottomley2908d772006-08-29 09:22:51 -0500353 SAS_DPRINTK("%s: task 0x%p not at LU\n",
354 __FUNCTION__, task);
355 return TASK_IS_NOT_AT_LU;
Darrick J. Wong02cd7432007-01-11 14:15:46 -0800356 case TMF_RESP_FUNC_FAILED:
357 SAS_DPRINTK("%s: task 0x%p failed to abort\n",
358 __FUNCTION__, task);
359 return TASK_ABORT_FAILED;
360 }
361
James Bottomley2908d772006-08-29 09:22:51 -0500362 }
363 }
364 return res;
365}
366
367static int sas_recover_lu(struct domain_device *dev, struct scsi_cmnd *cmd)
368{
369 int res = TMF_RESP_FUNC_FAILED;
370 struct scsi_lun lun;
371 struct sas_internal *i =
372 to_sas_internal(dev->port->ha->core.shost->transportt);
373
374 int_to_scsilun(cmd->device->lun, &lun);
375
376 SAS_DPRINTK("eh: device %llx LUN %x has the task\n",
377 SAS_ADDR(dev->sas_addr),
378 cmd->device->lun);
379
380 if (i->dft->lldd_abort_task_set)
381 res = i->dft->lldd_abort_task_set(dev, lun.scsi_lun);
382
383 if (res == TMF_RESP_FUNC_FAILED) {
384 if (i->dft->lldd_clear_task_set)
385 res = i->dft->lldd_clear_task_set(dev, lun.scsi_lun);
386 }
387
388 if (res == TMF_RESP_FUNC_FAILED) {
389 if (i->dft->lldd_lu_reset)
390 res = i->dft->lldd_lu_reset(dev, lun.scsi_lun);
391 }
392
393 return res;
394}
395
396static int sas_recover_I_T(struct domain_device *dev)
397{
398 int res = TMF_RESP_FUNC_FAILED;
399 struct sas_internal *i =
400 to_sas_internal(dev->port->ha->core.shost->transportt);
401
402 SAS_DPRINTK("I_T nexus reset for dev %016llx\n",
403 SAS_ADDR(dev->sas_addr));
404
405 if (i->dft->lldd_I_T_nexus_reset)
406 res = i->dft->lldd_I_T_nexus_reset(dev);
407
408 return res;
409}
410
Darrick J. Wongad689232007-01-26 14:08:52 -0800411/* Find the sas_phy that's attached to this device */
412struct sas_phy *find_local_sas_phy(struct domain_device *dev)
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800413{
Darrick J. Wongad689232007-01-26 14:08:52 -0800414 struct domain_device *pdev = dev->parent;
415 struct ex_phy *exphy = NULL;
416 int i;
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800417
Darrick J. Wongad689232007-01-26 14:08:52 -0800418 /* Directly attached device */
419 if (!pdev)
420 return dev->port->phy;
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800421
Darrick J. Wongad689232007-01-26 14:08:52 -0800422 /* Otherwise look in the expander */
423 for (i = 0; i < pdev->ex_dev.num_phys; i++)
424 if (!memcmp(dev->sas_addr,
425 pdev->ex_dev.ex_phy[i].attached_sas_addr,
426 SAS_ADDR_SIZE)) {
427 exphy = &pdev->ex_dev.ex_phy[i];
428 break;
429 }
430
431 BUG_ON(!exphy);
432 return exphy->phy;
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800433}
434
Darrick J. Wonga9344e62007-01-29 23:48:19 -0800435/* Attempt to send a LUN reset message to a device */
Darrick J. Wongad689232007-01-26 14:08:52 -0800436int sas_eh_device_reset_handler(struct scsi_cmnd *cmd)
James Bottomley2908d772006-08-29 09:22:51 -0500437{
Darrick J. Wongad689232007-01-26 14:08:52 -0800438 struct domain_device *dev = cmd_to_domain_dev(cmd);
Darrick J. Wonga9344e62007-01-29 23:48:19 -0800439 struct sas_internal *i =
440 to_sas_internal(dev->port->ha->core.shost->transportt);
441 struct scsi_lun lun;
442 int res;
443
444 int_to_scsilun(cmd->device->lun, &lun);
445
446 if (!i->dft->lldd_lu_reset)
447 return FAILED;
448
449 res = i->dft->lldd_lu_reset(dev, lun.scsi_lun);
450 if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
451 return SUCCESS;
452
453 return FAILED;
454}
455
456/* Attempt to send a phy (bus) reset */
457int sas_eh_bus_reset_handler(struct scsi_cmnd *cmd)
458{
459 struct domain_device *dev = cmd_to_domain_dev(cmd);
Darrick J. Wongad689232007-01-26 14:08:52 -0800460 struct sas_phy *phy = find_local_sas_phy(dev);
461 int res;
462
463 res = sas_phy_reset(phy, 1);
464 if (res)
Darrick J. Wonga9344e62007-01-29 23:48:19 -0800465 SAS_DPRINTK("Bus reset of %s failed 0x%x\n",
Darrick J. Wongad689232007-01-26 14:08:52 -0800466 phy->dev.kobj.k_name,
467 res);
468 if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
469 return SUCCESS;
470
471 return FAILED;
472}
473
474/* Try to reset a device */
475static int try_to_reset_cmd_device(struct Scsi_Host *shost,
476 struct scsi_cmnd *cmd)
477{
Darrick J. Wonga9344e62007-01-29 23:48:19 -0800478 int res;
Darrick J. Wongad689232007-01-26 14:08:52 -0800479
Darrick J. Wonga9344e62007-01-29 23:48:19 -0800480 if (!shost->hostt->eh_device_reset_handler)
481 goto try_bus_reset;
482
483 res = shost->hostt->eh_device_reset_handler(cmd);
484 if (res == SUCCESS)
485 return res;
486
487try_bus_reset:
488 if (shost->hostt->eh_bus_reset_handler)
489 return shost->hostt->eh_bus_reset_handler(cmd);
490
491 return FAILED;
Darrick J. Wongad689232007-01-26 14:08:52 -0800492}
493
494static int sas_eh_handle_sas_errors(struct Scsi_Host *shost,
495 struct list_head *work_q,
496 struct list_head *done_q)
497{
James Bottomley2908d772006-08-29 09:22:51 -0500498 struct scsi_cmnd *cmd, *n;
499 enum task_disposition res = TASK_IS_DONE;
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800500 int tmf_resp, need_reset;
James Bottomley2908d772006-08-29 09:22:51 -0500501 struct sas_internal *i = to_sas_internal(shost->transportt);
Darrick J. Wongad689232007-01-26 14:08:52 -0800502 unsigned long flags;
503 struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
James Bottomley2908d772006-08-29 09:22:51 -0500504
James Bottomley2908d772006-08-29 09:22:51 -0500505Again:
Darrick J. Wongad689232007-01-26 14:08:52 -0800506 list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
James Bottomley2908d772006-08-29 09:22:51 -0500507 struct sas_task *task = TO_SAS_TASK(cmd);
Darrick J. Wongf4563932006-10-30 15:18:39 -0800508
Darrick J. Wongad689232007-01-26 14:08:52 -0800509 if (!task)
Darrick J. Wongf4563932006-10-30 15:18:39 -0800510 continue;
Darrick J. Wongad689232007-01-26 14:08:52 -0800511
512 list_del_init(&cmd->eh_entry);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800513
514 spin_lock_irqsave(&task->task_state_lock, flags);
515 need_reset = task->task_state_flags & SAS_TASK_NEED_DEV_RESET;
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800516 spin_unlock_irqrestore(&task->task_state_lock, flags);
517
Darrick J. Wongf4563932006-10-30 15:18:39 -0800518 SAS_DPRINTK("trying to find task 0x%p\n", task);
James Bottomley2908d772006-08-29 09:22:51 -0500519 res = sas_scsi_find_task(task);
520
521 cmd->eh_eflags = 0;
James Bottomley2908d772006-08-29 09:22:51 -0500522
523 switch (res) {
524 case TASK_IS_DONE:
525 SAS_DPRINTK("%s: task 0x%p is done\n", __FUNCTION__,
526 task);
527 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800528 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800529 try_to_reset_cmd_device(shost, cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500530 continue;
531 case TASK_IS_ABORTED:
532 SAS_DPRINTK("%s: task 0x%p is aborted\n",
533 __FUNCTION__, task);
534 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800535 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800536 try_to_reset_cmd_device(shost, cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500537 continue;
538 case TASK_IS_AT_LU:
539 SAS_DPRINTK("task 0x%p is at LU: lu recover\n", task);
540 tmf_resp = sas_recover_lu(task->dev, cmd);
541 if (tmf_resp == TMF_RESP_FUNC_COMPLETE) {
542 SAS_DPRINTK("dev %016llx LU %x is "
543 "recovered\n",
544 SAS_ADDR(task->dev),
545 cmd->device->lun);
546 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800547 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800548 try_to_reset_cmd_device(shost, cmd);
549 sas_scsi_clear_queue_lu(work_q, cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500550 goto Again;
551 }
552 /* fallthrough */
553 case TASK_IS_NOT_AT_LU:
Darrick J. Wong02cd7432007-01-11 14:15:46 -0800554 case TASK_ABORT_FAILED:
James Bottomley2908d772006-08-29 09:22:51 -0500555 SAS_DPRINTK("task 0x%p is not at LU: I_T recover\n",
556 task);
557 tmf_resp = sas_recover_I_T(task->dev);
558 if (tmf_resp == TMF_RESP_FUNC_COMPLETE) {
559 SAS_DPRINTK("I_T %016llx recovered\n",
560 SAS_ADDR(task->dev->sas_addr));
561 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800562 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800563 try_to_reset_cmd_device(shost, cmd);
564 sas_scsi_clear_queue_I_T(work_q, task->dev);
James Bottomley2908d772006-08-29 09:22:51 -0500565 goto Again;
566 }
567 /* Hammer time :-) */
568 if (i->dft->lldd_clear_nexus_port) {
569 struct asd_sas_port *port = task->dev->port;
570 SAS_DPRINTK("clearing nexus for port:%d\n",
571 port->id);
572 res = i->dft->lldd_clear_nexus_port(port);
573 if (res == TMF_RESP_FUNC_COMPLETE) {
574 SAS_DPRINTK("clear nexus port:%d "
575 "succeeded\n", port->id);
576 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800577 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800578 try_to_reset_cmd_device(shost, cmd);
579 sas_scsi_clear_queue_port(work_q,
James Bottomley2908d772006-08-29 09:22:51 -0500580 port);
581 goto Again;
582 }
583 }
584 if (i->dft->lldd_clear_nexus_ha) {
585 SAS_DPRINTK("clear nexus ha\n");
586 res = i->dft->lldd_clear_nexus_ha(ha);
587 if (res == TMF_RESP_FUNC_COMPLETE) {
588 SAS_DPRINTK("clear nexus ha "
589 "succeeded\n");
590 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800591 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800592 try_to_reset_cmd_device(shost, cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500593 goto out;
594 }
595 }
596 /* If we are here -- this means that no amount
597 * of effort could recover from errors. Quite
598 * possibly the HA just disappeared.
599 */
600 SAS_DPRINTK("error from device %llx, LUN %x "
601 "couldn't be recovered in any way\n",
602 SAS_ADDR(task->dev->sas_addr),
603 cmd->device->lun);
604
605 task->task_done(task);
Darrick J. Wong3ebf6922007-01-11 14:15:17 -0800606 if (need_reset)
Darrick J. Wongad689232007-01-26 14:08:52 -0800607 try_to_reset_cmd_device(shost, cmd);
James Bottomley2908d772006-08-29 09:22:51 -0500608 goto clear_q;
609 }
610 }
611out:
Darrick J. Wongad689232007-01-26 14:08:52 -0800612 return list_empty(work_q);
James Bottomley2908d772006-08-29 09:22:51 -0500613clear_q:
614 SAS_DPRINTK("--- Exit %s -- clear_q\n", __FUNCTION__);
Darrick J. Wongad689232007-01-26 14:08:52 -0800615 list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
James Bottomley2908d772006-08-29 09:22:51 -0500616 struct sas_task *task = TO_SAS_TASK(cmd);
617 list_del_init(&cmd->eh_entry);
618 task->task_done(task);
619 }
Darrick J. Wongad689232007-01-26 14:08:52 -0800620 return list_empty(work_q);
621}
622
623void sas_scsi_recover_host(struct Scsi_Host *shost)
624{
625 struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
626 unsigned long flags;
627 LIST_HEAD(eh_work_q);
628
629 spin_lock_irqsave(shost->host_lock, flags);
630 list_splice_init(&shost->eh_cmd_q, &eh_work_q);
631 spin_unlock_irqrestore(shost->host_lock, flags);
632
633 SAS_DPRINTK("Enter %s\n", __FUNCTION__);
634 /*
635 * Deal with commands that still have SAS tasks (i.e. they didn't
636 * complete via the normal sas_task completion mechanism)
637 */
638 if (sas_eh_handle_sas_errors(shost, &eh_work_q, &ha->eh_done_q))
639 goto out;
640
641 /*
642 * Now deal with SCSI commands that completed ok but have a an error
643 * code (and hopefully sense data) attached. This is roughly what
644 * scsi_unjam_host does, but we skip scsi_eh_abort_cmds because any
645 * command we see here has no sas_task and is thus unknown to the HA.
646 */
647 if (!scsi_eh_get_sense(&eh_work_q, &ha->eh_done_q))
648 scsi_eh_ready_devs(shost, &eh_work_q, &ha->eh_done_q);
649
650out:
651 scsi_eh_flush_done_q(&ha->eh_done_q);
652 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__);
653 return;
James Bottomley2908d772006-08-29 09:22:51 -0500654}
655
656enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
657{
658 struct sas_task *task = TO_SAS_TASK(cmd);
659 unsigned long flags;
660
661 if (!task) {
Darrick J. Wong6d4dcd42007-01-11 14:15:00 -0800662 cmd->timeout_per_command /= 2;
663 SAS_DPRINTK("command 0x%p, task 0x%p, gone: %s\n",
664 cmd, task, (cmd->timeout_per_command ?
665 "EH_RESET_TIMER" : "EH_NOT_HANDLED"));
666 if (!cmd->timeout_per_command)
667 return EH_NOT_HANDLED;
668 return EH_RESET_TIMER;
James Bottomley2908d772006-08-29 09:22:51 -0500669 }
670
671 spin_lock_irqsave(&task->task_state_lock, flags);
Darrick J. Wong396819f2007-01-11 14:15:20 -0800672 BUG_ON(task->task_state_flags & SAS_TASK_STATE_ABORTED);
James Bottomley2908d772006-08-29 09:22:51 -0500673 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
674 spin_unlock_irqrestore(&task->task_state_lock, flags);
675 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n",
676 cmd, task);
677 return EH_HANDLED;
678 }
Darrick J. Wongb218a0d2007-01-11 14:14:55 -0800679 if (!(task->task_state_flags & SAS_TASK_AT_INITIATOR)) {
680 spin_unlock_irqrestore(&task->task_state_lock, flags);
681 SAS_DPRINTK("command 0x%p, task 0x%p, not at initiator: "
682 "EH_RESET_TIMER\n",
683 cmd, task);
684 return EH_RESET_TIMER;
685 }
James Bottomley2908d772006-08-29 09:22:51 -0500686 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
687 spin_unlock_irqrestore(&task->task_state_lock, flags);
688
689 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_NOT_HANDLED\n",
690 cmd, task);
691
692 return EH_NOT_HANDLED;
693}
694
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700695int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
696{
697 struct domain_device *dev = sdev_to_domain_dev(sdev);
698
699 if (dev_is_sata(dev))
700 return ata_scsi_ioctl(sdev, cmd, arg);
701
702 return -EINVAL;
703}
704
James Bottomley2908d772006-08-29 09:22:51 -0500705struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy)
706{
707 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent);
708 struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
709 struct domain_device *found_dev = NULL;
710 int i;
Darrick J. Wong980fa2f2007-01-11 14:15:40 -0800711 unsigned long flags;
James Bottomley2908d772006-08-29 09:22:51 -0500712
Darrick J. Wong980fa2f2007-01-11 14:15:40 -0800713 spin_lock_irqsave(&ha->phy_port_lock, flags);
James Bottomley2908d772006-08-29 09:22:51 -0500714 for (i = 0; i < ha->num_phys; i++) {
715 struct asd_sas_port *port = ha->sas_port[i];
716 struct domain_device *dev;
717
718 spin_lock(&port->dev_list_lock);
719 list_for_each_entry(dev, &port->dev_list, dev_list_node) {
720 if (rphy == dev->rphy) {
721 found_dev = dev;
722 spin_unlock(&port->dev_list_lock);
723 goto found;
724 }
725 }
726 spin_unlock(&port->dev_list_lock);
727 }
728 found:
Darrick J. Wong980fa2f2007-01-11 14:15:40 -0800729 spin_unlock_irqrestore(&ha->phy_port_lock, flags);
James Bottomley2908d772006-08-29 09:22:51 -0500730
731 return found_dev;
732}
733
734static inline struct domain_device *sas_find_target(struct scsi_target *starget)
735{
736 struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
737
738 return sas_find_dev_by_rphy(rphy);
739}
740
741int sas_target_alloc(struct scsi_target *starget)
742{
743 struct domain_device *found_dev = sas_find_target(starget);
Darrick J. Wong338ec572006-10-18 14:43:37 -0700744 int res;
James Bottomley2908d772006-08-29 09:22:51 -0500745
746 if (!found_dev)
747 return -ENODEV;
748
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700749 if (dev_is_sata(found_dev)) {
Darrick J. Wong338ec572006-10-18 14:43:37 -0700750 res = sas_ata_init_host_and_port(found_dev, starget);
751 if (res)
752 return res;
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700753 }
754
James Bottomley2908d772006-08-29 09:22:51 -0500755 starget->hostdata = found_dev;
756 return 0;
757}
758
759#define SAS_DEF_QD 32
760#define SAS_MAX_QD 64
761
762int sas_slave_configure(struct scsi_device *scsi_dev)
763{
764 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
765 struct sas_ha_struct *sas_ha;
766
767 BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE);
768
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700769 if (dev_is_sata(dev)) {
770 ata_sas_slave_configure(scsi_dev, dev->sata_dev.ap);
771 return 0;
772 }
773
James Bottomley2908d772006-08-29 09:22:51 -0500774 sas_ha = dev->port->ha;
775
776 sas_read_port_mode_page(scsi_dev);
777
778 if (scsi_dev->tagged_supported) {
779 scsi_set_tag_type(scsi_dev, MSG_SIMPLE_TAG);
780 scsi_activate_tcq(scsi_dev, SAS_DEF_QD);
781 } else {
782 SAS_DPRINTK("device %llx, LUN %x doesn't support "
783 "TCQ\n", SAS_ADDR(dev->sas_addr),
784 scsi_dev->lun);
785 scsi_dev->tagged_supported = 0;
786 scsi_set_tag_type(scsi_dev, 0);
787 scsi_deactivate_tcq(scsi_dev, 1);
788 }
789
Darrick J. Wongf27708f2007-01-26 14:08:58 -0800790 scsi_dev->allow_restart = 1;
791
James Bottomley2908d772006-08-29 09:22:51 -0500792 return 0;
793}
794
795void sas_slave_destroy(struct scsi_device *scsi_dev)
796{
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -0700797 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
798
799 if (dev_is_sata(dev))
800 ata_port_disable(dev->sata_dev.ap);
James Bottomley2908d772006-08-29 09:22:51 -0500801}
802
803int sas_change_queue_depth(struct scsi_device *scsi_dev, int new_depth)
804{
805 int res = min(new_depth, SAS_MAX_QD);
806
807 if (scsi_dev->tagged_supported)
808 scsi_adjust_queue_depth(scsi_dev, scsi_get_tag_type(scsi_dev),
809 res);
810 else {
811 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
812 sas_printk("device %llx LUN %x queue depth changed to 1\n",
813 SAS_ADDR(dev->sas_addr),
814 scsi_dev->lun);
815 scsi_adjust_queue_depth(scsi_dev, 0, 1);
816 res = 1;
817 }
818
819 return res;
820}
821
822int sas_change_queue_type(struct scsi_device *scsi_dev, int qt)
823{
824 if (!scsi_dev->tagged_supported)
825 return 0;
826
827 scsi_deactivate_tcq(scsi_dev, 1);
828
829 scsi_set_tag_type(scsi_dev, qt);
830 scsi_activate_tcq(scsi_dev, scsi_dev->queue_depth);
831
832 return qt;
833}
834
835int sas_bios_param(struct scsi_device *scsi_dev,
836 struct block_device *bdev,
837 sector_t capacity, int *hsc)
838{
839 hsc[0] = 255;
840 hsc[1] = 63;
841 sector_div(capacity, 255*63);
842 hsc[2] = capacity;
843
844 return 0;
845}
846
847/* ---------- Task Collector Thread implementation ---------- */
848
849static void sas_queue(struct sas_ha_struct *sas_ha)
850{
851 struct scsi_core *core = &sas_ha->core;
852 unsigned long flags;
853 LIST_HEAD(q);
854 int can_queue;
855 int res;
856 struct sas_internal *i = to_sas_internal(core->shost->transportt);
857
858 spin_lock_irqsave(&core->task_queue_lock, flags);
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400859 while (!kthread_should_stop() &&
James Bottomley2908d772006-08-29 09:22:51 -0500860 !list_empty(&core->task_queue)) {
861
862 can_queue = sas_ha->lldd_queue_size - core->task_queue_size;
863 if (can_queue >= 0) {
864 can_queue = core->task_queue_size;
865 list_splice_init(&core->task_queue, &q);
866 } else {
867 struct list_head *a, *n;
868
869 can_queue = sas_ha->lldd_queue_size;
870 list_for_each_safe(a, n, &core->task_queue) {
871 list_move_tail(a, &q);
872 if (--can_queue == 0)
873 break;
874 }
875 can_queue = sas_ha->lldd_queue_size;
876 }
877 core->task_queue_size -= can_queue;
878 spin_unlock_irqrestore(&core->task_queue_lock, flags);
879 {
880 struct sas_task *task = list_entry(q.next,
881 struct sas_task,
882 list);
883 list_del_init(&q);
884 res = i->dft->lldd_execute_task(task, can_queue,
885 GFP_KERNEL);
886 if (unlikely(res))
887 __list_add(&q, task->list.prev, &task->list);
888 }
889 spin_lock_irqsave(&core->task_queue_lock, flags);
890 if (res) {
891 list_splice_init(&q, &core->task_queue); /*at head*/
892 core->task_queue_size += can_queue;
893 }
894 }
895 spin_unlock_irqrestore(&core->task_queue_lock, flags);
896}
897
James Bottomley2908d772006-08-29 09:22:51 -0500898/**
899 * sas_queue_thread -- The Task Collector thread
900 * @_sas_ha: pointer to struct sas_ha
901 */
902static int sas_queue_thread(void *_sas_ha)
903{
904 struct sas_ha_struct *sas_ha = _sas_ha;
James Bottomley2908d772006-08-29 09:22:51 -0500905
James Bottomley2908d772006-08-29 09:22:51 -0500906 while (1) {
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400907 set_current_state(TASK_INTERRUPTIBLE);
908 schedule();
James Bottomley2908d772006-08-29 09:22:51 -0500909 sas_queue(sas_ha);
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400910 if (kthread_should_stop())
James Bottomley2908d772006-08-29 09:22:51 -0500911 break;
912 }
913
James Bottomley2908d772006-08-29 09:22:51 -0500914 return 0;
915}
916
917int sas_init_queue(struct sas_ha_struct *sas_ha)
918{
James Bottomley2908d772006-08-29 09:22:51 -0500919 struct scsi_core *core = &sas_ha->core;
920
921 spin_lock_init(&core->task_queue_lock);
922 core->task_queue_size = 0;
923 INIT_LIST_HEAD(&core->task_queue);
James Bottomley2908d772006-08-29 09:22:51 -0500924
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400925 core->queue_thread = kthread_run(sas_queue_thread, sas_ha,
926 "sas_queue_%d", core->shost->host_no);
927 if (IS_ERR(core->queue_thread))
928 return PTR_ERR(core->queue_thread);
929 return 0;
James Bottomley2908d772006-08-29 09:22:51 -0500930}
931
932void sas_shutdown_queue(struct sas_ha_struct *sas_ha)
933{
934 unsigned long flags;
935 struct scsi_core *core = &sas_ha->core;
936 struct sas_task *task, *n;
937
Christoph Hellwigd7a54e32007-04-26 09:38:01 -0400938 kthread_stop(core->queue_thread);
James Bottomley2908d772006-08-29 09:22:51 -0500939
940 if (!list_empty(&core->task_queue))
941 SAS_DPRINTK("HA: %llx: scsi core task queue is NOT empty!?\n",
942 SAS_ADDR(sas_ha->sas_addr));
943
944 spin_lock_irqsave(&core->task_queue_lock, flags);
945 list_for_each_entry_safe(task, n, &core->task_queue, list) {
946 struct scsi_cmnd *cmd = task->uldd_task;
947
948 list_del_init(&task->list);
949
950 ASSIGN_SAS_TASK(cmd, NULL);
951 sas_free_task(task);
952 cmd->result = DID_ABORT << 16;
953 cmd->scsi_done(cmd);
954 }
955 spin_unlock_irqrestore(&core->task_queue_lock, flags);
956}
957
Darrick J. Wong396819f2007-01-11 14:15:20 -0800958/*
959 * Call the LLDD task abort routine directly. This function is intended for
960 * use by upper layers that need to tell the LLDD to abort a task.
961 */
962int __sas_task_abort(struct sas_task *task)
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800963{
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800964 struct sas_internal *si =
965 to_sas_internal(task->dev->port->ha->core.shost->transportt);
966 unsigned long flags;
967 int res;
968
969 spin_lock_irqsave(&task->task_state_lock, flags);
Darrick J. Wong396819f2007-01-11 14:15:20 -0800970 if (task->task_state_flags & SAS_TASK_STATE_ABORTED ||
971 task->task_state_flags & SAS_TASK_STATE_DONE) {
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800972 spin_unlock_irqrestore(&task->task_state_lock, flags);
Darrick J. Wong396819f2007-01-11 14:15:20 -0800973 SAS_DPRINTK("%s: Task %p already finished.\n", __FUNCTION__,
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800974 task);
975 return 0;
976 }
Darrick J. Wong396819f2007-01-11 14:15:20 -0800977 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800978 spin_unlock_irqrestore(&task->task_state_lock, flags);
979
980 if (!si->dft->lldd_abort_task)
981 return -ENODEV;
982
983 res = si->dft->lldd_abort_task(task);
Darrick J. Wong396819f2007-01-11 14:15:20 -0800984
985 spin_lock_irqsave(&task->task_state_lock, flags);
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800986 if ((task->task_state_flags & SAS_TASK_STATE_DONE) ||
987 (res == TMF_RESP_FUNC_COMPLETE))
988 {
Darrick J. Wong396819f2007-01-11 14:15:20 -0800989 spin_unlock_irqrestore(&task->task_state_lock, flags);
990 task->task_done(task);
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800991 return 0;
992 }
993
Darrick J. Wong79a5eb62006-10-30 15:18:50 -0800994 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
995 task->task_state_flags &= ~SAS_TASK_STATE_ABORTED;
996 spin_unlock_irqrestore(&task->task_state_lock, flags);
997
998 return -EAGAIN;
999}
1000
Darrick J. Wong396819f2007-01-11 14:15:20 -08001001/*
1002 * Tell an upper layer that it needs to initiate an abort for a given task.
1003 * This should only ever be called by an LLDD.
1004 */
1005void sas_task_abort(struct sas_task *task)
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001006{
Darrick J. Wong396819f2007-01-11 14:15:20 -08001007 struct scsi_cmnd *sc = task->uldd_task;
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001008
Darrick J. Wong396819f2007-01-11 14:15:20 -08001009 /* Escape for libsas internal commands */
1010 if (!sc) {
1011 if (!del_timer(&task->timer))
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001012 return;
Darrick J. Wong396819f2007-01-11 14:15:20 -08001013 task->timer.function(task->timer.data);
1014 return;
1015 }
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001016
Darrick J. Wong396819f2007-01-11 14:15:20 -08001017 scsi_req_abort_cmd(sc);
1018 scsi_schedule_eh(sc->device->host);
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001019}
1020
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -07001021int sas_slave_alloc(struct scsi_device *scsi_dev)
1022{
1023 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
1024
1025 if (dev_is_sata(dev))
1026 return ata_sas_port_init(dev->sata_dev.ap);
1027
1028 return 0;
1029}
1030
1031void sas_target_destroy(struct scsi_target *starget)
1032{
1033 struct domain_device *found_dev = sas_find_target(starget);
1034
1035 if (!found_dev)
1036 return;
1037
1038 if (dev_is_sata(found_dev))
1039 ata_sas_port_destroy(found_dev->sata_dev.ap);
1040
1041 return;
1042}
1043
James Bottomley2908d772006-08-29 09:22:51 -05001044EXPORT_SYMBOL_GPL(sas_queuecommand);
1045EXPORT_SYMBOL_GPL(sas_target_alloc);
1046EXPORT_SYMBOL_GPL(sas_slave_configure);
1047EXPORT_SYMBOL_GPL(sas_slave_destroy);
1048EXPORT_SYMBOL_GPL(sas_change_queue_depth);
1049EXPORT_SYMBOL_GPL(sas_change_queue_type);
1050EXPORT_SYMBOL_GPL(sas_bios_param);
Darrick J. Wong396819f2007-01-11 14:15:20 -08001051EXPORT_SYMBOL_GPL(__sas_task_abort);
Darrick J. Wong79a5eb62006-10-30 15:18:50 -08001052EXPORT_SYMBOL_GPL(sas_task_abort);
Darrick J. Wongdea22212006-11-07 17:28:55 -08001053EXPORT_SYMBOL_GPL(sas_phy_reset);
Darrick J. Wongacbf1672007-01-11 14:14:57 -08001054EXPORT_SYMBOL_GPL(sas_phy_enable);
Darrick J. Wongad689232007-01-26 14:08:52 -08001055EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler);
Darrick J. Wonga9344e62007-01-29 23:48:19 -08001056EXPORT_SYMBOL_GPL(sas_eh_bus_reset_handler);
Darrick J. Wongfa1c1e82006-08-10 19:19:47 -07001057EXPORT_SYMBOL_GPL(sas_slave_alloc);
1058EXPORT_SYMBOL_GPL(sas_target_destroy);
1059EXPORT_SYMBOL_GPL(sas_ioctl);