aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/port.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/isci/port.c')
-rw-r--r--drivers/scsi/isci/port.c89
1 files changed, 40 insertions, 49 deletions
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index df37b1bf7d11..c434d5a0effa 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -365,11 +365,11 @@ static void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *i
365 "%s: isci_port = %p\n", __func__, isci_port); 365 "%s: isci_port = %p\n", __func__, isci_port);
366} 366}
367 367
368static void isci_port_stop_complete(struct scic_sds_controller *scic, 368static void isci_port_stop_complete(struct isci_host *ihost,
369 struct isci_port *iport, 369 struct isci_port *iport,
370 enum sci_status completion_status) 370 enum sci_status completion_status)
371{ 371{
372 dev_dbg(&scic_to_ihost(scic)->pdev->dev, "Port stop complete\n"); 372 dev_dbg(&ihost->pdev->dev, "Port stop complete\n");
373} 373}
374 374
375/** 375/**
@@ -541,8 +541,7 @@ static enum sci_status scic_sds_port_clear_phy(struct isci_port *iport,
541 /* Make sure that this phy is part of this port */ 541 /* Make sure that this phy is part of this port */
542 if (iport->phy_table[iphy->phy_index] == iphy && 542 if (iport->phy_table[iphy->phy_index] == iphy &&
543 phy_get_non_dummy_port(iphy) == iport) { 543 phy_get_non_dummy_port(iphy) == iport) {
544 struct scic_sds_controller *scic = iport->owning_controller; 544 struct isci_host *ihost = iport->owning_controller;
545 struct isci_host *ihost = scic_to_ihost(scic);
546 545
547 /* Yep it is assigned to this port so remove it */ 546 /* Yep it is assigned to this port so remove it */
548 scic_sds_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS]); 547 scic_sds_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS]);
@@ -654,10 +653,10 @@ static void scic_sds_port_construct_dummy_rnc(struct isci_port *iport, u16 rni)
654 */ 653 */
655static void scic_sds_port_construct_dummy_task(struct isci_port *iport, u16 tag) 654static void scic_sds_port_construct_dummy_task(struct isci_port *iport, u16 tag)
656{ 655{
657 struct scic_sds_controller *scic = iport->owning_controller; 656 struct isci_host *ihost = iport->owning_controller;
658 struct scu_task_context *task_context; 657 struct scu_task_context *task_context;
659 658
660 task_context = &scic->task_context_table[ISCI_TAG_TCI(tag)]; 659 task_context = &ihost->task_context_table[ISCI_TAG_TCI(tag)];
661 memset(task_context, 0, sizeof(struct scu_task_context)); 660 memset(task_context, 0, sizeof(struct scu_task_context));
662 661
663 task_context->initiator_request = 1; 662 task_context->initiator_request = 1;
@@ -674,13 +673,13 @@ static void scic_sds_port_construct_dummy_task(struct isci_port *iport, u16 tag)
674 673
675static void scic_sds_port_destroy_dummy_resources(struct isci_port *iport) 674static void scic_sds_port_destroy_dummy_resources(struct isci_port *iport)
676{ 675{
677 struct scic_sds_controller *scic = iport->owning_controller; 676 struct isci_host *ihost = iport->owning_controller;
678 677
679 if (iport->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG) 678 if (iport->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG)
680 isci_free_tag(scic_to_ihost(scic), iport->reserved_tag); 679 isci_free_tag(ihost, iport->reserved_tag);
681 680
682 if (iport->reserved_rni != SCU_DUMMY_INDEX) 681 if (iport->reserved_rni != SCU_DUMMY_INDEX)
683 scic_sds_remote_node_table_release_remote_node_index(&scic->available_remote_nodes, 682 scic_sds_remote_node_table_release_remote_node_index(&ihost->available_remote_nodes,
684 1, iport->reserved_rni); 683 1, iport->reserved_rni);
685 684
686 iport->reserved_rni = SCU_DUMMY_INDEX; 685 iport->reserved_rni = SCU_DUMMY_INDEX;
@@ -749,15 +748,14 @@ static void scic_sds_port_activate_phy(struct isci_port *iport,
749 struct isci_phy *iphy, 748 struct isci_phy *iphy,
750 bool do_notify_user) 749 bool do_notify_user)
751{ 750{
752 struct scic_sds_controller *scic = iport->owning_controller; 751 struct isci_host *ihost = iport->owning_controller;
753 struct isci_host *ihost = scic_to_ihost(scic);
754 752
755 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) 753 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA)
756 scic_sds_phy_resume(iphy); 754 scic_sds_phy_resume(iphy);
757 755
758 iport->active_phy_mask |= 1 << iphy->phy_index; 756 iport->active_phy_mask |= 1 << iphy->phy_index;
759 757
760 scic_sds_controller_clear_invalid_phy(scic, iphy); 758 scic_sds_controller_clear_invalid_phy(ihost, iphy);
761 759
762 if (do_notify_user == true) 760 if (do_notify_user == true)
763 isci_port_link_up(ihost, iport, iphy); 761 isci_port_link_up(ihost, iport, iphy);
@@ -767,8 +765,7 @@ void scic_sds_port_deactivate_phy(struct isci_port *iport,
767 struct isci_phy *iphy, 765 struct isci_phy *iphy,
768 bool do_notify_user) 766 bool do_notify_user)
769{ 767{
770 struct scic_sds_controller *scic = scic_sds_port_get_controller(iport); 768 struct isci_host *ihost = scic_sds_port_get_controller(iport);
771 struct isci_host *ihost = scic_to_ihost(scic);
772 769
773 iport->active_phy_mask &= ~(1 << iphy->phy_index); 770 iport->active_phy_mask &= ~(1 << iphy->phy_index);
774 771
@@ -793,16 +790,16 @@ void scic_sds_port_deactivate_phy(struct isci_port *iport,
793static void scic_sds_port_invalid_link_up(struct isci_port *iport, 790static void scic_sds_port_invalid_link_up(struct isci_port *iport,
794 struct isci_phy *iphy) 791 struct isci_phy *iphy)
795{ 792{
796 struct scic_sds_controller *scic = iport->owning_controller; 793 struct isci_host *ihost = iport->owning_controller;
797 794
798 /* 795 /*
799 * Check to see if we have alreay reported this link as bad and if 796 * Check to see if we have alreay reported this link as bad and if
800 * not go ahead and tell the SCI_USER that we have discovered an 797 * not go ahead and tell the SCI_USER that we have discovered an
801 * invalid link. 798 * invalid link.
802 */ 799 */
803 if ((scic->invalid_phy_mask & (1 << iphy->phy_index)) == 0) { 800 if ((ihost->invalid_phy_mask & (1 << iphy->phy_index)) == 0) {
804 scic_sds_controller_set_invalid_phy(scic, iphy); 801 scic_sds_controller_set_invalid_phy(ihost, iphy);
805 dev_warn(&scic_to_ihost(scic)->pdev->dev, "Invalid link up!\n"); 802 dev_warn(&ihost->pdev->dev, "Invalid link up!\n");
806 } 803 }
807} 804}
808 805
@@ -931,7 +928,7 @@ static void port_timeout(unsigned long data)
931{ 928{
932 struct sci_timer *tmr = (struct sci_timer *)data; 929 struct sci_timer *tmr = (struct sci_timer *)data;
933 struct isci_port *iport = container_of(tmr, typeof(*iport), timer); 930 struct isci_port *iport = container_of(tmr, typeof(*iport), timer);
934 struct isci_host *ihost = scic_to_ihost(iport->owning_controller); 931 struct isci_host *ihost = iport->owning_controller;
935 unsigned long flags; 932 unsigned long flags;
936 u32 current_state; 933 u32 current_state;
937 934
@@ -1041,19 +1038,19 @@ static void scic_sds_port_suspend_port_task_scheduler(struct isci_port *iport)
1041 */ 1038 */
1042static void scic_sds_port_post_dummy_request(struct isci_port *iport) 1039static void scic_sds_port_post_dummy_request(struct isci_port *iport)
1043{ 1040{
1044 struct scic_sds_controller *scic = iport->owning_controller; 1041 struct isci_host *ihost = iport->owning_controller;
1045 u16 tag = iport->reserved_tag; 1042 u16 tag = iport->reserved_tag;
1046 struct scu_task_context *tc; 1043 struct scu_task_context *tc;
1047 u32 command; 1044 u32 command;
1048 1045
1049 tc = &scic->task_context_table[ISCI_TAG_TCI(tag)]; 1046 tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)];
1050 tc->abort = 0; 1047 tc->abort = 0;
1051 1048
1052 command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 1049 command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
1053 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | 1050 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1054 ISCI_TAG_TCI(tag); 1051 ISCI_TAG_TCI(tag);
1055 1052
1056 scic_sds_controller_post_request(scic, command); 1053 scic_sds_controller_post_request(ihost, command);
1057} 1054}
1058 1055
1059/** 1056/**
@@ -1065,19 +1062,19 @@ static void scic_sds_port_post_dummy_request(struct isci_port *iport)
1065 */ 1062 */
1066static void scic_sds_port_abort_dummy_request(struct isci_port *iport) 1063static void scic_sds_port_abort_dummy_request(struct isci_port *iport)
1067{ 1064{
1068 struct scic_sds_controller *scic = iport->owning_controller; 1065 struct isci_host *ihost = iport->owning_controller;
1069 u16 tag = iport->reserved_tag; 1066 u16 tag = iport->reserved_tag;
1070 struct scu_task_context *tc; 1067 struct scu_task_context *tc;
1071 u32 command; 1068 u32 command;
1072 1069
1073 tc = &scic->task_context_table[ISCI_TAG_TCI(tag)]; 1070 tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)];
1074 tc->abort = 1; 1071 tc->abort = 1;
1075 1072
1076 command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT | 1073 command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT |
1077 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | 1074 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1078 ISCI_TAG_TCI(tag); 1075 ISCI_TAG_TCI(tag);
1079 1076
1080 scic_sds_controller_post_request(scic, command); 1077 scic_sds_controller_post_request(ihost, command);
1081} 1078}
1082 1079
1083/** 1080/**
@@ -1115,8 +1112,7 @@ static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state
1115{ 1112{
1116 u32 index; 1113 u32 index;
1117 struct isci_port *iport = container_of(sm, typeof(*iport), sm); 1114 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1118 struct scic_sds_controller *scic = iport->owning_controller; 1115 struct isci_host *ihost = iport->owning_controller;
1119 struct isci_host *ihost = scic_to_ihost(scic);
1120 1116
1121 isci_port_ready(ihost, iport); 1117 isci_port_ready(ihost, iport);
1122 1118
@@ -1141,13 +1137,13 @@ static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state
1141 1137
1142static void scic_sds_port_invalidate_dummy_remote_node(struct isci_port *iport) 1138static void scic_sds_port_invalidate_dummy_remote_node(struct isci_port *iport)
1143{ 1139{
1144 struct scic_sds_controller *scic = iport->owning_controller; 1140 struct isci_host *ihost = iport->owning_controller;
1145 u8 phys_index = iport->physical_port_index; 1141 u8 phys_index = iport->physical_port_index;
1146 union scu_remote_node_context *rnc; 1142 union scu_remote_node_context *rnc;
1147 u16 rni = iport->reserved_rni; 1143 u16 rni = iport->reserved_rni;
1148 u32 command; 1144 u32 command;
1149 1145
1150 rnc = &scic->remote_node_context_table[rni]; 1146 rnc = &ihost->remote_node_context_table[rni];
1151 1147
1152 rnc->ssp.is_valid = false; 1148 rnc->ssp.is_valid = false;
1153 1149
@@ -1155,13 +1151,13 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct isci_port *iport)
1155 * controller and give it ample time to act before posting the rnc 1151 * controller and give it ample time to act before posting the rnc
1156 * invalidate 1152 * invalidate
1157 */ 1153 */
1158 readl(&scic->smu_registers->interrupt_status); /* flush */ 1154 readl(&ihost->smu_registers->interrupt_status); /* flush */
1159 udelay(10); 1155 udelay(10);
1160 1156
1161 command = SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE | 1157 command = SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE |
1162 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; 1158 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1163 1159
1164 scic_sds_controller_post_request(scic, command); 1160 scic_sds_controller_post_request(ihost, command);
1165} 1161}
1166 1162
1167/** 1163/**
@@ -1175,8 +1171,7 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct isci_port *iport)
1175static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm) 1171static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
1176{ 1172{
1177 struct isci_port *iport = container_of(sm, typeof(*iport), sm); 1173 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1178 struct scic_sds_controller *scic = iport->owning_controller; 1174 struct isci_host *ihost = iport->owning_controller;
1179 struct isci_host *ihost = scic_to_ihost(scic);
1180 1175
1181 /* 1176 /*
1182 * Kill the dummy task for this port if it has not yet posted 1177 * Kill the dummy task for this port if it has not yet posted
@@ -1194,8 +1189,7 @@ static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_
1194static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm) 1189static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
1195{ 1190{
1196 struct isci_port *iport = container_of(sm, typeof(*iport), sm); 1191 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1197 struct scic_sds_controller *scic = iport->owning_controller; 1192 struct isci_host *ihost = iport->owning_controller;
1198 struct isci_host *ihost = scic_to_ihost(scic);
1199 1193
1200 if (iport->active_phy_mask == 0) { 1194 if (iport->active_phy_mask == 0) {
1201 isci_port_not_ready(ihost, iport); 1195 isci_port_not_ready(ihost, iport);
@@ -1218,7 +1212,7 @@ static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_
1218 1212
1219enum sci_status scic_sds_port_start(struct isci_port *iport) 1213enum sci_status scic_sds_port_start(struct isci_port *iport)
1220{ 1214{
1221 struct scic_sds_controller *scic = iport->owning_controller; 1215 struct isci_host *ihost = iport->owning_controller;
1222 enum sci_status status = SCI_SUCCESS; 1216 enum sci_status status = SCI_SUCCESS;
1223 enum scic_sds_port_states state; 1217 enum scic_sds_port_states state;
1224 u32 phy_mask; 1218 u32 phy_mask;
@@ -1241,7 +1235,7 @@ enum sci_status scic_sds_port_start(struct isci_port *iport)
1241 1235
1242 if (iport->reserved_rni == SCU_DUMMY_INDEX) { 1236 if (iport->reserved_rni == SCU_DUMMY_INDEX) {
1243 u16 rni = scic_sds_remote_node_table_allocate_remote_node( 1237 u16 rni = scic_sds_remote_node_table_allocate_remote_node(
1244 &scic->available_remote_nodes, 1); 1238 &ihost->available_remote_nodes, 1);
1245 1239
1246 if (rni != SCU_DUMMY_INDEX) 1240 if (rni != SCU_DUMMY_INDEX)
1247 scic_sds_port_construct_dummy_rnc(iport, rni); 1241 scic_sds_port_construct_dummy_rnc(iport, rni);
@@ -1251,7 +1245,6 @@ enum sci_status scic_sds_port_start(struct isci_port *iport)
1251 } 1245 }
1252 1246
1253 if (iport->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) { 1247 if (iport->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) {
1254 struct isci_host *ihost = scic_to_ihost(scic);
1255 u16 tag; 1248 u16 tag;
1256 1249
1257 tag = isci_alloc_tag(ihost); 1250 tag = isci_alloc_tag(ihost);
@@ -1634,30 +1627,30 @@ scic_sds_port_disable_port_task_scheduler(struct isci_port *iport)
1634 1627
1635static void scic_sds_port_post_dummy_remote_node(struct isci_port *iport) 1628static void scic_sds_port_post_dummy_remote_node(struct isci_port *iport)
1636{ 1629{
1637 struct scic_sds_controller *scic = iport->owning_controller; 1630 struct isci_host *ihost = iport->owning_controller;
1638 u8 phys_index = iport->physical_port_index; 1631 u8 phys_index = iport->physical_port_index;
1639 union scu_remote_node_context *rnc; 1632 union scu_remote_node_context *rnc;
1640 u16 rni = iport->reserved_rni; 1633 u16 rni = iport->reserved_rni;
1641 u32 command; 1634 u32 command;
1642 1635
1643 rnc = &scic->remote_node_context_table[rni]; 1636 rnc = &ihost->remote_node_context_table[rni];
1644 rnc->ssp.is_valid = true; 1637 rnc->ssp.is_valid = true;
1645 1638
1646 command = SCU_CONTEXT_COMMAND_POST_RNC_32 | 1639 command = SCU_CONTEXT_COMMAND_POST_RNC_32 |
1647 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; 1640 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1648 1641
1649 scic_sds_controller_post_request(scic, command); 1642 scic_sds_controller_post_request(ihost, command);
1650 1643
1651 /* ensure hardware has seen the post rnc command and give it 1644 /* ensure hardware has seen the post rnc command and give it
1652 * ample time to act before sending the suspend 1645 * ample time to act before sending the suspend
1653 */ 1646 */
1654 readl(&scic->smu_registers->interrupt_status); /* flush */ 1647 readl(&ihost->smu_registers->interrupt_status); /* flush */
1655 udelay(10); 1648 udelay(10);
1656 1649
1657 command = SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX | 1650 command = SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX |
1658 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; 1651 phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni;
1659 1652
1660 scic_sds_controller_post_request(scic, command); 1653 scic_sds_controller_post_request(ihost, command);
1661} 1654}
1662 1655
1663static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm) 1656static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
@@ -1684,8 +1677,7 @@ static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
1684static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm) 1677static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
1685{ 1678{
1686 struct isci_port *iport = container_of(sm, typeof(*iport), sm); 1679 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1687 struct scic_sds_controller *scic = iport->owning_controller; 1680 struct isci_host *ihost = iport->owning_controller;
1688 struct isci_host *ihost = scic_to_ihost(scic);
1689 u32 prev_state; 1681 u32 prev_state;
1690 1682
1691 prev_state = iport->sm.previous_state_id; 1683 prev_state = iport->sm.previous_state_id;
@@ -1758,7 +1750,7 @@ static const struct sci_base_state scic_sds_port_state_table[] = {
1758}; 1750};
1759 1751
1760void scic_sds_port_construct(struct isci_port *iport, u8 index, 1752void scic_sds_port_construct(struct isci_port *iport, u8 index,
1761 struct scic_sds_controller *scic) 1753 struct isci_host *ihost)
1762{ 1754{
1763 sci_init_sm(&iport->sm, scic_sds_port_state_table, SCI_PORT_STOPPED); 1755 sci_init_sm(&iport->sm, scic_sds_port_state_table, SCI_PORT_STOPPED);
1764 1756
@@ -1767,7 +1759,7 @@ void scic_sds_port_construct(struct isci_port *iport, u8 index,
1767 iport->active_phy_mask = 0; 1759 iport->active_phy_mask = 0;
1768 iport->ready_exit = false; 1760 iport->ready_exit = false;
1769 1761
1770 iport->owning_controller = scic; 1762 iport->owning_controller = ihost;
1771 1763
1772 iport->started_request_count = 0; 1764 iport->started_request_count = 0;
1773 iport->assigned_device_count = 0; 1765 iport->assigned_device_count = 0;
@@ -1810,8 +1802,7 @@ void scic_sds_port_broadcast_change_received(
1810 struct isci_port *iport, 1802 struct isci_port *iport,
1811 struct isci_phy *iphy) 1803 struct isci_phy *iphy)
1812{ 1804{
1813 struct scic_sds_controller *scic = iport->owning_controller; 1805 struct isci_host *ihost = iport->owning_controller;
1814 struct isci_host *ihost = scic_to_ihost(scic);
1815 1806
1816 /* notify the user. */ 1807 /* notify the user. */
1817 isci_port_bc_change_received(ihost, iport, iphy); 1808 isci_port_bc_change_received(ihost, iport, iphy);