Lines Matching +full:tcs +full:- +full:wait
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
78 return sci_remote_node_context_suspend(&idev->rnc, reason, in sci_remote_device_suspend()
83 * isci_remote_device_ready() - This function is called by the ihost when the
92 dev_dbg(&ihost->pdev->dev, in isci_remote_device_ready()
95 clear_bit(IDEV_IO_NCQERROR, &idev->flags); in isci_remote_device_ready()
96 set_bit(IDEV_IO_READY, &idev->flags); in isci_remote_device_ready()
97 if (test_and_clear_bit(IDEV_START_PENDING, &idev->flags)) in isci_remote_device_ready()
98 wake_up(&ihost->eventq); in isci_remote_device_ready()
107 if (!test_bit(IREQ_ACTIVE, &ireq->flags) || in sci_remote_device_terminate_req()
108 (ireq->target_device != idev) || in sci_remote_device_terminate_req()
109 (check_abort && !test_bit(IREQ_PENDING_ABORT, &ireq->flags))) in sci_remote_device_terminate_req()
112 dev_dbg(&ihost->pdev->dev, in sci_remote_device_terminate_req()
114 __func__, idev, idev->flags, ireq, ireq->target_device); in sci_remote_device_terminate_req()
116 set_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags); in sci_remote_device_terminate_req()
125 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_terminate_reqs_checkabort()
130 struct isci_request *ireq = ihost->reqs[i]; in sci_remote_device_terminate_reqs_checkabort()
149 return (localcount != idev->rnc.suspend_count) in isci_compare_suspendcount()
150 || sci_remote_node_context_is_being_destroyed(&idev->rnc); in isci_compare_suspendcount()
162 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_check_reqterm()
164 && !test_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags); in isci_check_reqterm()
165 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_check_reqterm()
178 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_check_devempty()
180 && idev->started_request_count == 0; in isci_check_devempty()
181 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_check_devempty()
195 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
198 dev_dbg(&ihost->pdev->dev, "%s: failed isci_get_device(idev=%p)\n", in isci_remote_device_terminate_requests()
200 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
203 /* If already suspended, don't wait for another suspension. */ in isci_remote_device_terminate_requests()
206 = sci_remote_node_context_is_suspended(&idev->rnc) in isci_remote_device_terminate_requests()
207 ? 0 : idev->rnc.suspend_count; in isci_remote_device_terminate_requests()
209 dev_dbg(&ihost->pdev->dev, in isci_remote_device_terminate_requests()
212 "about to wait\n", in isci_remote_device_terminate_requests()
213 __func__, idev, ireq, idev->started_request_count, in isci_remote_device_terminate_requests()
214 rnc_suspend_count, idev->rnc.suspend_count); in isci_remote_device_terminate_requests()
219 set_bit(IREQ_NO_AUTO_FREE_TAG, &ireq->flags); in isci_remote_device_terminate_requests()
221 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
222 if (!wait_event_timeout(ihost->eventq, in isci_remote_device_terminate_requests()
227 dev_warn(&ihost->pdev->dev, "%s host%d timeout single\n", in isci_remote_device_terminate_requests()
228 __func__, ihost->id); in isci_remote_device_terminate_requests()
229 dev_dbg(&ihost->pdev->dev, in isci_remote_device_terminate_requests()
236 "ireq=%p, ireq->flags = %lx\n", in isci_remote_device_terminate_requests()
238 dev_state_name(idev->sm.current_state_id), in isci_remote_device_terminate_requests()
239 idev->started_request_count, idev->flags, in isci_remote_device_terminate_requests()
240 rnc_suspend_count, idev->rnc.suspend_count, in isci_remote_device_terminate_requests()
241 rnc_state_name(idev->rnc.sm.current_state_id), in isci_remote_device_terminate_requests()
242 idev->rnc.suspend_type, in isci_remote_device_terminate_requests()
243 idev->rnc.destination_state, in isci_remote_device_terminate_requests()
244 ireq, ireq->flags); in isci_remote_device_terminate_requests()
246 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
247 clear_bit(IREQ_NO_AUTO_FREE_TAG, &ireq->flags); in isci_remote_device_terminate_requests()
248 if (!test_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags)) in isci_remote_device_terminate_requests()
249 isci_free_tag(ihost, ireq->io_tag); in isci_remote_device_terminate_requests()
250 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
252 /* Terminate all TCs. */ in isci_remote_device_terminate_requests()
254 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_terminate_requests()
255 if (!wait_event_timeout(ihost->eventq, in isci_remote_device_terminate_requests()
260 dev_warn(&ihost->pdev->dev, "%s host%d timeout all\n", in isci_remote_device_terminate_requests()
261 __func__, ihost->id); in isci_remote_device_terminate_requests()
262 dev_dbg(&ihost->pdev->dev, in isci_remote_device_terminate_requests()
271 dev_state_name(idev->sm.current_state_id), in isci_remote_device_terminate_requests()
272 idev->started_request_count, idev->flags, in isci_remote_device_terminate_requests()
274 rnc_state_name(idev->rnc.sm.current_state_id), in isci_remote_device_terminate_requests()
275 idev->rnc.suspend_count, in isci_remote_device_terminate_requests()
276 idev->rnc.suspend_type, in isci_remote_device_terminate_requests()
277 idev->rnc.destination_state); in isci_remote_device_terminate_requests()
280 dev_dbg(&ihost->pdev->dev, "%s: idev=%p, wait done\n", in isci_remote_device_terminate_requests()
288 * isci_remote_device_not_ready() - This function is called by the ihost when
300 dev_dbg(&ihost->pdev->dev, in isci_remote_device_not_ready()
305 set_bit(IDEV_IO_NCQERROR, &idev->flags); in isci_remote_device_not_ready()
315 clear_bit(IDEV_IO_READY, &idev->flags); in isci_remote_device_not_ready()
327 BUG_ON(idev->started_request_count != 0); in rnc_destruct_done()
328 sci_change_state(&idev->sm, SCI_DEV_STOPPED); in rnc_destruct_done()
340 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_stop()
341 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_stop()
355 BUG_ON(idev->started_request_count != 0); in sci_remote_device_stop()
356 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_stop()
358 /* Transition to the stopping state and wait for the in sci_remote_device_stop()
372 if (idev->started_request_count == 0) in sci_remote_device_stop()
373 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_stop()
396 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_reset()
397 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_reset()
426 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_reset_complete()
427 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_reset_complete()
442 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_frame_handler()
443 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_frame_handler()
444 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_frame_handler()
471 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_remote_device_frame_handler()
481 if (ireq && ireq->target_device == idev) { in sci_remote_device_frame_handler()
495 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_remote_device_frame_handler()
501 if (hdr->fis_type == FIS_SETDEVBITS && in sci_remote_device_frame_handler()
502 (hdr->status & ATA_ERR)) { in sci_remote_device_frame_handler()
503 idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; in sci_remote_device_frame_handler()
507 } else if (hdr->fis_type == FIS_REGD2H && in sci_remote_device_frame_handler()
508 (hdr->status & ATA_ERR)) { in sci_remote_device_frame_handler()
513 idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; in sci_remote_device_frame_handler()
514 sci_change_state(&idev->sm, SCI_STP_DEV_NCQ_ERROR); in sci_remote_device_frame_handler()
527 status = sci_io_request_frame_handler(idev->working_request, frame_index); in sci_remote_device_frame_handler()
537 struct sci_base_state_machine *sm = &idev->sm; in is_remote_device_ready()
538 enum sci_remote_device_states state = sm->current_state_id; in is_remote_device_ready()
562 struct isci_request *ireq = idev->working_request; in atapi_remote_device_resume_done()
564 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_remote_device_resume_done()
571 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_event_handler()
572 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_event_handler()
578 status = sci_remote_node_context_event_handler(&idev->rnc, event_code); in sci_remote_device_event_handler()
611 /* Decode device-specific states that may require an RNC resume during in sci_remote_device_event_handler()
619 return sci_remote_node_context_resume(&idev->rnc, in sci_remote_device_event_handler()
632 status = sci_remote_node_context_resume(&idev->rnc, NULL, NULL); in sci_remote_device_event_handler()
642 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_request()
648 kref_get(&idev->kref); in sci_remote_device_start_request()
649 idev->started_request_count++; in sci_remote_device_start_request()
657 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start_io()
658 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start_io()
659 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_io()
685 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
693 * the command idle state. - Evalute the type of IO request to in sci_remote_device_start_io()
694 * be started - If its an NCQ request change to NCQ substate - in sci_remote_device_start_io()
707 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
715 if (task->ata_task.use_ncq) in sci_remote_device_start_io()
718 idev->working_request = ireq; in sci_remote_device_start_io()
727 if (task->ata_task.use_ncq) { in sci_remote_device_start_io()
732 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
748 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
756 idev->working_request = ireq; in sci_remote_device_start_io()
757 sci_change_state(&idev->sm, SCI_SMP_DEV_CMD); in sci_remote_device_start_io()
793 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_complete_io()
794 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_complete_io()
795 struct isci_port *iport = idev->owning_port; in sci_remote_device_complete_io()
823 if (ireq->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { in sci_remote_device_complete_io()
830 } else if (idev->started_request_count == 0) in sci_remote_device_complete_io()
844 if (idev->started_request_count == 0) in sci_remote_device_complete_io()
845 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_complete_io()
867 if (idev->working_request) in sci_remote_device_continue_request()
868 sci_controller_continue_io(idev->working_request); in sci_remote_device_continue_request()
875 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start_task()
876 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start_task()
877 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_task()
911 idev->working_request = ireq; in sci_remote_device_start_task()
924 status = sci_remote_node_context_start_task(&idev->rnc, ireq, in sci_remote_device_start_task()
940 status = sci_remote_node_context_start_task(&idev->rnc, ireq, in sci_remote_device_start_task()
955 struct isci_port *iport = idev->owning_port; in sci_remote_device_post_request()
960 (iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | in sci_remote_device_post_request()
961 idev->rnc.remote_node_index; in sci_remote_device_post_request()
963 sci_controller_post_request(iport->owning_controller, context); in sci_remote_device_post_request()
978 sci_change_state(&idev->sm, SCI_DEV_READY); in remote_device_resume_done()
984 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_idle_substate_resume_complete_handler()
989 if (idev->sm.previous_state_id != SCI_STP_DEV_NCQ) in sci_stp_remote_device_ready_idle_substate_resume_complete_handler()
998 sci_change_state(&idev->sm, SCI_DEV_STOPPED); in sci_remote_device_initial_state_enter()
1002 * sci_remote_device_destruct() - free remote node context and destruct
1007 * non-reentrant. The return value shall indicate if the device was
1016 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_destruct()
1017 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_destruct()
1026 ihost = idev->owning_port->owning_controller; in sci_remote_device_destruct()
1028 idev->rnc.remote_node_index); in sci_remote_device_destruct()
1029 idev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; in sci_remote_device_destruct()
1036 * isci_remote_device_deconstruct() - This function frees an isci_remote_device.
1043 dev_dbg(&ihost->pdev->dev, in isci_remote_device_deconstruct()
1050 BUG_ON(idev->started_request_count > 0); in isci_remote_device_deconstruct()
1053 list_del_init(&idev->node); in isci_remote_device_deconstruct()
1060 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_stopped_state_enter()
1066 prev_state = idev->sm.previous_state_id; in sci_remote_device_stopped_state_enter()
1076 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_starting_state_enter()
1085 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_ready_state_enter()
1086 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ready_state_enter()
1088 if (dev->dev_type == SAS_SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { in sci_remote_device_ready_state_enter()
1089 sci_change_state(&idev->sm, SCI_STP_DEV_IDLE); in sci_remote_device_ready_state_enter()
1090 } else if (dev_is_expander(dev->dev_type)) { in sci_remote_device_ready_state_enter()
1091 sci_change_state(&idev->sm, SCI_SMP_DEV_IDLE); in sci_remote_device_ready_state_enter()
1099 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ready_state_exit()
1101 if (dev->dev_type == SAS_END_DEVICE) { in sci_remote_device_ready_state_exit()
1102 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_ready_state_exit()
1112 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_resetting_state_enter()
1114 dev_dbg(&ihost->pdev->dev, in sci_remote_device_resetting_state_enter()
1123 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_resetting_state_exit()
1125 dev_dbg(&ihost->pdev->dev, in sci_remote_device_resetting_state_exit()
1128 sci_remote_node_context_resume(&idev->rnc, NULL, NULL); in sci_remote_device_resetting_state_exit()
1135 idev->working_request = NULL; in sci_stp_remote_device_ready_idle_substate_enter()
1136 if (sci_remote_node_context_is_ready(&idev->rnc)) { in sci_stp_remote_device_ready_idle_substate_enter()
1142 sci_remote_node_context_resume(&idev->rnc, in sci_stp_remote_device_ready_idle_substate_enter()
1151 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_cmd_substate_enter()
1153 BUG_ON(idev->working_request == NULL); in sci_stp_remote_device_ready_cmd_substate_enter()
1162 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_ncq_error_substate_enter()
1164 if (idev->not_ready_reason == SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED) in sci_stp_remote_device_ready_ncq_error_substate_enter()
1166 idev->not_ready_reason); in sci_stp_remote_device_ready_ncq_error_substate_enter()
1172 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_smp_remote_device_ready_idle_substate_enter()
1180 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_smp_remote_device_ready_cmd_substate_enter()
1182 BUG_ON(idev->working_request == NULL); in sci_smp_remote_device_ready_cmd_substate_enter()
1192 idev->working_request = NULL; in sci_smp_remote_device_ready_cmd_substate_exit()
1238 * sci_remote_device_construct() - common construction
1250 idev->owning_port = iport; in sci_remote_device_construct()
1251 idev->started_request_count = 0; in sci_remote_device_construct()
1253 sci_init_sm(&idev->sm, sci_remote_device_state_table, SCI_DEV_INITIAL); in sci_remote_device_construct()
1255 sci_remote_node_context_construct(&idev->rnc, in sci_remote_device_construct()
1260 * sci_remote_device_da_construct() - construct direct attached device.
1268 * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
1269 * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
1270 * sata-only controller instance.
1271 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1283 idev->device_port_width = hweight32(properties.phy_mask); in sci_remote_device_da_construct()
1285 status = sci_controller_allocate_remote_node_context(iport->owning_controller, in sci_remote_device_da_construct()
1287 &idev->rnc.remote_node_index); in sci_remote_device_da_construct()
1292 idev->connection_rate = sci_port_get_max_allowed_speed(iport); in sci_remote_device_da_construct()
1298 * sci_remote_device_ea_construct() - construct expander attached device
1304 * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
1305 * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
1306 * sata-only controller instance.
1307 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1312 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ea_construct()
1317 status = sci_controller_allocate_remote_node_context(iport->owning_controller, in sci_remote_device_ea_construct()
1319 &idev->rnc.remote_node_index); in sci_remote_device_ea_construct()
1323 /* For SAS-2 the physical link rate is actually a logical link in sci_remote_device_ea_construct()
1327 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay in sci_remote_device_ea_construct()
1330 idev->connection_rate = min_t(u16, sci_port_get_max_allowed_speed(iport), in sci_remote_device_ea_construct()
1331 dev->linkrate); in sci_remote_device_ea_construct()
1334 idev->device_port_width = 1; in sci_remote_device_ea_construct()
1346 status = sci_remote_node_context_resume(&idev->rnc, cb_fn, cb_p); in sci_remote_device_resume()
1356 struct isci_host *ihost = idev->owning_port->owning_controller; in isci_remote_device_resume_from_abort_complete()
1358 idev->abort_resume_cb; in isci_remote_device_resume_from_abort_complete()
1360 dev_dbg(scirdev_to_dev(idev), "%s: passing-along resume: %p\n", in isci_remote_device_resume_from_abort_complete()
1364 idev->abort_resume_cb = NULL; in isci_remote_device_resume_from_abort_complete()
1365 abort_resume_cb(idev->abort_resume_cbparam); in isci_remote_device_resume_from_abort_complete()
1367 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort_complete()
1368 wake_up(&ihost->eventq); in isci_remote_device_resume_from_abort_complete()
1378 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_test_resume_done()
1379 done = !test_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags) in isci_remote_device_test_resume_done()
1380 || test_bit(IDEV_STOP_PENDING, &idev->flags) in isci_remote_device_test_resume_done()
1381 || sci_remote_node_context_is_being_destroyed(&idev->rnc); in isci_remote_device_test_resume_done()
1382 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_test_resume_done()
1391 dev_dbg(&ihost->pdev->dev, "%s: starting resume wait: %p\n", in isci_remote_device_wait_for_resume_from_abort()
1395 if (!wait_event_timeout(ihost->eventq, in isci_remote_device_wait_for_resume_from_abort()
1399 dev_warn(&ihost->pdev->dev, "%s: #### Timeout waiting for " in isci_remote_device_wait_for_resume_from_abort()
1402 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_wait_for_resume_from_abort()
1404 dev_dbg(&ihost->pdev->dev, "%s: resume wait done: %p\n", in isci_remote_device_wait_for_resume_from_abort()
1416 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_resume_from_abort()
1420 idev->abort_resume_cb = idev->rnc.user_callback; in isci_remote_device_resume_from_abort()
1421 idev->abort_resume_cbparam = idev->rnc.user_cookie; in isci_remote_device_resume_from_abort()
1422 set_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort()
1423 clear_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags); in isci_remote_device_resume_from_abort()
1424 destroyed = sci_remote_node_context_is_being_destroyed(&idev->rnc); in isci_remote_device_resume_from_abort()
1429 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_resume_from_abort()
1433 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort()
1439 * sci_remote_device_start() - This method will start the supplied remote
1454 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start()
1455 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start()
1477 struct isci_host *ihost = iport->isci_host; in isci_remote_device_construct()
1478 struct domain_device *dev = idev->domain_dev; in isci_remote_device_construct()
1481 if (dev->parent && dev_is_expander(dev->parent->dev_type)) in isci_remote_device_construct()
1487 dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n", in isci_remote_device_construct()
1497 dev_warn(&ihost->pdev->dev, "remote device start failed: %d\n", in isci_remote_device_construct()
1518 idev = &ihost->devices[i]; in isci_remote_device_alloc()
1519 if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) in isci_remote_device_alloc()
1524 dev_warn(&ihost->pdev->dev, "%s: failed\n", __func__); in isci_remote_device_alloc()
1527 if (WARN_ONCE(!list_empty(&idev->node), "found non-idle remote device\n")) in isci_remote_device_alloc()
1536 struct isci_host *ihost = idev->isci_port->isci_host; in isci_remote_device_release()
1538 idev->domain_dev = NULL; in isci_remote_device_release()
1539 idev->isci_port = NULL; in isci_remote_device_release()
1540 clear_bit(IDEV_START_PENDING, &idev->flags); in isci_remote_device_release()
1541 clear_bit(IDEV_STOP_PENDING, &idev->flags); in isci_remote_device_release()
1542 clear_bit(IDEV_IO_READY, &idev->flags); in isci_remote_device_release()
1543 clear_bit(IDEV_GONE, &idev->flags); in isci_remote_device_release()
1545 clear_bit(IDEV_ALLOCATED, &idev->flags); in isci_remote_device_release()
1546 wake_up(&ihost->eventq); in isci_remote_device_release()
1550 * isci_remote_device_stop() - This function is called internally to stop the
1562 dev_dbg(&ihost->pdev->dev, in isci_remote_device_stop()
1565 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_stop()
1566 idev->domain_dev->lldd_dev = NULL; /* disable new lookups */ in isci_remote_device_stop()
1567 set_bit(IDEV_GONE, &idev->flags); in isci_remote_device_stop()
1569 set_bit(IDEV_STOP_PENDING, &idev->flags); in isci_remote_device_stop()
1571 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_stop()
1573 /* Wait for the stop complete callback. */ in isci_remote_device_stop()
1575 /* nothing to wait for */; in isci_remote_device_stop()
1579 dev_dbg(&ihost->pdev->dev, in isci_remote_device_stop()
1586 * isci_remote_device_gone() - This function is called by libsas when a domain
1594 struct isci_remote_device *idev = dev->lldd_dev; in isci_remote_device_gone()
1596 dev_dbg(&ihost->pdev->dev, in isci_remote_device_gone()
1598 __func__, dev, idev, idev->isci_port); in isci_remote_device_gone()
1605 * isci_remote_device_found() - This function is called by libsas when a remote
1616 struct isci_port *isci_port = dev->port->lldd_port; in isci_remote_device_found()
1620 dev_dbg(&isci_host->pdev->dev, in isci_remote_device_found()
1624 return -ENODEV; in isci_remote_device_found()
1628 return -ENODEV; in isci_remote_device_found()
1630 kref_init(&isci_device->kref); in isci_remote_device_found()
1631 INIT_LIST_HEAD(&isci_device->node); in isci_remote_device_found()
1633 spin_lock_irq(&isci_host->scic_lock); in isci_remote_device_found()
1634 isci_device->domain_dev = dev; in isci_remote_device_found()
1635 isci_device->isci_port = isci_port; in isci_remote_device_found()
1636 list_add_tail(&isci_device->node, &isci_port->remote_dev_list); in isci_remote_device_found()
1638 set_bit(IDEV_START_PENDING, &isci_device->flags); in isci_remote_device_found()
1641 dev_dbg(&isci_host->pdev->dev, in isci_remote_device_found()
1647 dev->lldd_dev = isci_device; in isci_remote_device_found()
1650 spin_unlock_irq(&isci_host->scic_lock); in isci_remote_device_found()
1652 /* wait for the device ready callback. */ in isci_remote_device_found()
1655 return status == SCI_SUCCESS ? 0 : -ENODEV; in isci_remote_device_found()
1667 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_suspend_terminate()
1668 set_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags); in isci_remote_device_suspend_terminate()
1670 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_suspend_terminate()
1672 /* Terminate and wait for the completions. */ in isci_remote_device_suspend_terminate()
1675 dev_dbg(&ihost->pdev->dev, in isci_remote_device_suspend_terminate()
1687 return sci_remote_node_context_is_safe_to_abort(&idev->rnc); in isci_remote_device_is_safe_to_abort()
1703 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_reset_complete()
1705 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_reset_complete()
1714 if (dev_is_sata(idev->domain_dev)) { in isci_dev_set_hang_detection_timeout()
1717 &idev->flags)) in isci_dev_set_hang_detection_timeout()
1720 &idev->flags)) in isci_dev_set_hang_detection_timeout()
1723 sci_port_set_hang_detection_timeout(idev->owning_port, in isci_dev_set_hang_detection_timeout()