Commit | Line | Data |
---|---|---|
6f231dda DW |
1 | /* |
2 | * This file is provided under a dual BSD/GPLv2 license. When using or | |
3 | * redistributing this file, you may do so under either license. | |
4 | * | |
5 | * GPL LICENSE SUMMARY | |
6 | * | |
7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of version 2 of the GNU General Public License as | |
11 | * published by the Free Software Foundation. | |
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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
21 | * The full GNU General Public License is included in this distribution | |
22 | * in the file called LICENSE.GPL. | |
23 | * | |
24 | * BSD LICENSE | |
25 | * | |
26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | |
27 | * All rights reserved. | |
28 | * | |
29 | * Redistribution and use in source and binary forms, with or without | |
30 | * modification, are permitted provided that the following conditions | |
31 | * are met: | |
32 | * | |
33 | * * Redistributions of source code must retain the above copyright | |
34 | * notice, this list of conditions and the following disclaimer. | |
35 | * * Redistributions in binary form must reproduce the above copyright | |
36 | * notice, this list of conditions and the following disclaimer in | |
37 | * the documentation and/or other materials provided with the | |
38 | * distribution. | |
39 | * * Neither the name of Intel Corporation nor the names of its | |
40 | * contributors may be used to endorse or promote products derived | |
41 | * from this software without specific prior written permission. | |
42 | * | |
43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
54 | */ | |
55 | ||
56 | #include <linux/completion.h> | |
50e7f9b5 | 57 | #include <linux/irqflags.h> |
af5ae893 | 58 | #include "sas.h" |
6f231dda | 59 | #include "scic_task_request.h" |
6f231dda | 60 | #include "scic_io_request.h" |
88f3b62a DW |
61 | #include "remote_device.h" |
62 | #include "remote_node_context.h" | |
6f231dda DW |
63 | #include "isci.h" |
64 | #include "request.h" | |
65 | #include "sata.h" | |
66 | #include "task.h" | |
af5ae893 DJ |
67 | #include "scic_sds_stp_request.h" |
68 | ||
50e7f9b5 | 69 | /** |
1077a574 DW |
70 | * isci_task_refuse() - complete the request to the upper layer driver in |
71 | * the case where an I/O needs to be completed back in the submit path. | |
72 | * @ihost: host on which the the request was queued | |
73 | * @task: request to complete | |
74 | * @response: response code for the completed task. | |
75 | * @status: status code for the completed task. | |
50e7f9b5 | 76 | * |
50e7f9b5 | 77 | */ |
1077a574 DW |
78 | static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task, |
79 | enum service_response response, | |
80 | enum exec_status status) | |
81 | ||
50e7f9b5 | 82 | { |
1077a574 | 83 | enum isci_completion_selection disposition; |
50e7f9b5 | 84 | |
1077a574 DW |
85 | disposition = isci_perform_normal_io_completion; |
86 | disposition = isci_task_set_completion_status(task, response, status, | |
87 | disposition); | |
50e7f9b5 DW |
88 | |
89 | /* Tasks aborted specifically by a call to the lldd_abort_task | |
1077a574 DW |
90 | * function should not be completed to the host in the regular path. |
91 | */ | |
92 | switch (disposition) { | |
50e7f9b5 DW |
93 | case isci_perform_normal_io_completion: |
94 | /* Normal notification (task_done) */ | |
1077a574 | 95 | dev_dbg(&ihost->pdev->dev, |
ed8a72d1 JS |
96 | "%s: Normal - task = %p, response=%d, " |
97 | "status=%d\n", | |
50e7f9b5 DW |
98 | __func__, task, response, status); |
99 | ||
1077a574 | 100 | task->lldd_task = NULL; |
50e7f9b5 | 101 | |
ed8a72d1 | 102 | isci_execpath_callback(ihost, task, task->task_done); |
50e7f9b5 DW |
103 | break; |
104 | ||
105 | case isci_perform_aborted_io_completion: | |
106 | /* No notification because this request is already in the | |
107 | * abort path. | |
108 | */ | |
1077a574 | 109 | dev_warn(&ihost->pdev->dev, |
ed8a72d1 JS |
110 | "%s: Aborted - task = %p, response=%d, " |
111 | "status=%d\n", | |
50e7f9b5 DW |
112 | __func__, task, response, status); |
113 | break; | |
114 | ||
115 | case isci_perform_error_io_completion: | |
116 | /* Use sas_task_abort */ | |
1077a574 | 117 | dev_warn(&ihost->pdev->dev, |
ed8a72d1 JS |
118 | "%s: Error - task = %p, response=%d, " |
119 | "status=%d\n", | |
50e7f9b5 | 120 | __func__, task, response, status); |
ed8a72d1 JS |
121 | |
122 | isci_execpath_callback(ihost, task, sas_task_abort); | |
50e7f9b5 DW |
123 | break; |
124 | ||
125 | default: | |
1077a574 | 126 | dev_warn(&ihost->pdev->dev, |
50e7f9b5 DW |
127 | "%s: isci task notification default case!", |
128 | __func__); | |
129 | sas_task_abort(task); | |
130 | break; | |
131 | } | |
132 | } | |
6f231dda | 133 | |
1077a574 DW |
134 | #define for_each_sas_task(num, task) \ |
135 | for (; num > 0; num--,\ | |
136 | task = list_entry(task->list.next, struct sas_task, list)) | |
137 | ||
6f231dda DW |
138 | /** |
139 | * isci_task_execute_task() - This function is one of the SAS Domain Template | |
140 | * functions. This function is called by libsas to send a task down to | |
141 | * hardware. | |
142 | * @task: This parameter specifies the SAS task to send. | |
143 | * @num: This parameter specifies the number of tasks to queue. | |
144 | * @gfp_flags: This parameter specifies the context of this call. | |
145 | * | |
146 | * status, zero indicates success. | |
147 | */ | |
148 | int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags) | |
149 | { | |
4393aa4e | 150 | struct isci_host *ihost = dev_to_ihost(task->dev); |
6f231dda DW |
151 | struct isci_request *request = NULL; |
152 | struct isci_remote_device *device; | |
153 | unsigned long flags; | |
6f231dda DW |
154 | int ret; |
155 | enum sci_status status; | |
f0846c68 | 156 | enum isci_status device_status; |
6f231dda | 157 | |
1077a574 | 158 | dev_dbg(&ihost->pdev->dev, "%s: num=%d\n", __func__, num); |
6f231dda DW |
159 | |
160 | /* Check if we have room for more tasks */ | |
1077a574 | 161 | ret = isci_host_can_queue(ihost, num); |
6f231dda DW |
162 | |
163 | if (ret) { | |
1077a574 | 164 | dev_warn(&ihost->pdev->dev, "%s: queue full\n", __func__); |
6f231dda DW |
165 | return ret; |
166 | } | |
167 | ||
1077a574 DW |
168 | for_each_sas_task(num, task) { |
169 | dev_dbg(&ihost->pdev->dev, | |
6f231dda DW |
170 | "task = %p, num = %d; dev = %p; cmd = %p\n", |
171 | task, num, task->dev, task->uldd_task); | |
172 | ||
4393aa4e | 173 | device = task->dev->lldd_dev; |
6f231dda | 174 | |
f0846c68 JS |
175 | if (device) |
176 | device_status = device->status; | |
177 | else | |
178 | device_status = isci_freed; | |
179 | ||
180 | /* From this point onward, any process that needs to guarantee | |
181 | * that there is no kernel I/O being started will have to wait | |
182 | * for the quiesce spinlock. | |
183 | */ | |
184 | ||
185 | if (device_status != isci_ready_for_io) { | |
6f231dda DW |
186 | |
187 | /* Forces a retry from scsi mid layer. */ | |
d2d61433 DJ |
188 | dev_dbg(&ihost->pdev->dev, |
189 | "%s: task %p: isci_host->status = %d, " | |
190 | "device = %p; device_status = 0x%x\n\n", | |
191 | __func__, | |
192 | task, | |
193 | isci_host_get_state(ihost), | |
194 | device, | |
195 | device_status); | |
6f231dda | 196 | |
f0846c68 JS |
197 | if (device_status == isci_ready) { |
198 | /* Indicate QUEUE_FULL so that the scsi midlayer | |
199 | * retries. | |
200 | */ | |
1077a574 DW |
201 | isci_task_refuse(ihost, task, |
202 | SAS_TASK_COMPLETE, | |
203 | SAS_QUEUE_FULL); | |
f0846c68 JS |
204 | } else { |
205 | /* Else, the device is going down. */ | |
1077a574 DW |
206 | isci_task_refuse(ihost, task, |
207 | SAS_TASK_UNDELIVERED, | |
208 | SAS_DEVICE_UNKNOWN); | |
f0846c68 | 209 | } |
1077a574 | 210 | isci_host_can_dequeue(ihost, 1); |
f0846c68 JS |
211 | } else { |
212 | /* There is a device and it's ready for I/O. */ | |
213 | spin_lock_irqsave(&task->task_state_lock, flags); | |
6f231dda | 214 | |
f0846c68 | 215 | if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { |
6f231dda | 216 | |
f0846c68 JS |
217 | spin_unlock_irqrestore(&task->task_state_lock, |
218 | flags); | |
6f231dda | 219 | |
1077a574 DW |
220 | isci_task_refuse(ihost, task, |
221 | SAS_TASK_UNDELIVERED, | |
222 | SAM_STAT_TASK_ABORTED); | |
6f231dda | 223 | |
f0846c68 | 224 | /* The I/O was aborted. */ |
6f231dda | 225 | |
f0846c68 | 226 | } else { |
6f231dda DW |
227 | task->task_state_flags |= SAS_TASK_AT_INITIATOR; |
228 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
f0846c68 JS |
229 | |
230 | /* build and send the request. */ | |
1077a574 | 231 | status = isci_request_execute(ihost, task, &request, |
f0846c68 JS |
232 | gfp_flags); |
233 | ||
234 | if (status != SCI_SUCCESS) { | |
235 | ||
236 | spin_lock_irqsave(&task->task_state_lock, flags); | |
237 | /* Did not really start this command. */ | |
238 | task->task_state_flags &= ~SAS_TASK_AT_INITIATOR; | |
239 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
240 | ||
241 | /* Indicate QUEUE_FULL so that the scsi | |
242 | * midlayer retries. if the request | |
243 | * failed for remote device reasons, | |
244 | * it gets returned as | |
245 | * SAS_TASK_UNDELIVERED next time | |
246 | * through. | |
247 | */ | |
1077a574 DW |
248 | isci_task_refuse(ihost, task, |
249 | SAS_TASK_COMPLETE, | |
250 | SAS_QUEUE_FULL); | |
251 | isci_host_can_dequeue(ihost, 1); | |
f0846c68 | 252 | } |
6f231dda DW |
253 | } |
254 | } | |
1077a574 | 255 | } |
6f231dda DW |
256 | return 0; |
257 | } | |
258 | ||
259 | ||
260 | ||
261 | /** | |
262 | * isci_task_request_build() - This function builds the task request object. | |
263 | * @isci_host: This parameter specifies the ISCI host object | |
264 | * @request: This parameter points to the isci_request object allocated in the | |
265 | * request construct function. | |
266 | * @tmf: This parameter is the task management struct to be built | |
267 | * | |
268 | * SCI_SUCCESS on successfull completion, or specific failure code. | |
269 | */ | |
270 | static enum sci_status isci_task_request_build( | |
271 | struct isci_host *isci_host, | |
272 | struct isci_request **isci_request, | |
273 | struct isci_tmf *isci_tmf) | |
274 | { | |
275 | struct scic_sds_remote_device *sci_device; | |
276 | enum sci_status status = SCI_FAILURE; | |
6cb4d6b3 | 277 | struct isci_request *request = NULL; |
6f231dda | 278 | struct isci_remote_device *isci_device; |
a1a113b0 | 279 | struct domain_device *dev; |
6f231dda DW |
280 | |
281 | dev_dbg(&isci_host->pdev->dev, | |
282 | "%s: isci_tmf = %p\n", __func__, isci_tmf); | |
283 | ||
284 | isci_device = isci_tmf->device; | |
57f20f4e | 285 | sci_device = &isci_device->sci; |
a1a113b0 | 286 | dev = isci_device->domain_dev; |
6f231dda DW |
287 | |
288 | /* do common allocation and init of request object. */ | |
289 | status = isci_request_alloc_tmf( | |
290 | isci_host, | |
291 | isci_tmf, | |
292 | &request, | |
293 | isci_device, | |
294 | GFP_ATOMIC | |
295 | ); | |
296 | ||
297 | if (status != SCI_SUCCESS) | |
298 | goto out; | |
299 | ||
300 | /* let the core do it's construct. */ | |
301 | status = scic_task_request_construct( | |
302 | isci_host->core_controller, | |
303 | sci_device, | |
304 | SCI_CONTROLLER_INVALID_IO_TAG, | |
305 | request, | |
306 | request->sci_request_mem_ptr, | |
307 | &request->sci_request_handle | |
308 | ); | |
309 | ||
310 | if (status != SCI_SUCCESS) { | |
311 | dev_warn(&isci_host->pdev->dev, | |
312 | "%s: scic_task_request_construct failed - " | |
313 | "status = 0x%x\n", | |
314 | __func__, | |
315 | status); | |
316 | goto errout; | |
317 | } | |
318 | ||
890cae9b | 319 | request->sci_request_handle->ireq = request; |
6f231dda | 320 | |
a1a113b0 DW |
321 | /* XXX convert to get this from task->tproto like other drivers */ |
322 | if (dev->dev_type == SAS_END_DEV) { | |
6f231dda DW |
323 | isci_tmf->proto = SAS_PROTOCOL_SSP; |
324 | status = scic_task_request_construct_ssp( | |
325 | request->sci_request_handle | |
326 | ); | |
327 | if (status != SCI_SUCCESS) | |
328 | goto errout; | |
329 | } | |
330 | ||
a1a113b0 | 331 | if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { |
6f231dda DW |
332 | isci_tmf->proto = SAS_PROTOCOL_SATA; |
333 | status = isci_sata_management_task_request_build(request); | |
334 | ||
335 | if (status != SCI_SUCCESS) | |
336 | goto errout; | |
337 | } | |
338 | ||
339 | goto out; | |
340 | ||
341 | errout: | |
342 | ||
343 | /* release the dma memory if we fail. */ | |
344 | isci_request_free(isci_host, request); | |
345 | request = NULL; | |
346 | ||
347 | out: | |
348 | *isci_request = request; | |
349 | return status; | |
350 | } | |
351 | ||
352 | /** | |
353 | * isci_tmf_timeout_cb() - This function is called as a kernel callback when | |
354 | * the timeout period for the TMF has expired. | |
355 | * | |
356 | * | |
357 | */ | |
358 | static void isci_tmf_timeout_cb(void *tmf_request_arg) | |
359 | { | |
360 | struct isci_request *request = (struct isci_request *)tmf_request_arg; | |
361 | struct isci_tmf *tmf = isci_request_access_tmf(request); | |
362 | enum sci_status status; | |
363 | ||
6f231dda DW |
364 | /* This task management request has timed-out. Terminate the request |
365 | * so that the request eventually completes to the requestor in the | |
366 | * request completion callback path. | |
367 | */ | |
368 | /* Note - the timer callback function itself has provided spinlock | |
369 | * exclusion from the start and completion paths. No need to take | |
370 | * the request->isci_host->scic_lock here. | |
371 | */ | |
372 | ||
373 | if (tmf->timeout_timer != NULL) { | |
374 | /* Call the users callback, if any. */ | |
375 | if (tmf->cb_state_func != NULL) | |
376 | tmf->cb_state_func(isci_tmf_timed_out, tmf, | |
377 | tmf->cb_data); | |
378 | ||
379 | /* Terminate the TMF transmit request. */ | |
380 | status = scic_controller_terminate_request( | |
381 | request->isci_host->core_controller, | |
57f20f4e | 382 | &request->isci_device->sci, |
6f231dda DW |
383 | request->sci_request_handle |
384 | ); | |
385 | ||
386 | dev_dbg(&request->isci_host->pdev->dev, | |
387 | "%s: tmf_request = %p; tmf = %p; status = %d\n", | |
388 | __func__, request, tmf, status); | |
389 | } else | |
390 | dev_dbg(&request->isci_host->pdev->dev, | |
391 | "%s: timer already canceled! " | |
392 | "tmf_request = %p; tmf = %p\n", | |
393 | __func__, request, tmf); | |
394 | ||
395 | /* No need to unlock since the caller to this callback is doing it for | |
396 | * us. | |
397 | * request->isci_host->scic_lock | |
398 | */ | |
399 | } | |
400 | ||
401 | /** | |
402 | * isci_task_execute_tmf() - This function builds and sends a task request, | |
403 | * then waits for the completion. | |
404 | * @isci_host: This parameter specifies the ISCI host object | |
405 | * @tmf: This parameter is the pointer to the task management structure for | |
406 | * this request. | |
407 | * @timeout_ms: This parameter specifies the timeout period for the task | |
408 | * management request. | |
409 | * | |
410 | * TMF_RESP_FUNC_COMPLETE on successful completion of the TMF (this includes | |
411 | * error conditions reported in the IU status), or TMF_RESP_FUNC_FAILED. | |
412 | */ | |
413 | int isci_task_execute_tmf( | |
414 | struct isci_host *isci_host, | |
415 | struct isci_tmf *tmf, | |
416 | unsigned long timeout_ms) | |
417 | { | |
418 | DECLARE_COMPLETION_ONSTACK(completion); | |
467e855a | 419 | enum sci_task_status status = SCI_TASK_FAILURE; |
6f231dda DW |
420 | struct scic_sds_remote_device *sci_device; |
421 | struct isci_remote_device *isci_device = tmf->device; | |
422 | struct isci_request *request; | |
423 | int ret = TMF_RESP_FUNC_FAILED; | |
424 | unsigned long flags; | |
425 | ||
426 | /* sanity check, return TMF_RESP_FUNC_FAILED | |
427 | * if the device is not there and ready. | |
428 | */ | |
8acaec15 | 429 | if (!isci_device || isci_device->status != isci_ready_for_io) { |
6f231dda DW |
430 | dev_dbg(&isci_host->pdev->dev, |
431 | "%s: isci_device = %p not ready (%d)\n", | |
432 | __func__, | |
8acaec15 | 433 | isci_device, isci_device->status); |
6f231dda DW |
434 | return TMF_RESP_FUNC_FAILED; |
435 | } else | |
436 | dev_dbg(&isci_host->pdev->dev, | |
437 | "%s: isci_device = %p\n", | |
438 | __func__, isci_device); | |
439 | ||
57f20f4e | 440 | sci_device = &isci_device->sci; |
6f231dda DW |
441 | |
442 | /* Assign the pointer to the TMF's completion kernel wait structure. */ | |
443 | tmf->complete = &completion; | |
444 | ||
445 | isci_task_request_build( | |
446 | isci_host, | |
447 | &request, | |
448 | tmf | |
449 | ); | |
450 | ||
451 | if (!request) { | |
452 | dev_warn(&isci_host->pdev->dev, | |
453 | "%s: isci_task_request_build failed\n", | |
454 | __func__); | |
455 | return TMF_RESP_FUNC_FAILED; | |
456 | } | |
457 | ||
458 | /* Allocate the TMF timeout timer. */ | |
6f231dda | 459 | spin_lock_irqsave(&isci_host->scic_lock, flags); |
7c40a803 | 460 | tmf->timeout_timer = isci_timer_create(isci_host, request, isci_tmf_timeout_cb); |
6f231dda DW |
461 | |
462 | /* Start the timer. */ | |
463 | if (tmf->timeout_timer) | |
464 | isci_timer_start(tmf->timeout_timer, timeout_ms); | |
465 | else | |
466 | dev_warn(&isci_host->pdev->dev, | |
467 | "%s: isci_timer_create failed!!!!\n", | |
468 | __func__); | |
469 | ||
470 | /* start the TMF io. */ | |
471 | status = scic_controller_start_task( | |
472 | isci_host->core_controller, | |
473 | sci_device, | |
474 | request->sci_request_handle, | |
475 | SCI_CONTROLLER_INVALID_IO_TAG | |
476 | ); | |
477 | ||
467e855a | 478 | if (status != SCI_TASK_SUCCESS) { |
6f231dda DW |
479 | dev_warn(&isci_host->pdev->dev, |
480 | "%s: start_io failed - status = 0x%x, request = %p\n", | |
481 | __func__, | |
482 | status, | |
483 | request); | |
484 | goto cleanup_request; | |
485 | } | |
486 | ||
487 | /* Call the users callback, if any. */ | |
488 | if (tmf->cb_state_func != NULL) | |
489 | tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data); | |
490 | ||
491 | /* Change the state of the TMF-bearing request to "started". */ | |
492 | isci_request_change_state(request, started); | |
493 | ||
494 | /* add the request to the remote device request list. */ | |
495 | list_add(&request->dev_node, &isci_device->reqs_in_process); | |
496 | ||
497 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | |
498 | ||
499 | /* Wait for the TMF to complete, or a timeout. */ | |
500 | wait_for_completion(&completion); | |
501 | ||
502 | isci_print_tmf(tmf); | |
503 | ||
504 | if (tmf->status == SCI_SUCCESS) | |
505 | ret = TMF_RESP_FUNC_COMPLETE; | |
506 | else if (tmf->status == SCI_FAILURE_IO_RESPONSE_VALID) { | |
507 | dev_dbg(&isci_host->pdev->dev, | |
508 | "%s: tmf.status == " | |
509 | "SCI_FAILURE_IO_RESPONSE_VALID\n", | |
510 | __func__); | |
511 | ret = TMF_RESP_FUNC_COMPLETE; | |
512 | } | |
513 | /* Else - leave the default "failed" status alone. */ | |
514 | ||
515 | dev_dbg(&isci_host->pdev->dev, | |
516 | "%s: completed request = %p\n", | |
517 | __func__, | |
518 | request); | |
519 | ||
520 | if (request->io_request_completion != NULL) { | |
521 | ||
522 | /* The fact that this is non-NULL for a TMF request | |
523 | * means there is a thread waiting for this TMF to | |
524 | * finish. | |
525 | */ | |
526 | complete(request->io_request_completion); | |
527 | } | |
528 | ||
529 | spin_lock_irqsave(&isci_host->scic_lock, flags); | |
530 | ||
531 | cleanup_request: | |
532 | ||
533 | /* Clean up the timer if needed. */ | |
534 | if (tmf->timeout_timer) { | |
7c40a803 | 535 | isci_del_timer(isci_host, tmf->timeout_timer); |
6f231dda DW |
536 | tmf->timeout_timer = NULL; |
537 | } | |
538 | ||
539 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | |
540 | ||
541 | isci_request_free(isci_host, request); | |
542 | ||
543 | return ret; | |
544 | } | |
545 | ||
546 | void isci_task_build_tmf( | |
547 | struct isci_tmf *tmf, | |
548 | struct isci_remote_device *isci_device, | |
549 | enum isci_tmf_function_codes code, | |
550 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, | |
551 | struct isci_tmf *, | |
552 | void *), | |
c3f42feb | 553 | void *cb_data) |
6f231dda DW |
554 | { |
555 | dev_dbg(&isci_device->isci_port->isci_host->pdev->dev, | |
556 | "%s: isci_device = %p\n", __func__, isci_device); | |
557 | ||
558 | memset(tmf, 0, sizeof(*tmf)); | |
559 | ||
560 | tmf->device = isci_device; | |
561 | tmf->tmf_code = code; | |
562 | tmf->timeout_timer = NULL; | |
563 | tmf->cb_state_func = tmf_sent_cb; | |
c3f42feb JS |
564 | tmf->cb_data = cb_data; |
565 | } | |
1fad9e93 | 566 | |
35173d57 | 567 | static void isci_task_build_abort_task_tmf( |
c3f42feb JS |
568 | struct isci_tmf *tmf, |
569 | struct isci_remote_device *isci_device, | |
570 | enum isci_tmf_function_codes code, | |
571 | void (*tmf_sent_cb)(enum isci_tmf_cb_state, | |
572 | struct isci_tmf *, | |
573 | void *), | |
574 | struct isci_request *old_request) | |
575 | { | |
576 | isci_task_build_tmf(tmf, isci_device, code, tmf_sent_cb, | |
577 | (void *)old_request); | |
578 | tmf->io_tag = old_request->io_tag; | |
6f231dda DW |
579 | } |
580 | ||
581 | static struct isci_request *isci_task_get_request_from_task( | |
582 | struct sas_task *task, | |
6f231dda DW |
583 | struct isci_remote_device **isci_device) |
584 | { | |
585 | ||
586 | struct isci_request *request = NULL; | |
587 | unsigned long flags; | |
588 | ||
589 | spin_lock_irqsave(&task->task_state_lock, flags); | |
590 | ||
591 | request = task->lldd_task; | |
592 | ||
593 | /* If task is already done, the request isn't valid */ | |
594 | if (!(task->task_state_flags & SAS_TASK_STATE_DONE) && | |
595 | (task->task_state_flags & SAS_TASK_AT_INITIATOR) && | |
596 | (request != NULL)) { | |
597 | ||
6f231dda DW |
598 | if (isci_device != NULL) |
599 | *isci_device = request->isci_device; | |
600 | } | |
601 | ||
602 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
603 | ||
604 | return request; | |
605 | } | |
606 | ||
607 | /** | |
608 | * isci_task_validate_request_to_abort() - This function checks the given I/O | |
609 | * against the "started" state. If the request is still "started", it's | |
610 | * state is changed to aborted. NOTE: isci_host->scic_lock MUST BE HELD | |
611 | * BEFORE CALLING THIS FUNCTION. | |
612 | * @isci_request: This parameter specifies the request object to control. | |
613 | * @isci_host: This parameter specifies the ISCI host object | |
614 | * @isci_device: This is the device to which the request is pending. | |
615 | * @aborted_io_completion: This is a completion structure that will be added to | |
616 | * the request in case it is changed to aborting; this completion is | |
617 | * triggered when the request is fully completed. | |
618 | * | |
619 | * Either "started" on successful change of the task status to "aborted", or | |
620 | * "unallocated" if the task cannot be controlled. | |
621 | */ | |
622 | static enum isci_request_status isci_task_validate_request_to_abort( | |
623 | struct isci_request *isci_request, | |
624 | struct isci_host *isci_host, | |
625 | struct isci_remote_device *isci_device, | |
626 | struct completion *aborted_io_completion) | |
627 | { | |
628 | enum isci_request_status old_state = unallocated; | |
629 | ||
630 | /* Only abort the task if it's in the | |
631 | * device's request_in_process list | |
632 | */ | |
633 | if (isci_request && !list_empty(&isci_request->dev_node)) { | |
634 | old_state = isci_request_change_started_to_aborted( | |
635 | isci_request, aborted_io_completion); | |
636 | ||
6f231dda DW |
637 | } |
638 | ||
639 | return old_state; | |
640 | } | |
641 | ||
642 | static void isci_request_cleanup_completed_loiterer( | |
643 | struct isci_host *isci_host, | |
644 | struct isci_remote_device *isci_device, | |
645 | struct isci_request *isci_request) | |
646 | { | |
18d3d72a JS |
647 | struct sas_task *task; |
648 | unsigned long flags; | |
649 | ||
650 | task = (isci_request->ttype == io_task) | |
651 | ? isci_request_access_task(isci_request) | |
652 | : NULL; | |
6f231dda DW |
653 | |
654 | dev_dbg(&isci_host->pdev->dev, | |
655 | "%s: isci_device=%p, request=%p, task=%p\n", | |
18d3d72a | 656 | __func__, isci_device, isci_request, task); |
6f231dda DW |
657 | |
658 | spin_lock_irqsave(&isci_host->scic_lock, flags); | |
659 | list_del_init(&isci_request->dev_node); | |
6f231dda DW |
660 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); |
661 | ||
a5fde225 JS |
662 | if (task != NULL) { |
663 | ||
664 | spin_lock_irqsave(&task->task_state_lock, flags); | |
665 | task->lldd_task = NULL; | |
666 | ||
667 | isci_set_task_doneflags(task); | |
668 | ||
669 | /* If this task is not in the abort path, call task_done. */ | |
670 | if (!(task->task_state_flags & SAS_TASK_STATE_ABORTED)) { | |
671 | ||
672 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
673 | task->task_done(task); | |
674 | } else | |
675 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
676 | } | |
6f231dda DW |
677 | isci_request_free(isci_host, isci_request); |
678 | } | |
4dc043c4 JS |
679 | |
680 | /** | |
681 | * @isci_termination_timed_out(): this function will deal with a request for | |
682 | * which the wait for termination has timed-out. | |
683 | * | |
684 | * @isci_host This SCU. | |
685 | * @isci_request The I/O request being terminated. | |
686 | */ | |
687 | static void | |
688 | isci_termination_timed_out( | |
689 | struct isci_host * host, | |
690 | struct isci_request * request | |
691 | ) | |
692 | { | |
693 | unsigned long state_flags; | |
694 | ||
695 | dev_warn(&host->pdev->dev, | |
696 | "%s: host = %p; request = %p\n", | |
697 | __func__, host, request); | |
698 | ||
699 | /* At this point, the request to terminate | |
700 | * has timed out. The best we can do is to | |
701 | * have the request die a silent death | |
702 | * if it ever completes. | |
703 | */ | |
704 | spin_lock_irqsave(&request->state_lock, state_flags); | |
705 | ||
706 | if (request->status == started) { | |
707 | ||
708 | /* Set the request state to "dead", | |
709 | * and clear the task pointer so that an actual | |
710 | * completion event callback doesn't do | |
711 | * anything. | |
712 | */ | |
713 | request->status = dead; | |
714 | ||
715 | /* Clear the timeout completion event pointer.*/ | |
716 | request->io_request_completion = NULL; | |
717 | ||
718 | if (request->ttype == io_task) { | |
719 | ||
720 | /* Break links with the sas_task. */ | |
721 | if (request->ttype_ptr.io_task_ptr != NULL) { | |
722 | ||
723 | request->ttype_ptr.io_task_ptr->lldd_task = NULL; | |
724 | request->ttype_ptr.io_task_ptr = NULL; | |
725 | } | |
726 | } | |
727 | } | |
728 | spin_unlock_irqrestore(&request->state_lock, state_flags); | |
729 | } | |
730 | ||
731 | ||
6f231dda DW |
732 | /** |
733 | * isci_terminate_request_core() - This function will terminate the given | |
734 | * request, and wait for it to complete. This function must only be called | |
735 | * from a thread that can wait. Note that the request is terminated and | |
736 | * completed (back to the host, if started there). | |
737 | * @isci_host: This SCU. | |
738 | * @isci_device: The target. | |
739 | * @isci_request: The I/O request to be terminated. | |
740 | * | |
741 | * | |
742 | */ | |
743 | static void isci_terminate_request_core( | |
744 | struct isci_host *isci_host, | |
745 | struct isci_remote_device *isci_device, | |
cbb65c66 | 746 | struct isci_request *isci_request) |
6f231dda | 747 | { |
cbb65c66 | 748 | enum sci_status status = SCI_SUCCESS; |
6f231dda DW |
749 | bool was_terminated = false; |
750 | bool needs_cleanup_handling = false; | |
751 | enum isci_request_status request_status; | |
752 | unsigned long flags; | |
4dc043c4 JS |
753 | unsigned long timeout_remaining; |
754 | ||
6f231dda DW |
755 | |
756 | dev_dbg(&isci_host->pdev->dev, | |
757 | "%s: device = %p; request = %p\n", | |
758 | __func__, isci_device, isci_request); | |
759 | ||
6f231dda | 760 | spin_lock_irqsave(&isci_host->scic_lock, flags); |
4dc043c4 JS |
761 | |
762 | /* Note that we are not going to control | |
763 | * the target to abort the request. | |
764 | */ | |
765 | isci_request->complete_in_target = true; | |
766 | ||
6f231dda DW |
767 | /* Make sure the request wasn't just sitting around signalling |
768 | * device condition (if the request handle is NULL, then the | |
769 | * request completed but needed additional handling here). | |
770 | */ | |
771 | if (isci_request->sci_request_handle != NULL) { | |
772 | was_terminated = true; | |
cbb65c66 | 773 | needs_cleanup_handling = true; |
6f231dda DW |
774 | status = scic_controller_terminate_request( |
775 | isci_host->core_controller, | |
57f20f4e DW |
776 | &isci_device->sci, |
777 | isci_request->sci_request_handle); | |
6f231dda DW |
778 | } |
779 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | |
780 | ||
781 | /* | |
782 | * The only time the request to terminate will | |
783 | * fail is when the io request is completed and | |
784 | * being aborted. | |
785 | */ | |
4dc043c4 | 786 | if (status != SCI_SUCCESS) { |
6f231dda DW |
787 | dev_err(&isci_host->pdev->dev, |
788 | "%s: scic_controller_terminate_request" | |
789 | " returned = 0x%x\n", | |
790 | __func__, | |
791 | status); | |
4dc043c4 JS |
792 | /* Clear the completion pointer from the request. */ |
793 | isci_request->io_request_completion = NULL; | |
794 | ||
795 | } else { | |
6f231dda DW |
796 | if (was_terminated) { |
797 | dev_dbg(&isci_host->pdev->dev, | |
798 | "%s: before completion wait (%p)\n", | |
799 | __func__, | |
cbb65c66 | 800 | isci_request->io_request_completion); |
6f231dda DW |
801 | |
802 | /* Wait here for the request to complete. */ | |
4dc043c4 JS |
803 | #define TERMINATION_TIMEOUT_MSEC 50 |
804 | timeout_remaining | |
805 | = wait_for_completion_timeout( | |
806 | isci_request->io_request_completion, | |
807 | msecs_to_jiffies(TERMINATION_TIMEOUT_MSEC)); | |
808 | ||
809 | if (!timeout_remaining) { | |
810 | ||
811 | isci_termination_timed_out(isci_host, | |
812 | isci_request); | |
813 | ||
814 | dev_err(&isci_host->pdev->dev, | |
815 | "%s: *** Timeout waiting for " | |
816 | "termination(%p/%p)\n", | |
817 | __func__, | |
818 | isci_request->io_request_completion, | |
819 | isci_request); | |
820 | ||
821 | } else | |
822 | dev_dbg(&isci_host->pdev->dev, | |
823 | "%s: after completion wait (%p)\n", | |
824 | __func__, | |
825 | isci_request->io_request_completion); | |
826 | } | |
827 | /* Clear the completion pointer from the request. */ | |
828 | isci_request->io_request_completion = NULL; | |
829 | ||
830 | /* Peek at the status of the request. This will tell | |
831 | * us if there was special handling on the request such that it | |
832 | * needs to be detached and freed here. | |
833 | */ | |
834 | spin_lock_irqsave(&isci_request->state_lock, flags); | |
835 | request_status = isci_request_get_state(isci_request); | |
836 | ||
837 | if ((isci_request->ttype == io_task) /* TMFs are in their own thread */ | |
838 | && ((request_status == aborted) | |
839 | || (request_status == aborting) | |
840 | || (request_status == terminating) | |
841 | || (request_status == completed) | |
842 | || (request_status == dead) | |
843 | ) | |
844 | ) { | |
845 | ||
846 | /* The completion routine won't free a request in | |
847 | * the aborted/aborting/etc. states, so we do | |
848 | * it here. | |
849 | */ | |
850 | needs_cleanup_handling = true; | |
6f231dda | 851 | } |
4dc043c4 | 852 | spin_unlock_irqrestore(&isci_request->state_lock, flags); |
6f231dda DW |
853 | |
854 | if (needs_cleanup_handling) | |
855 | isci_request_cleanup_completed_loiterer( | |
856 | isci_host, isci_device, isci_request | |
857 | ); | |
858 | } | |
859 | } | |
cbb65c66 | 860 | |
6f231dda DW |
861 | static void isci_terminate_request( |
862 | struct isci_host *isci_host, | |
863 | struct isci_remote_device *isci_device, | |
864 | struct isci_request *isci_request, | |
865 | enum isci_request_status new_request_state) | |
866 | { | |
867 | enum isci_request_status old_state; | |
6f231dda | 868 | DECLARE_COMPLETION_ONSTACK(request_completion); |
6f231dda DW |
869 | |
870 | /* Change state to "new_request_state" if it is currently "started" */ | |
871 | old_state = isci_request_change_started_to_newstate( | |
872 | isci_request, | |
873 | &request_completion, | |
874 | new_request_state | |
875 | ); | |
876 | ||
f219f010 JS |
877 | if ((old_state == started) || |
878 | (old_state == completed) || | |
879 | (old_state == aborting)) { | |
6f231dda | 880 | |
a5fde225 JS |
881 | /* If the old_state is started: |
882 | * This request was not already being aborted. If it had been, | |
6f231dda DW |
883 | * then the aborting I/O (ie. the TMF request) would not be in |
884 | * the aborting state, and thus would be terminated here. Note | |
885 | * that since the TMF completion's call to the kernel function | |
886 | * "complete()" does not happen until the pending I/O request | |
887 | * terminate fully completes, we do not have to implement a | |
888 | * special wait here for already aborting requests - the | |
889 | * termination of the TMF request will force the request | |
890 | * to finish it's already started terminate. | |
a5fde225 JS |
891 | * |
892 | * If old_state == completed: | |
893 | * This request completed from the SCU hardware perspective | |
894 | * and now just needs cleaning up in terms of freeing the | |
895 | * request and potentially calling up to libsas. | |
f219f010 JS |
896 | * |
897 | * If old_state == aborting: | |
898 | * This request has already gone through a TMF timeout, but may | |
899 | * not have been terminated; needs cleaning up at least. | |
6f231dda DW |
900 | */ |
901 | isci_terminate_request_core(isci_host, isci_device, | |
cbb65c66 | 902 | isci_request); |
a5fde225 | 903 | } |
6f231dda DW |
904 | } |
905 | ||
906 | /** | |
907 | * isci_terminate_pending_requests() - This function will change the all of the | |
908 | * requests on the given device's state to "aborting", will terminate the | |
909 | * requests, and wait for them to complete. This function must only be | |
910 | * called from a thread that can wait. Note that the requests are all | |
911 | * terminated and completed (back to the host, if started there). | |
912 | * @isci_host: This parameter specifies SCU. | |
913 | * @isci_device: This parameter specifies the target. | |
914 | * | |
915 | * | |
916 | */ | |
917 | void isci_terminate_pending_requests( | |
918 | struct isci_host *isci_host, | |
919 | struct isci_remote_device *isci_device, | |
920 | enum isci_request_status new_request_state) | |
921 | { | |
4dc043c4 JS |
922 | struct isci_request *request; |
923 | struct isci_request *next_request; | |
924 | unsigned long flags; | |
925 | struct list_head aborted_request_list; | |
926 | ||
927 | INIT_LIST_HEAD(&aborted_request_list); | |
6f231dda DW |
928 | |
929 | dev_dbg(&isci_host->pdev->dev, | |
930 | "%s: isci_device = %p (new request state = %d)\n", | |
931 | __func__, isci_device, new_request_state); | |
932 | ||
4dc043c4 | 933 | spin_lock_irqsave(&isci_host->scic_lock, flags); |
6f231dda | 934 | |
4dc043c4 JS |
935 | /* Move all of the pending requests off of the device list. */ |
936 | list_splice_init(&isci_device->reqs_in_process, | |
937 | &aborted_request_list); | |
6f231dda | 938 | |
4dc043c4 | 939 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); |
6f231dda | 940 | |
4dc043c4 JS |
941 | /* Iterate through the now-local list. */ |
942 | list_for_each_entry_safe(request, next_request, | |
943 | &aborted_request_list, dev_node) { | |
6f231dda | 944 | |
4dc043c4 JS |
945 | dev_warn(&isci_host->pdev->dev, |
946 | "%s: isci_device=%p request=%p; task=%p\n", | |
947 | __func__, | |
948 | isci_device, request, | |
949 | ((request->ttype == io_task) | |
950 | ? isci_request_access_task(request) | |
951 | : NULL)); | |
952 | ||
953 | /* Mark all still pending I/O with the selected next | |
954 | * state, terminate and free it. | |
955 | */ | |
956 | isci_terminate_request(isci_host, isci_device, | |
957 | request, new_request_state | |
958 | ); | |
959 | } | |
6f231dda DW |
960 | } |
961 | ||
962 | /** | |
963 | * isci_task_send_lu_reset_sas() - This function is called by of the SAS Domain | |
964 | * Template functions. | |
965 | * @lun: This parameter specifies the lun to be reset. | |
966 | * | |
967 | * status, zero indicates success. | |
968 | */ | |
969 | static int isci_task_send_lu_reset_sas( | |
970 | struct isci_host *isci_host, | |
971 | struct isci_remote_device *isci_device, | |
972 | u8 *lun) | |
973 | { | |
974 | struct isci_tmf tmf; | |
975 | int ret = TMF_RESP_FUNC_FAILED; | |
976 | ||
977 | dev_dbg(&isci_host->pdev->dev, | |
978 | "%s: isci_host = %p, isci_device = %p\n", | |
979 | __func__, isci_host, isci_device); | |
980 | /* Send the LUN reset to the target. By the time the call returns, | |
981 | * the TMF has fully exected in the target (in which case the return | |
982 | * value is "TMF_RESP_FUNC_COMPLETE", or the request timed-out (or | |
983 | * was otherwise unable to be executed ("TMF_RESP_FUNC_FAILED"). | |
984 | */ | |
985 | isci_task_build_tmf(&tmf, isci_device, isci_tmf_ssp_lun_reset, NULL, | |
986 | NULL); | |
987 | ||
988 | #define ISCI_LU_RESET_TIMEOUT_MS 2000 /* 2 second timeout. */ | |
989 | ret = isci_task_execute_tmf(isci_host, &tmf, ISCI_LU_RESET_TIMEOUT_MS); | |
990 | ||
991 | if (ret == TMF_RESP_FUNC_COMPLETE) | |
992 | dev_dbg(&isci_host->pdev->dev, | |
993 | "%s: %p: TMF_LU_RESET passed\n", | |
994 | __func__, isci_device); | |
995 | else | |
996 | dev_dbg(&isci_host->pdev->dev, | |
997 | "%s: %p: TMF_LU_RESET failed (%x)\n", | |
998 | __func__, isci_device, ret); | |
999 | ||
1000 | return ret; | |
1001 | } | |
1002 | ||
1003 | /** | |
1004 | * isci_task_lu_reset() - This function is one of the SAS Domain Template | |
1005 | * functions. This is one of the Task Management functoins called by libsas, | |
1006 | * to reset the given lun. Note the assumption that while this call is | |
1007 | * executing, no I/O will be sent by the host to the device. | |
1008 | * @lun: This parameter specifies the lun to be reset. | |
1009 | * | |
1010 | * status, zero indicates success. | |
1011 | */ | |
4393aa4e | 1012 | int isci_task_lu_reset(struct domain_device *domain_device, u8 *lun) |
6f231dda | 1013 | { |
4393aa4e | 1014 | struct isci_host *isci_host = dev_to_ihost(domain_device); |
6f231dda DW |
1015 | struct isci_remote_device *isci_device = NULL; |
1016 | int ret; | |
1017 | bool device_stopping = false; | |
1018 | ||
4393aa4e | 1019 | isci_device = domain_device->lldd_dev; |
6f231dda | 1020 | |
4393aa4e DW |
1021 | dev_dbg(&isci_host->pdev->dev, |
1022 | "%s: domain_device=%p, isci_host=%p; isci_device=%p\n", | |
6f231dda DW |
1023 | __func__, domain_device, isci_host, isci_device); |
1024 | ||
d06b487b | 1025 | if (isci_device != NULL) { |
6f231dda DW |
1026 | device_stopping = (isci_device->status == isci_stopping) |
1027 | || (isci_device->status == isci_stopped); | |
d06b487b DW |
1028 | set_bit(IDEV_EH, &isci_device->flags); |
1029 | } | |
6f231dda DW |
1030 | |
1031 | /* If there is a device reset pending on any request in the | |
1032 | * device's list, fail this LUN reset request in order to | |
1033 | * escalate to the device reset. | |
1034 | */ | |
4393aa4e DW |
1035 | if (!isci_device || device_stopping || |
1036 | isci_device_is_reset_pending(isci_host, isci_device)) { | |
6f231dda | 1037 | dev_warn(&isci_host->pdev->dev, |
4393aa4e | 1038 | "%s: No dev (%p), or " |
6f231dda | 1039 | "RESET PENDING: domain_device=%p\n", |
4393aa4e | 1040 | __func__, isci_device, domain_device); |
6f231dda DW |
1041 | return TMF_RESP_FUNC_FAILED; |
1042 | } | |
1043 | ||
6f231dda DW |
1044 | /* Send the task management part of the reset. */ |
1045 | if (sas_protocol_ata(domain_device->tproto)) { | |
4393aa4e | 1046 | ret = isci_task_send_lu_reset_sata(isci_host, isci_device, lun); |
6f231dda DW |
1047 | } else |
1048 | ret = isci_task_send_lu_reset_sas(isci_host, isci_device, lun); | |
1049 | ||
1050 | /* If the LUN reset worked, all the I/O can now be terminated. */ | |
1051 | if (ret == TMF_RESP_FUNC_COMPLETE) | |
1052 | /* Terminate all I/O now. */ | |
1053 | isci_terminate_pending_requests(isci_host, | |
1054 | isci_device, | |
1055 | terminating); | |
1056 | ||
6f231dda DW |
1057 | return ret; |
1058 | } | |
1059 | ||
1060 | ||
1061 | /* int (*lldd_clear_nexus_port)(struct asd_sas_port *); */ | |
1062 | int isci_task_clear_nexus_port(struct asd_sas_port *port) | |
1063 | { | |
1064 | return TMF_RESP_FUNC_FAILED; | |
1065 | } | |
1066 | ||
1067 | ||
1068 | ||
1069 | int isci_task_clear_nexus_ha(struct sas_ha_struct *ha) | |
1070 | { | |
1071 | return TMF_RESP_FUNC_FAILED; | |
1072 | } | |
1073 | ||
6f231dda DW |
1074 | /* Task Management Functions. Must be called from process context. */ |
1075 | ||
1076 | /** | |
1077 | * isci_abort_task_process_cb() - This is a helper function for the abort task | |
1078 | * TMF command. It manages the request state with respect to the successful | |
1079 | * transmission / completion of the abort task request. | |
1080 | * @cb_state: This parameter specifies when this function was called - after | |
1081 | * the TMF request has been started and after it has timed-out. | |
1082 | * @tmf: This parameter specifies the TMF in progress. | |
1083 | * | |
1084 | * | |
1085 | */ | |
1086 | static void isci_abort_task_process_cb( | |
1087 | enum isci_tmf_cb_state cb_state, | |
1088 | struct isci_tmf *tmf, | |
1089 | void *cb_data) | |
1090 | { | |
1091 | struct isci_request *old_request; | |
1092 | ||
1093 | old_request = (struct isci_request *)cb_data; | |
1094 | ||
1095 | dev_dbg(&old_request->isci_host->pdev->dev, | |
1096 | "%s: tmf=%p, old_request=%p\n", | |
1097 | __func__, tmf, old_request); | |
1098 | ||
1099 | switch (cb_state) { | |
1100 | ||
1101 | case isci_tmf_started: | |
1102 | /* The TMF has been started. Nothing to do here, since the | |
1103 | * request state was already set to "aborted" by the abort | |
1104 | * task function. | |
1105 | */ | |
6cb4d6b3 BB |
1106 | if ((old_request->status != aborted) |
1107 | && (old_request->status != completed)) | |
1108 | dev_err(&old_request->isci_host->pdev->dev, | |
1109 | "%s: Bad request status (%d): tmf=%p, old_request=%p\n", | |
1110 | __func__, old_request->status, tmf, old_request); | |
6f231dda DW |
1111 | break; |
1112 | ||
1113 | case isci_tmf_timed_out: | |
1114 | ||
1115 | /* Set the task's state to "aborting", since the abort task | |
1116 | * function thread set it to "aborted" (above) in anticipation | |
1117 | * of the task management request working correctly. Since the | |
1118 | * timeout has now fired, the TMF request failed. We set the | |
1119 | * state such that the request completion will indicate the | |
1120 | * device is no longer present. | |
1121 | */ | |
1122 | isci_request_change_state(old_request, aborting); | |
1123 | break; | |
1124 | ||
1125 | default: | |
1126 | dev_err(&old_request->isci_host->pdev->dev, | |
1127 | "%s: Bad cb_state (%d): tmf=%p, old_request=%p\n", | |
1128 | __func__, cb_state, tmf, old_request); | |
1129 | break; | |
1130 | } | |
1131 | } | |
1132 | ||
1133 | /** | |
1134 | * isci_task_abort_task() - This function is one of the SAS Domain Template | |
1135 | * functions. This function is called by libsas to abort a specified task. | |
1136 | * @task: This parameter specifies the SAS task to abort. | |
1137 | * | |
1138 | * status, zero indicates success. | |
1139 | */ | |
1140 | int isci_task_abort_task(struct sas_task *task) | |
1141 | { | |
4393aa4e | 1142 | struct isci_host *isci_host = dev_to_ihost(task->dev); |
6f231dda | 1143 | DECLARE_COMPLETION_ONSTACK(aborted_io_completion); |
a5fde225 JS |
1144 | struct isci_request *old_request = NULL; |
1145 | enum isci_request_status old_state; | |
6f231dda | 1146 | struct isci_remote_device *isci_device = NULL; |
a5fde225 JS |
1147 | struct isci_tmf tmf; |
1148 | int ret = TMF_RESP_FUNC_FAILED; | |
1149 | unsigned long flags; | |
1150 | bool any_dev_reset = false; | |
1151 | bool device_stopping; | |
6f231dda DW |
1152 | |
1153 | /* Get the isci_request reference from the task. Note that | |
1154 | * this check does not depend on the pending request list | |
1155 | * in the device, because tasks driving resets may land here | |
1156 | * after completion in the core. | |
1157 | */ | |
4393aa4e | 1158 | old_request = isci_task_get_request_from_task(task, &isci_device); |
6f231dda DW |
1159 | |
1160 | dev_dbg(&isci_host->pdev->dev, | |
1161 | "%s: task = %p\n", __func__, task); | |
1162 | ||
1163 | /* Check if the device has been / is currently being removed. | |
1164 | * If so, no task management will be done, and the I/O will | |
1165 | * be terminated. | |
1166 | */ | |
1167 | device_stopping = (isci_device->status == isci_stopping) | |
1168 | || (isci_device->status == isci_stopped); | |
1169 | ||
d06b487b DW |
1170 | /* XXX need to fix device lookup lifetime (needs to be done |
1171 | * under scic_lock, among other things...), but for now assume | |
1172 | * the device is available like the above code | |
1173 | */ | |
1174 | set_bit(IDEV_EH, &isci_device->flags); | |
1175 | ||
6f231dda DW |
1176 | /* This version of the driver will fail abort requests for |
1177 | * SATA/STP. Failing the abort request this way will cause the | |
1178 | * SCSI error handler thread to escalate to LUN reset | |
1179 | */ | |
1180 | if (sas_protocol_ata(task->task_proto) && !device_stopping) { | |
1181 | dev_warn(&isci_host->pdev->dev, | |
1182 | " task %p is for a STP/SATA device;" | |
1183 | " returning TMF_RESP_FUNC_FAILED\n" | |
1184 | " to cause a LUN reset...\n", task); | |
1185 | return TMF_RESP_FUNC_FAILED; | |
1186 | } | |
1187 | ||
1188 | dev_dbg(&isci_host->pdev->dev, | |
1189 | "%s: old_request == %p\n", __func__, old_request); | |
1190 | ||
a5fde225 JS |
1191 | if (!device_stopping) |
1192 | any_dev_reset = isci_device_is_reset_pending(isci_host,isci_device); | |
1193 | ||
6f231dda DW |
1194 | spin_lock_irqsave(&task->task_state_lock, flags); |
1195 | ||
1196 | /* Don't do resets to stopping devices. */ | |
a5fde225 | 1197 | if (device_stopping) { |
6f231dda | 1198 | |
a5fde225 JS |
1199 | task->task_state_flags &= ~SAS_TASK_NEED_DEV_RESET; |
1200 | any_dev_reset = false; | |
6f231dda | 1201 | |
a5fde225 | 1202 | } else /* See if there is a pending device reset for this device. */ |
6f231dda | 1203 | any_dev_reset = any_dev_reset |
a5fde225 | 1204 | || (task->task_state_flags & SAS_TASK_NEED_DEV_RESET); |
6f231dda DW |
1205 | |
1206 | /* If the extraction of the request reference from the task | |
1207 | * failed, then the request has been completed (or if there is a | |
1208 | * pending reset then this abort request function must be failed | |
1209 | * in order to escalate to the target reset). | |
1210 | */ | |
a5fde225 | 1211 | if ((old_request == NULL) || any_dev_reset) { |
6f231dda DW |
1212 | |
1213 | /* If the device reset task flag is set, fail the task | |
1214 | * management request. Otherwise, the original request | |
1215 | * has completed. | |
1216 | */ | |
1217 | if (any_dev_reset) { | |
1218 | ||
1219 | /* Turn off the task's DONE to make sure this | |
1220 | * task is escalated to a target reset. | |
1221 | */ | |
1222 | task->task_state_flags &= ~SAS_TASK_STATE_DONE; | |
1223 | ||
a5fde225 JS |
1224 | /* Make the reset happen as soon as possible. */ |
1225 | task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; | |
1226 | ||
1227 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
1228 | ||
6f231dda DW |
1229 | /* Fail the task management request in order to |
1230 | * escalate to the target reset. | |
1231 | */ | |
1232 | ret = TMF_RESP_FUNC_FAILED; | |
1233 | ||
1234 | dev_dbg(&isci_host->pdev->dev, | |
1235 | "%s: Failing task abort in order to " | |
1236 | "escalate to target reset because\n" | |
1237 | "SAS_TASK_NEED_DEV_RESET is set for " | |
1238 | "task %p on dev %p\n", | |
1239 | __func__, task, isci_device); | |
1240 | ||
6f231dda | 1241 | |
a5fde225 | 1242 | } else { |
6f231dda DW |
1243 | /* The request has already completed and there |
1244 | * is nothing to do here other than to set the task | |
1245 | * done bit, and indicate that the task abort function | |
1246 | * was sucessful. | |
1247 | */ | |
1248 | isci_set_task_doneflags(task); | |
1249 | ||
a5fde225 | 1250 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
6f231dda | 1251 | |
a5fde225 | 1252 | ret = TMF_RESP_FUNC_COMPLETE; |
6f231dda | 1253 | |
a5fde225 JS |
1254 | dev_dbg(&isci_host->pdev->dev, |
1255 | "%s: abort task not needed for %p\n", | |
1256 | __func__, task); | |
6f231dda | 1257 | } |
6f231dda DW |
1258 | |
1259 | return ret; | |
1260 | } | |
a5fde225 JS |
1261 | else |
1262 | spin_unlock_irqrestore(&task->task_state_lock, flags); | |
6f231dda DW |
1263 | |
1264 | spin_lock_irqsave(&isci_host->scic_lock, flags); | |
1265 | ||
f219f010 | 1266 | /* Check the request status and change to "aborted" if currently |
a5fde225 | 1267 | * "starting"; if true then set the I/O kernel completion |
6f231dda DW |
1268 | * struct that will be triggered when the request completes. |
1269 | */ | |
a5fde225 JS |
1270 | old_state = isci_task_validate_request_to_abort( |
1271 | old_request, isci_host, isci_device, | |
1272 | &aborted_io_completion); | |
f219f010 JS |
1273 | if ((old_state != started) && |
1274 | (old_state != completed) && | |
1275 | (old_state != aborting)) { | |
6f231dda DW |
1276 | |
1277 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | |
1278 | ||
a5fde225 JS |
1279 | /* The request was already being handled by someone else (because |
1280 | * they got to set the state away from started). | |
1281 | */ | |
1282 | dev_dbg(&isci_host->pdev->dev, | |
1283 | "%s: device = %p; old_request %p already being aborted\n", | |
1284 | __func__, | |
1285 | isci_device, old_request); | |
6f231dda DW |
1286 | |
1287 | return TMF_RESP_FUNC_COMPLETE; | |
1288 | } | |
a5fde225 JS |
1289 | if ((task->task_proto == SAS_PROTOCOL_SMP) |
1290 | || device_stopping | |
1291 | || old_request->complete_in_target | |
1292 | ) { | |
6f231dda DW |
1293 | |
1294 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | |
1295 | ||
a5fde225 JS |
1296 | dev_dbg(&isci_host->pdev->dev, |
1297 | "%s: SMP request (%d)" | |
1298 | " or device is stopping (%d)" | |
1299 | " or complete_in_target (%d), thus no TMF\n", | |
1300 | __func__, (task->task_proto == SAS_PROTOCOL_SMP), | |
1301 | device_stopping, old_request->complete_in_target); | |
1302 | ||
6f231dda DW |
1303 | /* Set the state on the task. */ |
1304 | isci_task_all_done(task); | |
1305 | ||
1306 | ret = TMF_RESP_FUNC_COMPLETE; | |
1307 | ||
1308 | /* Stopping and SMP devices are not sent a TMF, and are not | |
a5fde225 | 1309 | * reset, but the outstanding I/O request is terminated below. |
6f231dda | 1310 | */ |
6f231dda DW |
1311 | } else { |
1312 | /* Fill in the tmf stucture */ | |
c3f42feb JS |
1313 | isci_task_build_abort_task_tmf(&tmf, isci_device, |
1314 | isci_tmf_ssp_task_abort, | |
1315 | isci_abort_task_process_cb, | |
1316 | old_request); | |
6f231dda | 1317 | |
6f231dda DW |
1318 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); |
1319 | ||
1320 | #define ISCI_ABORT_TASK_TIMEOUT_MS 500 /* half second timeout. */ | |
1321 | ret = isci_task_execute_tmf(isci_host, &tmf, | |
1322 | ISCI_ABORT_TASK_TIMEOUT_MS); | |
1323 | ||
a5fde225 | 1324 | if (ret != TMF_RESP_FUNC_COMPLETE) |
6f231dda DW |
1325 | dev_err(&isci_host->pdev->dev, |
1326 | "%s: isci_task_send_tmf failed\n", | |
1327 | __func__); | |
1328 | } | |
a5fde225 JS |
1329 | if (ret == TMF_RESP_FUNC_COMPLETE) { |
1330 | old_request->complete_in_target = true; | |
1331 | ||
1332 | /* Clean up the request on our side, and wait for the aborted I/O to | |
1333 | * complete. | |
1334 | */ | |
cbb65c66 | 1335 | isci_terminate_request_core(isci_host, isci_device, old_request); |
a5fde225 | 1336 | } |
6f231dda | 1337 | |
a5fde225 JS |
1338 | /* Make sure we do not leave a reference to aborted_io_completion */ |
1339 | old_request->io_request_completion = NULL; | |
6f231dda DW |
1340 | return ret; |
1341 | } | |
1342 | ||
1343 | /** | |
1344 | * isci_task_abort_task_set() - This function is one of the SAS Domain Template | |
1345 | * functions. This is one of the Task Management functoins called by libsas, | |
1346 | * to abort all task for the given lun. | |
1347 | * @d_device: This parameter specifies the domain device associated with this | |
1348 | * request. | |
1349 | * @lun: This parameter specifies the lun associated with this request. | |
1350 | * | |
1351 | * status, zero indicates success. | |
1352 | */ | |
1353 | int isci_task_abort_task_set( | |
1354 | struct domain_device *d_device, | |
1355 | u8 *lun) | |
1356 | { | |
1357 | return TMF_RESP_FUNC_FAILED; | |
1358 | } | |
1359 | ||
1360 | ||
1361 | /** | |
1362 | * isci_task_clear_aca() - This function is one of the SAS Domain Template | |
1363 | * functions. This is one of the Task Management functoins called by libsas. | |
1364 | * @d_device: This parameter specifies the domain device associated with this | |
1365 | * request. | |
1366 | * @lun: This parameter specifies the lun associated with this request. | |
1367 | * | |
1368 | * status, zero indicates success. | |
1369 | */ | |
1370 | int isci_task_clear_aca( | |
1371 | struct domain_device *d_device, | |
1372 | u8 *lun) | |
1373 | { | |
1374 | return TMF_RESP_FUNC_FAILED; | |
1375 | } | |
1376 | ||
1377 | ||
1378 | ||
1379 | /** | |
1380 | * isci_task_clear_task_set() - This function is one of the SAS Domain Template | |
1381 | * functions. This is one of the Task Management functoins called by libsas. | |
1382 | * @d_device: This parameter specifies the domain device associated with this | |
1383 | * request. | |
1384 | * @lun: This parameter specifies the lun associated with this request. | |
1385 | * | |
1386 | * status, zero indicates success. | |
1387 | */ | |
1388 | int isci_task_clear_task_set( | |
1389 | struct domain_device *d_device, | |
1390 | u8 *lun) | |
1391 | { | |
1392 | return TMF_RESP_FUNC_FAILED; | |
1393 | } | |
1394 | ||
1395 | ||
1396 | /** | |
1397 | * isci_task_query_task() - This function is implemented to cause libsas to | |
1398 | * correctly escalate the failed abort to a LUN or target reset (this is | |
1399 | * because sas_scsi_find_task libsas function does not correctly interpret | |
1400 | * all return codes from the abort task call). When TMF_RESP_FUNC_SUCC is | |
1401 | * returned, libsas turns this into a LUN reset; when FUNC_FAILED is | |
1402 | * returned, libsas will turn this into a target reset | |
1403 | * @task: This parameter specifies the sas task being queried. | |
1404 | * @lun: This parameter specifies the lun associated with this request. | |
1405 | * | |
1406 | * status, zero indicates success. | |
1407 | */ | |
1408 | int isci_task_query_task( | |
1409 | struct sas_task *task) | |
1410 | { | |
1411 | /* See if there is a pending device reset for this device. */ | |
1412 | if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) | |
1413 | return TMF_RESP_FUNC_FAILED; | |
1414 | else | |
1415 | return TMF_RESP_FUNC_SUCC; | |
1416 | } | |
1417 | ||
af5ae893 | 1418 | /* |
6f231dda DW |
1419 | * isci_task_request_complete() - This function is called by the sci core when |
1420 | * an task request completes. | |
af5ae893 DJ |
1421 | * @ihost: This parameter specifies the ISCI host object |
1422 | * @ireq: This parameter is the completed isci_request object. | |
6f231dda DW |
1423 | * @completion_status: This parameter specifies the completion status from the |
1424 | * sci core. | |
1425 | * | |
1426 | * none. | |
1427 | */ | |
af5ae893 DJ |
1428 | void |
1429 | isci_task_request_complete(struct isci_host *ihost, | |
1430 | struct isci_request *ireq, | |
1431 | enum sci_task_status completion_status) | |
6f231dda | 1432 | { |
af5ae893 | 1433 | struct isci_remote_device *idev = ireq->isci_device; |
6f231dda | 1434 | enum isci_request_status old_state; |
af5ae893 | 1435 | struct isci_tmf *tmf = isci_request_access_tmf(ireq); |
6f231dda | 1436 | struct completion *tmf_complete; |
af5ae893 DJ |
1437 | struct scic_sds_request *sci_req = ireq->sci_request_handle; |
1438 | struct scic_sds_stp_request *stp_req = | |
1439 | container_of(sci_req, typeof(*stp_req), parent); | |
6f231dda | 1440 | |
af5ae893 | 1441 | dev_dbg(&ihost->pdev->dev, |
6f231dda | 1442 | "%s: request = %p, status=%d\n", |
af5ae893 | 1443 | __func__, ireq, completion_status); |
6f231dda | 1444 | |
af5ae893 | 1445 | old_state = isci_request_change_state(ireq, completed); |
6f231dda DW |
1446 | |
1447 | tmf->status = completion_status; | |
af5ae893 | 1448 | ireq->complete_in_target = true; |
6f231dda | 1449 | |
af5ae893 | 1450 | if (tmf->proto == SAS_PROTOCOL_SSP) { |
6f231dda | 1451 | memcpy(&tmf->resp.resp_iu, |
af5ae893 DJ |
1452 | sci_req->response_buffer, |
1453 | SSP_RESP_IU_MAX_SIZE); | |
1454 | } else if (tmf->proto == SAS_PROTOCOL_SATA) { | |
6f231dda | 1455 | memcpy(&tmf->resp.d2h_fis, |
af5ae893 | 1456 | &stp_req->d2h_reg_fis, |
f2f30080 | 1457 | sizeof(struct dev_to_host_fis)); |
6f231dda DW |
1458 | } |
1459 | ||
1460 | /* Manage the timer if it is still running. */ | |
1461 | if (tmf->timeout_timer) { | |
af5ae893 | 1462 | isci_del_timer(ihost, tmf->timeout_timer); |
6f231dda DW |
1463 | tmf->timeout_timer = NULL; |
1464 | } | |
1465 | ||
1466 | /* PRINT_TMF( ((struct isci_tmf *)request->task)); */ | |
1467 | tmf_complete = tmf->complete; | |
1468 | ||
af5ae893 DJ |
1469 | scic_controller_complete_io(ihost->core_controller, |
1470 | &idev->sci, | |
1471 | ireq->sci_request_handle); | |
1472 | ||
1473 | /* | |
1474 | * NULL the request handle to make sure it cannot be terminated | |
6f231dda DW |
1475 | * or completed again. |
1476 | */ | |
af5ae893 | 1477 | ireq->sci_request_handle = NULL; |
6f231dda | 1478 | |
af5ae893 DJ |
1479 | isci_request_change_state(ireq, unallocated); |
1480 | list_del_init(&ireq->dev_node); | |
6f231dda DW |
1481 | |
1482 | /* The task management part completes last. */ | |
1483 | complete(tmf_complete); | |
1484 | } | |
1485 | ||
d06b487b | 1486 | static int isci_reset_device(struct domain_device *dev, int hard_reset) |
6f231dda | 1487 | { |
d06b487b DW |
1488 | struct isci_remote_device *idev = dev->lldd_dev; |
1489 | struct sas_phy *phy = sas_find_local_phy(dev); | |
1490 | struct isci_host *ihost = dev_to_ihost(dev); | |
6f231dda | 1491 | enum sci_status status; |
d06b487b DW |
1492 | unsigned long flags; |
1493 | int rc; | |
6f231dda | 1494 | |
d06b487b | 1495 | dev_dbg(&ihost->pdev->dev, "%s: idev %p\n", __func__, idev); |
6f231dda | 1496 | |
d06b487b DW |
1497 | if (!idev) { |
1498 | dev_warn(&ihost->pdev->dev, | |
1499 | "%s: idev is GONE!\n", | |
6f231dda DW |
1500 | __func__); |
1501 | ||
1502 | return TMF_RESP_FUNC_COMPLETE; /* Nothing to reset. */ | |
1503 | } | |
1504 | ||
d06b487b DW |
1505 | spin_lock_irqsave(&ihost->scic_lock, flags); |
1506 | status = scic_remote_device_reset(&idev->sci); | |
6f231dda | 1507 | if (status != SCI_SUCCESS) { |
d06b487b | 1508 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
6f231dda | 1509 | |
d06b487b DW |
1510 | dev_warn(&ihost->pdev->dev, |
1511 | "%s: scic_remote_device_reset(%p) returned %d!\n", | |
1512 | __func__, idev, status); | |
6f231dda DW |
1513 | |
1514 | return TMF_RESP_FUNC_FAILED; | |
1515 | } | |
d06b487b | 1516 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
6f231dda | 1517 | |
6f231dda | 1518 | /* Make sure all pending requests are able to be fully terminated. */ |
d06b487b | 1519 | isci_device_clear_reset_pending(ihost, idev); |
6f231dda | 1520 | |
d06b487b DW |
1521 | rc = sas_phy_reset(phy, hard_reset); |
1522 | msleep(2000); /* just like mvsas */ | |
6f231dda | 1523 | |
d06b487b DW |
1524 | /* Terminate in-progress I/O now. */ |
1525 | isci_remote_device_nuke_requests(ihost, idev); | |
6f231dda | 1526 | |
d06b487b DW |
1527 | spin_lock_irqsave(&ihost->scic_lock, flags); |
1528 | status = scic_remote_device_reset_complete(&idev->sci); | |
1529 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | |
6f231dda | 1530 | |
d06b487b DW |
1531 | if (status != SCI_SUCCESS) { |
1532 | dev_warn(&ihost->pdev->dev, | |
1533 | "%s: scic_remote_device_reset_complete(%p) " | |
1534 | "returned %d!\n", __func__, idev, status); | |
6f231dda DW |
1535 | } |
1536 | ||
d06b487b | 1537 | dev_dbg(&ihost->pdev->dev, "%s: idev %p complete.\n", __func__, idev); |
6f231dda | 1538 | |
d06b487b DW |
1539 | return rc; |
1540 | } | |
6f231dda | 1541 | |
d06b487b DW |
1542 | int isci_task_I_T_nexus_reset(struct domain_device *dev) |
1543 | { | |
1544 | struct isci_host *ihost = dev_to_ihost(dev); | |
1545 | int ret = TMF_RESP_FUNC_FAILED, hard_reset = 1; | |
1546 | struct isci_remote_device *idev; | |
1547 | unsigned long flags; | |
1548 | ||
1549 | /* XXX mvsas is not protecting against ->lldd_dev_gone(), are we | |
1550 | * being too paranoid, or is mvsas busted?! | |
1551 | */ | |
1552 | spin_lock_irqsave(&ihost->scic_lock, flags); | |
1553 | idev = dev->lldd_dev; | |
1554 | if (!idev || !test_bit(IDEV_EH, &idev->flags)) | |
1555 | ret = TMF_RESP_FUNC_COMPLETE; | |
1556 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | |
1557 | ||
1558 | if (ret == TMF_RESP_FUNC_COMPLETE) | |
1559 | return ret; | |
1560 | ||
1561 | if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) | |
1562 | hard_reset = 0; | |
1563 | ||
1564 | return isci_reset_device(dev, hard_reset); | |
1565 | } | |
1566 | ||
1567 | int isci_bus_reset_handler(struct scsi_cmnd *cmd) | |
1568 | { | |
1569 | struct domain_device *dev = sdev_to_domain_dev(cmd->device); | |
1570 | int hard_reset = 1; | |
1571 | ||
1572 | if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) | |
1573 | hard_reset = 0; | |
6f231dda | 1574 | |
d06b487b | 1575 | return isci_reset_device(dev, hard_reset); |
6f231dda | 1576 | } |