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()
168 * to its ready state. If the remote node context is already setup to
169 * transition to its final state then this function does nothing. none
177 if (sci_rnc->destination_state != RNC_DEST_FINAL) { in sci_remote_node_context_setup_to_resume()
178 sci_rnc->destination_state = dest_param; in sci_remote_node_context_setup_to_resume()
180 sci_rnc->user_callback = callback; in sci_remote_node_context_setup_to_resume()
181 sci_rnc->user_cookie = callback_parameter; in sci_remote_node_context_setup_to_resume()
193 sci_rnc->destination_state = RNC_DEST_FINAL; in sci_remote_node_context_setup_to_destroy()
194 sci_rnc->user_callback = callback; in sci_remote_node_context_setup_to_destroy()
195 sci_rnc->user_cookie = callback_parameter; in sci_remote_node_context_setup_to_destroy()
197 wake_up(&ihost->eventq); in sci_remote_node_context_setup_to_destroy()
207 if (rnc->user_callback != NULL) { in sci_remote_node_context_notify_user()
208 (*rnc->user_callback)(rnc->user_cookie); in sci_remote_node_context_notify_user()
210 rnc->user_callback = NULL; in sci_remote_node_context_notify_user()
211 rnc->user_cookie = NULL; in sci_remote_node_context_notify_user()
217 switch (rnc->destination_state) { in sci_remote_node_context_continue_state_transitions()
220 rnc->destination_state = RNC_DEST_READY; in sci_remote_node_context_continue_state_transitions()
223 sci_remote_node_context_resume(rnc, rnc->user_callback, in sci_remote_node_context_continue_state_transitions()
224 rnc->user_cookie); in sci_remote_node_context_continue_state_transitions()
227 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_continue_state_transitions()
236 struct domain_device *dev = idev->domain_dev; in sci_remote_node_context_validate_context_buffer()
237 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_validate_context_buffer()
239 rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); in sci_remote_node_context_validate_context_buffer()
241 rnc_buffer->ssp.is_valid = true; in sci_remote_node_context_validate_context_buffer()
243 if (dev_is_sata(dev) && dev->parent) { in sci_remote_node_context_validate_context_buffer()
248 if (!dev->parent) in sci_remote_node_context_validate_context_buffer()
249 sci_port_setup_transports(idev->owning_port, in sci_remote_node_context_validate_context_buffer()
250 sci_rnc->remote_node_index); in sci_remote_node_context_validate_context_buffer()
258 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_invalidate_context_buffer()
260 rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); in sci_remote_node_context_invalidate_context_buffer()
262 rnc_buffer->ssp.is_valid = false; in sci_remote_node_context_invalidate_context_buffer()
272 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_initial_state_enter()
274 /* Check to see if we have gotten back to the initial state because in sci_remote_node_context_initial_state_enter()
277 if (sm->previous_state_id == SCI_RNC_INVALIDATING) { in sci_remote_node_context_initial_state_enter()
278 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_initial_state_enter()
282 wake_up(&ihost->eventq); in sci_remote_node_context_initial_state_enter()
309 dev = idev->domain_dev; in sci_remote_node_context_resuming_state_enter()
317 if (dev_is_sata(dev) && !dev->parent) in sci_remote_node_context_resuming_state_enter()
318 sci_port_setup_transports(idev->owning_port, rnc->remote_node_index); in sci_remote_node_context_resuming_state_enter()
329 dest_select = rnc->destination_state; in sci_remote_node_context_ready_state_enter()
330 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_ready_state_enter()
335 rnc, rnc->suspend_reason, in sci_remote_node_context_ready_state_enter()
356 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_tx_rx_suspended_state_enter()
357 u32 new_count = rnc->suspend_count + 1; in sci_remote_node_context_tx_rx_suspended_state_enter()
360 rnc->suspend_count = 1; in sci_remote_node_context_tx_rx_suspended_state_enter()
362 rnc->suspend_count = new_count; in sci_remote_node_context_tx_rx_suspended_state_enter()
368 wake_up(&ihost->eventq); in sci_remote_node_context_tx_rx_suspended_state_enter()
379 if (dev_is_sata(idev->domain_dev)) in sci_remote_node_context_await_suspend_state_exit()
415 rnc->remote_node_index = remote_node_index; in sci_remote_node_context_construct()
416 rnc->destination_state = RNC_DEST_UNSPECIFIED; in sci_remote_node_context_construct()
418 sci_init_sm(&rnc->sm, sci_remote_node_context_state_table, SCI_RNC_INITIAL); in sci_remote_node_context_construct()
424 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_event_handler() local
427 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_event_handler()
428 switch (state) { in sci_remote_node_context_event_handler()
432 sci_change_state(&sci_rnc->sm, SCI_RNC_READY); in sci_remote_node_context_event_handler()
440 if (sci_rnc->destination_state == RNC_DEST_FINAL) in sci_remote_node_context_event_handler()
444 sci_change_state(&sci_rnc->sm, next_state); in sci_remote_node_context_event_handler()
453 "suspended by hardware while being " in sci_remote_node_context_event_handler()
463 sci_change_state(&sci_rnc->sm, SCI_RNC_READY); in sci_remote_node_context_event_handler()
472 "suspended by hardware while being resumed.\n", in sci_remote_node_context_event_handler()
483 sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); in sci_remote_node_context_event_handler()
484 sci_rnc->suspend_type = scu_get_event_type(event_code); in sci_remote_node_context_event_handler()
487 sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); in sci_remote_node_context_event_handler()
488 sci_rnc->suspend_type = scu_get_event_type(event_code); in sci_remote_node_context_event_handler()
505 if (sci_rnc->suspend_type == scu_get_event_type(event_code)) in sci_remote_node_context_event_handler()
506 sci_change_state(&sci_rnc->sm, next_state); in sci_remote_node_context_event_handler()
510 "%s: invalid state: %s\n", __func__, in sci_remote_node_context_event_handler()
511 rnc_state_name(state)); in sci_remote_node_context_event_handler()
518 "%s: code: %#x state: %s\n", __func__, event_code, in sci_remote_node_context_event_handler()
519 rnc_state_name(state)); in sci_remote_node_context_event_handler()
528 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_destruct() local
530 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_destruct()
531 switch (state) { in sci_remote_node_context_destruct()
541 sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING); in sci_remote_node_context_destruct()
548 "%s: invalid state: %s\n", __func__, in sci_remote_node_context_destruct()
549 rnc_state_name(state)); in sci_remote_node_context_destruct()
551 * can not fail since it is either in the initial/destroyed state or is in sci_remote_node_context_destruct()
557 "%s: invalid state %s\n", __func__, in sci_remote_node_context_destruct()
558 rnc_state_name(state)); in sci_remote_node_context_destruct()
568 enum scis_sds_remote_node_context_states state in sci_remote_node_context_suspend() local
569 = sci_rnc->sm.current_state_id; in sci_remote_node_context_suspend()
576 "%s: current state %s, current suspend_type %x dest state %d," in sci_remote_node_context_suspend()
578 __func__, rnc_state_name(state), sci_rnc->suspend_type, in sci_remote_node_context_suspend()
579 sci_rnc->destination_state, suspend_reason, in sci_remote_node_context_suspend()
582 /* Disable automatic state continuations if explicitly suspending. */ in sci_remote_node_context_suspend()
584 (sci_rnc->destination_state == RNC_DEST_FINAL)) in sci_remote_node_context_suspend()
585 dest_param = sci_rnc->destination_state; in sci_remote_node_context_suspend()
587 switch (state) { in sci_remote_node_context_suspend()
591 if (sci_rnc->destination_state == RNC_DEST_FINAL) { in sci_remote_node_context_suspend()
601 /* Set the destination state to AWAIT - this signals the in sci_remote_node_context_suspend()
602 * entry into the SCI_RNC_READY state that a suspension in sci_remote_node_context_suspend()
605 if (sci_rnc->destination_state != RNC_DEST_FINAL) in sci_remote_node_context_suspend()
606 sci_rnc->destination_state = RNC_DEST_SUSPENDED; in sci_remote_node_context_suspend()
607 sci_rnc->suspend_type = suspend_type; in sci_remote_node_context_suspend()
608 sci_rnc->suspend_reason = suspend_reason; in sci_remote_node_context_suspend()
620 if ((sci_rnc->suspend_type == SCU_EVENT_TL_RNC_SUSPEND_TX_RX) in sci_remote_node_context_suspend()
621 || (suspend_type == sci_rnc->suspend_type)) in sci_remote_node_context_suspend()
626 "%s: invalid state %s\n", __func__, in sci_remote_node_context_suspend()
627 rnc_state_name(state)); in sci_remote_node_context_suspend()
630 sci_rnc->destination_state = dest_param; in sci_remote_node_context_suspend()
631 sci_rnc->suspend_type = suspend_type; in sci_remote_node_context_suspend()
632 sci_rnc->suspend_reason = suspend_reason; in sci_remote_node_context_suspend()
634 if (status == SCI_SUCCESS) { /* Already in the destination state? */ in sci_remote_node_context_suspend()
635 struct isci_host *ihost = idev->owning_port->owning_controller; in sci_remote_node_context_suspend()
637 wake_up_all(&ihost->eventq); /* Let observers look. */ in sci_remote_node_context_suspend()
649 if (state != SCI_RNC_AWAIT_SUSPENSION) in sci_remote_node_context_suspend()
650 sci_change_state(&sci_rnc->sm, SCI_RNC_AWAIT_SUSPENSION); in sci_remote_node_context_suspend()
659 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_resume() local
662 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_resume()
664 "%s: state %s, cb_fn = %p, cb_p = %p; dest_state = %d; " in sci_remote_node_context_resume()
666 __func__, rnc_state_name(state), cb_fn, cb_p, in sci_remote_node_context_resume()
667 sci_rnc->destination_state, in sci_remote_node_context_resume()
668 test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags) in sci_remote_node_context_resume()
671 switch (state) { in sci_remote_node_context_resume()
673 if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) in sci_remote_node_context_resume()
678 if (!test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags)) { in sci_remote_node_context_resume()
680 sci_change_state(&sci_rnc->sm, SCI_RNC_POSTING); in sci_remote_node_context_resume()
690 switch (sci_rnc->destination_state) { in sci_remote_node_context_resume()
711 struct domain_device *dev = idev->domain_dev; in sci_remote_node_context_resume()
720 if (!test_bit(IDEV_ABORT_PATH_ACTIVE, &idev->flags)) { in sci_remote_node_context_resume()
721 if ((dev_is_sata(dev) && dev->parent) || in sci_remote_node_context_resume()
722 (sci_rnc->destination_state == RNC_DEST_FINAL)) in sci_remote_node_context_resume()
723 sci_change_state(&sci_rnc->sm, in sci_remote_node_context_resume()
726 sci_change_state(&sci_rnc->sm, in sci_remote_node_context_resume()
738 "%s: invalid state %s\n", __func__, in sci_remote_node_context_resume()
739 rnc_state_name(state)); in sci_remote_node_context_resume()
747 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_start_io() local
749 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_start_io()
751 switch (state) { in sci_remote_node_context_start_io()
758 "%s: invalid state %s\n", __func__, in sci_remote_node_context_start_io()
759 rnc_state_name(state)); in sci_remote_node_context_start_io()
763 "%s: invalid state %s\n", __func__, in sci_remote_node_context_start_io()
764 rnc_state_name(state)); in sci_remote_node_context_start_io()
786 enum scis_sds_remote_node_context_states state; in sci_remote_node_context_is_safe_to_abort() local
788 state = sci_rnc->sm.current_state_id; in sci_remote_node_context_is_safe_to_abort()
789 switch (state) { in sci_remote_node_context_is_safe_to_abort()
802 "%s: invalid state %d\n", __func__, state); in sci_remote_node_context_is_safe_to_abort()