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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
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.
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.
56 #include <linux/completion.h>
57 #include <linux/irqflags.h>
59 #include <scsi/libsas.h>
60 #include "remote_device.h"
61 #include "remote_node_context.h"
68 * isci_task_refuse() - complete the request to the upper layer driver in
69 * the case where an I/O needs to be completed back in the submit path.
70 * @ihost: host on which the the request was queued
71 * @task: request to complete
72 * @response: response code for the completed task.
73 * @status: status code for the completed task.
76 static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task,
77 enum service_response response,
78 enum exec_status status)
83 /* Normal notification (task_done) */
84 dev_dbg(&ihost->pdev->dev, "%s: task = %p, response=%d, status=%d\n",
85 __func__, task, response, status);
87 spin_lock_irqsave(&task->task_state_lock, flags);
89 task->task_status.resp = response;
90 task->task_status.stat = status;
92 /* Normal notification (task_done) */
93 task->task_state_flags |= SAS_TASK_STATE_DONE;
94 task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
95 task->lldd_task = NULL;
96 spin_unlock_irqrestore(&task->task_state_lock, flags);
98 task->task_done(task);
101 #define for_each_sas_task(num, task) \
102 for (; num > 0; num--,\
103 task = list_entry(task->list.next, struct sas_task, list))
106 static inline int isci_device_io_ready(struct isci_remote_device *idev,
107 struct sas_task *task)
109 return idev ? test_bit(IDEV_IO_READY, &idev->flags) ||
110 (test_bit(IDEV_IO_NCQERROR, &idev->flags) &&
111 isci_task_is_ncq_recovery(task))
115 * isci_task_execute_task() - This function is one of the SAS Domain Template
116 * functions. This function is called by libsas to send a task down to
118 * @task: This parameter specifies the SAS task to send.
119 * @gfp_flags: This parameter specifies the context of this call.
121 * status, zero indicates success.
123 int isci_task_execute_task(struct sas_task *task, gfp_t gfp_flags)
125 struct isci_host *ihost = dev_to_ihost(task->dev);
126 struct isci_remote_device *idev;
128 enum sci_status status = SCI_FAILURE;
132 spin_lock_irqsave(&ihost->scic_lock, flags);
133 idev = isci_lookup_device(task->dev);
134 io_ready = isci_device_io_ready(idev, task);
135 tag = isci_alloc_tag(ihost);
136 spin_unlock_irqrestore(&ihost->scic_lock, flags);
138 dev_dbg(&ihost->pdev->dev,
139 "task: %p, dev: %p idev: %p:%#lx cmd = %p\n",
140 task, task->dev, idev, idev ? idev->flags : 0,
144 isci_task_refuse(ihost, task, SAS_TASK_UNDELIVERED,
146 } else if (!io_ready || tag == SCI_CONTROLLER_INVALID_IO_TAG) {
147 /* Indicate QUEUE_FULL so that the scsi midlayer
150 isci_task_refuse(ihost, task, SAS_TASK_COMPLETE,
153 /* There is a device and it's ready for I/O. */
154 spin_lock_irqsave(&task->task_state_lock, flags);
156 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
157 /* The I/O was aborted. */
158 spin_unlock_irqrestore(&task->task_state_lock, flags);
160 isci_task_refuse(ihost, task,
161 SAS_TASK_UNDELIVERED,
162 SAS_SAM_STAT_TASK_ABORTED);
164 struct isci_request *ireq;
166 /* do common allocation and init of request object. */
167 ireq = isci_io_request_from_tag(ihost, task, tag);
168 spin_unlock_irqrestore(&task->task_state_lock, flags);
170 /* build and send the request. */
171 /* do common allocation and init of request object. */
172 status = isci_request_execute(ihost, idev, task, ireq);
174 if (status != SCI_SUCCESS) {
175 if (test_bit(IDEV_GONE, &idev->flags)) {
176 /* Indicate that the device
179 isci_task_refuse(ihost, task,
180 SAS_TASK_UNDELIVERED,
183 /* Indicate QUEUE_FULL so that
184 * the scsi midlayer retries.
185 * If the request failed for
186 * remote device reasons, it
188 * SAS_TASK_UNDELIVERED next
191 isci_task_refuse(ihost, task,
199 if (status != SCI_SUCCESS && tag != SCI_CONTROLLER_INVALID_IO_TAG) {
200 spin_lock_irqsave(&ihost->scic_lock, flags);
201 /* command never hit the device, so just free
202 * the tci and skip the sequence increment
204 isci_tci_free(ihost, ISCI_TAG_TCI(tag));
205 spin_unlock_irqrestore(&ihost->scic_lock, flags);
208 isci_put_device(idev);
212 static struct isci_request *isci_task_request_build(struct isci_host *ihost,
213 struct isci_remote_device *idev,
214 u16 tag, struct isci_tmf *isci_tmf)
216 enum sci_status status = SCI_FAILURE;
217 struct isci_request *ireq = NULL;
218 struct domain_device *dev;
220 dev_dbg(&ihost->pdev->dev,
221 "%s: isci_tmf = %p\n", __func__, isci_tmf);
223 dev = idev->domain_dev;
225 /* do common allocation and init of request object. */
226 ireq = isci_tmf_request_from_tag(ihost, isci_tmf, tag);
230 /* let the core do it's construct. */
231 status = sci_task_request_construct(ihost, idev, tag,
234 if (status != SCI_SUCCESS) {
235 dev_warn(&ihost->pdev->dev,
236 "%s: sci_task_request_construct failed - "
243 /* XXX convert to get this from task->tproto like other drivers */
244 if (dev->dev_type == SAS_END_DEVICE) {
245 isci_tmf->proto = SAS_PROTOCOL_SSP;
246 status = sci_task_request_construct_ssp(ireq);
247 if (status != SCI_SUCCESS)
254 static int isci_task_execute_tmf(struct isci_host *ihost,
255 struct isci_remote_device *idev,
256 struct isci_tmf *tmf, unsigned long timeout_ms)
258 DECLARE_COMPLETION_ONSTACK(completion);
259 enum sci_status status = SCI_FAILURE;
260 struct isci_request *ireq;
261 int ret = TMF_RESP_FUNC_FAILED;
263 unsigned long timeleft;
266 spin_lock_irqsave(&ihost->scic_lock, flags);
267 tag = isci_alloc_tag(ihost);
268 spin_unlock_irqrestore(&ihost->scic_lock, flags);
270 if (tag == SCI_CONTROLLER_INVALID_IO_TAG)
273 /* sanity check, return TMF_RESP_FUNC_FAILED
274 * if the device is not there and ready.
277 (!test_bit(IDEV_IO_READY, &idev->flags) &&
278 !test_bit(IDEV_IO_NCQERROR, &idev->flags))) {
279 dev_dbg(&ihost->pdev->dev,
280 "%s: idev = %p not ready (%#lx)\n",
282 idev, idev ? idev->flags : 0);
285 dev_dbg(&ihost->pdev->dev,
289 /* Assign the pointer to the TMF's completion kernel wait structure. */
290 tmf->complete = &completion;
291 tmf->status = SCI_FAILURE_TIMEOUT;
293 ireq = isci_task_request_build(ihost, idev, tag, tmf);
297 spin_lock_irqsave(&ihost->scic_lock, flags);
299 /* start the TMF io. */
300 status = sci_controller_start_task(ihost, idev, ireq);
302 if (status != SCI_SUCCESS) {
303 dev_dbg(&ihost->pdev->dev,
304 "%s: start_io failed - status = 0x%x, request = %p\n",
308 spin_unlock_irqrestore(&ihost->scic_lock, flags);
311 spin_unlock_irqrestore(&ihost->scic_lock, flags);
313 /* The RNC must be unsuspended before the TMF can get a response. */
314 isci_remote_device_resume_from_abort(ihost, idev);
316 /* Wait for the TMF to complete, or a timeout. */
317 timeleft = wait_for_completion_timeout(&completion,
318 msecs_to_jiffies(timeout_ms));
321 /* The TMF did not complete - this could be because
322 * of an unplug. Terminate the TMF request now.
324 isci_remote_device_suspend_terminate(ihost, idev, ireq);
327 isci_print_tmf(ihost, tmf);
329 if (tmf->status == SCI_SUCCESS)
330 ret = TMF_RESP_FUNC_COMPLETE;
331 else if (tmf->status == SCI_FAILURE_IO_RESPONSE_VALID) {
332 dev_dbg(&ihost->pdev->dev,
334 "SCI_FAILURE_IO_RESPONSE_VALID\n",
336 ret = TMF_RESP_FUNC_COMPLETE;
338 /* Else - leave the default "failed" status alone. */
340 dev_dbg(&ihost->pdev->dev,
341 "%s: completed request = %p\n",
348 spin_lock_irqsave(&ihost->scic_lock, flags);
349 isci_tci_free(ihost, ISCI_TAG_TCI(tag));
350 spin_unlock_irqrestore(&ihost->scic_lock, flags);
355 static void isci_task_build_tmf(struct isci_tmf *tmf,
356 enum isci_tmf_function_codes code)
358 memset(tmf, 0, sizeof(*tmf));
359 tmf->tmf_code = code;
362 static void isci_task_build_abort_task_tmf(struct isci_tmf *tmf,
363 enum isci_tmf_function_codes code,
364 struct isci_request *old_request)
366 isci_task_build_tmf(tmf, code);
367 tmf->io_tag = old_request->io_tag;
371 * isci_task_send_lu_reset_sas() - This function is called by of the SAS Domain
372 * Template functions.
373 * @lun: This parameter specifies the lun to be reset.
375 * status, zero indicates success.
377 static int isci_task_send_lu_reset_sas(
378 struct isci_host *isci_host,
379 struct isci_remote_device *isci_device,
383 int ret = TMF_RESP_FUNC_FAILED;
385 dev_dbg(&isci_host->pdev->dev,
386 "%s: isci_host = %p, isci_device = %p\n",
387 __func__, isci_host, isci_device);
388 /* Send the LUN reset to the target. By the time the call returns,
389 * the TMF has fully exected in the target (in which case the return
390 * value is "TMF_RESP_FUNC_COMPLETE", or the request timed-out (or
391 * was otherwise unable to be executed ("TMF_RESP_FUNC_FAILED").
393 isci_task_build_tmf(&tmf, isci_tmf_ssp_lun_reset);
395 #define ISCI_LU_RESET_TIMEOUT_MS 2000 /* 2 second timeout. */
396 ret = isci_task_execute_tmf(isci_host, isci_device, &tmf, ISCI_LU_RESET_TIMEOUT_MS);
398 if (ret == TMF_RESP_FUNC_COMPLETE)
399 dev_dbg(&isci_host->pdev->dev,
400 "%s: %p: TMF_LU_RESET passed\n",
401 __func__, isci_device);
403 dev_dbg(&isci_host->pdev->dev,
404 "%s: %p: TMF_LU_RESET failed (%x)\n",
405 __func__, isci_device, ret);
410 int isci_task_lu_reset(struct domain_device *dev, u8 *lun)
412 struct isci_host *ihost = dev_to_ihost(dev);
413 struct isci_remote_device *idev;
415 int ret = TMF_RESP_FUNC_COMPLETE;
417 spin_lock_irqsave(&ihost->scic_lock, flags);
418 idev = isci_get_device(dev->lldd_dev);
419 spin_unlock_irqrestore(&ihost->scic_lock, flags);
421 dev_dbg(&ihost->pdev->dev,
422 "%s: domain_device=%p, isci_host=%p; isci_device=%p\n",
423 __func__, dev, ihost, idev);
426 /* If the device is gone, escalate to I_T_Nexus_Reset. */
427 dev_dbg(&ihost->pdev->dev, "%s: No dev\n", __func__);
429 ret = TMF_RESP_FUNC_FAILED;
433 /* Suspend the RNC, kill all TCs */
434 if (isci_remote_device_suspend_terminate(ihost, idev, NULL)
436 /* The suspend/terminate only fails if isci_get_device fails */
437 ret = TMF_RESP_FUNC_FAILED;
440 /* All pending I/Os have been terminated and cleaned up. */
441 if (!test_bit(IDEV_GONE, &idev->flags)) {
442 if (dev_is_sata(dev))
443 sas_ata_schedule_reset(dev);
445 /* Send the task management part of the reset. */
446 ret = isci_task_send_lu_reset_sas(ihost, idev, lun);
449 isci_put_device(idev);
454 /* int (*lldd_clear_nexus_port)(struct asd_sas_port *); */
455 int isci_task_clear_nexus_port(struct asd_sas_port *port)
457 return TMF_RESP_FUNC_FAILED;
462 int isci_task_clear_nexus_ha(struct sas_ha_struct *ha)
464 return TMF_RESP_FUNC_FAILED;
467 /* Task Management Functions. Must be called from process context. */
470 * isci_task_abort_task() - This function is one of the SAS Domain Template
471 * functions. This function is called by libsas to abort a specified task.
472 * @task: This parameter specifies the SAS task to abort.
474 * status, zero indicates success.
476 int isci_task_abort_task(struct sas_task *task)
478 struct isci_host *ihost = dev_to_ihost(task->dev);
479 DECLARE_COMPLETION_ONSTACK(aborted_io_completion);
480 struct isci_request *old_request = NULL;
481 struct isci_remote_device *idev = NULL;
483 int ret = TMF_RESP_FUNC_FAILED;
485 int target_done_already = 0;
487 /* Get the isci_request reference from the task. Note that
488 * this check does not depend on the pending request list
489 * in the device, because tasks driving resets may land here
490 * after completion in the core.
492 spin_lock_irqsave(&ihost->scic_lock, flags);
493 spin_lock(&task->task_state_lock);
495 old_request = task->lldd_task;
497 /* If task is already done, the request isn't valid */
498 if (!(task->task_state_flags & SAS_TASK_STATE_DONE) &&
500 idev = isci_get_device(task->dev->lldd_dev);
501 target_done_already = test_bit(IREQ_COMPLETE_IN_TARGET,
502 &old_request->flags);
504 spin_unlock(&task->task_state_lock);
505 spin_unlock_irqrestore(&ihost->scic_lock, flags);
507 dev_warn(&ihost->pdev->dev,
508 "%s: dev = %p (%s%s), task = %p, old_request == %p\n",
510 (dev_is_sata(task->dev) ? "STP/SATA"
511 : ((dev_is_expander(task->dev->dev_type))
514 ((idev) ? ((test_bit(IDEV_GONE, &idev->flags))
520 /* Device reset conditions signalled in task_state_flags are the
521 * responsbility of libsas to observe at the start of the error
524 if (!idev || !old_request) {
525 /* The request has already completed and there
526 * is nothing to do here other than to set the task
527 * done bit, and indicate that the task abort function
530 spin_lock_irqsave(&task->task_state_lock, flags);
531 task->task_state_flags |= SAS_TASK_STATE_DONE;
532 task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
533 spin_unlock_irqrestore(&task->task_state_lock, flags);
535 ret = TMF_RESP_FUNC_COMPLETE;
537 dev_warn(&ihost->pdev->dev,
538 "%s: abort task not needed for %p\n",
542 /* Suspend the RNC, kill the TC */
543 if (isci_remote_device_suspend_terminate(ihost, idev, old_request)
545 dev_warn(&ihost->pdev->dev,
546 "%s: isci_remote_device_reset_terminate(dev=%p, "
547 "req=%p, task=%p) failed\n",
548 __func__, idev, old_request, task);
549 ret = TMF_RESP_FUNC_FAILED;
552 spin_lock_irqsave(&ihost->scic_lock, flags);
554 if (task->task_proto == SAS_PROTOCOL_SMP ||
555 sas_protocol_ata(task->task_proto) ||
556 target_done_already ||
557 test_bit(IDEV_GONE, &idev->flags)) {
559 spin_unlock_irqrestore(&ihost->scic_lock, flags);
561 /* No task to send, so explicitly resume the device here */
562 isci_remote_device_resume_from_abort(ihost, idev);
564 dev_warn(&ihost->pdev->dev,
566 " or complete_in_target (%d), "
567 "or IDEV_GONE (%d), thus no TMF\n",
569 ((task->task_proto == SAS_PROTOCOL_SMP)
571 : (sas_protocol_ata(task->task_proto)
575 test_bit(IREQ_COMPLETE_IN_TARGET,
576 &old_request->flags),
577 test_bit(IDEV_GONE, &idev->flags));
579 spin_lock_irqsave(&task->task_state_lock, flags);
580 task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
581 task->task_state_flags |= SAS_TASK_STATE_DONE;
582 spin_unlock_irqrestore(&task->task_state_lock, flags);
584 ret = TMF_RESP_FUNC_COMPLETE;
586 /* Fill in the tmf structure */
587 isci_task_build_abort_task_tmf(&tmf, isci_tmf_ssp_task_abort,
590 spin_unlock_irqrestore(&ihost->scic_lock, flags);
592 /* Send the task management request. */
593 #define ISCI_ABORT_TASK_TIMEOUT_MS 500 /* 1/2 second timeout */
594 ret = isci_task_execute_tmf(ihost, idev, &tmf,
595 ISCI_ABORT_TASK_TIMEOUT_MS);
598 dev_warn(&ihost->pdev->dev,
599 "%s: Done; dev = %p, task = %p , old_request == %p\n",
600 __func__, idev, task, old_request);
601 isci_put_device(idev);
606 * isci_task_abort_task_set() - This function is one of the SAS Domain Template
607 * functions. This is one of the Task Management functoins called by libsas,
608 * to abort all task for the given lun.
609 * @d_device: This parameter specifies the domain device associated with this
611 * @lun: This parameter specifies the lun associated with this request.
613 * status, zero indicates success.
615 int isci_task_abort_task_set(
616 struct domain_device *d_device,
619 return TMF_RESP_FUNC_FAILED;
624 * isci_task_clear_task_set() - This function is one of the SAS Domain Template
625 * functions. This is one of the Task Management functoins called by libsas.
626 * @d_device: This parameter specifies the domain device associated with this
628 * @lun: This parameter specifies the lun associated with this request.
630 * status, zero indicates success.
632 int isci_task_clear_task_set(
633 struct domain_device *d_device,
636 return TMF_RESP_FUNC_FAILED;
641 * isci_task_query_task() - This function is implemented to cause libsas to
642 * correctly escalate the failed abort to a LUN or target reset (this is
643 * because sas_scsi_find_task libsas function does not correctly interpret
644 * all return codes from the abort task call). When TMF_RESP_FUNC_SUCC is
645 * returned, libsas turns this into a LUN reset; when FUNC_FAILED is
646 * returned, libsas will turn this into a target reset
647 * @task: This parameter specifies the sas task being queried.
649 * status, zero indicates success.
651 int isci_task_query_task(
652 struct sas_task *task)
654 /* See if there is a pending device reset for this device. */
655 if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET)
656 return TMF_RESP_FUNC_FAILED;
658 return TMF_RESP_FUNC_SUCC;
662 * isci_task_request_complete() - This function is called by the sci core when
663 * an task request completes.
664 * @ihost: This parameter specifies the ISCI host object
665 * @ireq: This parameter is the completed isci_request object.
666 * @completion_status: This parameter specifies the completion status from the
672 isci_task_request_complete(struct isci_host *ihost,
673 struct isci_request *ireq,
674 enum sci_task_status completion_status)
676 struct isci_tmf *tmf = isci_request_access_tmf(ireq);
677 struct completion *tmf_complete = NULL;
679 dev_dbg(&ihost->pdev->dev,
680 "%s: request = %p, status=%d\n",
681 __func__, ireq, completion_status);
683 set_bit(IREQ_COMPLETE_IN_TARGET, &ireq->flags);
686 tmf->status = completion_status;
688 if (tmf->proto == SAS_PROTOCOL_SSP) {
689 memcpy(tmf->resp.rsp_buf,
691 SSP_RESP_IU_MAX_SIZE);
692 } else if (tmf->proto == SAS_PROTOCOL_SATA) {
693 memcpy(&tmf->resp.d2h_fis,
695 sizeof(struct dev_to_host_fis));
697 /* PRINT_TMF( ((struct isci_tmf *)request->task)); */
698 tmf_complete = tmf->complete;
700 sci_controller_complete_io(ihost, ireq->target_device, ireq);
701 /* set the 'terminated' flag handle to make sure it cannot be terminated
702 * or completed again.
704 set_bit(IREQ_TERMINATED, &ireq->flags);
706 if (test_and_clear_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags))
707 wake_up_all(&ihost->eventq);
709 if (!test_bit(IREQ_NO_AUTO_FREE_TAG, &ireq->flags))
710 isci_free_tag(ihost, ireq->io_tag);
712 /* The task management part completes last. */
714 complete(tmf_complete);
717 static int isci_reset_device(struct isci_host *ihost,
718 struct domain_device *dev,
719 struct isci_remote_device *idev)
721 int rc = TMF_RESP_FUNC_COMPLETE, reset_stat = -1;
722 struct sas_phy *phy = sas_get_local_phy(dev);
723 struct isci_port *iport = dev->port->lldd_port;
725 dev_dbg(&ihost->pdev->dev, "%s: idev %p\n", __func__, idev);
727 /* Suspend the RNC, terminate all outstanding TCs. */
728 if (isci_remote_device_suspend_terminate(ihost, idev, NULL)
730 rc = TMF_RESP_FUNC_FAILED;
733 /* Note that since the termination for outstanding requests succeeded,
734 * this function will return success. This is because the resets will
735 * only fail if the device has been removed (ie. hotplug), and the
736 * primary duty of this function is to cleanup tasks, so that is the
739 if (!test_bit(IDEV_GONE, &idev->flags)) {
740 if (scsi_is_sas_phy_local(phy)) {
741 struct isci_phy *iphy = &ihost->phys[phy->number];
743 reset_stat = isci_port_perform_hard_reset(ihost, iport,
746 reset_stat = sas_phy_reset(phy, !dev_is_sata(dev));
748 /* Explicitly resume the RNC here, since there was no task sent. */
749 isci_remote_device_resume_from_abort(ihost, idev);
751 dev_dbg(&ihost->pdev->dev, "%s: idev %p complete, reset_stat=%d.\n",
752 __func__, idev, reset_stat);
754 sas_put_local_phy(phy);
758 int isci_task_I_T_nexus_reset(struct domain_device *dev)
760 struct isci_host *ihost = dev_to_ihost(dev);
761 struct isci_remote_device *idev;
765 spin_lock_irqsave(&ihost->scic_lock, flags);
766 idev = isci_get_device(dev->lldd_dev);
767 spin_unlock_irqrestore(&ihost->scic_lock, flags);
770 /* XXX: need to cleanup any ireqs targeting this
777 ret = isci_reset_device(ihost, dev, idev);
779 isci_put_device(idev);