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
301 dev_dbg(&ihost->pdev->dev, in isci_remote_device_not_ready()
306 set_bit(IDEV_IO_NCQERROR, &idev->flags); in isci_remote_device_not_ready()
316 clear_bit(IDEV_IO_READY, &idev->flags); in isci_remote_device_not_ready()
328 BUG_ON(idev->started_request_count != 0); in rnc_destruct_done()
329 sci_change_state(&idev->sm, SCI_DEV_STOPPED); in rnc_destruct_done()
341 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_stop()
342 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_stop()
356 BUG_ON(idev->started_request_count != 0); in sci_remote_device_stop()
357 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_stop()
359 /* Transition to the stopping state and wait for the in sci_remote_device_stop()
373 if (idev->started_request_count == 0) in sci_remote_device_stop()
374 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_stop()
397 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_reset()
398 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_reset()
427 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_reset_complete()
428 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_reset_complete()
443 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_frame_handler()
444 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_frame_handler()
445 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_frame_handler()
472 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_remote_device_frame_handler()
482 if (ireq && ireq->target_device == idev) { in sci_remote_device_frame_handler()
496 status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, in sci_remote_device_frame_handler()
502 if (hdr->fis_type == FIS_SETDEVBITS && in sci_remote_device_frame_handler()
503 (hdr->status & ATA_ERR)) { in sci_remote_device_frame_handler()
504 idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; in sci_remote_device_frame_handler()
508 } else if (hdr->fis_type == FIS_REGD2H && in sci_remote_device_frame_handler()
509 (hdr->status & ATA_ERR)) { in sci_remote_device_frame_handler()
514 idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; in sci_remote_device_frame_handler()
515 sci_change_state(&idev->sm, SCI_STP_DEV_NCQ_ERROR); in sci_remote_device_frame_handler()
528 status = sci_io_request_frame_handler(idev->working_request, frame_index); in sci_remote_device_frame_handler()
538 struct sci_base_state_machine *sm = &idev->sm; in is_remote_device_ready()
539 enum sci_remote_device_states state = sm->current_state_id; in is_remote_device_ready()
563 struct isci_request *ireq = idev->working_request; in atapi_remote_device_resume_done()
565 sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); in atapi_remote_device_resume_done()
572 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_event_handler()
573 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_event_handler()
579 status = sci_remote_node_context_event_handler(&idev->rnc, event_code); in sci_remote_device_event_handler()
612 /* Decode device-specific states that may require an RNC resume during in sci_remote_device_event_handler()
620 return sci_remote_node_context_resume(&idev->rnc, in sci_remote_device_event_handler()
633 status = sci_remote_node_context_resume(&idev->rnc, NULL, NULL); in sci_remote_device_event_handler()
643 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_request()
649 kref_get(&idev->kref); in sci_remote_device_start_request()
650 idev->started_request_count++; in sci_remote_device_start_request()
658 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start_io()
659 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start_io()
660 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_io()
686 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
694 * the command idle state. - Evalute the type of IO request to in sci_remote_device_start_io()
695 * be started - If its an NCQ request change to NCQ substate - in sci_remote_device_start_io()
708 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
716 if (task->ata_task.use_ncq) in sci_remote_device_start_io()
719 idev->working_request = ireq; in sci_remote_device_start_io()
728 if (task->ata_task.use_ncq) { in sci_remote_device_start_io()
733 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
749 status = sci_remote_node_context_start_io(&idev->rnc, ireq); in sci_remote_device_start_io()
757 idev->working_request = ireq; in sci_remote_device_start_io()
758 sci_change_state(&idev->sm, SCI_SMP_DEV_CMD); in sci_remote_device_start_io()
794 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_complete_io()
795 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_complete_io()
796 struct isci_port *iport = idev->owning_port; in sci_remote_device_complete_io()
824 if (ireq->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { in sci_remote_device_complete_io()
831 } else if (idev->started_request_count == 0) in sci_remote_device_complete_io()
845 if (idev->started_request_count == 0) in sci_remote_device_complete_io()
846 sci_remote_node_context_destruct(&idev->rnc, in sci_remote_device_complete_io()
868 if (idev->working_request) in sci_remote_device_continue_request()
869 sci_controller_continue_io(idev->working_request); in sci_remote_device_continue_request()
876 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start_task()
877 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start_task()
878 struct isci_port *iport = idev->owning_port; in sci_remote_device_start_task()
912 idev->working_request = ireq; in sci_remote_device_start_task()
925 status = sci_remote_node_context_start_task(&idev->rnc, ireq, in sci_remote_device_start_task()
941 status = sci_remote_node_context_start_task(&idev->rnc, ireq, in sci_remote_device_start_task()
956 struct isci_port *iport = idev->owning_port; in sci_remote_device_post_request()
961 (iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | in sci_remote_device_post_request()
962 idev->rnc.remote_node_index; in sci_remote_device_post_request()
964 sci_controller_post_request(iport->owning_controller, context); in sci_remote_device_post_request()
979 sci_change_state(&idev->sm, SCI_DEV_READY); in remote_device_resume_done()
985 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_idle_substate_resume_complete_handler()
990 if (idev->sm.previous_state_id != SCI_STP_DEV_NCQ) in sci_stp_remote_device_ready_idle_substate_resume_complete_handler()
999 sci_change_state(&idev->sm, SCI_DEV_STOPPED); in sci_remote_device_initial_state_enter()
1003 * sci_remote_device_destruct() - free remote node context and destruct
1008 * non-reentrant. The return value shall indicate if the device was
1017 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_destruct()
1018 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_destruct()
1027 ihost = idev->owning_port->owning_controller; in sci_remote_device_destruct()
1029 idev->rnc.remote_node_index); in sci_remote_device_destruct()
1030 idev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; in sci_remote_device_destruct()
1037 * isci_remote_device_deconstruct() - This function frees an isci_remote_device.
1044 dev_dbg(&ihost->pdev->dev, in isci_remote_device_deconstruct()
1051 BUG_ON(idev->started_request_count > 0); in isci_remote_device_deconstruct()
1054 list_del_init(&idev->node); in isci_remote_device_deconstruct()
1061 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_stopped_state_enter()
1067 prev_state = idev->sm.previous_state_id; in sci_remote_device_stopped_state_enter()
1077 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_starting_state_enter()
1086 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_ready_state_enter()
1087 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ready_state_enter()
1089 if (dev->dev_type == SAS_SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { in sci_remote_device_ready_state_enter()
1090 sci_change_state(&idev->sm, SCI_STP_DEV_IDLE); in sci_remote_device_ready_state_enter()
1091 } else if (dev_is_expander(dev->dev_type)) { in sci_remote_device_ready_state_enter()
1092 sci_change_state(&idev->sm, SCI_SMP_DEV_IDLE); in sci_remote_device_ready_state_enter()
1100 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ready_state_exit()
1102 if (dev->dev_type == SAS_END_DEVICE) { in sci_remote_device_ready_state_exit()
1103 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_ready_state_exit()
1113 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_resetting_state_enter()
1115 dev_dbg(&ihost->pdev->dev, in sci_remote_device_resetting_state_enter()
1124 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_device_resetting_state_exit()
1126 dev_dbg(&ihost->pdev->dev, in sci_remote_device_resetting_state_exit()
1129 sci_remote_node_context_resume(&idev->rnc, NULL, NULL); in sci_remote_device_resetting_state_exit()
1136 idev->working_request = NULL; in sci_stp_remote_device_ready_idle_substate_enter()
1137 if (sci_remote_node_context_is_ready(&idev->rnc)) { in sci_stp_remote_device_ready_idle_substate_enter()
1143 sci_remote_node_context_resume(&idev->rnc, in sci_stp_remote_device_ready_idle_substate_enter()
1152 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_cmd_substate_enter()
1154 BUG_ON(idev->working_request == NULL); in sci_stp_remote_device_ready_cmd_substate_enter()
1163 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_stp_remote_device_ready_ncq_error_substate_enter()
1165 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()
1167 idev->not_ready_reason); in sci_stp_remote_device_ready_ncq_error_substate_enter()
1173 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_smp_remote_device_ready_idle_substate_enter()
1181 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_smp_remote_device_ready_cmd_substate_enter()
1183 BUG_ON(idev->working_request == NULL); in sci_smp_remote_device_ready_cmd_substate_enter()
1193 idev->working_request = NULL; in sci_smp_remote_device_ready_cmd_substate_exit()
1239 * sci_remote_device_construct() - common construction
1251 idev->owning_port = iport; in sci_remote_device_construct()
1252 idev->started_request_count = 0; in sci_remote_device_construct()
1254 sci_init_sm(&idev->sm, sci_remote_device_state_table, SCI_DEV_INITIAL); in sci_remote_device_construct()
1256 sci_remote_node_context_construct(&idev->rnc, in sci_remote_device_construct()
1261 * sci_remote_device_da_construct() - construct direct attached device.
1269 * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
1270 * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
1271 * sata-only controller instance.
1272 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1284 idev->device_port_width = hweight32(properties.phy_mask); in sci_remote_device_da_construct()
1286 status = sci_controller_allocate_remote_node_context(iport->owning_controller, in sci_remote_device_da_construct()
1288 &idev->rnc.remote_node_index); in sci_remote_device_da_construct()
1293 idev->connection_rate = sci_port_get_max_allowed_speed(iport); in sci_remote_device_da_construct()
1299 * sci_remote_device_ea_construct() - construct expander attached device
1305 * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed.
1306 * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to
1307 * sata-only controller instance.
1308 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1313 struct domain_device *dev = idev->domain_dev; in sci_remote_device_ea_construct()
1318 status = sci_controller_allocate_remote_node_context(iport->owning_controller, in sci_remote_device_ea_construct()
1320 &idev->rnc.remote_node_index); in sci_remote_device_ea_construct()
1324 /* For SAS-2 the physical link rate is actually a logical link in sci_remote_device_ea_construct()
1328 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay in sci_remote_device_ea_construct()
1331 idev->connection_rate = min_t(u16, sci_port_get_max_allowed_speed(iport), in sci_remote_device_ea_construct()
1332 dev->linkrate); in sci_remote_device_ea_construct()
1335 idev->device_port_width = 1; in sci_remote_device_ea_construct()
1347 status = sci_remote_node_context_resume(&idev->rnc, cb_fn, cb_p); in sci_remote_device_resume()
1357 struct isci_host *ihost = idev->owning_port->owning_controller; in isci_remote_device_resume_from_abort_complete()
1359 idev->abort_resume_cb; in isci_remote_device_resume_from_abort_complete()
1361 dev_dbg(scirdev_to_dev(idev), "%s: passing-along resume: %p\n", in isci_remote_device_resume_from_abort_complete()
1365 idev->abort_resume_cb = NULL; in isci_remote_device_resume_from_abort_complete()
1366 abort_resume_cb(idev->abort_resume_cbparam); in isci_remote_device_resume_from_abort_complete()
1368 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort_complete()
1369 wake_up(&ihost->eventq); in isci_remote_device_resume_from_abort_complete()
1379 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_test_resume_done()
1380 done = !test_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags) in isci_remote_device_test_resume_done()
1381 || test_bit(IDEV_STOP_PENDING, &idev->flags) in isci_remote_device_test_resume_done()
1382 || sci_remote_node_context_is_being_destroyed(&idev->rnc); in isci_remote_device_test_resume_done()
1383 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_test_resume_done()
1392 dev_dbg(&ihost->pdev->dev, "%s: starting resume wait: %p\n", in isci_remote_device_wait_for_resume_from_abort()
1396 if (!wait_event_timeout(ihost->eventq, in isci_remote_device_wait_for_resume_from_abort()
1400 dev_warn(&ihost->pdev->dev, "%s: #### Timeout waiting for " in isci_remote_device_wait_for_resume_from_abort()
1403 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_wait_for_resume_from_abort()
1405 dev_dbg(&ihost->pdev->dev, "%s: resume wait done: %p\n", in isci_remote_device_wait_for_resume_from_abort()
1417 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_resume_from_abort()
1421 idev->abort_resume_cb = idev->rnc.user_callback; in isci_remote_device_resume_from_abort()
1422 idev->abort_resume_cbparam = idev->rnc.user_cookie; in isci_remote_device_resume_from_abort()
1423 set_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort()
1424 clear_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags); in isci_remote_device_resume_from_abort()
1425 destroyed = sci_remote_node_context_is_being_destroyed(&idev->rnc); in isci_remote_device_resume_from_abort()
1430 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_resume_from_abort()
1434 clear_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags); in isci_remote_device_resume_from_abort()
1440 * sci_remote_device_start() - This method will start the supplied remote
1455 struct sci_base_state_machine *sm = &idev->sm; in sci_remote_device_start()
1456 enum sci_remote_device_states state = sm->current_state_id; in sci_remote_device_start()
1478 struct isci_host *ihost = iport->isci_host; in isci_remote_device_construct()
1479 struct domain_device *dev = idev->domain_dev; in isci_remote_device_construct()
1482 if (dev->parent && dev_is_expander(dev->parent->dev_type)) in isci_remote_device_construct()
1488 dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n", in isci_remote_device_construct()
1498 dev_warn(&ihost->pdev->dev, "remote device start failed: %d\n", in isci_remote_device_construct()
1520 idev = &ihost->devices[i]; in isci_remote_device_alloc()
1521 if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) in isci_remote_device_alloc()
1526 dev_warn(&ihost->pdev->dev, "%s: failed\n", __func__); in isci_remote_device_alloc()
1529 if (WARN_ONCE(!list_empty(&idev->node), "found non-idle remote device\n")) in isci_remote_device_alloc()
1538 struct isci_host *ihost = idev->isci_port->isci_host; in isci_remote_device_release()
1540 idev->domain_dev = NULL; in isci_remote_device_release()
1541 idev->isci_port = NULL; in isci_remote_device_release()
1542 clear_bit(IDEV_START_PENDING, &idev->flags); in isci_remote_device_release()
1543 clear_bit(IDEV_STOP_PENDING, &idev->flags); in isci_remote_device_release()
1544 clear_bit(IDEV_IO_READY, &idev->flags); in isci_remote_device_release()
1545 clear_bit(IDEV_GONE, &idev->flags); in isci_remote_device_release()
1547 clear_bit(IDEV_ALLOCATED, &idev->flags); in isci_remote_device_release()
1548 wake_up(&ihost->eventq); in isci_remote_device_release()
1552 * isci_remote_device_stop() - This function is called internally to stop the
1564 dev_dbg(&ihost->pdev->dev, in isci_remote_device_stop()
1567 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_stop()
1568 idev->domain_dev->lldd_dev = NULL; /* disable new lookups */ in isci_remote_device_stop()
1569 set_bit(IDEV_GONE, &idev->flags); in isci_remote_device_stop()
1571 set_bit(IDEV_STOP_PENDING, &idev->flags); in isci_remote_device_stop()
1573 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_stop()
1575 /* Wait for the stop complete callback. */ in isci_remote_device_stop()
1577 /* nothing to wait for */; in isci_remote_device_stop()
1581 dev_dbg(&ihost->pdev->dev, in isci_remote_device_stop()
1588 * isci_remote_device_gone() - This function is called by libsas when a domain
1595 struct isci_remote_device *idev = dev->lldd_dev; in isci_remote_device_gone()
1597 dev_dbg(&ihost->pdev->dev, in isci_remote_device_gone()
1599 __func__, dev, idev, idev->isci_port); in isci_remote_device_gone()
1606 * isci_remote_device_found() - This function is called by libsas when a remote
1617 struct isci_port *isci_port = dev->port->lldd_port; in isci_remote_device_found()
1621 dev_dbg(&isci_host->pdev->dev, in isci_remote_device_found()
1625 return -ENODEV; in isci_remote_device_found()
1629 return -ENODEV; in isci_remote_device_found()
1631 kref_init(&isci_device->kref); in isci_remote_device_found()
1632 INIT_LIST_HEAD(&isci_device->node); in isci_remote_device_found()
1634 spin_lock_irq(&isci_host->scic_lock); in isci_remote_device_found()
1635 isci_device->domain_dev = dev; in isci_remote_device_found()
1636 isci_device->isci_port = isci_port; in isci_remote_device_found()
1637 list_add_tail(&isci_device->node, &isci_port->remote_dev_list); in isci_remote_device_found()
1639 set_bit(IDEV_START_PENDING, &isci_device->flags); in isci_remote_device_found()
1642 dev_dbg(&isci_host->pdev->dev, in isci_remote_device_found()
1648 dev->lldd_dev = isci_device; in isci_remote_device_found()
1651 spin_unlock_irq(&isci_host->scic_lock); in isci_remote_device_found()
1653 /* wait for the device ready callback. */ in isci_remote_device_found()
1656 return status == SCI_SUCCESS ? 0 : -ENODEV; in isci_remote_device_found()
1668 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_suspend_terminate()
1669 set_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags); in isci_remote_device_suspend_terminate()
1671 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_suspend_terminate()
1673 /* Terminate and wait for the completions. */ in isci_remote_device_suspend_terminate()
1676 dev_dbg(&ihost->pdev->dev, in isci_remote_device_suspend_terminate()
1688 return sci_remote_node_context_is_safe_to_abort(&idev->rnc); in isci_remote_device_is_safe_to_abort()
1704 spin_lock_irqsave(&ihost->scic_lock, flags); in isci_remote_device_reset_complete()
1706 spin_unlock_irqrestore(&ihost->scic_lock, flags); in isci_remote_device_reset_complete()
1715 if (dev_is_sata(idev->domain_dev)) { in isci_dev_set_hang_detection_timeout()
1718 &idev->flags)) in isci_dev_set_hang_detection_timeout()
1721 &idev->flags)) in isci_dev_set_hang_detection_timeout()
1724 sci_port_set_hang_detection_timeout(idev->owning_port, in isci_dev_set_hang_detection_timeout()