67 static const char *
const strings[] =
RNC_STATES;
69 return strings[
state];
84 u32 current_state = sci_rnc->
sm.current_state_id;
86 if (current_state == SCI_RNC_READY) {
95 u32 current_state = sci_rnc->
sm.current_state_id;
97 if (current_state == SCI_RNC_TX_RX_SUSPENDED)
121 rnc = sci_rnc_by_id(ihost, rni);
124 * sci_remote_device_node_count(idev));
126 rnc->
ssp.remote_node_index = rni;
128 rnc->
ssp.logical_port_index = idev->
owning_port->physical_port_index;
135 rnc->
ssp.nexus_loss_timer_enable =
true;
136 rnc->
ssp.check_bit =
false;
137 rnc->
ssp.is_valid =
false;
138 rnc->
ssp.is_remote_node_context =
true;
139 rnc->
ssp.function_number = 0;
141 rnc->
ssp.arbitration_wait_time = 0;
143 if (dev_is_sata(dev)) {
144 rnc->
ssp.connection_occupancy_timeout =
146 rnc->
ssp.connection_inactivity_timeout =
149 rnc->
ssp.connection_occupancy_timeout =
151 rnc->
ssp.connection_inactivity_timeout =
155 rnc->
ssp.initial_arbitration_wait_time = 0;
159 rnc->
ssp.oaf_features = 0;
160 rnc->
ssp.oaf_source_zone_group = 0;
161 rnc->
ssp.oaf_more_compatibility_features = 0;
173 static void sci_remote_node_context_setup_to_resume(
176 void *callback_parameter,
181 if (callback !=
NULL) {
188 static void sci_remote_node_context_setup_to_destroy(
191 void *callback_parameter)
193 struct isci_host *ihost = idev_to_ihost(rnc_to_dev(sci_rnc));
208 static void sci_remote_node_context_notify_user(
245 rnc_buffer->
ssp.is_valid =
true;
247 if (dev_is_sata(dev) && dev->
parent) {
266 rnc_buffer->
ssp.is_valid =
false;
283 sci_remote_node_context_notify_user(rnc);
294 sci_remote_node_context_validate_context_buffer(sci_rnc);
303 sci_remote_node_context_invalidate_context_buffer(rnc);
312 idev = rnc_to_dev(rnc);
321 if (dev_is_sata(dev) && !dev->
parent)
346 sci_remote_node_context_notify_user(rnc);
353 sci_remote_node_context_continue_state_transitions(rnc);
373 sci_remote_node_context_continue_state_transitions(rnc);
376 static void sci_remote_node_context_await_suspend_state_exit(
387 static const struct sci_base_state sci_remote_node_context_state_table[] = {
388 [SCI_RNC_INITIAL] = {
389 .enter_state = sci_remote_node_context_initial_state_enter,
391 [SCI_RNC_POSTING] = {
392 .enter_state = sci_remote_node_context_posting_state_enter,
394 [SCI_RNC_INVALIDATING] = {
395 .enter_state = sci_remote_node_context_invalidating_state_enter,
397 [SCI_RNC_RESUMING] = {
398 .enter_state = sci_remote_node_context_resuming_state_enter,
401 .enter_state = sci_remote_node_context_ready_state_enter,
403 [SCI_RNC_TX_SUSPENDED] = {
404 .enter_state = sci_remote_node_context_tx_suspended_state_enter,
406 [SCI_RNC_TX_RX_SUSPENDED] = {
407 .enter_state = sci_remote_node_context_tx_rx_suspended_state_enter,
409 [SCI_RNC_AWAIT_SUSPENSION] = {
410 .exit_state = sci_remote_node_context_await_suspend_state_exit,
415 u16 remote_node_index)
422 sci_init_sm(&rnc->
sm, sci_remote_node_context_state_table, SCI_RNC_INITIAL);
428 enum scis_sds_remote_node_context_states
state;
431 state = sci_rnc->
sm.current_state_id;
433 case SCI_RNC_POSTING:
442 case SCI_RNC_INVALIDATING:
445 next_state = SCI_RNC_INITIAL;
447 next_state = SCI_RNC_POSTING;
455 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
456 "%s: SCIC Remote Node Context 0x%p was "
457 "suspeneded by hardware while being "
458 "invalidated.\n", __func__, sci_rnc);
465 case SCI_RNC_RESUMING:
474 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
475 "%s: SCIC Remote Node Context 0x%p was "
476 "suspeneded by hardware while being resumed.\n",
498 case SCI_RNC_AWAIT_SUSPENSION:
501 next_state = SCI_RNC_TX_SUSPENDED;
504 next_state = SCI_RNC_TX_RX_SUSPENDED;
513 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
514 "%s: invalid state: %s\n", __func__,
521 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
522 "%s: code: %#x state: %s\n", __func__, event_code,
532 enum scis_sds_remote_node_context_states
state;
534 state = sci_rnc->
sm.current_state_id;
536 case SCI_RNC_INVALIDATING:
537 sci_remote_node_context_setup_to_destroy(sci_rnc, cb_fn, cb_p);
539 case SCI_RNC_POSTING:
540 case SCI_RNC_RESUMING:
542 case SCI_RNC_TX_SUSPENDED:
543 case SCI_RNC_TX_RX_SUSPENDED:
544 sci_remote_node_context_setup_to_destroy(sci_rnc, cb_fn, cb_p);
547 case SCI_RNC_AWAIT_SUSPENSION:
548 sci_remote_node_context_setup_to_destroy(sci_rnc, cb_fn, cb_p);
550 case SCI_RNC_INITIAL:
551 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
552 "%s: invalid state: %s\n", __func__,
560 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
561 "%s: invalid state %s\n", __func__,
572 enum scis_sds_remote_node_context_states
state
573 = sci_rnc->
sm.current_state_id;
580 "%s: current state %s, current suspend_type %x dest state %d,"
581 " arg suspend_reason %d, arg suspend_type %x",
594 case SCI_RNC_INVALIDATING:
597 "%s: already destroying %p\n",
602 case SCI_RNC_RESUMING:
604 case SCI_RNC_POSTING:
615 case SCI_RNC_TX_SUSPENDED:
619 case SCI_RNC_TX_RX_SUSPENDED:
623 case SCI_RNC_AWAIT_SUSPENSION:
629 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
630 "%s: invalid state %s\n", __func__,
653 if (state != SCI_RNC_AWAIT_SUSPENSION)
663 enum scis_sds_remote_node_context_states
state;
666 state = sci_rnc->
sm.current_state_id;
668 "%s: state %s, cb_fn = %p, cb_p = %p; dest_state = %d; "
669 "dev resume path %s\n",
673 ?
"<abort active>" :
"<normal>");
676 case SCI_RNC_INITIAL:
680 sci_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p,
683 sci_remote_node_context_construct_buffer(sci_rnc);
688 case SCI_RNC_POSTING:
689 case SCI_RNC_INVALIDATING:
690 case SCI_RNC_RESUMING:
700 sci_remote_node_context_setup_to_resume(
701 sci_rnc, cb_fn, cb_p,
705 sci_remote_node_context_setup_to_resume(
706 sci_rnc, cb_fn, cb_p,
712 case SCI_RNC_TX_SUSPENDED:
713 case SCI_RNC_TX_RX_SUSPENDED:
721 sci_remote_node_context_setup_to_resume(
725 if ((dev_is_sata(dev) && dev->
parent) ||
728 SCI_RNC_INVALIDATING);
736 case SCI_RNC_AWAIT_SUSPENSION:
737 sci_remote_node_context_setup_to_resume(
741 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
742 "%s: invalid state %s\n", __func__,
751 enum scis_sds_remote_node_context_states
state;
753 state = sci_rnc->
sm.current_state_id;
758 case SCI_RNC_TX_SUSPENDED:
759 case SCI_RNC_TX_RX_SUSPENDED:
760 case SCI_RNC_AWAIT_SUSPENSION:
761 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
762 "%s: invalid state %s\n", __func__,
766 dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)),
767 "%s: invalid state %s\n", __func__,
782 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
783 "%s: resume failed: %d\n", __func__, status);
790 enum scis_sds_remote_node_context_states
state;
792 state = sci_rnc->
sm.current_state_id;
794 case SCI_RNC_INVALIDATING:
795 case SCI_RNC_TX_RX_SUSPENDED:
797 case SCI_RNC_POSTING:
798 case SCI_RNC_RESUMING:
800 case SCI_RNC_TX_SUSPENDED:
801 case SCI_RNC_AWAIT_SUSPENSION:
802 case SCI_RNC_INITIAL:
805 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
806 "%s: invalid state %d\n", __func__, state);