Lines Matching +full:retain +full:- +full:state +full:- +full:suspended
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.
33 * * Redistributions of source code must retain the above copyright
65 const char *rnc_state_name(enum scis_sds_remote_node_context_states state) in rnc_state_name() argument
69 if (state >= ARRAY_SIZE(strings)) in rnc_state_name()
72 return strings[state]; in rnc_state_name()
78 * @sci_rnc: The state of the remote node context object to check.
80 * This method will return true if the remote node context is in a READY state
82 * the ready state. false if the remote node context is not in the ready state.
87 u32 current_state = sci_rnc->sm.current_state_id; in sci_remote_node_context_is_ready()
98 u32 current_state = sci_rnc->sm.current_state_id; in sci_remote_node_context_is_suspended()
107 if (id < ihost->remote_node_entries && in sci_rnc_by_id()
108 ihost->device_table[id]) in sci_rnc_by_id()
109 return &ihost->remote_node_context_table[id]; in sci_rnc_by_id()
117 struct domain_device *dev = idev->domain_dev; in sci_remote_node_context_construct_buffer()
118 int rni = sci_rnc->remote_node_index; in sci_remote_node_context_construct_buffer()
123 ihost = idev->owning_port->owning_controller; in sci_remote_node_context_construct_buffer()
129 rnc->ssp.remote_node_index = rni; in sci_remote_node_context_construct_buffer()
130 rnc->ssp.remote_node_port_width = idev->device_port_width; in sci_remote_node_context_construct_buffer()
131 rnc->ssp.logical_port_index = idev->owning_port->physical_port_index; in sci_remote_node_context_construct_buffer()
134 sas_addr = cpu_to_le64(SAS_ADDR(dev->sas_addr)); in sci_remote_node_context_construct_buffer()
135 rnc->ssp.remote_sas_address_hi = upper_32_bits(sas_addr); in sci_remote_node_context_construct_buffer()
136 rnc->ssp.remote_sas_address_lo = lower_32_bits(sas_addr); in sci_remote_node_context_construct_buffer()
138 rnc->ssp.nexus_loss_timer_enable = true; in sci_remote_node_context_construct_buffer()
139 rnc->ssp.check_bit = false; in sci_remote_node_context_construct_buffer()
140 rnc->ssp.is_valid = false; in sci_remote_node_context_construct_buffer()
141 rnc->ssp.is_remote_node_context = true; in sci_remote_node_context_construct_buffer()
142 rnc->ssp.function_number = 0; in sci_remote_node_context_construct_buffer()
144 rnc->ssp.arbitration_wait_time = 0; in sci_remote_node_context_construct_buffer()
147 rnc->ssp.connection_occupancy_timeout = in sci_remote_node_context_construct_buffer()
148 ihost->user_parameters.stp_max_occupancy_timeout; in sci_remote_node_context_construct_buffer()
149 rnc->ssp.connection_inactivity_timeout = in sci_remote_node_context_construct_buffer()
150 ihost->user_parameters.stp_inactivity_timeout; in sci_remote_node_context_construct_buffer()
152 rnc->ssp.connection_occupancy_timeout = in sci_remote_node_context_construct_buffer()
153 ihost->user_parameters.ssp_max_occupancy_timeout; in sci_remote_node_context_construct_buffer()
154 rnc->ssp.connection_inactivity_timeout = in sci_remote_node_context_construct_buffer()
155 ihost->user_parameters.ssp_inactivity_timeout; in sci_remote_node_context_construct_buffer()
158 rnc->ssp.initial_arbitration_wait_time = 0; in sci_remote_node_context_construct_buffer()
161 rnc->ssp.oaf_connection_rate = idev->connection_rate; in sci_remote_node_context_construct_buffer()
162 rnc->ssp.oaf_features = 0; in sci_remote_node_context_construct_buffer()
163 rnc->ssp.oaf_source_zone_group = 0; in sci_remote_node_context_construct_buffer()
164 rnc->ssp.oaf_more_compatibility_features = 0; in sci_remote_node_context_construct_buffer()
173 * to its ready state. If the remote node context is already setup to
174 * transition to its final state then this function does nothing. none
182 if (sci_rnc->destination_state != RNC_DEST_FINAL) { in sci_remote_node_context_setup_to_resume()
183 sci_rnc->destination_state = dest_param; in sci_remote_node_context_setup_to_resume()
185 sci_rnc->user_callback = callback; in sci_remote_node_context_setup_to_resume()
186 sci_rnc->user_cookie = callback_parameter; in sci_remote_node_context_setup_to_resume()
198 sci_rnc->destination_state = RNC_DEST_FINAL; in sci_remote_node_context_setup_to_destroy()
199 sci_rnc->user_callback = callback; in sci_remote_node_context_setup_to_destroy()
200 sci_rnc->user_cookie = callback_parameter; in sci_remote_node_context_setup_to_destroy()
202 wake_up(&ihost->eventq); in sci_remote_node_context_setup_to_destroy()
214 if (rnc->user_callback != NULL) { in sci_remote_node_context_notify_user()
215 (*rnc->user_callback)(rnc->user_cookie); in sci_remote_node_context_notify_user()
217 rnc->user_callback = NULL; in sci_remote_node_context_notify_user()
218 rnc->user_cookie = NULL; in sci_remote_node_context_notify_user()
224 switch (rnc->destination_state) { in sci_remote_node_context_continue_state_transitions()
227 rnc->destination_state = RNC_DEST_READY; in sci_remote_node_context_continue_state_transitions()
230 sci_remote_node_context_resume(rnc, rnc->user_callback, in sci_remote_node_context_continue_state_transitions()
231 rnc->user_cookie); in sci_remote_node_context_continue_state_transitions()
234 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_continue_state_transitions()
243 struct domain_device *dev = idev->domain_dev; in sci_remote_node_context_validate_context_buffer()
244 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_validate_context_buffer()
246 rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); in sci_remote_node_context_validate_context_buffer()
248 rnc_buffer->ssp.is_valid = true; in sci_remote_node_context_validate_context_buffer()
250 if (dev_is_sata(dev) && dev->parent) { in sci_remote_node_context_validate_context_buffer()
255 if (!dev->parent) in sci_remote_node_context_validate_context_buffer()
256 sci_port_setup_transports(idev->owning_port, in sci_remote_node_context_validate_context_buffer()
257 sci_rnc->remote_node_index); in sci_remote_node_context_validate_context_buffer()
265 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_invalidate_context_buffer()
267 rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); in sci_remote_node_context_invalidate_context_buffer()
269 rnc_buffer->ssp.is_valid = false; in sci_remote_node_context_invalidate_context_buffer()
279 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_initial_state_enter()
281 /* Check to see if we have gotten back to the initial state because in sci_remote_node_context_initial_state_enter()
284 if (sm->previous_state_id == SCI_RNC_INVALIDATING) { in sci_remote_node_context_initial_state_enter()
285 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_initial_state_enter()
289 wake_up(&ihost->eventq); in sci_remote_node_context_initial_state_enter()
316 dev = idev->domain_dev; in sci_remote_node_context_resuming_state_enter()
324 if (dev_is_sata(dev) && !dev->parent) in sci_remote_node_context_resuming_state_enter()
325 sci_port_setup_transports(idev->owning_port, rnc->remote_node_index); in sci_remote_node_context_resuming_state_enter()
336 dest_select = rnc->destination_state; in sci_remote_node_context_ready_state_enter()
337 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_ready_state_enter()
342 rnc, rnc->suspend_reason, in sci_remote_node_context_ready_state_enter()
363 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_tx_rx_suspended_state_enter()
364 u32 new_count = rnc->suspend_count + 1; in sci_remote_node_context_tx_rx_suspended_state_enter()
367 rnc->suspend_count = 1; in sci_remote_node_context_tx_rx_suspended_state_enter()
369 rnc->suspend_count = new_count; in sci_remote_node_context_tx_rx_suspended_state_enter()
375 wake_up(&ihost->eventq); in sci_remote_node_context_tx_rx_suspended_state_enter()
386 if (dev_is_sata(idev->domain_dev)) in sci_remote_node_context_await_suspend_state_exit()
422 rnc->remote_node_index = remote_node_index; in sci_remote_node_context_construct()
423 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_construct()
425 sci_init_sm(&rnc->sm, sci_remote_node_context_state_table, SCI_RNC_INITIAL); in sci_remote_node_context_construct()
431 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_event_handler() local
434 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_event_handler()
435 switch (state) { in sci_remote_node_context_event_handler()
439 sci_change_state(&sci_rnc->sm, SCI_RNC_READY); in sci_remote_node_context_event_handler()
447 if (sci_rnc->destination_state == RNC_DEST_FINAL) in sci_remote_node_context_event_handler()
451 sci_change_state(&sci_rnc->sm, next_state); in sci_remote_node_context_event_handler()
460 "suspended by hardware while being " in sci_remote_node_context_event_handler()
470 sci_change_state(&sci_rnc->sm, SCI_RNC_READY); in sci_remote_node_context_event_handler()
479 "suspended by hardware while being resumed.\n", in sci_remote_node_context_event_handler()
490 sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); in sci_remote_node_context_event_handler()
491 sci_rnc->suspend_type = scu_get_event_type(event_code); in sci_remote_node_context_event_handler()
494 sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); in sci_remote_node_context_event_handler()
495 sci_rnc->suspend_type = scu_get_event_type(event_code); in sci_remote_node_context_event_handler()
512 if (sci_rnc->suspend_type == scu_get_event_type(event_code)) in sci_remote_node_context_event_handler()
513 sci_change_state(&sci_rnc->sm, next_state); in sci_remote_node_context_event_handler()
517 "%s: invalid state: %s\n", __func__, in sci_remote_node_context_event_handler()
518 rnc_state_name(state)); in sci_remote_node_context_event_handler()
525 "%s: code: %#x state: %s\n", __func__, event_code, in sci_remote_node_context_event_handler()
526 rnc_state_name(state)); in sci_remote_node_context_event_handler()
535 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_destruct() local
537 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_destruct()
538 switch (state) { in sci_remote_node_context_destruct()
548 sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING); in sci_remote_node_context_destruct()
555 "%s: invalid state: %s\n", __func__, in sci_remote_node_context_destruct()
556 rnc_state_name(state)); in sci_remote_node_context_destruct()
558 * can not fail since it is either in the initial/destroyed state or is in sci_remote_node_context_destruct()
564 "%s: invalid state %s\n", __func__, in sci_remote_node_context_destruct()
565 rnc_state_name(state)); in sci_remote_node_context_destruct()
575 enum scis_sds_remote_node_context_states state in sci_remote_node_context_suspend() local
576 = sci_rnc->sm.current_state_id; in sci_remote_node_context_suspend()
583 "%s: current state %s, current suspend_type %x dest state %d," in sci_remote_node_context_suspend()
585 __func__, rnc_state_name(state), sci_rnc->suspend_type, in sci_remote_node_context_suspend()
586 sci_rnc->destination_state, suspend_reason, in sci_remote_node_context_suspend()
589 /* Disable automatic state continuations if explicitly suspending. */ in sci_remote_node_context_suspend()
591 (sci_rnc->destination_state == RNC_DEST_FINAL)) in sci_remote_node_context_suspend()
592 dest_param = sci_rnc->destination_state; in sci_remote_node_context_suspend()
594 switch (state) { in sci_remote_node_context_suspend()
598 if (sci_rnc->destination_state == RNC_DEST_FINAL) { in sci_remote_node_context_suspend()
608 /* Set the destination state to AWAIT - this signals the in sci_remote_node_context_suspend()
609 * entry into the SCI_RNC_READY state that a suspension in sci_remote_node_context_suspend()
612 if (sci_rnc->destination_state != RNC_DEST_FINAL) in sci_remote_node_context_suspend()
613 sci_rnc->destination_state = RNC_DEST_SUSPENDED; in sci_remote_node_context_suspend()
614 sci_rnc->suspend_type = suspend_type; in sci_remote_node_context_suspend()
615 sci_rnc->suspend_reason = suspend_reason; in sci_remote_node_context_suspend()
627 if ((sci_rnc->suspend_type == SCU_EVENT_TL_RNC_SUSPEND_TX_RX) in sci_remote_node_context_suspend()
628 || (suspend_type == sci_rnc->suspend_type)) in sci_remote_node_context_suspend()
633 "%s: invalid state %s\n", __func__, in sci_remote_node_context_suspend()
634 rnc_state_name(state)); in sci_remote_node_context_suspend()
637 sci_rnc->destination_state = dest_param; in sci_remote_node_context_suspend()
638 sci_rnc->suspend_type = suspend_type; in sci_remote_node_context_suspend()
639 sci_rnc->suspend_reason = suspend_reason; in sci_remote_node_context_suspend()
641 if (status == SCI_SUCCESS) { /* Already in the destination state? */ in sci_remote_node_context_suspend()
642 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_suspend()
644 wake_up_all(&ihost->eventq); /* Let observers look. */ in sci_remote_node_context_suspend()
656 if (state != SCI_RNC_AWAIT_SUSPENSION) in sci_remote_node_context_suspend()
657 sci_change_state(&sci_rnc->sm, SCI_RNC_AWAIT_SUSPENSION); in sci_remote_node_context_suspend()
666 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_resume() local
669 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_resume()
671 "%s: state %s, cb_fn = %p, cb_p = %p; dest_state = %d; " in sci_remote_node_context_resume()
673 __func__, rnc_state_name(state), cb_fn, cb_p, in sci_remote_node_context_resume()
674 sci_rnc->destination_state, in sci_remote_node_context_resume()
675 test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags) in sci_remote_node_context_resume()
678 switch (state) { in sci_remote_node_context_resume()
680 if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) in sci_remote_node_context_resume()
685 if (!test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags)) { in sci_remote_node_context_resume()
687 sci_change_state(&sci_rnc->sm, SCI_RNC_POSTING); in sci_remote_node_context_resume()
697 switch (sci_rnc->destination_state) { in sci_remote_node_context_resume()
718 struct domain_device *dev = idev->domain_dev; in sci_remote_node_context_resume()
727 if (!test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags)) { in sci_remote_node_context_resume()
728 if ((dev_is_sata(dev) && dev->parent) || in sci_remote_node_context_resume()
729 (sci_rnc->destination_state == RNC_DEST_FINAL)) in sci_remote_node_context_resume()
730 sci_change_state(&sci_rnc->sm, in sci_remote_node_context_resume()
733 sci_change_state(&sci_rnc->sm, in sci_remote_node_context_resume()
745 "%s: invalid state %s\n", __func__, in sci_remote_node_context_resume()
746 rnc_state_name(state)); in sci_remote_node_context_resume()
754 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_start_io() local
756 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_start_io()
758 switch (state) { in sci_remote_node_context_start_io()
765 "%s: invalid state %s\n", __func__, in sci_remote_node_context_start_io()
766 rnc_state_name(state)); in sci_remote_node_context_start_io()
770 "%s: invalid state %s\n", __func__, in sci_remote_node_context_start_io()
771 rnc_state_name(state)); in sci_remote_node_context_start_io()
793 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_is_safe_to_abort() local
795 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_is_safe_to_abort()
796 switch (state) { in sci_remote_node_context_is_safe_to_abort()
809 "%s: invalid state %d\n", __func__, state); in sci_remote_node_context_is_safe_to_abort()