aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/isci/host.c32
-rw-r--r--drivers/scsi/isci/host.h11
-rw-r--r--drivers/scsi/isci/phy.c10
-rw-r--r--drivers/scsi/isci/phy.h10
-rw-r--r--drivers/scsi/isci/port.c622
-rw-r--r--drivers/scsi/isci/port.h174
-rw-r--r--drivers/scsi/isci/port_config.c99
-rw-r--r--drivers/scsi/isci/remote_device.c61
-rw-r--r--drivers/scsi/isci/remote_device.h10
-rw-r--r--drivers/scsi/isci/request.c33
10 files changed, 481 insertions, 581 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index c5c2733a5197..4e11f9e6d766 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1054,9 +1054,9 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic,
1054 1054
1055 /* Start all of the ports on this controller */ 1055 /* Start all of the ports on this controller */
1056 for (index = 0; index < scic->logical_port_entries; index++) { 1056 for (index = 0; index < scic->logical_port_entries; index++) {
1057 struct scic_sds_port *sci_port = &ihost->ports[index].sci; 1057 struct isci_port *iport = &ihost->ports[index];
1058 1058
1059 result = scic_sds_port_start(sci_port); 1059 result = scic_sds_port_start(iport);
1060 if (result) 1060 if (result)
1061 return result; 1061 return result;
1062 } 1062 }
@@ -1306,8 +1306,8 @@ void isci_host_deinit(struct isci_host *ihost)
1306 1306
1307 /* Cancel any/all outstanding port timers */ 1307 /* Cancel any/all outstanding port timers */
1308 for (i = 0; i < ihost->sci.logical_port_entries; i++) { 1308 for (i = 0; i < ihost->sci.logical_port_entries; i++) {
1309 struct scic_sds_port *sci_port = &ihost->ports[i].sci; 1309 struct isci_port *iport = &ihost->ports[i];
1310 del_timer_sync(&sci_port->timer.timer); 1310 del_timer_sync(&iport->timer.timer);
1311 } 1311 }
1312 1312
1313 /* Cancel any/all outstanding phy timers */ 1313 /* Cancel any/all outstanding phy timers */
@@ -1552,9 +1552,9 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller
1552 struct isci_host *ihost = scic_to_ihost(scic); 1552 struct isci_host *ihost = scic_to_ihost(scic);
1553 1553
1554 for (index = 0; index < scic->logical_port_entries; index++) { 1554 for (index = 0; index < scic->logical_port_entries; index++) {
1555 struct scic_sds_port *sci_port = &ihost->ports[index].sci; 1555 struct isci_port *iport = &ihost->ports[index];
1556 1556
1557 port_status = scic_sds_port_stop(sci_port); 1557 port_status = scic_sds_port_stop(iport);
1558 1558
1559 if ((port_status != SCI_SUCCESS) && 1559 if ((port_status != SCI_SUCCESS) &&
1560 (port_status != SCI_FAILURE_INVALID_STATE)) { 1560 (port_status != SCI_FAILURE_INVALID_STATE)) {
@@ -1564,7 +1564,7 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller
1564 "%s: Controller stop operation failed to " 1564 "%s: Controller stop operation failed to "
1565 "stop port %d because of status %d.\n", 1565 "stop port %d because of status %d.\n",
1566 __func__, 1566 __func__,
1567 sci_port->logical_port_index, 1567 iport->logical_port_index,
1568 port_status); 1568 port_status);
1569 } 1569 }
1570 } 1570 }
@@ -1780,14 +1780,14 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
1780 1780
1781 /* Construct the ports for this controller */ 1781 /* Construct the ports for this controller */
1782 for (i = 0; i < SCI_MAX_PORTS; i++) 1782 for (i = 0; i < SCI_MAX_PORTS; i++)
1783 scic_sds_port_construct(&ihost->ports[i].sci, i, scic); 1783 scic_sds_port_construct(&ihost->ports[i], i, scic);
1784 scic_sds_port_construct(&ihost->ports[i].sci, SCIC_SDS_DUMMY_PORT, scic); 1784 scic_sds_port_construct(&ihost->ports[i], SCIC_SDS_DUMMY_PORT, scic);
1785 1785
1786 /* Construct the phys for this controller */ 1786 /* Construct the phys for this controller */
1787 for (i = 0; i < SCI_MAX_PHYS; i++) { 1787 for (i = 0; i < SCI_MAX_PHYS; i++) {
1788 /* Add all the PHYs to the dummy port */ 1788 /* Add all the PHYs to the dummy port */
1789 scic_sds_phy_construct(&ihost->phys[i], 1789 scic_sds_phy_construct(&ihost->phys[i],
1790 &ihost->ports[SCI_MAX_PORTS].sci, i); 1790 &ihost->ports[SCI_MAX_PORTS], i);
1791 } 1791 }
1792 1792
1793 scic->invalid_phy_mask = 0; 1793 scic->invalid_phy_mask = 0;
@@ -2233,7 +2233,7 @@ static enum sci_status scic_controller_initialize(struct scic_sds_controller *sc
2233 } 2233 }
2234 2234
2235 for (i = 0; i < scic->logical_port_entries; i++) { 2235 for (i = 0; i < scic->logical_port_entries; i++) {
2236 result = scic_sds_port_initialize(&ihost->ports[i].sci, 2236 result = scic_sds_port_initialize(&ihost->ports[i],
2237 &scic->scu_registers->peg0.ptsg.port[i], 2237 &scic->scu_registers->peg0.ptsg.port[i],
2238 &scic->scu_registers->peg0.ptsg.protocol_engine, 2238 &scic->scu_registers->peg0.ptsg.protocol_engine,
2239 &scic->scu_registers->peg0.viit[i]); 2239 &scic->scu_registers->peg0.viit[i]);
@@ -2484,19 +2484,19 @@ int isci_host_init(struct isci_host *isci_host)
2484} 2484}
2485 2485
2486void scic_sds_controller_link_up(struct scic_sds_controller *scic, 2486void scic_sds_controller_link_up(struct scic_sds_controller *scic,
2487 struct scic_sds_port *port, struct isci_phy *iphy) 2487 struct isci_port *iport, struct isci_phy *iphy)
2488{ 2488{
2489 switch (scic->sm.current_state_id) { 2489 switch (scic->sm.current_state_id) {
2490 case SCIC_STARTING: 2490 case SCIC_STARTING:
2491 sci_del_timer(&scic->phy_timer); 2491 sci_del_timer(&scic->phy_timer);
2492 scic->phy_startup_timer_pending = false; 2492 scic->phy_startup_timer_pending = false;
2493 scic->port_agent.link_up_handler(scic, &scic->port_agent, 2493 scic->port_agent.link_up_handler(scic, &scic->port_agent,
2494 port, iphy); 2494 iport, iphy);
2495 scic_sds_controller_start_next_phy(scic); 2495 scic_sds_controller_start_next_phy(scic);
2496 break; 2496 break;
2497 case SCIC_READY: 2497 case SCIC_READY:
2498 scic->port_agent.link_up_handler(scic, &scic->port_agent, 2498 scic->port_agent.link_up_handler(scic, &scic->port_agent,
2499 port, iphy); 2499 iport, iphy);
2500 break; 2500 break;
2501 default: 2501 default:
2502 dev_dbg(scic_to_dev(scic), 2502 dev_dbg(scic_to_dev(scic),
@@ -2507,13 +2507,13 @@ void scic_sds_controller_link_up(struct scic_sds_controller *scic,
2507} 2507}
2508 2508
2509void scic_sds_controller_link_down(struct scic_sds_controller *scic, 2509void scic_sds_controller_link_down(struct scic_sds_controller *scic,
2510 struct scic_sds_port *port, struct isci_phy *iphy) 2510 struct isci_port *iport, struct isci_phy *iphy)
2511{ 2511{
2512 switch (scic->sm.current_state_id) { 2512 switch (scic->sm.current_state_id) {
2513 case SCIC_STARTING: 2513 case SCIC_STARTING:
2514 case SCIC_READY: 2514 case SCIC_READY:
2515 scic->port_agent.link_down_handler(scic, &scic->port_agent, 2515 scic->port_agent.link_down_handler(scic, &scic->port_agent,
2516 port, iphy); 2516 iport, iphy);
2517 break; 2517 break;
2518 default: 2518 default:
2519 dev_dbg(scic_to_dev(scic), 2519 dev_dbg(scic_to_dev(scic),
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index 1edd13535c24..fb8048e5fce7 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -108,7 +108,7 @@ struct scic_power_control {
108struct scic_sds_port_configuration_agent; 108struct scic_sds_port_configuration_agent;
109typedef void (*port_config_fn)(struct scic_sds_controller *, 109typedef void (*port_config_fn)(struct scic_sds_controller *,
110 struct scic_sds_port_configuration_agent *, 110 struct scic_sds_port_configuration_agent *,
111 struct scic_sds_port *, struct isci_phy *); 111 struct isci_port *, struct isci_phy *);
112 112
113struct scic_sds_port_configuration_agent { 113struct scic_sds_port_configuration_agent {
114 u16 phy_configured_mask; 114 u16 phy_configured_mask;
@@ -532,9 +532,8 @@ static inline struct device *sciphy_to_dev(struct isci_phy *iphy)
532 return &iphy->isci_port->isci_host->pdev->dev; 532 return &iphy->isci_port->isci_host->pdev->dev;
533} 533}
534 534
535static inline struct device *sciport_to_dev(struct scic_sds_port *sci_port) 535static inline struct device *sciport_to_dev(struct isci_port *iport)
536{ 536{
537 struct isci_port *iport = sci_port_to_iport(sci_port);
538 537
539 if (!iport || !iport->isci_host) 538 if (!iport || !iport->isci_host)
540 return NULL; 539 return NULL;
@@ -613,12 +612,12 @@ void scic_sds_controller_power_control_queue_remove(
613 612
614void scic_sds_controller_link_up( 613void scic_sds_controller_link_up(
615 struct scic_sds_controller *scic, 614 struct scic_sds_controller *scic,
616 struct scic_sds_port *sci_port, 615 struct isci_port *iport,
617 struct isci_phy *iphy); 616 struct isci_phy *iphy);
618 617
619void scic_sds_controller_link_down( 618void scic_sds_controller_link_down(
620 struct scic_sds_controller *scic, 619 struct scic_sds_controller *scic,
621 struct scic_sds_port *sci_port, 620 struct isci_port *iport,
622 struct isci_phy *iphy); 621 struct isci_phy *iphy);
623 622
624void scic_sds_controller_remote_device_stopped( 623void scic_sds_controller_remote_device_stopped(
@@ -649,7 +648,7 @@ void isci_host_deinit(
649 648
650void isci_host_port_link_up( 649void isci_host_port_link_up(
651 struct isci_host *, 650 struct isci_host *,
652 struct scic_sds_port *, 651 struct isci_port *,
653 struct isci_phy *); 652 struct isci_phy *);
654int isci_host_dev_found(struct domain_device *); 653int isci_host_dev_found(struct domain_device *);
655 654
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 0e60fb7bc1ab..fd0e9734e5d0 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -286,7 +286,7 @@ done:
286 * port (i.e. it's contained in the dummy port). !NULL All other 286 * port (i.e. it's contained in the dummy port). !NULL All other
287 * values indicate a handle/pointer to the port containing the phy. 287 * values indicate a handle/pointer to the port containing the phy.
288 */ 288 */
289struct scic_sds_port *phy_get_non_dummy_port( 289struct isci_port *phy_get_non_dummy_port(
290 struct isci_phy *iphy) 290 struct isci_phy *iphy)
291{ 291{
292 if (scic_sds_port_get_index(iphy->owning_port) == SCIC_SDS_DUMMY_PORT) 292 if (scic_sds_port_get_index(iphy->owning_port) == SCIC_SDS_DUMMY_PORT)
@@ -304,9 +304,9 @@ struct scic_sds_port *phy_get_non_dummy_port(
304 */ 304 */
305void scic_sds_phy_set_port( 305void scic_sds_phy_set_port(
306 struct isci_phy *iphy, 306 struct isci_phy *iphy,
307 struct scic_sds_port *sci_port) 307 struct isci_port *iport)
308{ 308{
309 iphy->owning_port = sci_port; 309 iphy->owning_port = iport;
310 310
311 if (iphy->bcn_received_while_port_unassigned) { 311 if (iphy->bcn_received_while_port_unassigned) {
312 iphy->bcn_received_while_port_unassigned = false; 312 iphy->bcn_received_while_port_unassigned = false;
@@ -1291,12 +1291,12 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
1291}; 1291};
1292 1292
1293void scic_sds_phy_construct(struct isci_phy *iphy, 1293void scic_sds_phy_construct(struct isci_phy *iphy,
1294 struct scic_sds_port *owning_port, u8 phy_index) 1294 struct isci_port *iport, u8 phy_index)
1295{ 1295{
1296 sci_init_sm(&iphy->sm, scic_sds_phy_state_table, SCI_PHY_INITIAL); 1296 sci_init_sm(&iphy->sm, scic_sds_phy_state_table, SCI_PHY_INITIAL);
1297 1297
1298 /* Copy the rest of the input data to our locals */ 1298 /* Copy the rest of the input data to our locals */
1299 iphy->owning_port = owning_port; 1299 iphy->owning_port = iport;
1300 iphy->phy_index = phy_index; 1300 iphy->phy_index = phy_index;
1301 iphy->bcn_received_while_port_unassigned = false; 1301 iphy->bcn_received_while_port_unassigned = false;
1302 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; 1302 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h
index 345fbeacb5cf..19aa444517b4 100644
--- a/drivers/scsi/isci/phy.h
+++ b/drivers/scsi/isci/phy.h
@@ -93,7 +93,7 @@ enum scic_sds_phy_protocol {
93 */ 93 */
94struct isci_phy { 94struct isci_phy {
95 struct sci_base_state_machine sm; 95 struct sci_base_state_machine sm;
96 struct scic_sds_port *owning_port; 96 struct isci_port *owning_port;
97 enum sas_linkrate max_negotiated_speed; 97 enum sas_linkrate max_negotiated_speed;
98 enum scic_sds_phy_protocol protocol; 98 enum scic_sds_phy_protocol protocol;
99 u8 phy_index; 99 u8 phy_index;
@@ -178,7 +178,7 @@ struct scic_phy_properties {
178 * supplied phy. This field may be set to NULL 178 * supplied phy. This field may be set to NULL
179 * if the phy is not currently contained in a port. 179 * if the phy is not currently contained in a port.
180 */ 180 */
181 struct scic_sds_port *owning_port; 181 struct isci_port *iport;
182 182
183 /** 183 /**
184 * This field specifies the link rate at which the phy is 184 * This field specifies the link rate at which the phy is
@@ -459,14 +459,14 @@ enum scic_sds_phy_states {
459 459
460void scic_sds_phy_construct( 460void scic_sds_phy_construct(
461 struct isci_phy *iphy, 461 struct isci_phy *iphy,
462 struct scic_sds_port *owning_port, 462 struct isci_port *iport,
463 u8 phy_index); 463 u8 phy_index);
464 464
465struct scic_sds_port *phy_get_non_dummy_port(struct isci_phy *iphy); 465struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy);
466 466
467void scic_sds_phy_set_port( 467void scic_sds_phy_set_port(
468 struct isci_phy *iphy, 468 struct isci_phy *iphy,
469 struct scic_sds_port *owning_port); 469 struct isci_port *iport);
470 470
471enum sci_status scic_sds_phy_initialize( 471enum sci_status scic_sds_phy_initialize(
472 struct isci_phy *iphy, 472 struct isci_phy *iphy,
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index d53c0b1748e7..04591882ee77 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -83,7 +83,7 @@ static void isci_port_change_state(struct isci_port *iport, enum isci_status sta
83 * transmit_identification register. 83 * transmit_identification register.
84 */ 84 */
85static void 85static void
86scic_sds_port_get_protocols(struct scic_sds_port *sci_port, 86scic_sds_port_get_protocols(struct isci_port *iport,
87 struct scic_phy_proto *protocols) 87 struct scic_phy_proto *protocols)
88{ 88{
89 u8 index; 89 u8 index;
@@ -91,8 +91,8 @@ scic_sds_port_get_protocols(struct scic_sds_port *sci_port,
91 protocols->all = 0; 91 protocols->all = 0;
92 92
93 for (index = 0; index < SCI_MAX_PHYS; index++) { 93 for (index = 0; index < SCI_MAX_PHYS; index++) {
94 if (sci_port->phy_table[index] != NULL) { 94 if (iport->phy_table[index] != NULL) {
95 scic_sds_phy_get_protocols(sci_port->phy_table[index], 95 scic_sds_phy_get_protocols(iport->phy_table[index],
96 protocols); 96 protocols);
97 } 97 }
98 } 98 }
@@ -107,7 +107,7 @@ scic_sds_port_get_protocols(struct scic_sds_port *sci_port,
107 * Return a bit mask indicating which phys are a part of this port. Each bit 107 * Return a bit mask indicating which phys are a part of this port. Each bit
108 * corresponds to a phy identifier (e.g. bit 0 = phy id 0). 108 * corresponds to a phy identifier (e.g. bit 0 = phy id 0).
109 */ 109 */
110static u32 scic_sds_port_get_phys(struct scic_sds_port *sci_port) 110static u32 scic_sds_port_get_phys(struct isci_port *iport)
111{ 111{
112 u32 index; 112 u32 index;
113 u32 mask; 113 u32 mask;
@@ -115,7 +115,7 @@ static u32 scic_sds_port_get_phys(struct scic_sds_port *sci_port)
115 mask = 0; 115 mask = 0;
116 116
117 for (index = 0; index < SCI_MAX_PHYS; index++) { 117 for (index = 0; index < SCI_MAX_PHYS; index++) {
118 if (sci_port->phy_table[index] != NULL) { 118 if (iport->phy_table[index] != NULL) {
119 mask |= (1 << index); 119 mask |= (1 << index);
120 } 120 }
121 } 121 }
@@ -136,30 +136,29 @@ static u32 scic_sds_port_get_phys(struct scic_sds_port *sci_port)
136 * value is returned if the specified port is not valid. When this value is 136 * value is returned if the specified port is not valid. When this value is
137 * returned, no data is copied to the properties output parameter. 137 * returned, no data is copied to the properties output parameter.
138 */ 138 */
139static enum sci_status scic_port_get_properties(struct scic_sds_port *port, 139static enum sci_status scic_port_get_properties(struct isci_port *iport,
140 struct scic_port_properties *prop) 140 struct scic_port_properties *prop)
141{ 141{
142 if ((port == NULL) || 142 if (!iport || iport->logical_port_index == SCIC_SDS_DUMMY_PORT)
143 (port->logical_port_index == SCIC_SDS_DUMMY_PORT))
144 return SCI_FAILURE_INVALID_PORT; 143 return SCI_FAILURE_INVALID_PORT;
145 144
146 prop->index = port->logical_port_index; 145 prop->index = iport->logical_port_index;
147 prop->phy_mask = scic_sds_port_get_phys(port); 146 prop->phy_mask = scic_sds_port_get_phys(iport);
148 scic_sds_port_get_sas_address(port, &prop->local.sas_address); 147 scic_sds_port_get_sas_address(iport, &prop->local.sas_address);
149 scic_sds_port_get_protocols(port, &prop->local.protocols); 148 scic_sds_port_get_protocols(iport, &prop->local.protocols);
150 scic_sds_port_get_attached_sas_address(port, &prop->remote.sas_address); 149 scic_sds_port_get_attached_sas_address(iport, &prop->remote.sas_address);
151 150
152 return SCI_SUCCESS; 151 return SCI_SUCCESS;
153} 152}
154 153
155static void scic_port_bcn_enable(struct scic_sds_port *sci_port) 154static void scic_port_bcn_enable(struct isci_port *iport)
156{ 155{
157 struct isci_phy *iphy; 156 struct isci_phy *iphy;
158 u32 val; 157 u32 val;
159 int i; 158 int i;
160 159
161 for (i = 0; i < ARRAY_SIZE(sci_port->phy_table); i++) { 160 for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) {
162 iphy = sci_port->phy_table[i]; 161 iphy = iport->phy_table[i];
163 if (!iphy) 162 if (!iphy)
164 continue; 163 continue;
165 val = readl(&iphy->link_layer_registers->link_layer_control); 164 val = readl(&iphy->link_layer_registers->link_layer_control);
@@ -179,8 +178,8 @@ void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport)
179 if (!test_and_clear_bit(IPORT_BCN_PENDING, &iport->flags)) 178 if (!test_and_clear_bit(IPORT_BCN_PENDING, &iport->flags))
180 return; 179 return;
181 180
182 for (i = 0; i < ARRAY_SIZE(iport->sci.phy_table); i++) { 181 for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) {
183 struct isci_phy *iphy = iport->sci.phy_table[i]; 182 struct isci_phy *iphy = iport->phy_table[i];
184 183
185 if (!iphy) 184 if (!iphy)
186 continue; 185 continue;
@@ -191,12 +190,10 @@ void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport)
191 } 190 }
192} 191}
193 192
194void isci_port_bc_change_received(struct isci_host *ihost, 193static void isci_port_bc_change_received(struct isci_host *ihost,
195 struct scic_sds_port *sci_port, 194 struct isci_port *iport,
196 struct isci_phy *iphy) 195 struct isci_phy *iphy)
197{ 196{
198 struct isci_port *iport = iphy->isci_port;
199
200 if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) { 197 if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) {
201 dev_dbg(&ihost->pdev->dev, 198 dev_dbg(&ihost->pdev->dev,
202 "%s: disabled BCN; isci_phy = %p, sas_phy = %p\n", 199 "%s: disabled BCN; isci_phy = %p, sas_phy = %p\n",
@@ -212,31 +209,30 @@ void isci_port_bc_change_received(struct isci_host *ihost,
212 ihost->sas_ha.notify_port_event(&iphy->sas_phy, 209 ihost->sas_ha.notify_port_event(&iphy->sas_phy,
213 PORTE_BROADCAST_RCVD); 210 PORTE_BROADCAST_RCVD);
214 } 211 }
215 scic_port_bcn_enable(sci_port); 212 scic_port_bcn_enable(iport);
216} 213}
217 214
218static void isci_port_link_up(struct isci_host *isci_host, 215static void isci_port_link_up(struct isci_host *isci_host,
219 struct scic_sds_port *port, 216 struct isci_port *iport,
220 struct isci_phy *iphy) 217 struct isci_phy *iphy)
221{ 218{
222 unsigned long flags; 219 unsigned long flags;
223 struct scic_port_properties properties; 220 struct scic_port_properties properties;
224 struct isci_port *isci_port = sci_port_to_iport(port);
225 unsigned long success = true; 221 unsigned long success = true;
226 222
227 BUG_ON(iphy->isci_port != NULL); 223 BUG_ON(iphy->isci_port != NULL);
228 224
229 iphy->isci_port = isci_port; 225 iphy->isci_port = iport;
230 226
231 dev_dbg(&isci_host->pdev->dev, 227 dev_dbg(&isci_host->pdev->dev,
232 "%s: isci_port = %p\n", 228 "%s: isci_port = %p\n",
233 __func__, isci_port); 229 __func__, iport);
234 230
235 spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); 231 spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags);
236 232
237 isci_port_change_state(iphy->isci_port, isci_starting); 233 isci_port_change_state(iphy->isci_port, isci_starting);
238 234
239 scic_port_get_properties(port, &properties); 235 scic_port_get_properties(iport, &properties);
240 236
241 if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) { 237 if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) {
242 u64 attached_sas_address; 238 u64 attached_sas_address;
@@ -370,7 +366,7 @@ static void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *i
370} 366}
371 367
372static void isci_port_stop_complete(struct scic_sds_controller *scic, 368static void isci_port_stop_complete(struct scic_sds_controller *scic,
373 struct scic_sds_port *sci_port, 369 struct isci_port *iport,
374 enum sci_status completion_status) 370 enum sci_status completion_status)
375{ 371{
376 dev_dbg(&scic_to_ihost(scic)->pdev->dev, "Port stop complete\n"); 372 dev_dbg(&scic_to_ihost(scic)->pdev->dev, "Port stop complete\n");
@@ -408,30 +404,30 @@ static void isci_port_hard_reset_complete(struct isci_port *isci_port,
408 * assignment for the port false if this is not a valid phy assignment for the 404 * assignment for the port false if this is not a valid phy assignment for the
409 * port 405 * port
410 */ 406 */
411bool scic_sds_port_is_valid_phy_assignment(struct scic_sds_port *sci_port, 407bool scic_sds_port_is_valid_phy_assignment(struct isci_port *iport,
412 u32 phy_index) 408 u32 phy_index)
413{ 409{
414 /* Initialize to invalid value. */ 410 /* Initialize to invalid value. */
415 u32 existing_phy_index = SCI_MAX_PHYS; 411 u32 existing_phy_index = SCI_MAX_PHYS;
416 u32 index; 412 u32 index;
417 413
418 if ((sci_port->physical_port_index == 1) && (phy_index != 1)) { 414 if ((iport->physical_port_index == 1) && (phy_index != 1)) {
419 return false; 415 return false;
420 } 416 }
421 417
422 if (sci_port->physical_port_index == 3 && phy_index != 3) { 418 if (iport->physical_port_index == 3 && phy_index != 3) {
423 return false; 419 return false;
424 } 420 }
425 421
426 if ( 422 if (
427 (sci_port->physical_port_index == 2) 423 (iport->physical_port_index == 2)
428 && ((phy_index == 0) || (phy_index == 1)) 424 && ((phy_index == 0) || (phy_index == 1))
429 ) { 425 ) {
430 return false; 426 return false;
431 } 427 }
432 428
433 for (index = 0; index < SCI_MAX_PHYS; index++) { 429 for (index = 0; index < SCI_MAX_PHYS; index++) {
434 if ((sci_port->phy_table[index] != NULL) 430 if ((iport->phy_table[index] != NULL)
435 && (index != phy_index)) { 431 && (index != phy_index)) {
436 existing_phy_index = index; 432 existing_phy_index = index;
437 } 433 }
@@ -442,9 +438,9 @@ bool scic_sds_port_is_valid_phy_assignment(struct scic_sds_port *sci_port,
442 * operating at the same maximum link rate. */ 438 * operating at the same maximum link rate. */
443 if ( 439 if (
444 (existing_phy_index < SCI_MAX_PHYS) 440 (existing_phy_index < SCI_MAX_PHYS)
445 && (sci_port->owning_controller->user_parameters.sds1.phys[ 441 && (iport->owning_controller->user_parameters.sds1.phys[
446 phy_index].max_speed_generation != 442 phy_index].max_speed_generation !=
447 sci_port->owning_controller->user_parameters.sds1.phys[ 443 iport->owning_controller->user_parameters.sds1.phys[
448 existing_phy_index].max_speed_generation) 444 existing_phy_index].max_speed_generation)
449 ) 445 )
450 return false; 446 return false;
@@ -465,25 +461,25 @@ bool scic_sds_port_is_valid_phy_assignment(struct scic_sds_port *sci_port,
465 * port false if this is not a valid phy assignment for the port 461 * port false if this is not a valid phy assignment for the port
466 */ 462 */
467static bool scic_sds_port_is_phy_mask_valid( 463static bool scic_sds_port_is_phy_mask_valid(
468 struct scic_sds_port *sci_port, 464 struct isci_port *iport,
469 u32 phy_mask) 465 u32 phy_mask)
470{ 466{
471 if (sci_port->physical_port_index == 0) { 467 if (iport->physical_port_index == 0) {
472 if (((phy_mask & 0x0F) == 0x0F) 468 if (((phy_mask & 0x0F) == 0x0F)
473 || ((phy_mask & 0x03) == 0x03) 469 || ((phy_mask & 0x03) == 0x03)
474 || ((phy_mask & 0x01) == 0x01) 470 || ((phy_mask & 0x01) == 0x01)
475 || (phy_mask == 0)) 471 || (phy_mask == 0))
476 return true; 472 return true;
477 } else if (sci_port->physical_port_index == 1) { 473 } else if (iport->physical_port_index == 1) {
478 if (((phy_mask & 0x02) == 0x02) 474 if (((phy_mask & 0x02) == 0x02)
479 || (phy_mask == 0)) 475 || (phy_mask == 0))
480 return true; 476 return true;
481 } else if (sci_port->physical_port_index == 2) { 477 } else if (iport->physical_port_index == 2) {
482 if (((phy_mask & 0x0C) == 0x0C) 478 if (((phy_mask & 0x0C) == 0x0C)
483 || ((phy_mask & 0x04) == 0x04) 479 || ((phy_mask & 0x04) == 0x04)
484 || (phy_mask == 0)) 480 || (phy_mask == 0))
485 return true; 481 return true;
486 } else if (sci_port->physical_port_index == 3) { 482 } else if (iport->physical_port_index == 3) {
487 if (((phy_mask & 0x08) == 0x08) 483 if (((phy_mask & 0x08) == 0x08)
488 || (phy_mask == 0)) 484 || (phy_mask == 0))
489 return true; 485 return true;
@@ -500,7 +496,7 @@ static bool scic_sds_port_is_phy_mask_valid(
500 * point) phys contained in the port. All other values specify a struct scic_sds_phy 496 * point) phys contained in the port. All other values specify a struct scic_sds_phy
501 * object that is active in the port. 497 * object that is active in the port.
502 */ 498 */
503static struct isci_phy *scic_sds_port_get_a_connected_phy(struct scic_sds_port *sci_port) 499static struct isci_phy *scic_sds_port_get_a_connected_phy(struct isci_port *iport)
504{ 500{
505 u32 index; 501 u32 index;
506 struct isci_phy *iphy; 502 struct isci_phy *iphy;
@@ -509,29 +505,29 @@ static struct isci_phy *scic_sds_port_get_a_connected_phy(struct scic_sds_port *
509 /* Ensure that the phy is both part of the port and currently 505 /* Ensure that the phy is both part of the port and currently
510 * connected to the remote end-point. 506 * connected to the remote end-point.
511 */ 507 */
512 iphy = sci_port->phy_table[index]; 508 iphy = iport->phy_table[index];
513 if (iphy && scic_sds_port_active_phy(sci_port, iphy)) 509 if (iphy && scic_sds_port_active_phy(iport, iphy))
514 return iphy; 510 return iphy;
515 } 511 }
516 512
517 return NULL; 513 return NULL;
518} 514}
519 515
520static enum sci_status scic_sds_port_set_phy(struct scic_sds_port *port, struct isci_phy *iphy) 516static enum sci_status scic_sds_port_set_phy(struct isci_port *iport, struct isci_phy *iphy)
521{ 517{
522 /* Check to see if we can add this phy to a port 518 /* Check to see if we can add this phy to a port
523 * that means that the phy is not part of a port and that the port does 519 * that means that the phy is not part of a port and that the port does
524 * not already have a phy assinged to the phy index. 520 * not already have a phy assinged to the phy index.
525 */ 521 */
526 if (!port->phy_table[iphy->phy_index] && 522 if (!iport->phy_table[iphy->phy_index] &&
527 !phy_get_non_dummy_port(iphy) && 523 !phy_get_non_dummy_port(iphy) &&
528 scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index)) { 524 scic_sds_port_is_valid_phy_assignment(iport, iphy->phy_index)) {
529 /* Phy is being added in the stopped state so we are in MPC mode 525 /* Phy is being added in the stopped state so we are in MPC mode
530 * make logical port index = physical port index 526 * make logical port index = physical port index
531 */ 527 */
532 port->logical_port_index = port->physical_port_index; 528 iport->logical_port_index = iport->physical_port_index;
533 port->phy_table[iphy->phy_index] = iphy; 529 iport->phy_table[iphy->phy_index] = iphy;
534 scic_sds_phy_set_port(iphy, port); 530 scic_sds_phy_set_port(iphy, iport);
535 531
536 return SCI_SUCCESS; 532 return SCI_SUCCESS;
537 } 533 }
@@ -539,18 +535,18 @@ static enum sci_status scic_sds_port_set_phy(struct scic_sds_port *port, struct
539 return SCI_FAILURE; 535 return SCI_FAILURE;
540} 536}
541 537
542static enum sci_status scic_sds_port_clear_phy(struct scic_sds_port *port, 538static enum sci_status scic_sds_port_clear_phy(struct isci_port *iport,
543 struct isci_phy *iphy) 539 struct isci_phy *iphy)
544{ 540{
545 /* Make sure that this phy is part of this port */ 541 /* Make sure that this phy is part of this port */
546 if (port->phy_table[iphy->phy_index] == iphy && 542 if (iport->phy_table[iphy->phy_index] == iphy &&
547 phy_get_non_dummy_port(iphy) == port) { 543 phy_get_non_dummy_port(iphy) == iport) {
548 struct scic_sds_controller *scic = port->owning_controller; 544 struct scic_sds_controller *scic = iport->owning_controller;
549 struct isci_host *ihost = scic_to_ihost(scic); 545 struct isci_host *ihost = scic_to_ihost(scic);
550 546
551 /* Yep it is assigned to this port so remove it */ 547 /* Yep it is assigned to this port so remove it */
552 scic_sds_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS].sci); 548 scic_sds_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS]);
553 port->phy_table[iphy->phy_index] = NULL; 549 iport->phy_table[iphy->phy_index] = NULL;
554 return SCI_SUCCESS; 550 return SCI_SUCCESS;
555 } 551 }
556 552
@@ -568,7 +564,7 @@ static enum sci_status scic_sds_port_clear_phy(struct scic_sds_port *port,
568 * 564 *
569 */ 565 */
570void scic_sds_port_get_sas_address( 566void scic_sds_port_get_sas_address(
571 struct scic_sds_port *sci_port, 567 struct isci_port *iport,
572 struct sci_sas_address *sas_address) 568 struct sci_sas_address *sas_address)
573{ 569{
574 u32 index; 570 u32 index;
@@ -577,8 +573,8 @@ void scic_sds_port_get_sas_address(
577 sas_address->low = 0; 573 sas_address->low = 0;
578 574
579 for (index = 0; index < SCI_MAX_PHYS; index++) { 575 for (index = 0; index < SCI_MAX_PHYS; index++) {
580 if (sci_port->phy_table[index] != NULL) { 576 if (iport->phy_table[index] != NULL) {
581 scic_sds_phy_get_sas_address(sci_port->phy_table[index], sas_address); 577 scic_sds_phy_get_sas_address(iport->phy_table[index], sas_address);
582 } 578 }
583 } 579 }
584} 580}
@@ -594,7 +590,7 @@ void scic_sds_port_get_sas_address(
594 * 590 *
595 */ 591 */
596void scic_sds_port_get_attached_sas_address( 592void scic_sds_port_get_attached_sas_address(
597 struct scic_sds_port *sci_port, 593 struct isci_port *iport,
598 struct sci_sas_address *sas_address) 594 struct sci_sas_address *sas_address)
599{ 595{
600 struct isci_phy *iphy; 596 struct isci_phy *iphy;
@@ -603,7 +599,7 @@ void scic_sds_port_get_attached_sas_address(
603 * Ensure that the phy is both part of the port and currently 599 * Ensure that the phy is both part of the port and currently
604 * connected to the remote end-point. 600 * connected to the remote end-point.
605 */ 601 */
606 iphy = scic_sds_port_get_a_connected_phy(sci_port); 602 iphy = scic_sds_port_get_a_connected_phy(iport);
607 if (iphy) { 603 if (iphy) {
608 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) { 604 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) {
609 scic_sds_phy_get_attached_sas_address(iphy, 605 scic_sds_phy_get_attached_sas_address(iphy,
@@ -628,11 +624,11 @@ void scic_sds_port_get_attached_sas_address(
628 * This structure will be posted to the hardware to work around a scheduler 624 * This structure will be posted to the hardware to work around a scheduler
629 * error in the hardware. 625 * error in the hardware.
630 */ 626 */
631static void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u16 rni) 627static void scic_sds_port_construct_dummy_rnc(struct isci_port *iport, u16 rni)
632{ 628{
633 union scu_remote_node_context *rnc; 629 union scu_remote_node_context *rnc;
634 630
635 rnc = &sci_port->owning_controller->remote_node_context_table[rni]; 631 rnc = &iport->owning_controller->remote_node_context_table[rni];
636 632
637 memset(rnc, 0, sizeof(union scu_remote_node_context)); 633 memset(rnc, 0, sizeof(union scu_remote_node_context));
638 634
@@ -641,7 +637,7 @@ static void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u1
641 637
642 rnc->ssp.remote_node_index = rni; 638 rnc->ssp.remote_node_index = rni;
643 rnc->ssp.remote_node_port_width = 1; 639 rnc->ssp.remote_node_port_width = 1;
644 rnc->ssp.logical_port_index = sci_port->physical_port_index; 640 rnc->ssp.logical_port_index = iport->physical_port_index;
645 641
646 rnc->ssp.nexus_loss_timer_enable = false; 642 rnc->ssp.nexus_loss_timer_enable = false;
647 rnc->ssp.check_bit = false; 643 rnc->ssp.check_bit = false;
@@ -656,9 +652,9 @@ static void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u1
656 * structure will be posted to the hardwre to work around a scheduler error 652 * structure will be posted to the hardwre to work around a scheduler error
657 * in the hardware. 653 * in the hardware.
658 */ 654 */
659static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tag) 655static void scic_sds_port_construct_dummy_task(struct isci_port *iport, u16 tag)
660{ 656{
661 struct scic_sds_controller *scic = sci_port->owning_controller; 657 struct scic_sds_controller *scic = iport->owning_controller;
662 struct scu_task_context *task_context; 658 struct scu_task_context *task_context;
663 659
664 task_context = &scic->task_context_table[ISCI_TAG_TCI(tag)]; 660 task_context = &scic->task_context_table[ISCI_TAG_TCI(tag)];
@@ -666,29 +662,29 @@ static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u
666 662
667 task_context->initiator_request = 1; 663 task_context->initiator_request = 1;
668 task_context->connection_rate = 1; 664 task_context->connection_rate = 1;
669 task_context->logical_port_index = sci_port->physical_port_index; 665 task_context->logical_port_index = iport->physical_port_index;
670 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; 666 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP;
671 task_context->task_index = ISCI_TAG_TCI(tag); 667 task_context->task_index = ISCI_TAG_TCI(tag);
672 task_context->valid = SCU_TASK_CONTEXT_VALID; 668 task_context->valid = SCU_TASK_CONTEXT_VALID;
673 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 669 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
674 task_context->remote_node_index = sci_port->reserved_rni; 670 task_context->remote_node_index = iport->reserved_rni;
675 task_context->do_not_dma_ssp_good_response = 1; 671 task_context->do_not_dma_ssp_good_response = 1;
676 task_context->task_phase = 0x01; 672 task_context->task_phase = 0x01;
677} 673}
678 674
679static void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port) 675static void scic_sds_port_destroy_dummy_resources(struct isci_port *iport)
680{ 676{
681 struct scic_sds_controller *scic = sci_port->owning_controller; 677 struct scic_sds_controller *scic = iport->owning_controller;
682 678
683 if (sci_port->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG) 679 if (iport->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG)
684 isci_free_tag(scic_to_ihost(scic), sci_port->reserved_tag); 680 isci_free_tag(scic_to_ihost(scic), iport->reserved_tag);
685 681
686 if (sci_port->reserved_rni != SCU_DUMMY_INDEX) 682 if (iport->reserved_rni != SCU_DUMMY_INDEX)
687 scic_sds_remote_node_table_release_remote_node_index(&scic->available_remote_nodes, 683 scic_sds_remote_node_table_release_remote_node_index(&scic->available_remote_nodes,
688 1, sci_port->reserved_rni); 684 1, iport->reserved_rni);
689 685
690 sci_port->reserved_rni = SCU_DUMMY_INDEX; 686 iport->reserved_rni = SCU_DUMMY_INDEX;
691 sci_port->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; 687 iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG;
692} 688}
693 689
694/** 690/**
@@ -704,14 +700,14 @@ static void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port
704 * if the phy being added to the port 700 * if the phy being added to the port
705 */ 701 */
706enum sci_status scic_sds_port_initialize( 702enum sci_status scic_sds_port_initialize(
707 struct scic_sds_port *sci_port, 703 struct isci_port *iport,
708 void __iomem *port_task_scheduler_registers, 704 void __iomem *port_task_scheduler_registers,
709 void __iomem *port_configuration_regsiter, 705 void __iomem *port_configuration_regsiter,
710 void __iomem *viit_registers) 706 void __iomem *viit_registers)
711{ 707{
712 sci_port->port_task_scheduler_registers = port_task_scheduler_registers; 708 iport->port_task_scheduler_registers = port_task_scheduler_registers;
713 sci_port->port_pe_configuration_register = port_configuration_regsiter; 709 iport->port_pe_configuration_register = port_configuration_regsiter;
714 sci_port->viit_registers = viit_registers; 710 iport->viit_registers = viit_registers;
715 711
716 return SCI_SUCCESS; 712 return SCI_SUCCESS;
717} 713}
@@ -720,20 +716,20 @@ enum sci_status scic_sds_port_initialize(
720/** 716/**
721 * This method assigns the direct attached device ID for this port. 717 * This method assigns the direct attached device ID for this port.
722 * 718 *
723 * @param[in] sci_port The port for which the direct attached device id is to 719 * @param[in] iport The port for which the direct attached device id is to
724 * be assigned. 720 * be assigned.
725 * @param[in] device_id The direct attached device ID to assign to the port. 721 * @param[in] device_id The direct attached device ID to assign to the port.
726 * This will be the RNi for the device 722 * This will be the RNi for the device
727 */ 723 */
728void scic_sds_port_setup_transports( 724void scic_sds_port_setup_transports(
729 struct scic_sds_port *sci_port, 725 struct isci_port *iport,
730 u32 device_id) 726 u32 device_id)
731{ 727{
732 u8 index; 728 u8 index;
733 729
734 for (index = 0; index < SCI_MAX_PHYS; index++) { 730 for (index = 0; index < SCI_MAX_PHYS; index++) {
735 if (sci_port->active_phy_mask & (1 << index)) 731 if (iport->active_phy_mask & (1 << index))
736 scic_sds_phy_setup_transport(sci_port->phy_table[index], device_id); 732 scic_sds_phy_setup_transport(iport->phy_table[index], device_id);
737 } 733 }
738} 734}
739 735
@@ -749,39 +745,38 @@ void scic_sds_port_setup_transports(
749 * the phy to the port - enabling the Protocol Engine in the silicon. - 745 * the phy to the port - enabling the Protocol Engine in the silicon. -
750 * notifying the user that the link is up. none 746 * notifying the user that the link is up. none
751 */ 747 */
752static void scic_sds_port_activate_phy(struct scic_sds_port *sci_port, 748static void scic_sds_port_activate_phy(struct isci_port *iport,
753 struct isci_phy *iphy, 749 struct isci_phy *iphy,
754 bool do_notify_user) 750 bool do_notify_user)
755{ 751{
756 struct scic_sds_controller *scic = sci_port->owning_controller; 752 struct scic_sds_controller *scic = iport->owning_controller;
757 struct isci_host *ihost = scic_to_ihost(scic); 753 struct isci_host *ihost = scic_to_ihost(scic);
758 754
759 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) 755 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA)
760 scic_sds_phy_resume(iphy); 756 scic_sds_phy_resume(iphy);
761 757
762 sci_port->active_phy_mask |= 1 << iphy->phy_index; 758 iport->active_phy_mask |= 1 << iphy->phy_index;
763 759
764 scic_sds_controller_clear_invalid_phy(scic, iphy); 760 scic_sds_controller_clear_invalid_phy(scic, iphy);
765 761
766 if (do_notify_user == true) 762 if (do_notify_user == true)
767 isci_port_link_up(ihost, sci_port, iphy); 763 isci_port_link_up(ihost, iport, iphy);
768} 764}
769 765
770void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port, 766void scic_sds_port_deactivate_phy(struct isci_port *iport,
771 struct isci_phy *iphy, 767 struct isci_phy *iphy,
772 bool do_notify_user) 768 bool do_notify_user)
773{ 769{
774 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); 770 struct scic_sds_controller *scic = scic_sds_port_get_controller(iport);
775 struct isci_port *iport = sci_port_to_iport(sci_port);
776 struct isci_host *ihost = scic_to_ihost(scic); 771 struct isci_host *ihost = scic_to_ihost(scic);
777 772
778 sci_port->active_phy_mask &= ~(1 << iphy->phy_index); 773 iport->active_phy_mask &= ~(1 << iphy->phy_index);
779 774
780 iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; 775 iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
781 776
782 /* Re-assign the phy back to the LP as if it were a narrow port */ 777 /* Re-assign the phy back to the LP as if it were a narrow port */
783 writel(iphy->phy_index, 778 writel(iphy->phy_index,
784 &sci_port->port_pe_configuration_register[iphy->phy_index]); 779 &iport->port_pe_configuration_register[iphy->phy_index]);
785 780
786 if (do_notify_user == true) 781 if (do_notify_user == true)
787 isci_port_link_down(ihost, iphy, iport); 782 isci_port_link_down(ihost, iphy, iport);
@@ -795,10 +790,10 @@ void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
795 * This function will disable the phy and report that the phy is not valid for 790 * This function will disable the phy and report that the phy is not valid for
796 * this port object. None 791 * this port object. None
797 */ 792 */
798static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port, 793static void scic_sds_port_invalid_link_up(struct isci_port *iport,
799 struct isci_phy *iphy) 794 struct isci_phy *iphy)
800{ 795{
801 struct scic_sds_controller *scic = sci_port->owning_controller; 796 struct scic_sds_controller *scic = iport->owning_controller;
802 797
803 /* 798 /*
804 * Check to see if we have alreay reported this link as bad and if 799 * Check to see if we have alreay reported this link as bad and if
@@ -825,17 +820,17 @@ static bool is_port_ready_state(enum scic_sds_port_states state)
825} 820}
826 821
827/* flag dummy rnc hanling when exiting a ready state */ 822/* flag dummy rnc hanling when exiting a ready state */
828static void port_state_machine_change(struct scic_sds_port *sci_port, 823static void port_state_machine_change(struct isci_port *iport,
829 enum scic_sds_port_states state) 824 enum scic_sds_port_states state)
830{ 825{
831 struct sci_base_state_machine *sm = &sci_port->sm; 826 struct sci_base_state_machine *sm = &iport->sm;
832 enum scic_sds_port_states old_state = sm->current_state_id; 827 enum scic_sds_port_states old_state = sm->current_state_id;
833 828
834 if (is_port_ready_state(old_state) && !is_port_ready_state(state)) 829 if (is_port_ready_state(old_state) && !is_port_ready_state(state))
835 sci_port->ready_exit = true; 830 iport->ready_exit = true;
836 831
837 sci_change_state(sm, state); 832 sci_change_state(sm, state);
838 sci_port->ready_exit = false; 833 iport->ready_exit = false;
839} 834}
840 835
841/** 836/**
@@ -851,14 +846,14 @@ static void port_state_machine_change(struct scic_sds_port *sci_port,
851 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in 846 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in
852 * the same port. none 847 * the same port. none
853 */ 848 */
854static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port, 849static void scic_sds_port_general_link_up_handler(struct isci_port *iport,
855 struct isci_phy *iphy, 850 struct isci_phy *iphy,
856 bool do_notify_user) 851 bool do_notify_user)
857{ 852{
858 struct sci_sas_address port_sas_address; 853 struct sci_sas_address port_sas_address;
859 struct sci_sas_address phy_sas_address; 854 struct sci_sas_address phy_sas_address;
860 855
861 scic_sds_port_get_attached_sas_address(sci_port, &port_sas_address); 856 scic_sds_port_get_attached_sas_address(iport, &port_sas_address);
862 scic_sds_phy_get_attached_sas_address(iphy, &phy_sas_address); 857 scic_sds_phy_get_attached_sas_address(iphy, &phy_sas_address);
863 858
864 /* If the SAS address of the new phy matches the SAS address of 859 /* If the SAS address of the new phy matches the SAS address of
@@ -868,14 +863,14 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port
868 */ 863 */
869 if ((phy_sas_address.high == port_sas_address.high && 864 if ((phy_sas_address.high == port_sas_address.high &&
870 phy_sas_address.low == port_sas_address.low) || 865 phy_sas_address.low == port_sas_address.low) ||
871 sci_port->active_phy_mask == 0) { 866 iport->active_phy_mask == 0) {
872 struct sci_base_state_machine *sm = &sci_port->sm; 867 struct sci_base_state_machine *sm = &iport->sm;
873 868
874 scic_sds_port_activate_phy(sci_port, iphy, do_notify_user); 869 scic_sds_port_activate_phy(iport, iphy, do_notify_user);
875 if (sm->current_state_id == SCI_PORT_RESETTING) 870 if (sm->current_state_id == SCI_PORT_RESETTING)
876 port_state_machine_change(sci_port, SCI_PORT_READY); 871 port_state_machine_change(iport, SCI_PORT_READY);
877 } else 872 } else
878 scic_sds_port_invalid_link_up(sci_port, iphy); 873 scic_sds_port_invalid_link_up(iport, iphy);
879} 874}
880 875
881 876
@@ -889,13 +884,13 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port
889 * bool true Is returned if this is a wide ported port. false Is returned if 884 * bool true Is returned if this is a wide ported port. false Is returned if
890 * this is a narrow port. 885 * this is a narrow port.
891 */ 886 */
892static bool scic_sds_port_is_wide(struct scic_sds_port *sci_port) 887static bool scic_sds_port_is_wide(struct isci_port *iport)
893{ 888{
894 u32 index; 889 u32 index;
895 u32 phy_count = 0; 890 u32 phy_count = 0;
896 891
897 for (index = 0; index < SCI_MAX_PHYS; index++) { 892 for (index = 0; index < SCI_MAX_PHYS; index++) {
898 if (sci_port->phy_table[index] != NULL) { 893 if (iport->phy_table[index] != NULL) {
899 phy_count++; 894 phy_count++;
900 } 895 }
901 } 896 }
@@ -918,13 +913,13 @@ static bool scic_sds_port_is_wide(struct scic_sds_port *sci_port)
918 * devices this could become an invalid port configuration. 913 * devices this could become an invalid port configuration.
919 */ 914 */
920bool scic_sds_port_link_detected( 915bool scic_sds_port_link_detected(
921 struct scic_sds_port *sci_port, 916 struct isci_port *iport,
922 struct isci_phy *iphy) 917 struct isci_phy *iphy)
923{ 918{
924 if ((sci_port->logical_port_index != SCIC_SDS_DUMMY_PORT) && 919 if ((iport->logical_port_index != SCIC_SDS_DUMMY_PORT) &&
925 (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) && 920 (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) &&
926 scic_sds_port_is_wide(sci_port)) { 921 scic_sds_port_is_wide(iport)) {
927 scic_sds_port_invalid_link_up(sci_port, iphy); 922 scic_sds_port_invalid_link_up(iport, iphy);
928 923
929 return false; 924 return false;
930 } 925 }
@@ -935,8 +930,8 @@ bool scic_sds_port_link_detected(
935static void port_timeout(unsigned long data) 930static void port_timeout(unsigned long data)
936{ 931{
937 struct sci_timer *tmr = (struct sci_timer *)data; 932 struct sci_timer *tmr = (struct sci_timer *)data;
938 struct scic_sds_port *sci_port = container_of(tmr, typeof(*sci_port), timer); 933 struct isci_port *iport = container_of(tmr, typeof(*iport), timer);
939 struct isci_host *ihost = scic_to_ihost(sci_port->owning_controller); 934 struct isci_host *ihost = scic_to_ihost(iport->owning_controller);
940 unsigned long flags; 935 unsigned long flags;
941 u32 current_state; 936 u32 current_state;
942 937
@@ -945,33 +940,33 @@ static void port_timeout(unsigned long data)
945 if (tmr->cancel) 940 if (tmr->cancel)
946 goto done; 941 goto done;
947 942
948 current_state = sci_port->sm.current_state_id; 943 current_state = iport->sm.current_state_id;
949 944
950 if (current_state == SCI_PORT_RESETTING) { 945 if (current_state == SCI_PORT_RESETTING) {
951 /* if the port is still in the resetting state then the timeout 946 /* if the port is still in the resetting state then the timeout
952 * fired before the reset completed. 947 * fired before the reset completed.
953 */ 948 */
954 port_state_machine_change(sci_port, SCI_PORT_FAILED); 949 port_state_machine_change(iport, SCI_PORT_FAILED);
955 } else if (current_state == SCI_PORT_STOPPED) { 950 } else if (current_state == SCI_PORT_STOPPED) {
956 /* if the port is stopped then the start request failed In this 951 /* if the port is stopped then the start request failed In this
957 * case stay in the stopped state. 952 * case stay in the stopped state.
958 */ 953 */
959 dev_err(sciport_to_dev(sci_port), 954 dev_err(sciport_to_dev(iport),
960 "%s: SCIC Port 0x%p failed to stop before tiemout.\n", 955 "%s: SCIC Port 0x%p failed to stop before tiemout.\n",
961 __func__, 956 __func__,
962 sci_port); 957 iport);
963 } else if (current_state == SCI_PORT_STOPPING) { 958 } else if (current_state == SCI_PORT_STOPPING) {
964 /* if the port is still stopping then the stop has not completed */ 959 /* if the port is still stopping then the stop has not completed */
965 isci_port_stop_complete(sci_port->owning_controller, 960 isci_port_stop_complete(iport->owning_controller,
966 sci_port, 961 iport,
967 SCI_FAILURE_TIMEOUT); 962 SCI_FAILURE_TIMEOUT);
968 } else { 963 } else {
969 /* The port is in the ready state and we have a timer 964 /* The port is in the ready state and we have a timer
970 * reporting a timeout this should not happen. 965 * reporting a timeout this should not happen.
971 */ 966 */
972 dev_err(sciport_to_dev(sci_port), 967 dev_err(sciport_to_dev(iport),
973 "%s: SCIC Port 0x%p is processing a timeout operation " 968 "%s: SCIC Port 0x%p is processing a timeout operation "
974 "in state %d.\n", __func__, sci_port, current_state); 969 "in state %d.\n", __func__, iport, current_state);
975 } 970 }
976 971
977done: 972done:
@@ -985,29 +980,29 @@ done:
985 * 980 *
986 * 981 *
987 */ 982 */
988static void scic_sds_port_update_viit_entry(struct scic_sds_port *sci_port) 983static void scic_sds_port_update_viit_entry(struct isci_port *iport)
989{ 984{
990 struct sci_sas_address sas_address; 985 struct sci_sas_address sas_address;
991 986
992 scic_sds_port_get_sas_address(sci_port, &sas_address); 987 scic_sds_port_get_sas_address(iport, &sas_address);
993 988
994 writel(sas_address.high, 989 writel(sas_address.high,
995 &sci_port->viit_registers->initiator_sas_address_hi); 990 &iport->viit_registers->initiator_sas_address_hi);
996 writel(sas_address.low, 991 writel(sas_address.low,
997 &sci_port->viit_registers->initiator_sas_address_lo); 992 &iport->viit_registers->initiator_sas_address_lo);
998 993
999 /* This value get cleared just in case its not already cleared */ 994 /* This value get cleared just in case its not already cleared */
1000 writel(0, &sci_port->viit_registers->reserved); 995 writel(0, &iport->viit_registers->reserved);
1001 996
1002 /* We are required to update the status register last */ 997 /* We are required to update the status register last */
1003 writel(SCU_VIIT_ENTRY_ID_VIIT | 998 writel(SCU_VIIT_ENTRY_ID_VIIT |
1004 SCU_VIIT_IPPT_INITIATOR | 999 SCU_VIIT_IPPT_INITIATOR |
1005 ((1 << sci_port->physical_port_index) << SCU_VIIT_ENTRY_LPVIE_SHIFT) | 1000 ((1 << iport->physical_port_index) << SCU_VIIT_ENTRY_LPVIE_SHIFT) |
1006 SCU_VIIT_STATUS_ALL_VALID, 1001 SCU_VIIT_STATUS_ALL_VALID,
1007 &sci_port->viit_registers->status); 1002 &iport->viit_registers->status);
1008} 1003}
1009 1004
1010enum sas_linkrate scic_sds_port_get_max_allowed_speed(struct scic_sds_port *sci_port) 1005enum sas_linkrate scic_sds_port_get_max_allowed_speed(struct isci_port *iport)
1011{ 1006{
1012 u16 index; 1007 u16 index;
1013 struct isci_phy *iphy; 1008 struct isci_phy *iphy;
@@ -1017,8 +1012,8 @@ enum sas_linkrate scic_sds_port_get_max_allowed_speed(struct scic_sds_port *sci_
1017 * Loop through all of the phys in this port and find the phy with the 1012 * Loop through all of the phys in this port and find the phy with the
1018 * lowest maximum link rate. */ 1013 * lowest maximum link rate. */
1019 for (index = 0; index < SCI_MAX_PHYS; index++) { 1014 for (index = 0; index < SCI_MAX_PHYS; index++) {
1020 iphy = sci_port->phy_table[index]; 1015 iphy = iport->phy_table[index];
1021 if (iphy && scic_sds_port_active_phy(sci_port, iphy) && 1016 if (iphy && scic_sds_port_active_phy(iport, iphy) &&
1022 iphy->max_negotiated_speed < max_allowed_speed) 1017 iphy->max_negotiated_speed < max_allowed_speed)
1023 max_allowed_speed = iphy->max_negotiated_speed; 1018 max_allowed_speed = iphy->max_negotiated_speed;
1024 } 1019 }
@@ -1026,13 +1021,13 @@ enum sas_linkrate scic_sds_port_get_max_allowed_speed(struct scic_sds_port *sci_
1026 return max_allowed_speed; 1021 return max_allowed_speed;
1027} 1022}
1028 1023
1029static void scic_sds_port_suspend_port_task_scheduler(struct scic_sds_port *port) 1024static void scic_sds_port_suspend_port_task_scheduler(struct isci_port *iport)
1030{ 1025{
1031 u32 pts_control_value; 1026 u32 pts_control_value;
1032 1027
1033 pts_control_value = readl(&port->port_task_scheduler_registers->control); 1028 pts_control_value = readl(&iport->port_task_scheduler_registers->control);
1034 pts_control_value |= SCU_PTSxCR_GEN_BIT(SUSPEND); 1029 pts_control_value |= SCU_PTSxCR_GEN_BIT(SUSPEND);
1035 writel(pts_control_value, &port->port_task_scheduler_registers->control); 1030 writel(pts_control_value, &iport->port_task_scheduler_registers->control);
1036} 1031}
1037 1032
1038/** 1033/**
@@ -1044,10 +1039,10 @@ static void scic_sds_port_suspend_port_task_scheduler(struct scic_sds_port *port
1044 * ongoing requests. 1039 * ongoing requests.
1045 * 1040 *
1046 */ 1041 */
1047static void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port) 1042static void scic_sds_port_post_dummy_request(struct isci_port *iport)
1048{ 1043{
1049 struct scic_sds_controller *scic = sci_port->owning_controller; 1044 struct scic_sds_controller *scic = iport->owning_controller;
1050 u16 tag = sci_port->reserved_tag; 1045 u16 tag = iport->reserved_tag;
1051 struct scu_task_context *tc; 1046 struct scu_task_context *tc;
1052 u32 command; 1047 u32 command;
1053 1048
@@ -1055,7 +1050,7 @@ static void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port)
1055 tc->abort = 0; 1050 tc->abort = 0;
1056 1051
1057 command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 1052 command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
1058 sci_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | 1053 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1059 ISCI_TAG_TCI(tag); 1054 ISCI_TAG_TCI(tag);
1060 1055
1061 scic_sds_controller_post_request(scic, command); 1056 scic_sds_controller_post_request(scic, command);
@@ -1068,10 +1063,10 @@ static void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port)
1068 * @sci_port: The port on which the task must be aborted. 1063 * @sci_port: The port on which the task must be aborted.
1069 * 1064 *
1070 */ 1065 */
1071static void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port) 1066static void scic_sds_port_abort_dummy_request(struct isci_port *iport)
1072{ 1067{
1073 struct scic_sds_controller *scic = sci_port->owning_controller; 1068 struct scic_sds_controller *scic = iport->owning_controller;
1074 u16 tag = sci_port->reserved_tag; 1069 u16 tag = iport->reserved_tag;
1075 struct scu_task_context *tc; 1070 struct scu_task_context *tc;
1076 u32 command; 1071 u32 command;
1077 1072
@@ -1079,7 +1074,7 @@ static void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port)
1079 tc->abort = 1; 1074 tc->abort = 1;
1080 1075
1081 command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT | 1076 command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT |
1082 sci_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | 1077 iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT |
1083 ISCI_TAG_TCI(tag); 1078 ISCI_TAG_TCI(tag);
1084 1079
1085 scic_sds_controller_post_request(scic, command); 1080 scic_sds_controller_post_request(scic, command);
@@ -1087,31 +1082,31 @@ static void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port)
1087 1082
1088/** 1083/**
1089 * 1084 *
1090 * @sci_port: This is the struct scic_sds_port object to resume. 1085 * @sci_port: This is the struct isci_port object to resume.
1091 * 1086 *
1092 * This method will resume the port task scheduler for this port object. none 1087 * This method will resume the port task scheduler for this port object. none
1093 */ 1088 */
1094static void 1089static void
1095scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port) 1090scic_sds_port_resume_port_task_scheduler(struct isci_port *iport)
1096{ 1091{
1097 u32 pts_control_value; 1092 u32 pts_control_value;
1098 1093
1099 pts_control_value = readl(&port->port_task_scheduler_registers->control); 1094 pts_control_value = readl(&iport->port_task_scheduler_registers->control);
1100 pts_control_value &= ~SCU_PTSxCR_GEN_BIT(SUSPEND); 1095 pts_control_value &= ~SCU_PTSxCR_GEN_BIT(SUSPEND);
1101 writel(pts_control_value, &port->port_task_scheduler_registers->control); 1096 writel(pts_control_value, &iport->port_task_scheduler_registers->control);
1102} 1097}
1103 1098
1104static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm) 1099static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm)
1105{ 1100{
1106 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1101 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1107 1102
1108 scic_sds_port_suspend_port_task_scheduler(sci_port); 1103 scic_sds_port_suspend_port_task_scheduler(iport);
1109 1104
1110 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS; 1105 iport->not_ready_reason = SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS;
1111 1106
1112 if (sci_port->active_phy_mask != 0) { 1107 if (iport->active_phy_mask != 0) {
1113 /* At least one of the phys on the port is ready */ 1108 /* At least one of the phys on the port is ready */
1114 port_state_machine_change(sci_port, 1109 port_state_machine_change(iport,
1115 SCI_PORT_SUB_OPERATIONAL); 1110 SCI_PORT_SUB_OPERATIONAL);
1116 } 1111 }
1117} 1112}
@@ -1119,38 +1114,37 @@ static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_mac
1119static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm) 1114static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm)
1120{ 1115{
1121 u32 index; 1116 u32 index;
1122 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1117 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1123 struct scic_sds_controller *scic = sci_port->owning_controller; 1118 struct scic_sds_controller *scic = iport->owning_controller;
1124 struct isci_host *ihost = scic_to_ihost(scic); 1119 struct isci_host *ihost = scic_to_ihost(scic);
1125 struct isci_port *iport = sci_port_to_iport(sci_port);
1126 1120
1127 isci_port_ready(ihost, iport); 1121 isci_port_ready(ihost, iport);
1128 1122
1129 for (index = 0; index < SCI_MAX_PHYS; index++) { 1123 for (index = 0; index < SCI_MAX_PHYS; index++) {
1130 if (sci_port->phy_table[index]) { 1124 if (iport->phy_table[index]) {
1131 writel(sci_port->physical_port_index, 1125 writel(iport->physical_port_index,
1132 &sci_port->port_pe_configuration_register[ 1126 &iport->port_pe_configuration_register[
1133 sci_port->phy_table[index]->phy_index]); 1127 iport->phy_table[index]->phy_index]);
1134 } 1128 }
1135 } 1129 }
1136 1130
1137 scic_sds_port_update_viit_entry(sci_port); 1131 scic_sds_port_update_viit_entry(iport);
1138 1132
1139 scic_sds_port_resume_port_task_scheduler(sci_port); 1133 scic_sds_port_resume_port_task_scheduler(iport);
1140 1134
1141 /* 1135 /*
1142 * Post the dummy task for the port so the hardware can schedule 1136 * Post the dummy task for the port so the hardware can schedule
1143 * io correctly 1137 * io correctly
1144 */ 1138 */
1145 scic_sds_port_post_dummy_request(sci_port); 1139 scic_sds_port_post_dummy_request(iport);
1146} 1140}
1147 1141
1148static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci_port) 1142static void scic_sds_port_invalidate_dummy_remote_node(struct isci_port *iport)
1149{ 1143{
1150 struct scic_sds_controller *scic = sci_port->owning_controller; 1144 struct scic_sds_controller *scic = iport->owning_controller;
1151 u8 phys_index = sci_port->physical_port_index; 1145 u8 phys_index = iport->physical_port_index;
1152 union scu_remote_node_context *rnc; 1146 union scu_remote_node_context *rnc;
1153 u16 rni = sci_port->reserved_rni; 1147 u16 rni = iport->reserved_rni;
1154 u32 command; 1148 u32 command;
1155 1149
1156 rnc = &scic->remote_node_context_table[rni]; 1150 rnc = &scic->remote_node_context_table[rni];
@@ -1172,73 +1166,71 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci
1172 1166
1173/** 1167/**
1174 * 1168 *
1175 * @object: This is the object which is cast to a struct scic_sds_port object. 1169 * @object: This is the object which is cast to a struct isci_port object.
1176 * 1170 *
1177 * This method will perform the actions required by the struct scic_sds_port on 1171 * This method will perform the actions required by the struct isci_port on
1178 * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports 1172 * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports
1179 * the port not ready and suspends the port task scheduler. none 1173 * the port not ready and suspends the port task scheduler. none
1180 */ 1174 */
1181static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm) 1175static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
1182{ 1176{
1183 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1177 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1184 struct scic_sds_controller *scic = sci_port->owning_controller; 1178 struct scic_sds_controller *scic = iport->owning_controller;
1185 struct isci_host *ihost = scic_to_ihost(scic); 1179 struct isci_host *ihost = scic_to_ihost(scic);
1186 struct isci_port *iport = sci_port_to_iport(sci_port);
1187 1180
1188 /* 1181 /*
1189 * Kill the dummy task for this port if it has not yet posted 1182 * Kill the dummy task for this port if it has not yet posted
1190 * the hardware will treat this as a NOP and just return abort 1183 * the hardware will treat this as a NOP and just return abort
1191 * complete. 1184 * complete.
1192 */ 1185 */
1193 scic_sds_port_abort_dummy_request(sci_port); 1186 scic_sds_port_abort_dummy_request(iport);
1194 1187
1195 isci_port_not_ready(ihost, iport); 1188 isci_port_not_ready(ihost, iport);
1196 1189
1197 if (sci_port->ready_exit) 1190 if (iport->ready_exit)
1198 scic_sds_port_invalidate_dummy_remote_node(sci_port); 1191 scic_sds_port_invalidate_dummy_remote_node(iport);
1199} 1192}
1200 1193
1201static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm) 1194static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
1202{ 1195{
1203 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1196 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1204 struct scic_sds_controller *scic = sci_port->owning_controller; 1197 struct scic_sds_controller *scic = iport->owning_controller;
1205 struct isci_host *ihost = scic_to_ihost(scic); 1198 struct isci_host *ihost = scic_to_ihost(scic);
1206 struct isci_port *iport = sci_port_to_iport(sci_port);
1207 1199
1208 if (sci_port->active_phy_mask == 0) { 1200 if (iport->active_phy_mask == 0) {
1209 isci_port_not_ready(ihost, iport); 1201 isci_port_not_ready(ihost, iport);
1210 1202
1211 port_state_machine_change(sci_port, 1203 port_state_machine_change(iport,
1212 SCI_PORT_SUB_WAITING); 1204 SCI_PORT_SUB_WAITING);
1213 } else if (sci_port->started_request_count == 0) 1205 } else if (iport->started_request_count == 0)
1214 port_state_machine_change(sci_port, 1206 port_state_machine_change(iport,
1215 SCI_PORT_SUB_OPERATIONAL); 1207 SCI_PORT_SUB_OPERATIONAL);
1216} 1208}
1217 1209
1218static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm) 1210static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm)
1219{ 1211{
1220 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1212 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1221 1213
1222 scic_sds_port_suspend_port_task_scheduler(sci_port); 1214 scic_sds_port_suspend_port_task_scheduler(iport);
1223 if (sci_port->ready_exit) 1215 if (iport->ready_exit)
1224 scic_sds_port_invalidate_dummy_remote_node(sci_port); 1216 scic_sds_port_invalidate_dummy_remote_node(iport);
1225} 1217}
1226 1218
1227enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) 1219enum sci_status scic_sds_port_start(struct isci_port *iport)
1228{ 1220{
1229 struct scic_sds_controller *scic = sci_port->owning_controller; 1221 struct scic_sds_controller *scic = iport->owning_controller;
1230 enum sci_status status = SCI_SUCCESS; 1222 enum sci_status status = SCI_SUCCESS;
1231 enum scic_sds_port_states state; 1223 enum scic_sds_port_states state;
1232 u32 phy_mask; 1224 u32 phy_mask;
1233 1225
1234 state = sci_port->sm.current_state_id; 1226 state = iport->sm.current_state_id;
1235 if (state != SCI_PORT_STOPPED) { 1227 if (state != SCI_PORT_STOPPED) {
1236 dev_warn(sciport_to_dev(sci_port), 1228 dev_warn(sciport_to_dev(iport),
1237 "%s: in wrong state: %d\n", __func__, state); 1229 "%s: in wrong state: %d\n", __func__, state);
1238 return SCI_FAILURE_INVALID_STATE; 1230 return SCI_FAILURE_INVALID_STATE;
1239 } 1231 }
1240 1232
1241 if (sci_port->assigned_device_count > 0) { 1233 if (iport->assigned_device_count > 0) {
1242 /* TODO This is a start failure operation because 1234 /* TODO This is a start failure operation because
1243 * there are still devices assigned to this port. 1235 * there are still devices assigned to this port.
1244 * There must be no devices assigned to a port on a 1236 * There must be no devices assigned to a port on a
@@ -1247,18 +1239,18 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
1247 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 1239 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
1248 } 1240 }
1249 1241
1250 if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { 1242 if (iport->reserved_rni == SCU_DUMMY_INDEX) {
1251 u16 rni = scic_sds_remote_node_table_allocate_remote_node( 1243 u16 rni = scic_sds_remote_node_table_allocate_remote_node(
1252 &scic->available_remote_nodes, 1); 1244 &scic->available_remote_nodes, 1);
1253 1245
1254 if (rni != SCU_DUMMY_INDEX) 1246 if (rni != SCU_DUMMY_INDEX)
1255 scic_sds_port_construct_dummy_rnc(sci_port, rni); 1247 scic_sds_port_construct_dummy_rnc(iport, rni);
1256 else 1248 else
1257 status = SCI_FAILURE_INSUFFICIENT_RESOURCES; 1249 status = SCI_FAILURE_INSUFFICIENT_RESOURCES;
1258 sci_port->reserved_rni = rni; 1250 iport->reserved_rni = rni;
1259 } 1251 }
1260 1252
1261 if (sci_port->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) { 1253 if (iport->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) {
1262 struct isci_host *ihost = scic_to_ihost(scic); 1254 struct isci_host *ihost = scic_to_ihost(scic);
1263 u16 tag; 1255 u16 tag;
1264 1256
@@ -1266,20 +1258,20 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
1266 if (tag == SCI_CONTROLLER_INVALID_IO_TAG) 1258 if (tag == SCI_CONTROLLER_INVALID_IO_TAG)
1267 status = SCI_FAILURE_INSUFFICIENT_RESOURCES; 1259 status = SCI_FAILURE_INSUFFICIENT_RESOURCES;
1268 else 1260 else
1269 scic_sds_port_construct_dummy_task(sci_port, tag); 1261 scic_sds_port_construct_dummy_task(iport, tag);
1270 sci_port->reserved_tag = tag; 1262 iport->reserved_tag = tag;
1271 } 1263 }
1272 1264
1273 if (status == SCI_SUCCESS) { 1265 if (status == SCI_SUCCESS) {
1274 phy_mask = scic_sds_port_get_phys(sci_port); 1266 phy_mask = scic_sds_port_get_phys(iport);
1275 1267
1276 /* 1268 /*
1277 * There are one or more phys assigned to this port. Make sure 1269 * There are one or more phys assigned to this port. Make sure
1278 * the port's phy mask is in fact legal and supported by the 1270 * the port's phy mask is in fact legal and supported by the
1279 * silicon. 1271 * silicon.
1280 */ 1272 */
1281 if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { 1273 if (scic_sds_port_is_phy_mask_valid(iport, phy_mask) == true) {
1282 port_state_machine_change(sci_port, 1274 port_state_machine_change(iport,
1283 SCI_PORT_READY); 1275 SCI_PORT_READY);
1284 1276
1285 return SCI_SUCCESS; 1277 return SCI_SUCCESS;
@@ -1288,16 +1280,16 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port)
1288 } 1280 }
1289 1281
1290 if (status != SCI_SUCCESS) 1282 if (status != SCI_SUCCESS)
1291 scic_sds_port_destroy_dummy_resources(sci_port); 1283 scic_sds_port_destroy_dummy_resources(iport);
1292 1284
1293 return status; 1285 return status;
1294} 1286}
1295 1287
1296enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port) 1288enum sci_status scic_sds_port_stop(struct isci_port *iport)
1297{ 1289{
1298 enum scic_sds_port_states state; 1290 enum scic_sds_port_states state;
1299 1291
1300 state = sci_port->sm.current_state_id; 1292 state = iport->sm.current_state_id;
1301 switch (state) { 1293 switch (state) {
1302 case SCI_PORT_STOPPED: 1294 case SCI_PORT_STOPPED:
1303 return SCI_SUCCESS; 1295 return SCI_SUCCESS;
@@ -1305,34 +1297,34 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port)
1305 case SCI_PORT_SUB_OPERATIONAL: 1297 case SCI_PORT_SUB_OPERATIONAL:
1306 case SCI_PORT_SUB_CONFIGURING: 1298 case SCI_PORT_SUB_CONFIGURING:
1307 case SCI_PORT_RESETTING: 1299 case SCI_PORT_RESETTING:
1308 port_state_machine_change(sci_port, 1300 port_state_machine_change(iport,
1309 SCI_PORT_STOPPING); 1301 SCI_PORT_STOPPING);
1310 return SCI_SUCCESS; 1302 return SCI_SUCCESS;
1311 default: 1303 default:
1312 dev_warn(sciport_to_dev(sci_port), 1304 dev_warn(sciport_to_dev(iport),
1313 "%s: in wrong state: %d\n", __func__, state); 1305 "%s: in wrong state: %d\n", __func__, state);
1314 return SCI_FAILURE_INVALID_STATE; 1306 return SCI_FAILURE_INVALID_STATE;
1315 } 1307 }
1316} 1308}
1317 1309
1318static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 timeout) 1310static enum sci_status scic_port_hard_reset(struct isci_port *iport, u32 timeout)
1319{ 1311{
1320 enum sci_status status = SCI_FAILURE_INVALID_PHY; 1312 enum sci_status status = SCI_FAILURE_INVALID_PHY;
1321 struct isci_phy *iphy = NULL; 1313 struct isci_phy *iphy = NULL;
1322 enum scic_sds_port_states state; 1314 enum scic_sds_port_states state;
1323 u32 phy_index; 1315 u32 phy_index;
1324 1316
1325 state = sci_port->sm.current_state_id; 1317 state = iport->sm.current_state_id;
1326 if (state != SCI_PORT_SUB_OPERATIONAL) { 1318 if (state != SCI_PORT_SUB_OPERATIONAL) {
1327 dev_warn(sciport_to_dev(sci_port), 1319 dev_warn(sciport_to_dev(iport),
1328 "%s: in wrong state: %d\n", __func__, state); 1320 "%s: in wrong state: %d\n", __func__, state);
1329 return SCI_FAILURE_INVALID_STATE; 1321 return SCI_FAILURE_INVALID_STATE;
1330 } 1322 }
1331 1323
1332 /* Select a phy on which we can send the hard reset request. */ 1324 /* Select a phy on which we can send the hard reset request. */
1333 for (phy_index = 0; phy_index < SCI_MAX_PHYS && !iphy; phy_index++) { 1325 for (phy_index = 0; phy_index < SCI_MAX_PHYS && !iphy; phy_index++) {
1334 iphy = sci_port->phy_table[phy_index]; 1326 iphy = iport->phy_table[phy_index];
1335 if (iphy && !scic_sds_port_active_phy(sci_port, iphy)) { 1327 if (iphy && !scic_sds_port_active_phy(iport, iphy)) {
1336 /* 1328 /*
1337 * We found a phy but it is not ready select 1329 * We found a phy but it is not ready select
1338 * different phy 1330 * different phy
@@ -1349,10 +1341,10 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
1349 if (status != SCI_SUCCESS) 1341 if (status != SCI_SUCCESS)
1350 return status; 1342 return status;
1351 1343
1352 sci_mod_timer(&sci_port->timer, timeout); 1344 sci_mod_timer(&iport->timer, timeout);
1353 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; 1345 iport->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
1354 1346
1355 port_state_machine_change(sci_port, SCI_PORT_RESETTING); 1347 port_state_machine_change(iport, SCI_PORT_RESETTING);
1356 return SCI_SUCCESS; 1348 return SCI_SUCCESS;
1357} 1349}
1358 1350
@@ -1365,19 +1357,19 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
1365 * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other 1357 * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other
1366 * status is a failure to add the phy to the port. 1358 * status is a failure to add the phy to the port.
1367 */ 1359 */
1368enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, 1360enum sci_status scic_sds_port_add_phy(struct isci_port *iport,
1369 struct isci_phy *iphy) 1361 struct isci_phy *iphy)
1370{ 1362{
1371 enum sci_status status; 1363 enum sci_status status;
1372 enum scic_sds_port_states state; 1364 enum scic_sds_port_states state;
1373 1365
1374 state = sci_port->sm.current_state_id; 1366 state = iport->sm.current_state_id;
1375 switch (state) { 1367 switch (state) {
1376 case SCI_PORT_STOPPED: { 1368 case SCI_PORT_STOPPED: {
1377 struct sci_sas_address port_sas_address; 1369 struct sci_sas_address port_sas_address;
1378 1370
1379 /* Read the port assigned SAS Address if there is one */ 1371 /* Read the port assigned SAS Address if there is one */
1380 scic_sds_port_get_sas_address(sci_port, &port_sas_address); 1372 scic_sds_port_get_sas_address(iport, &port_sas_address);
1381 1373
1382 if (port_sas_address.high != 0 && port_sas_address.low != 0) { 1374 if (port_sas_address.high != 0 && port_sas_address.low != 0) {
1383 struct sci_sas_address phy_sas_address; 1375 struct sci_sas_address phy_sas_address;
@@ -1391,35 +1383,35 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1391 port_sas_address.low != phy_sas_address.low) 1383 port_sas_address.low != phy_sas_address.low)
1392 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 1384 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
1393 } 1385 }
1394 return scic_sds_port_set_phy(sci_port, iphy); 1386 return scic_sds_port_set_phy(iport, iphy);
1395 } 1387 }
1396 case SCI_PORT_SUB_WAITING: 1388 case SCI_PORT_SUB_WAITING:
1397 case SCI_PORT_SUB_OPERATIONAL: 1389 case SCI_PORT_SUB_OPERATIONAL:
1398 status = scic_sds_port_set_phy(sci_port, iphy); 1390 status = scic_sds_port_set_phy(iport, iphy);
1399 1391
1400 if (status != SCI_SUCCESS) 1392 if (status != SCI_SUCCESS)
1401 return status; 1393 return status;
1402 1394
1403 scic_sds_port_general_link_up_handler(sci_port, iphy, true); 1395 scic_sds_port_general_link_up_handler(iport, iphy, true);
1404 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1396 iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1405 port_state_machine_change(sci_port, SCI_PORT_SUB_CONFIGURING); 1397 port_state_machine_change(iport, SCI_PORT_SUB_CONFIGURING);
1406 1398
1407 return status; 1399 return status;
1408 case SCI_PORT_SUB_CONFIGURING: 1400 case SCI_PORT_SUB_CONFIGURING:
1409 status = scic_sds_port_set_phy(sci_port, iphy); 1401 status = scic_sds_port_set_phy(iport, iphy);
1410 1402
1411 if (status != SCI_SUCCESS) 1403 if (status != SCI_SUCCESS)
1412 return status; 1404 return status;
1413 scic_sds_port_general_link_up_handler(sci_port, iphy, true); 1405 scic_sds_port_general_link_up_handler(iport, iphy, true);
1414 1406
1415 /* Re-enter the configuring state since this may be the last phy in 1407 /* Re-enter the configuring state since this may be the last phy in
1416 * the port. 1408 * the port.
1417 */ 1409 */
1418 port_state_machine_change(sci_port, 1410 port_state_machine_change(iport,
1419 SCI_PORT_SUB_CONFIGURING); 1411 SCI_PORT_SUB_CONFIGURING);
1420 return SCI_SUCCESS; 1412 return SCI_SUCCESS;
1421 default: 1413 default:
1422 dev_warn(sciport_to_dev(sci_port), 1414 dev_warn(sciport_to_dev(iport),
1423 "%s: in wrong state: %d\n", __func__, state); 1415 "%s: in wrong state: %d\n", __func__, state);
1424 return SCI_FAILURE_INVALID_STATE; 1416 return SCI_FAILURE_INVALID_STATE;
1425 } 1417 }
@@ -1434,65 +1426,65 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1434 * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any 1426 * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any
1435 * other status is a failure to add the phy to the port. 1427 * other status is a failure to add the phy to the port.
1436 */ 1428 */
1437enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, 1429enum sci_status scic_sds_port_remove_phy(struct isci_port *iport,
1438 struct isci_phy *iphy) 1430 struct isci_phy *iphy)
1439{ 1431{
1440 enum sci_status status; 1432 enum sci_status status;
1441 enum scic_sds_port_states state; 1433 enum scic_sds_port_states state;
1442 1434
1443 state = sci_port->sm.current_state_id; 1435 state = iport->sm.current_state_id;
1444 1436
1445 switch (state) { 1437 switch (state) {
1446 case SCI_PORT_STOPPED: 1438 case SCI_PORT_STOPPED:
1447 return scic_sds_port_clear_phy(sci_port, iphy); 1439 return scic_sds_port_clear_phy(iport, iphy);
1448 case SCI_PORT_SUB_OPERATIONAL: 1440 case SCI_PORT_SUB_OPERATIONAL:
1449 status = scic_sds_port_clear_phy(sci_port, iphy); 1441 status = scic_sds_port_clear_phy(iport, iphy);
1450 if (status != SCI_SUCCESS) 1442 if (status != SCI_SUCCESS)
1451 return status; 1443 return status;
1452 1444
1453 scic_sds_port_deactivate_phy(sci_port, iphy, true); 1445 scic_sds_port_deactivate_phy(iport, iphy, true);
1454 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1446 iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1455 port_state_machine_change(sci_port, 1447 port_state_machine_change(iport,
1456 SCI_PORT_SUB_CONFIGURING); 1448 SCI_PORT_SUB_CONFIGURING);
1457 return SCI_SUCCESS; 1449 return SCI_SUCCESS;
1458 case SCI_PORT_SUB_CONFIGURING: 1450 case SCI_PORT_SUB_CONFIGURING:
1459 status = scic_sds_port_clear_phy(sci_port, iphy); 1451 status = scic_sds_port_clear_phy(iport, iphy);
1460 1452
1461 if (status != SCI_SUCCESS) 1453 if (status != SCI_SUCCESS)
1462 return status; 1454 return status;
1463 scic_sds_port_deactivate_phy(sci_port, iphy, true); 1455 scic_sds_port_deactivate_phy(iport, iphy, true);
1464 1456
1465 /* Re-enter the configuring state since this may be the last phy in 1457 /* Re-enter the configuring state since this may be the last phy in
1466 * the port 1458 * the port
1467 */ 1459 */
1468 port_state_machine_change(sci_port, 1460 port_state_machine_change(iport,
1469 SCI_PORT_SUB_CONFIGURING); 1461 SCI_PORT_SUB_CONFIGURING);
1470 return SCI_SUCCESS; 1462 return SCI_SUCCESS;
1471 default: 1463 default:
1472 dev_warn(sciport_to_dev(sci_port), 1464 dev_warn(sciport_to_dev(iport),
1473 "%s: in wrong state: %d\n", __func__, state); 1465 "%s: in wrong state: %d\n", __func__, state);
1474 return SCI_FAILURE_INVALID_STATE; 1466 return SCI_FAILURE_INVALID_STATE;
1475 } 1467 }
1476} 1468}
1477 1469
1478enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port, 1470enum sci_status scic_sds_port_link_up(struct isci_port *iport,
1479 struct isci_phy *iphy) 1471 struct isci_phy *iphy)
1480{ 1472{
1481 enum scic_sds_port_states state; 1473 enum scic_sds_port_states state;
1482 1474
1483 state = sci_port->sm.current_state_id; 1475 state = iport->sm.current_state_id;
1484 switch (state) { 1476 switch (state) {
1485 case SCI_PORT_SUB_WAITING: 1477 case SCI_PORT_SUB_WAITING:
1486 /* Since this is the first phy going link up for the port we 1478 /* Since this is the first phy going link up for the port we
1487 * can just enable it and continue 1479 * can just enable it and continue
1488 */ 1480 */
1489 scic_sds_port_activate_phy(sci_port, iphy, true); 1481 scic_sds_port_activate_phy(iport, iphy, true);
1490 1482
1491 port_state_machine_change(sci_port, 1483 port_state_machine_change(iport,
1492 SCI_PORT_SUB_OPERATIONAL); 1484 SCI_PORT_SUB_OPERATIONAL);
1493 return SCI_SUCCESS; 1485 return SCI_SUCCESS;
1494 case SCI_PORT_SUB_OPERATIONAL: 1486 case SCI_PORT_SUB_OPERATIONAL:
1495 scic_sds_port_general_link_up_handler(sci_port, iphy, true); 1487 scic_sds_port_general_link_up_handler(iport, iphy, true);
1496 return SCI_SUCCESS; 1488 return SCI_SUCCESS;
1497 case SCI_PORT_RESETTING: 1489 case SCI_PORT_RESETTING:
1498 /* TODO We should make sure that the phy that has gone 1490 /* TODO We should make sure that the phy that has gone
@@ -1509,82 +1501,82 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1509 /* In the resetting state we don't notify the user regarding 1501 /* In the resetting state we don't notify the user regarding
1510 * link up and link down notifications. 1502 * link up and link down notifications.
1511 */ 1503 */
1512 scic_sds_port_general_link_up_handler(sci_port, iphy, false); 1504 scic_sds_port_general_link_up_handler(iport, iphy, false);
1513 return SCI_SUCCESS; 1505 return SCI_SUCCESS;
1514 default: 1506 default:
1515 dev_warn(sciport_to_dev(sci_port), 1507 dev_warn(sciport_to_dev(iport),
1516 "%s: in wrong state: %d\n", __func__, state); 1508 "%s: in wrong state: %d\n", __func__, state);
1517 return SCI_FAILURE_INVALID_STATE; 1509 return SCI_FAILURE_INVALID_STATE;
1518 } 1510 }
1519} 1511}
1520 1512
1521enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, 1513enum sci_status scic_sds_port_link_down(struct isci_port *iport,
1522 struct isci_phy *iphy) 1514 struct isci_phy *iphy)
1523{ 1515{
1524 enum scic_sds_port_states state; 1516 enum scic_sds_port_states state;
1525 1517
1526 state = sci_port->sm.current_state_id; 1518 state = iport->sm.current_state_id;
1527 switch (state) { 1519 switch (state) {
1528 case SCI_PORT_SUB_OPERATIONAL: 1520 case SCI_PORT_SUB_OPERATIONAL:
1529 scic_sds_port_deactivate_phy(sci_port, iphy, true); 1521 scic_sds_port_deactivate_phy(iport, iphy, true);
1530 1522
1531 /* If there are no active phys left in the port, then 1523 /* If there are no active phys left in the port, then
1532 * transition the port to the WAITING state until such time 1524 * transition the port to the WAITING state until such time
1533 * as a phy goes link up 1525 * as a phy goes link up
1534 */ 1526 */
1535 if (sci_port->active_phy_mask == 0) 1527 if (iport->active_phy_mask == 0)
1536 port_state_machine_change(sci_port, 1528 port_state_machine_change(iport,
1537 SCI_PORT_SUB_WAITING); 1529 SCI_PORT_SUB_WAITING);
1538 return SCI_SUCCESS; 1530 return SCI_SUCCESS;
1539 case SCI_PORT_RESETTING: 1531 case SCI_PORT_RESETTING:
1540 /* In the resetting state we don't notify the user regarding 1532 /* In the resetting state we don't notify the user regarding
1541 * link up and link down notifications. */ 1533 * link up and link down notifications. */
1542 scic_sds_port_deactivate_phy(sci_port, iphy, false); 1534 scic_sds_port_deactivate_phy(iport, iphy, false);
1543 return SCI_SUCCESS; 1535 return SCI_SUCCESS;
1544 default: 1536 default:
1545 dev_warn(sciport_to_dev(sci_port), 1537 dev_warn(sciport_to_dev(iport),
1546 "%s: in wrong state: %d\n", __func__, state); 1538 "%s: in wrong state: %d\n", __func__, state);
1547 return SCI_FAILURE_INVALID_STATE; 1539 return SCI_FAILURE_INVALID_STATE;
1548 } 1540 }
1549} 1541}
1550 1542
1551enum sci_status scic_sds_port_start_io(struct scic_sds_port *sci_port, 1543enum sci_status scic_sds_port_start_io(struct isci_port *iport,
1552 struct scic_sds_remote_device *sci_dev, 1544 struct scic_sds_remote_device *sci_dev,
1553 struct isci_request *ireq) 1545 struct isci_request *ireq)
1554{ 1546{
1555 enum scic_sds_port_states state; 1547 enum scic_sds_port_states state;
1556 1548
1557 state = sci_port->sm.current_state_id; 1549 state = iport->sm.current_state_id;
1558 switch (state) { 1550 switch (state) {
1559 case SCI_PORT_SUB_WAITING: 1551 case SCI_PORT_SUB_WAITING:
1560 return SCI_FAILURE_INVALID_STATE; 1552 return SCI_FAILURE_INVALID_STATE;
1561 case SCI_PORT_SUB_OPERATIONAL: 1553 case SCI_PORT_SUB_OPERATIONAL:
1562 sci_port->started_request_count++; 1554 iport->started_request_count++;
1563 return SCI_SUCCESS; 1555 return SCI_SUCCESS;
1564 default: 1556 default:
1565 dev_warn(sciport_to_dev(sci_port), 1557 dev_warn(sciport_to_dev(iport),
1566 "%s: in wrong state: %d\n", __func__, state); 1558 "%s: in wrong state: %d\n", __func__, state);
1567 return SCI_FAILURE_INVALID_STATE; 1559 return SCI_FAILURE_INVALID_STATE;
1568 } 1560 }
1569} 1561}
1570 1562
1571enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port, 1563enum sci_status scic_sds_port_complete_io(struct isci_port *iport,
1572 struct scic_sds_remote_device *sci_dev, 1564 struct scic_sds_remote_device *sci_dev,
1573 struct isci_request *ireq) 1565 struct isci_request *ireq)
1574{ 1566{
1575 enum scic_sds_port_states state; 1567 enum scic_sds_port_states state;
1576 1568
1577 state = sci_port->sm.current_state_id; 1569 state = iport->sm.current_state_id;
1578 switch (state) { 1570 switch (state) {
1579 case SCI_PORT_STOPPED: 1571 case SCI_PORT_STOPPED:
1580 dev_warn(sciport_to_dev(sci_port), 1572 dev_warn(sciport_to_dev(iport),
1581 "%s: in wrong state: %d\n", __func__, state); 1573 "%s: in wrong state: %d\n", __func__, state);
1582 return SCI_FAILURE_INVALID_STATE; 1574 return SCI_FAILURE_INVALID_STATE;
1583 case SCI_PORT_STOPPING: 1575 case SCI_PORT_STOPPING:
1584 scic_sds_port_decrement_request_count(sci_port); 1576 scic_sds_port_decrement_request_count(iport);
1585 1577
1586 if (sci_port->started_request_count == 0) 1578 if (iport->started_request_count == 0)
1587 port_state_machine_change(sci_port, 1579 port_state_machine_change(iport,
1588 SCI_PORT_STOPPED); 1580 SCI_PORT_STOPPED);
1589 break; 1581 break;
1590 case SCI_PORT_READY: 1582 case SCI_PORT_READY:
@@ -1592,12 +1584,12 @@ enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port,
1592 case SCI_PORT_FAILED: 1584 case SCI_PORT_FAILED:
1593 case SCI_PORT_SUB_WAITING: 1585 case SCI_PORT_SUB_WAITING:
1594 case SCI_PORT_SUB_OPERATIONAL: 1586 case SCI_PORT_SUB_OPERATIONAL:
1595 scic_sds_port_decrement_request_count(sci_port); 1587 scic_sds_port_decrement_request_count(iport);
1596 break; 1588 break;
1597 case SCI_PORT_SUB_CONFIGURING: 1589 case SCI_PORT_SUB_CONFIGURING:
1598 scic_sds_port_decrement_request_count(sci_port); 1590 scic_sds_port_decrement_request_count(iport);
1599 if (sci_port->started_request_count == 0) { 1591 if (iport->started_request_count == 0) {
1600 port_state_machine_change(sci_port, 1592 port_state_machine_change(iport,
1601 SCI_PORT_SUB_OPERATIONAL); 1593 SCI_PORT_SUB_OPERATIONAL);
1602 } 1594 }
1603 break; 1595 break;
@@ -1613,13 +1605,13 @@ enum sci_status scic_sds_port_complete_io(struct scic_sds_port *sci_port,
1613 * will leave the port task scheduler in a suspended state. none 1605 * will leave the port task scheduler in a suspended state. none
1614 */ 1606 */
1615static void 1607static void
1616scic_sds_port_enable_port_task_scheduler(struct scic_sds_port *port) 1608scic_sds_port_enable_port_task_scheduler(struct isci_port *iport)
1617{ 1609{
1618 u32 pts_control_value; 1610 u32 pts_control_value;
1619 1611
1620 pts_control_value = readl(&port->port_task_scheduler_registers->control); 1612 pts_control_value = readl(&iport->port_task_scheduler_registers->control);
1621 pts_control_value |= SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND); 1613 pts_control_value |= SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND);
1622 writel(pts_control_value, &port->port_task_scheduler_registers->control); 1614 writel(pts_control_value, &iport->port_task_scheduler_registers->control);
1623} 1615}
1624 1616
1625/** 1617/**
@@ -1630,22 +1622,22 @@ scic_sds_port_enable_port_task_scheduler(struct scic_sds_port *port)
1630 * none 1622 * none
1631 */ 1623 */
1632static void 1624static void
1633scic_sds_port_disable_port_task_scheduler(struct scic_sds_port *port) 1625scic_sds_port_disable_port_task_scheduler(struct isci_port *iport)
1634{ 1626{
1635 u32 pts_control_value; 1627 u32 pts_control_value;
1636 1628
1637 pts_control_value = readl(&port->port_task_scheduler_registers->control); 1629 pts_control_value = readl(&iport->port_task_scheduler_registers->control);
1638 pts_control_value &= 1630 pts_control_value &=
1639 ~(SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND)); 1631 ~(SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND));
1640 writel(pts_control_value, &port->port_task_scheduler_registers->control); 1632 writel(pts_control_value, &iport->port_task_scheduler_registers->control);
1641} 1633}
1642 1634
1643static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port) 1635static void scic_sds_port_post_dummy_remote_node(struct isci_port *iport)
1644{ 1636{
1645 struct scic_sds_controller *scic = sci_port->owning_controller; 1637 struct scic_sds_controller *scic = iport->owning_controller;
1646 u8 phys_index = sci_port->physical_port_index; 1638 u8 phys_index = iport->physical_port_index;
1647 union scu_remote_node_context *rnc; 1639 union scu_remote_node_context *rnc;
1648 u16 rni = sci_port->reserved_rni; 1640 u16 rni = iport->reserved_rni;
1649 u32 command; 1641 u32 command;
1650 1642
1651 rnc = &scic->remote_node_context_table[rni]; 1643 rnc = &scic->remote_node_context_table[rni];
@@ -1670,67 +1662,65 @@ static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
1670 1662
1671static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm) 1663static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
1672{ 1664{
1673 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1665 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1674 1666
1675 if (sci_port->sm.previous_state_id == SCI_PORT_STOPPING) { 1667 if (iport->sm.previous_state_id == SCI_PORT_STOPPING) {
1676 /* 1668 /*
1677 * If we enter this state becasuse of a request to stop 1669 * If we enter this state becasuse of a request to stop
1678 * the port then we want to disable the hardwares port 1670 * the port then we want to disable the hardwares port
1679 * task scheduler. */ 1671 * task scheduler. */
1680 scic_sds_port_disable_port_task_scheduler(sci_port); 1672 scic_sds_port_disable_port_task_scheduler(iport);
1681 } 1673 }
1682} 1674}
1683 1675
1684static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm) 1676static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
1685{ 1677{
1686 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1678 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1687 1679
1688 /* Enable and suspend the port task scheduler */ 1680 /* Enable and suspend the port task scheduler */
1689 scic_sds_port_enable_port_task_scheduler(sci_port); 1681 scic_sds_port_enable_port_task_scheduler(iport);
1690} 1682}
1691 1683
1692static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm) 1684static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
1693{ 1685{
1694 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1686 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1695 struct scic_sds_controller *scic = sci_port->owning_controller; 1687 struct scic_sds_controller *scic = iport->owning_controller;
1696 struct isci_host *ihost = scic_to_ihost(scic); 1688 struct isci_host *ihost = scic_to_ihost(scic);
1697 struct isci_port *iport = sci_port_to_iport(sci_port);
1698 u32 prev_state; 1689 u32 prev_state;
1699 1690
1700 prev_state = sci_port->sm.previous_state_id; 1691 prev_state = iport->sm.previous_state_id;
1701 if (prev_state == SCI_PORT_RESETTING) 1692 if (prev_state == SCI_PORT_RESETTING)
1702 isci_port_hard_reset_complete(iport, SCI_SUCCESS); 1693 isci_port_hard_reset_complete(iport, SCI_SUCCESS);
1703 else 1694 else
1704 isci_port_not_ready(ihost, iport); 1695 isci_port_not_ready(ihost, iport);
1705 1696
1706 /* Post and suspend the dummy remote node context for this port. */ 1697 /* Post and suspend the dummy remote node context for this port. */
1707 scic_sds_port_post_dummy_remote_node(sci_port); 1698 scic_sds_port_post_dummy_remote_node(iport);
1708 1699
1709 /* Start the ready substate machine */ 1700 /* Start the ready substate machine */
1710 port_state_machine_change(sci_port, 1701 port_state_machine_change(iport,
1711 SCI_PORT_SUB_WAITING); 1702 SCI_PORT_SUB_WAITING);
1712} 1703}
1713 1704
1714static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm) 1705static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm)
1715{ 1706{
1716 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1707 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1717 1708
1718 sci_del_timer(&sci_port->timer); 1709 sci_del_timer(&iport->timer);
1719} 1710}
1720 1711
1721static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm) 1712static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
1722{ 1713{
1723 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1714 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1724 1715
1725 sci_del_timer(&sci_port->timer); 1716 sci_del_timer(&iport->timer);
1726 1717
1727 scic_sds_port_destroy_dummy_resources(sci_port); 1718 scic_sds_port_destroy_dummy_resources(iport);
1728} 1719}
1729 1720
1730static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm) 1721static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
1731{ 1722{
1732 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), sm); 1723 struct isci_port *iport = container_of(sm, typeof(*iport), sm);
1733 struct isci_port *iport = sci_port_to_iport(sci_port);
1734 1724
1735 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); 1725 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
1736} 1726}
@@ -1767,30 +1757,30 @@ static const struct sci_base_state scic_sds_port_state_table[] = {
1767 } 1757 }
1768}; 1758};
1769 1759
1770void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index, 1760void scic_sds_port_construct(struct isci_port *iport, u8 index,
1771 struct scic_sds_controller *scic) 1761 struct scic_sds_controller *scic)
1772{ 1762{
1773 sci_init_sm(&sci_port->sm, scic_sds_port_state_table, SCI_PORT_STOPPED); 1763 sci_init_sm(&iport->sm, scic_sds_port_state_table, SCI_PORT_STOPPED);
1774 1764
1775 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; 1765 iport->logical_port_index = SCIC_SDS_DUMMY_PORT;
1776 sci_port->physical_port_index = index; 1766 iport->physical_port_index = index;
1777 sci_port->active_phy_mask = 0; 1767 iport->active_phy_mask = 0;
1778 sci_port->ready_exit = false; 1768 iport->ready_exit = false;
1779 1769
1780 sci_port->owning_controller = scic; 1770 iport->owning_controller = scic;
1781 1771
1782 sci_port->started_request_count = 0; 1772 iport->started_request_count = 0;
1783 sci_port->assigned_device_count = 0; 1773 iport->assigned_device_count = 0;
1784 1774
1785 sci_port->reserved_rni = SCU_DUMMY_INDEX; 1775 iport->reserved_rni = SCU_DUMMY_INDEX;
1786 sci_port->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; 1776 iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG;
1787 1777
1788 sci_init_timer(&sci_port->timer, port_timeout); 1778 sci_init_timer(&iport->timer, port_timeout);
1789 1779
1790 sci_port->port_task_scheduler_registers = NULL; 1780 iport->port_task_scheduler_registers = NULL;
1791 1781
1792 for (index = 0; index < SCI_MAX_PHYS; index++) 1782 for (index = 0; index < SCI_MAX_PHYS; index++)
1793 sci_port->phy_table[index] = NULL; 1783 iport->phy_table[index] = NULL;
1794} 1784}
1795 1785
1796void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index) 1786void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index)
@@ -1817,14 +1807,14 @@ enum isci_status isci_port_get_state(
1817} 1807}
1818 1808
1819void scic_sds_port_broadcast_change_received( 1809void scic_sds_port_broadcast_change_received(
1820 struct scic_sds_port *sci_port, 1810 struct isci_port *iport,
1821 struct isci_phy *iphy) 1811 struct isci_phy *iphy)
1822{ 1812{
1823 struct scic_sds_controller *scic = sci_port->owning_controller; 1813 struct scic_sds_controller *scic = iport->owning_controller;
1824 struct isci_host *ihost = scic_to_ihost(scic); 1814 struct isci_host *ihost = scic_to_ihost(scic);
1825 1815
1826 /* notify the user. */ 1816 /* notify the user. */
1827 isci_port_bc_change_received(ihost, sci_port, iphy); 1817 isci_port_bc_change_received(ihost, iport, iphy);
1828} 1818}
1829 1819
1830int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport, 1820int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
@@ -1842,7 +1832,7 @@ int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *ipor
1842 spin_lock_irqsave(&ihost->scic_lock, flags); 1832 spin_lock_irqsave(&ihost->scic_lock, flags);
1843 1833
1844 #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT 1834 #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT
1845 status = scic_port_hard_reset(&iport->sci, ISCI_PORT_RESET_TIMEOUT); 1835 status = scic_port_hard_reset(iport, ISCI_PORT_RESET_TIMEOUT);
1846 1836
1847 spin_unlock_irqrestore(&ihost->scic_lock, flags); 1837 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1848 1838
@@ -1878,14 +1868,12 @@ int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *ipor
1878 /* Down all phys in the port. */ 1868 /* Down all phys in the port. */
1879 spin_lock_irqsave(&ihost->scic_lock, flags); 1869 spin_lock_irqsave(&ihost->scic_lock, flags);
1880 for (idx = 0; idx < SCI_MAX_PHYS; ++idx) { 1870 for (idx = 0; idx < SCI_MAX_PHYS; ++idx) {
1871 struct isci_phy *iphy = iport->phy_table[idx];
1881 1872
1882 if (iport->sci.phy_table[idx] != NULL) { 1873 if (!iphy)
1883 1874 continue;
1884 scic_sds_phy_stop( 1875 scic_sds_phy_stop(iphy);
1885 iport->sci.phy_table[idx]); 1876 scic_sds_phy_start(iphy);
1886 scic_sds_phy_start(
1887 iport->sci.phy_table[idx]);
1888 }
1889 } 1877 }
1890 spin_unlock_irqrestore(&ihost->scic_lock, flags); 1878 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1891 } 1879 }
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h
index b6ce56a6c11d..cdea48ece005 100644
--- a/drivers/scsi/isci/port.h
+++ b/drivers/scsi/isci/port.h
@@ -76,100 +76,19 @@ enum isci_status {
76}; 76};
77 77
78/** 78/**
79 * struct scic_sds_port 79 * struct isci_port - isci direct attached sas port object
80 * 80 * @event: counts bcns and port stop events (for bcn filtering)
81 * The core port object provides the the abstraction for an SCU port. 81 * @ready_exit: several states constitute 'ready'. When exiting ready we
82 */ 82 * need to take extra port-teardown actions that are
83struct scic_sds_port { 83 * skipped when exiting to another 'ready' state.
84 /** 84 * @logical_port_index: software port index
85 * This field contains the information for the base port state machine. 85 * @physical_port_index: hardware port index
86 */ 86 * @active_phy_mask: identifies phy members
87 struct sci_base_state_machine sm; 87 * @reserved_tag:
88 88 * @reserved_rni: reserver for port task scheduler workaround
89 bool ready_exit; 89 * @started_request_count: reference count for outstanding commands
90 90 * @not_ready_reason: set during state transitions and notified
91 /** 91 * @timer: timeout start/stop operations
92 * This field is the port index that is reported to the SCI USER.
93 * This allows the actual hardware physical port to change without
94 * the SCI USER getting a different answer for the get port index.
95 */
96 u8 logical_port_index;
97
98 /**
99 * This field is the port index used to program the SCU hardware.
100 */
101 u8 physical_port_index;
102
103 /**
104 * This field contains the active phy mask for the port.
105 * This mask is used in conjunction with the phy state to determine
106 * which phy to select for some port operations.
107 */
108 u8 active_phy_mask;
109
110 u16 reserved_rni;
111 u16 reserved_tag;
112
113 /**
114 * This field contains the count of the io requests started on this port
115 * object. It is used to control controller shutdown.
116 */
117 u32 started_request_count;
118
119 /**
120 * This field contains the number of devices assigned to this port.
121 * It is used to control port start requests.
122 */
123 u32 assigned_device_count;
124
125 /**
126 * This field contains the reason for the port not going ready. It is
127 * assigned in the state handlers and used in the state transition.
128 */
129 u32 not_ready_reason;
130
131 /**
132 * This field is the table of phys assigned to the port.
133 */
134 struct isci_phy *phy_table[SCI_MAX_PHYS];
135
136 /**
137 * This field is a pointer back to the controller that owns this
138 * port object.
139 */
140 struct scic_sds_controller *owning_controller;
141
142 /* timer used for port start/stop operations */
143 struct sci_timer timer;
144
145 /**
146 * This field is the pointer to the port task scheduler registers
147 * for the SCU hardware.
148 */
149 struct scu_port_task_scheduler_registers __iomem
150 *port_task_scheduler_registers;
151
152 /**
153 * This field is identical for all port objects and points to the port
154 * task scheduler group PE configuration registers.
155 * It is used to assign PEs to a port.
156 */
157 u32 __iomem *port_pe_configuration_register;
158
159 /**
160 * This field is the VIIT register space for ths port object.
161 */
162 struct scu_viit_entry __iomem *viit_registers;
163};
164
165
166
167/**
168 * struct isci_port - This class represents the port object used to internally
169 * represent libsas port objects. It also keeps a list of remote device
170 * objects.
171 *
172 *
173 */ 92 */
174struct isci_port { 93struct isci_port {
175 enum isci_status status; 94 enum isci_status status;
@@ -185,16 +104,25 @@ struct isci_port {
185 struct completion start_complete; 104 struct completion start_complete;
186 struct completion hard_reset_complete; 105 struct completion hard_reset_complete;
187 enum sci_status hard_reset_status; 106 enum sci_status hard_reset_status;
188 struct scic_sds_port sci; 107 struct sci_base_state_machine sm;
108 bool ready_exit;
109 u8 logical_port_index;
110 u8 physical_port_index;
111 u8 active_phy_mask;
112 u16 reserved_rni;
113 u16 reserved_tag;
114 u32 started_request_count;
115 u32 assigned_device_count;
116 u32 not_ready_reason;
117 struct isci_phy *phy_table[SCI_MAX_PHYS];
118 struct scic_sds_controller *owning_controller;
119 struct sci_timer timer;
120 struct scu_port_task_scheduler_registers __iomem *port_task_scheduler_registers;
121 /* XXX rework: only one register, no need to replicate per-port */
122 u32 __iomem *port_pe_configuration_register;
123 struct scu_viit_entry __iomem *viit_registers;
189}; 124};
190 125
191static inline struct isci_port *sci_port_to_iport(struct scic_sds_port *sci_port)
192{
193 struct isci_port *iport = container_of(sci_port, typeof(*iport), sci);
194
195 return iport;
196}
197
198enum scic_port_not_ready_reason_code { 126enum scic_port_not_ready_reason_code {
199 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS, 127 SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS,
200 SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED, 128 SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED,
@@ -299,90 +227,90 @@ enum scic_sds_port_states {
299 ((this_port)->physical_port_index) 227 ((this_port)->physical_port_index)
300 228
301 229
302static inline void scic_sds_port_decrement_request_count(struct scic_sds_port *sci_port) 230static inline void scic_sds_port_decrement_request_count(struct isci_port *iport)
303{ 231{
304 if (WARN_ONCE(sci_port->started_request_count == 0, 232 if (WARN_ONCE(iport->started_request_count == 0,
305 "%s: tried to decrement started_request_count past 0!?", 233 "%s: tried to decrement started_request_count past 0!?",
306 __func__)) 234 __func__))
307 /* pass */; 235 /* pass */;
308 else 236 else
309 sci_port->started_request_count--; 237 iport->started_request_count--;
310} 238}
311 239
312#define scic_sds_port_active_phy(port, phy) \ 240#define scic_sds_port_active_phy(port, phy) \
313 (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0) 241 (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0)
314 242
315void scic_sds_port_construct( 243void scic_sds_port_construct(
316 struct scic_sds_port *sci_port, 244 struct isci_port *iport,
317 u8 port_index, 245 u8 port_index,
318 struct scic_sds_controller *scic); 246 struct scic_sds_controller *scic);
319 247
320enum sci_status scic_sds_port_initialize( 248enum sci_status scic_sds_port_initialize(
321 struct scic_sds_port *sci_port, 249 struct isci_port *iport,
322 void __iomem *port_task_scheduler_registers, 250 void __iomem *port_task_scheduler_registers,
323 void __iomem *port_configuration_regsiter, 251 void __iomem *port_configuration_regsiter,
324 void __iomem *viit_registers); 252 void __iomem *viit_registers);
325 253
326enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port); 254enum sci_status scic_sds_port_start(struct isci_port *iport);
327enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port); 255enum sci_status scic_sds_port_stop(struct isci_port *iport);
328 256
329enum sci_status scic_sds_port_add_phy( 257enum sci_status scic_sds_port_add_phy(
330 struct scic_sds_port *sci_port, 258 struct isci_port *iport,
331 struct isci_phy *iphy); 259 struct isci_phy *iphy);
332 260
333enum sci_status scic_sds_port_remove_phy( 261enum sci_status scic_sds_port_remove_phy(
334 struct scic_sds_port *sci_port, 262 struct isci_port *iport,
335 struct isci_phy *iphy); 263 struct isci_phy *iphy);
336 264
337void scic_sds_port_setup_transports( 265void scic_sds_port_setup_transports(
338 struct scic_sds_port *sci_port, 266 struct isci_port *iport,
339 u32 device_id); 267 u32 device_id);
340 268
341void isci_port_bcn_enable(struct isci_host *, struct isci_port *); 269void isci_port_bcn_enable(struct isci_host *, struct isci_port *);
342 270
343void scic_sds_port_deactivate_phy( 271void scic_sds_port_deactivate_phy(
344 struct scic_sds_port *sci_port, 272 struct isci_port *iport,
345 struct isci_phy *iphy, 273 struct isci_phy *iphy,
346 bool do_notify_user); 274 bool do_notify_user);
347 275
348bool scic_sds_port_link_detected( 276bool scic_sds_port_link_detected(
349 struct scic_sds_port *sci_port, 277 struct isci_port *iport,
350 struct isci_phy *iphy); 278 struct isci_phy *iphy);
351 279
352enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port, 280enum sci_status scic_sds_port_link_up(struct isci_port *iport,
353 struct isci_phy *iphy); 281 struct isci_phy *iphy);
354enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, 282enum sci_status scic_sds_port_link_down(struct isci_port *iport,
355 struct isci_phy *iphy); 283 struct isci_phy *iphy);
356 284
357struct isci_request; 285struct isci_request;
358struct scic_sds_remote_device; 286struct scic_sds_remote_device;
359enum sci_status scic_sds_port_start_io( 287enum sci_status scic_sds_port_start_io(
360 struct scic_sds_port *sci_port, 288 struct isci_port *iport,
361 struct scic_sds_remote_device *sci_dev, 289 struct scic_sds_remote_device *sci_dev,
362 struct isci_request *ireq); 290 struct isci_request *ireq);
363 291
364enum sci_status scic_sds_port_complete_io( 292enum sci_status scic_sds_port_complete_io(
365 struct scic_sds_port *sci_port, 293 struct isci_port *iport,
366 struct scic_sds_remote_device *sci_dev, 294 struct scic_sds_remote_device *sci_dev,
367 struct isci_request *ireq); 295 struct isci_request *ireq);
368 296
369enum sas_linkrate scic_sds_port_get_max_allowed_speed( 297enum sas_linkrate scic_sds_port_get_max_allowed_speed(
370 struct scic_sds_port *sci_port); 298 struct isci_port *iport);
371 299
372void scic_sds_port_broadcast_change_received( 300void scic_sds_port_broadcast_change_received(
373 struct scic_sds_port *sci_port, 301 struct isci_port *iport,
374 struct isci_phy *iphy); 302 struct isci_phy *iphy);
375 303
376bool scic_sds_port_is_valid_phy_assignment( 304bool scic_sds_port_is_valid_phy_assignment(
377 struct scic_sds_port *sci_port, 305 struct isci_port *iport,
378 u32 phy_index); 306 u32 phy_index);
379 307
380void scic_sds_port_get_sas_address( 308void scic_sds_port_get_sas_address(
381 struct scic_sds_port *sci_port, 309 struct isci_port *iport,
382 struct sci_sas_address *sas_address); 310 struct sci_sas_address *sas_address);
383 311
384void scic_sds_port_get_attached_sas_address( 312void scic_sds_port_get_attached_sas_address(
385 struct scic_sds_port *sci_port, 313 struct isci_port *iport,
386 struct sci_sas_address *sas_address); 314 struct sci_sas_address *sas_address);
387 315
388enum isci_status isci_port_get_state( 316enum isci_status isci_port_get_state(
diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c
index 8444fd8219dd..bb62d2a25217 100644
--- a/drivers/scsi/isci/port_config.c
+++ b/drivers/scsi/isci/port_config.c
@@ -112,7 +112,7 @@ static s32 sci_sas_address_compare(
112 * port. port address if the port can be found to match the phy. 112 * port. port address if the port can be found to match the phy.
113 * NULL if there is no matching port for the phy. 113 * NULL if there is no matching port for the phy.
114 */ 114 */
115static struct scic_sds_port *scic_sds_port_configuration_agent_find_port( 115static struct isci_port *scic_sds_port_configuration_agent_find_port(
116 struct scic_sds_controller *scic, 116 struct scic_sds_controller *scic,
117 struct isci_phy *iphy) 117 struct isci_phy *iphy)
118{ 118{
@@ -132,14 +132,14 @@ static struct scic_sds_port *scic_sds_port_configuration_agent_find_port(
132 132
133 for (i = 0; i < scic->logical_port_entries; i++) { 133 for (i = 0; i < scic->logical_port_entries; i++) {
134 struct isci_host *ihost = scic_to_ihost(scic); 134 struct isci_host *ihost = scic_to_ihost(scic);
135 struct scic_sds_port *sci_port = &ihost->ports[i].sci; 135 struct isci_port *iport = &ihost->ports[i];
136 136
137 scic_sds_port_get_sas_address(sci_port, &port_sas_address); 137 scic_sds_port_get_sas_address(iport, &port_sas_address);
138 scic_sds_port_get_attached_sas_address(sci_port, &port_attached_device_address); 138 scic_sds_port_get_attached_sas_address(iport, &port_attached_device_address);
139 139
140 if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 && 140 if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 &&
141 sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0) 141 sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0)
142 return sci_port; 142 return iport;
143 } 143 }
144 144
145 return NULL; 145 return NULL;
@@ -315,7 +315,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
315 port_agent->phy_valid_port_range[phy_index].min_index = port_index; 315 port_agent->phy_valid_port_range[phy_index].min_index = port_index;
316 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; 316 port_agent->phy_valid_port_range[phy_index].max_index = phy_index;
317 317
318 scic_sds_port_add_phy(&ihost->ports[port_index].sci, 318 scic_sds_port_add_phy(&ihost->ports[port_index],
319 &ihost->phys[phy_index]); 319 &ihost->phys[phy_index]);
320 320
321 assigned_phy_mask |= (1 << phy_index); 321 assigned_phy_mask |= (1 << phy_index);
@@ -367,22 +367,20 @@ done:
367 367
368static void scic_sds_mpc_agent_link_up(struct scic_sds_controller *controller, 368static void scic_sds_mpc_agent_link_up(struct scic_sds_controller *controller,
369 struct scic_sds_port_configuration_agent *port_agent, 369 struct scic_sds_port_configuration_agent *port_agent,
370 struct scic_sds_port *port, 370 struct isci_port *iport,
371 struct isci_phy *iphy) 371 struct isci_phy *iphy)
372{ 372{
373 /* If the port has an invalid handle then the phy was not assigned to 373 /* If the port is NULL then the phy was not assigned to a port.
374 * a port. This is because the phy was not given the same SAS Address 374 * This is because the phy was not given the same SAS Address as
375 * as the other PHYs in the port. 375 * the other PHYs in the port.
376 */ 376 */
377 if (port != NULL) { 377 if (!iport)
378 port_agent->phy_ready_mask |= (1 << scic_sds_phy_get_index(iphy)); 378 return;
379
380 scic_sds_port_link_up(port, iphy);
381 379
382 if ((port->active_phy_mask & (1 << scic_sds_phy_get_index(iphy))) != 0) { 380 port_agent->phy_ready_mask |= (1 << scic_sds_phy_get_index(iphy));
383 port_agent->phy_configured_mask |= (1 << scic_sds_phy_get_index(iphy)); 381 scic_sds_port_link_up(iport, iphy);
384 } 382 if ((iport->active_phy_mask & (1 << scic_sds_phy_get_index(iphy))))
385 } 383 port_agent->phy_configured_mask |= (1 << scic_sds_phy_get_index(iphy));
386} 384}
387 385
388/** 386/**
@@ -405,10 +403,10 @@ static void scic_sds_mpc_agent_link_up(struct scic_sds_controller *controller,
405static void scic_sds_mpc_agent_link_down( 403static void scic_sds_mpc_agent_link_down(
406 struct scic_sds_controller *scic, 404 struct scic_sds_controller *scic,
407 struct scic_sds_port_configuration_agent *port_agent, 405 struct scic_sds_port_configuration_agent *port_agent,
408 struct scic_sds_port *sci_port, 406 struct isci_port *iport,
409 struct isci_phy *iphy) 407 struct isci_phy *iphy)
410{ 408{
411 if (sci_port != NULL) { 409 if (iport != NULL) {
412 /* 410 /*
413 * If we can form a new port from the remainder of the phys 411 * If we can form a new port from the remainder of the phys
414 * then we want to start the timer to allow the SCI User to 412 * then we want to start the timer to allow the SCI User to
@@ -436,7 +434,7 @@ static void scic_sds_mpc_agent_link_down(
436 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT); 434 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT);
437 } 435 }
438 436
439 scic_sds_port_link_down(sci_port, iphy); 437 scic_sds_port_link_down(iport, iphy);
440 } 438 }
441} 439}
442 440
@@ -496,14 +494,14 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
496{ 494{
497 u8 port_index; 495 u8 port_index;
498 enum sci_status status; 496 enum sci_status status;
499 struct scic_sds_port *port; 497 struct isci_port *iport;
500 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY; 498 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY;
501 struct isci_host *ihost = scic_to_ihost(controller); 499 struct isci_host *ihost = scic_to_ihost(controller);
502 500
503 port = scic_sds_port_configuration_agent_find_port(controller, iphy); 501 iport = scic_sds_port_configuration_agent_find_port(controller, iphy);
504 502
505 if (port != NULL) { 503 if (iport) {
506 if (scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index)) 504 if (scic_sds_port_is_valid_phy_assignment(iport, iphy->phy_index))
507 apc_activity = SCIC_SDS_APC_ADD_PHY; 505 apc_activity = SCIC_SDS_APC_ADD_PHY;
508 else 506 else
509 apc_activity = SCIC_SDS_APC_SKIP_PHY; 507 apc_activity = SCIC_SDS_APC_SKIP_PHY;
@@ -514,21 +512,19 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
514 * the timer and wait to see if a wider port can be made. 512 * the timer and wait to see if a wider port can be made.
515 * 513 *
516 * Note the break when we reach the condition of the port id == phy id */ 514 * Note the break when we reach the condition of the port id == phy id */
517 for ( 515 for (port_index = port_agent->phy_valid_port_range[iphy->phy_index].min_index;
518 port_index = port_agent->phy_valid_port_range[iphy->phy_index].min_index; 516 port_index <= port_agent->phy_valid_port_range[iphy->phy_index].max_index;
519 port_index <= port_agent->phy_valid_port_range[iphy->phy_index].max_index; 517 port_index++) {
520 port_index++
521 ) {
522 518
523 port = &ihost->ports[port_index].sci; 519 iport = &ihost->ports[port_index];
524 520
525 /* First we must make sure that this PHY can be added to this Port. */ 521 /* First we must make sure that this PHY can be added to this Port. */
526 if (scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index)) { 522 if (scic_sds_port_is_valid_phy_assignment(iport, iphy->phy_index)) {
527 /* 523 /*
528 * Port contains a PHY with a greater PHY ID than the current 524 * Port contains a PHY with a greater PHY ID than the current
529 * PHY that has gone link up. This phy can not be part of any 525 * PHY that has gone link up. This phy can not be part of any
530 * port so skip it and move on. */ 526 * port so skip it and move on. */
531 if (port->active_phy_mask > (1 << iphy->phy_index)) { 527 if (iport->active_phy_mask > (1 << iphy->phy_index)) {
532 apc_activity = SCIC_SDS_APC_SKIP_PHY; 528 apc_activity = SCIC_SDS_APC_SKIP_PHY;
533 break; 529 break;
534 } 530 }
@@ -537,7 +533,7 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
537 * We have reached the end of our Port list and have not found 533 * We have reached the end of our Port list and have not found
538 * any reason why we should not either add the PHY to the port 534 * any reason why we should not either add the PHY to the port
539 * or wait for more phys to become active. */ 535 * or wait for more phys to become active. */
540 if (port->physical_port_index == iphy->phy_index) { 536 if (iport->physical_port_index == iphy->phy_index) {
541 /* 537 /*
542 * The Port either has no active PHYs. 538 * The Port either has no active PHYs.
543 * Consider that if the port had any active PHYs we would have 539 * Consider that if the port had any active PHYs we would have
@@ -554,10 +550,10 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
554 * The current Port has no active PHYs and this PHY could be part 550 * The current Port has no active PHYs and this PHY could be part
555 * of this Port. Since we dont know as yet setup to start the 551 * of this Port. Since we dont know as yet setup to start the
556 * timer and see if there is a better configuration. */ 552 * timer and see if there is a better configuration. */
557 if (port->active_phy_mask == 0) { 553 if (iport->active_phy_mask == 0) {
558 apc_activity = SCIC_SDS_APC_START_TIMER; 554 apc_activity = SCIC_SDS_APC_START_TIMER;
559 } 555 }
560 } else if (port->active_phy_mask != 0) { 556 } else if (iport->active_phy_mask != 0) {
561 /* 557 /*
562 * The Port has an active phy and the current Phy can not 558 * The Port has an active phy and the current Phy can not
563 * participate in this port so skip the PHY and see if 559 * participate in this port so skip the PHY and see if
@@ -583,7 +579,7 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
583 579
584 switch (apc_activity) { 580 switch (apc_activity) {
585 case SCIC_SDS_APC_ADD_PHY: 581 case SCIC_SDS_APC_ADD_PHY:
586 status = scic_sds_port_add_phy(port, iphy); 582 status = scic_sds_port_add_phy(iport, iphy);
587 583
588 if (status == SCI_SUCCESS) { 584 if (status == SCI_SUCCESS) {
589 port_agent->phy_configured_mask |= (1 << iphy->phy_index); 585 port_agent->phy_configured_mask |= (1 << iphy->phy_index);
@@ -625,18 +621,18 @@ static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *contr
625 */ 621 */
626static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic, 622static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
627 struct scic_sds_port_configuration_agent *port_agent, 623 struct scic_sds_port_configuration_agent *port_agent,
628 struct scic_sds_port *sci_port, 624 struct isci_port *iport,
629 struct isci_phy *iphy) 625 struct isci_phy *iphy)
630{ 626{
631 u8 phy_index = iphy->phy_index; 627 u8 phy_index = iphy->phy_index;
632 628
633 if (!sci_port) { 629 if (!iport) {
634 /* the phy is not the part of this port */ 630 /* the phy is not the part of this port */
635 port_agent->phy_ready_mask |= 1 << phy_index; 631 port_agent->phy_ready_mask |= 1 << phy_index;
636 scic_sds_apc_agent_configure_ports(scic, port_agent, iphy, true); 632 scic_sds_apc_agent_configure_ports(scic, port_agent, iphy, true);
637 } else { 633 } else {
638 /* the phy is already the part of the port */ 634 /* the phy is already the part of the port */
639 u32 port_state = sci_port->sm.current_state_id; 635 u32 port_state = iport->sm.current_state_id;
640 636
641 /* if the PORT'S state is resetting then the link up is from 637 /* if the PORT'S state is resetting then the link up is from
642 * port hard reset in this case, we need to tell the port 638 * port hard reset in this case, we need to tell the port
@@ -644,7 +640,7 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
644 */ 640 */
645 BUG_ON(port_state != SCI_PORT_RESETTING); 641 BUG_ON(port_state != SCI_PORT_RESETTING);
646 port_agent->phy_ready_mask |= 1 << phy_index; 642 port_agent->phy_ready_mask |= 1 << phy_index;
647 scic_sds_port_link_up(sci_port, iphy); 643 scic_sds_port_link_up(iport, iphy);
648 } 644 }
649} 645}
650 646
@@ -652,9 +648,9 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
652 * 648 *
653 * @controller: This is the controller object that receives the link down 649 * @controller: This is the controller object that receives the link down
654 * notification. 650 * notification.
655 * @port: This is the port object associated with the phy. If the is no 651 * @iport: This is the port object associated with the phy. If the is no
656 * associated port this is an NULL. 652 * associated port this is an NULL.
657 * @phy: This is the phy object which has gone link down. 653 * @iphy: This is the phy object which has gone link down.
658 * 654 *
659 * This method handles the automatic port configuration link down 655 * This method handles the automatic port configuration link down
660 * notifications. not associated with a port there is no action taken. Is it 656 * notifications. not associated with a port there is no action taken. Is it
@@ -664,21 +660,20 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
664static void scic_sds_apc_agent_link_down( 660static void scic_sds_apc_agent_link_down(
665 struct scic_sds_controller *controller, 661 struct scic_sds_controller *controller,
666 struct scic_sds_port_configuration_agent *port_agent, 662 struct scic_sds_port_configuration_agent *port_agent,
667 struct scic_sds_port *port, 663 struct isci_port *iport,
668 struct isci_phy *iphy) 664 struct isci_phy *iphy)
669{ 665{
670 port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(iphy)); 666 port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(iphy));
671 667
672 if (port != NULL) { 668 if (!iport)
673 if (port_agent->phy_configured_mask & (1 << iphy->phy_index)) { 669 return;
674 enum sci_status status; 670 if (port_agent->phy_configured_mask & (1 << iphy->phy_index)) {
671 enum sci_status status;
675 672
676 status = scic_sds_port_remove_phy(port, iphy); 673 status = scic_sds_port_remove_phy(iport, iphy);
677 674
678 if (status == SCI_SUCCESS) { 675 if (status == SCI_SUCCESS)
679 port_agent->phy_configured_mask &= ~(1 << iphy->phy_index); 676 port_agent->phy_configured_mask &= ~(1 << iphy->phy_index);
680 }
681 }
682 } 677 }
683} 678}
684 679
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 71ab9081fe24..627cf731bad8 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -450,11 +450,11 @@ static void scic_sds_remote_device_start_request(struct scic_sds_remote_device *
450 struct isci_request *ireq, 450 struct isci_request *ireq,
451 enum sci_status status) 451 enum sci_status status)
452{ 452{
453 struct scic_sds_port *sci_port = sci_dev->owning_port; 453 struct isci_port *iport = sci_dev->owning_port;
454 454
455 /* cleanup requests that failed after starting on the port */ 455 /* cleanup requests that failed after starting on the port */
456 if (status != SCI_SUCCESS) 456 if (status != SCI_SUCCESS)
457 scic_sds_port_complete_io(sci_port, sci_dev, ireq); 457 scic_sds_port_complete_io(iport, sci_dev, ireq);
458 else { 458 else {
459 kref_get(&sci_dev_to_idev(sci_dev)->kref); 459 kref_get(&sci_dev_to_idev(sci_dev)->kref);
460 scic_sds_remote_device_increment_request_count(sci_dev); 460 scic_sds_remote_device_increment_request_count(sci_dev);
@@ -467,7 +467,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
467{ 467{
468 struct sci_base_state_machine *sm = &sci_dev->sm; 468 struct sci_base_state_machine *sm = &sci_dev->sm;
469 enum scic_sds_remote_device_states state = sm->current_state_id; 469 enum scic_sds_remote_device_states state = sm->current_state_id;
470 struct scic_sds_port *sci_port = sci_dev->owning_port; 470 struct isci_port *iport = sci_dev->owning_port;
471 enum sci_status status; 471 enum sci_status status;
472 472
473 switch (state) { 473 switch (state) {
@@ -489,7 +489,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
489 * successful it will start the request for the port object then 489 * successful it will start the request for the port object then
490 * increment its own request count. 490 * increment its own request count.
491 */ 491 */
492 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 492 status = scic_sds_port_start_io(iport, sci_dev, ireq);
493 if (status != SCI_SUCCESS) 493 if (status != SCI_SUCCESS)
494 return status; 494 return status;
495 495
@@ -511,7 +511,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
511 enum scic_sds_remote_device_states new_state; 511 enum scic_sds_remote_device_states new_state;
512 struct sas_task *task = isci_request_access_task(ireq); 512 struct sas_task *task = isci_request_access_task(ireq);
513 513
514 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 514 status = scic_sds_port_start_io(iport, sci_dev, ireq);
515 if (status != SCI_SUCCESS) 515 if (status != SCI_SUCCESS)
516 return status; 516 return status;
517 517
@@ -536,7 +536,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
536 struct sas_task *task = isci_request_access_task(ireq); 536 struct sas_task *task = isci_request_access_task(ireq);
537 537
538 if (task->ata_task.use_ncq) { 538 if (task->ata_task.use_ncq) {
539 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 539 status = scic_sds_port_start_io(iport, sci_dev, ireq);
540 if (status != SCI_SUCCESS) 540 if (status != SCI_SUCCESS)
541 return status; 541 return status;
542 542
@@ -552,7 +552,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
552 case SCI_STP_DEV_AWAIT_RESET: 552 case SCI_STP_DEV_AWAIT_RESET:
553 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; 553 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
554 case SCI_SMP_DEV_IDLE: 554 case SCI_SMP_DEV_IDLE:
555 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 555 status = scic_sds_port_start_io(iport, sci_dev, ireq);
556 if (status != SCI_SUCCESS) 556 if (status != SCI_SUCCESS)
557 return status; 557 return status;
558 558
@@ -579,7 +579,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
579 return status; 579 return status;
580} 580}
581 581
582static enum sci_status common_complete_io(struct scic_sds_port *sci_port, 582static enum sci_status common_complete_io(struct isci_port *iport,
583 struct scic_sds_remote_device *sci_dev, 583 struct scic_sds_remote_device *sci_dev,
584 struct isci_request *ireq) 584 struct isci_request *ireq)
585{ 585{
@@ -589,7 +589,7 @@ static enum sci_status common_complete_io(struct scic_sds_port *sci_port,
589 if (status != SCI_SUCCESS) 589 if (status != SCI_SUCCESS)
590 return status; 590 return status;
591 591
592 status = scic_sds_port_complete_io(sci_port, sci_dev, ireq); 592 status = scic_sds_port_complete_io(iport, sci_dev, ireq);
593 if (status != SCI_SUCCESS) 593 if (status != SCI_SUCCESS)
594 return status; 594 return status;
595 595
@@ -603,7 +603,7 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
603{ 603{
604 struct sci_base_state_machine *sm = &sci_dev->sm; 604 struct sci_base_state_machine *sm = &sci_dev->sm;
605 enum scic_sds_remote_device_states state = sm->current_state_id; 605 enum scic_sds_remote_device_states state = sm->current_state_id;
606 struct scic_sds_port *sci_port = sci_dev->owning_port; 606 struct isci_port *iport = sci_dev->owning_port;
607 enum sci_status status; 607 enum sci_status status;
608 608
609 switch (state) { 609 switch (state) {
@@ -621,12 +621,12 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
621 case SCI_DEV_READY: 621 case SCI_DEV_READY:
622 case SCI_STP_DEV_AWAIT_RESET: 622 case SCI_STP_DEV_AWAIT_RESET:
623 case SCI_DEV_RESETTING: 623 case SCI_DEV_RESETTING:
624 status = common_complete_io(sci_port, sci_dev, ireq); 624 status = common_complete_io(iport, sci_dev, ireq);
625 break; 625 break;
626 case SCI_STP_DEV_CMD: 626 case SCI_STP_DEV_CMD:
627 case SCI_STP_DEV_NCQ: 627 case SCI_STP_DEV_NCQ:
628 case SCI_STP_DEV_NCQ_ERROR: 628 case SCI_STP_DEV_NCQ_ERROR:
629 status = common_complete_io(sci_port, sci_dev, ireq); 629 status = common_complete_io(iport, sci_dev, ireq);
630 if (status != SCI_SUCCESS) 630 if (status != SCI_SUCCESS)
631 break; 631 break;
632 632
@@ -641,13 +641,13 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
641 sci_change_state(sm, SCI_STP_DEV_IDLE); 641 sci_change_state(sm, SCI_STP_DEV_IDLE);
642 break; 642 break;
643 case SCI_SMP_DEV_CMD: 643 case SCI_SMP_DEV_CMD:
644 status = common_complete_io(sci_port, sci_dev, ireq); 644 status = common_complete_io(iport, sci_dev, ireq);
645 if (status != SCI_SUCCESS) 645 if (status != SCI_SUCCESS)
646 break; 646 break;
647 sci_change_state(sm, SCI_SMP_DEV_IDLE); 647 sci_change_state(sm, SCI_SMP_DEV_IDLE);
648 break; 648 break;
649 case SCI_DEV_STOPPING: 649 case SCI_DEV_STOPPING:
650 status = common_complete_io(sci_port, sci_dev, ireq); 650 status = common_complete_io(iport, sci_dev, ireq);
651 if (status != SCI_SUCCESS) 651 if (status != SCI_SUCCESS)
652 break; 652 break;
653 653
@@ -661,7 +661,7 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
661 if (status != SCI_SUCCESS) 661 if (status != SCI_SUCCESS)
662 dev_err(scirdev_to_dev(sci_dev), 662 dev_err(scirdev_to_dev(sci_dev),
663 "%s: Port:0x%p Device:0x%p Request:0x%p Status:0x%x " 663 "%s: Port:0x%p Device:0x%p Request:0x%p Status:0x%x "
664 "could not complete\n", __func__, sci_port, 664 "could not complete\n", __func__, iport,
665 sci_dev, ireq, status); 665 sci_dev, ireq, status);
666 else 666 else
667 isci_put_device(sci_dev_to_idev(sci_dev)); 667 isci_put_device(sci_dev_to_idev(sci_dev));
@@ -684,7 +684,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
684{ 684{
685 struct sci_base_state_machine *sm = &sci_dev->sm; 685 struct sci_base_state_machine *sm = &sci_dev->sm;
686 enum scic_sds_remote_device_states state = sm->current_state_id; 686 enum scic_sds_remote_device_states state = sm->current_state_id;
687 struct scic_sds_port *sci_port = sci_dev->owning_port; 687 struct isci_port *iport = sci_dev->owning_port;
688 enum sci_status status; 688 enum sci_status status;
689 689
690 switch (state) { 690 switch (state) {
@@ -706,7 +706,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
706 case SCI_STP_DEV_NCQ: 706 case SCI_STP_DEV_NCQ:
707 case SCI_STP_DEV_NCQ_ERROR: 707 case SCI_STP_DEV_NCQ_ERROR:
708 case SCI_STP_DEV_AWAIT_RESET: 708 case SCI_STP_DEV_AWAIT_RESET:
709 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 709 status = scic_sds_port_start_io(iport, sci_dev, ireq);
710 if (status != SCI_SUCCESS) 710 if (status != SCI_SUCCESS)
711 return status; 711 return status;
712 712
@@ -746,7 +746,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
746 */ 746 */
747 return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS; 747 return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS;
748 case SCI_DEV_READY: 748 case SCI_DEV_READY:
749 status = scic_sds_port_start_io(sci_port, sci_dev, ireq); 749 status = scic_sds_port_start_io(iport, sci_dev, ireq);
750 if (status != SCI_SUCCESS) 750 if (status != SCI_SUCCESS)
751 return status; 751 return status;
752 752
@@ -1064,10 +1064,10 @@ static const struct sci_base_state scic_sds_remote_device_state_table[] = {
1064 * scic_remote_device_[de]a_construct(). scic_remote_device_destruct() 1064 * scic_remote_device_[de]a_construct(). scic_remote_device_destruct()
1065 * frees the remote_node_context(s) for the device. 1065 * frees the remote_node_context(s) for the device.
1066 */ 1066 */
1067static void scic_remote_device_construct(struct scic_sds_port *sci_port, 1067static void scic_remote_device_construct(struct isci_port *iport,
1068 struct scic_sds_remote_device *sci_dev) 1068 struct scic_sds_remote_device *sci_dev)
1069{ 1069{
1070 sci_dev->owning_port = sci_port; 1070 sci_dev->owning_port = iport;
1071 sci_dev->started_request_count = 0; 1071 sci_dev->started_request_count = 0;
1072 1072
1073 sci_init_sm(&sci_dev->sm, scic_sds_remote_device_state_table, SCI_DEV_INITIAL); 1073 sci_init_sm(&sci_dev->sm, scic_sds_remote_device_state_table, SCI_DEV_INITIAL);
@@ -1090,20 +1090,20 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port,
1090 * sata-only controller instance. 1090 * sata-only controller instance.
1091 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. 1091 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1092 */ 1092 */
1093static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci_port, 1093static enum sci_status scic_remote_device_da_construct(struct isci_port *iport,
1094 struct scic_sds_remote_device *sci_dev) 1094 struct scic_sds_remote_device *sci_dev)
1095{ 1095{
1096 enum sci_status status; 1096 enum sci_status status;
1097 struct domain_device *dev = sci_dev_to_domain(sci_dev); 1097 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1098 1098
1099 scic_remote_device_construct(sci_port, sci_dev); 1099 scic_remote_device_construct(iport, sci_dev);
1100 1100
1101 /* 1101 /*
1102 * This information is request to determine how many remote node context 1102 * This information is request to determine how many remote node context
1103 * entries will be needed to store the remote node. 1103 * entries will be needed to store the remote node.
1104 */ 1104 */
1105 sci_dev->is_direct_attached = true; 1105 sci_dev->is_direct_attached = true;
1106 status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller, 1106 status = scic_sds_controller_allocate_remote_node_context(iport->owning_controller,
1107 sci_dev, 1107 sci_dev,
1108 &sci_dev->rnc.remote_node_index); 1108 &sci_dev->rnc.remote_node_index);
1109 1109
@@ -1116,7 +1116,7 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
1116 else 1116 else
1117 return SCI_FAILURE_UNSUPPORTED_PROTOCOL; 1117 return SCI_FAILURE_UNSUPPORTED_PROTOCOL;
1118 1118
1119 sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(sci_port); 1119 sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(iport);
1120 1120
1121 /* / @todo Should I assign the port width by reading all of the phys on the port? */ 1121 /* / @todo Should I assign the port width by reading all of the phys on the port? */
1122 sci_dev->device_port_width = 1; 1122 sci_dev->device_port_width = 1;
@@ -1136,15 +1136,15 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
1136 * sata-only controller instance. 1136 * sata-only controller instance.
1137 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. 1137 * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted.
1138 */ 1138 */
1139static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci_port, 1139static enum sci_status scic_remote_device_ea_construct(struct isci_port *iport,
1140 struct scic_sds_remote_device *sci_dev) 1140 struct scic_sds_remote_device *sci_dev)
1141{ 1141{
1142 struct domain_device *dev = sci_dev_to_domain(sci_dev); 1142 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1143 enum sci_status status; 1143 enum sci_status status;
1144 1144
1145 scic_remote_device_construct(sci_port, sci_dev); 1145 scic_remote_device_construct(iport, sci_dev);
1146 1146
1147 status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller, 1147 status = scic_sds_controller_allocate_remote_node_context(iport->owning_controller,
1148 sci_dev, 1148 sci_dev,
1149 &sci_dev->rnc.remote_node_index); 1149 &sci_dev->rnc.remote_node_index);
1150 if (status != SCI_SUCCESS) 1150 if (status != SCI_SUCCESS)
@@ -1163,7 +1163,7 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
1163 * connection the logical link rate is that same as the 1163 * connection the logical link rate is that same as the
1164 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay 1164 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay
1165 * one another, so this code works for both situations. */ 1165 * one another, so this code works for both situations. */
1166 sci_dev->connection_rate = min_t(u16, scic_sds_port_get_max_allowed_speed(sci_port), 1166 sci_dev->connection_rate = min_t(u16, scic_sds_port_get_max_allowed_speed(iport),
1167 dev->linkrate); 1167 dev->linkrate);
1168 1168
1169 /* / @todo Should I assign the port width by reading all of the phys on the port? */ 1169 /* / @todo Should I assign the port width by reading all of the phys on the port? */
@@ -1212,15 +1212,14 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s
1212static enum sci_status isci_remote_device_construct(struct isci_port *iport, 1212static enum sci_status isci_remote_device_construct(struct isci_port *iport,
1213 struct isci_remote_device *idev) 1213 struct isci_remote_device *idev)
1214{ 1214{
1215 struct scic_sds_port *sci_port = &iport->sci;
1216 struct isci_host *ihost = iport->isci_host; 1215 struct isci_host *ihost = iport->isci_host;
1217 struct domain_device *dev = idev->domain_dev; 1216 struct domain_device *dev = idev->domain_dev;
1218 enum sci_status status; 1217 enum sci_status status;
1219 1218
1220 if (dev->parent && dev_is_expander(dev->parent)) 1219 if (dev->parent && dev_is_expander(dev->parent))
1221 status = scic_remote_device_ea_construct(sci_port, &idev->sci); 1220 status = scic_remote_device_ea_construct(iport, &idev->sci);
1222 else 1221 else
1223 status = scic_remote_device_da_construct(sci_port, &idev->sci); 1222 status = scic_remote_device_da_construct(iport, &idev->sci);
1224 1223
1225 if (status != SCI_SUCCESS) { 1224 if (status != SCI_SUCCESS) {
1226 dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n", 1225 dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n",
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h
index 6ac5dfb7d1db..578d75b8cd16 100644
--- a/drivers/scsi/isci/remote_device.h
+++ b/drivers/scsi/isci/remote_device.h
@@ -100,7 +100,7 @@ struct scic_sds_remote_device {
100 * This filed contains a pointer back to the port to which this device 100 * This filed contains a pointer back to the port to which this device
101 * is assigned. 101 * is assigned.
102 */ 102 */
103 struct scic_sds_port *owning_port; 103 struct isci_port *owning_port;
104 104
105 /** 105 /**
106 * This field contains the SCU silicon remote node context specific 106 * This field contains the SCU silicon remote node context specific
@@ -388,14 +388,6 @@ static inline bool dev_is_expander(struct domain_device *dev)
388 ((sci_dev)->started_request_count) 388 ((sci_dev)->started_request_count)
389 389
390/** 390/**
391 * scic_sds_remote_device_get_port() -
392 *
393 * This macro returns the owning port of this remote device obejct.
394 */
395#define scic_sds_remote_device_get_port(sci_dev) \
396 ((sci_dev)->owning_port)
397
398/**
399 * scic_sds_remote_device_get_controller() - 391 * scic_sds_remote_device_get_controller() -
400 * 392 *
401 * This macro returns the controller object that contains this device object 393 * This macro returns the controller object that contains this device object
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index c544bc79ce17..2d29abf3ce1f 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -210,10 +210,10 @@ static void scu_ssp_reqeust_construct_task_context(
210{ 210{
211 dma_addr_t dma_addr; 211 dma_addr_t dma_addr;
212 struct scic_sds_remote_device *target_device; 212 struct scic_sds_remote_device *target_device;
213 struct scic_sds_port *target_port; 213 struct isci_port *iport;
214 214
215 target_device = scic_sds_request_get_device(ireq); 215 target_device = scic_sds_request_get_device(ireq);
216 target_port = scic_sds_request_get_port(ireq); 216 iport = scic_sds_request_get_port(ireq);
217 217
218 /* Fill in the TC with the its required data */ 218 /* Fill in the TC with the its required data */
219 task_context->abort = 0; 219 task_context->abort = 0;
@@ -222,8 +222,7 @@ static void scu_ssp_reqeust_construct_task_context(
222 task_context->connection_rate = target_device->connection_rate; 222 task_context->connection_rate = target_device->connection_rate;
223 task_context->protocol_engine_index = 223 task_context->protocol_engine_index =
224 scic_sds_controller_get_protocol_engine_group(controller); 224 scic_sds_controller_get_protocol_engine_group(controller);
225 task_context->logical_port_index = 225 task_context->logical_port_index = scic_sds_port_get_index(iport);
226 scic_sds_port_get_index(target_port);
227 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; 226 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP;
228 task_context->valid = SCU_TASK_CONTEXT_VALID; 227 task_context->valid = SCU_TASK_CONTEXT_VALID;
229 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 228 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
@@ -245,11 +244,11 @@ static void scu_ssp_reqeust_construct_task_context(
245 task_context->task_phase = 0x01; 244 task_context->task_phase = 0x01;
246 245
247 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 246 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
248 (scic_sds_controller_get_protocol_engine_group(controller) << 247 (scic_sds_controller_get_protocol_engine_group(controller) <<
249 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | 248 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
250 (scic_sds_port_get_index(target_port) << 249 (scic_sds_port_get_index(iport) <<
251 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | 250 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
252 ISCI_TAG_TCI(ireq->io_tag)); 251 ISCI_TAG_TCI(ireq->io_tag));
253 252
254 /* 253 /*
255 * Copy the physical address for the command buffer to the 254 * Copy the physical address for the command buffer to the
@@ -350,10 +349,10 @@ static void scu_sata_reqeust_construct_task_context(
350{ 349{
351 dma_addr_t dma_addr; 350 dma_addr_t dma_addr;
352 struct scic_sds_remote_device *target_device; 351 struct scic_sds_remote_device *target_device;
353 struct scic_sds_port *target_port; 352 struct isci_port *iport;
354 353
355 target_device = scic_sds_request_get_device(ireq); 354 target_device = scic_sds_request_get_device(ireq);
356 target_port = scic_sds_request_get_port(ireq); 355 iport = scic_sds_request_get_port(ireq);
357 356
358 /* Fill in the TC with the its required data */ 357 /* Fill in the TC with the its required data */
359 task_context->abort = 0; 358 task_context->abort = 0;
@@ -363,7 +362,7 @@ static void scu_sata_reqeust_construct_task_context(
363 task_context->protocol_engine_index = 362 task_context->protocol_engine_index =
364 scic_sds_controller_get_protocol_engine_group(controller); 363 scic_sds_controller_get_protocol_engine_group(controller);
365 task_context->logical_port_index = 364 task_context->logical_port_index =
366 scic_sds_port_get_index(target_port); 365 scic_sds_port_get_index(iport);
367 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP; 366 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP;
368 task_context->valid = SCU_TASK_CONTEXT_VALID; 367 task_context->valid = SCU_TASK_CONTEXT_VALID;
369 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 368 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
@@ -391,7 +390,7 @@ static void scu_sata_reqeust_construct_task_context(
391 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 390 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
392 (scic_sds_controller_get_protocol_engine_group(controller) << 391 (scic_sds_controller_get_protocol_engine_group(controller) <<
393 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | 392 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
394 (scic_sds_port_get_index(target_port) << 393 (scic_sds_port_get_index(iport) <<
395 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | 394 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
396 ISCI_TAG_TCI(ireq->io_tag)); 395 ISCI_TAG_TCI(ireq->io_tag));
397 /* 396 /*
@@ -3105,7 +3104,7 @@ scic_io_request_construct_smp(struct device *dev,
3105 struct scatterlist *sg = &task->smp_task.smp_req; 3104 struct scatterlist *sg = &task->smp_task.smp_req;
3106 struct scic_sds_remote_device *sci_dev; 3105 struct scic_sds_remote_device *sci_dev;
3107 struct scu_task_context *task_context; 3106 struct scu_task_context *task_context;
3108 struct scic_sds_port *sci_port; 3107 struct isci_port *iport;
3109 struct smp_req *smp_req; 3108 struct smp_req *smp_req;
3110 void *kaddr; 3109 void *kaddr;
3111 u8 req_len; 3110 u8 req_len;
@@ -3149,7 +3148,7 @@ scic_io_request_construct_smp(struct device *dev,
3149 task_context = ireq->tc; 3148 task_context = ireq->tc;
3150 3149
3151 sci_dev = scic_sds_request_get_device(ireq); 3150 sci_dev = scic_sds_request_get_device(ireq);
3152 sci_port = scic_sds_request_get_port(ireq); 3151 iport = scic_sds_request_get_port(ireq);
3153 3152
3154 /* 3153 /*
3155 * Fill in the TC with the its required data 3154 * Fill in the TC with the its required data
@@ -3160,7 +3159,7 @@ scic_io_request_construct_smp(struct device *dev,
3160 task_context->connection_rate = sci_dev->connection_rate; 3159 task_context->connection_rate = sci_dev->connection_rate;
3161 task_context->protocol_engine_index = 3160 task_context->protocol_engine_index =
3162 scic_sds_controller_get_protocol_engine_group(scic); 3161 scic_sds_controller_get_protocol_engine_group(scic);
3163 task_context->logical_port_index = scic_sds_port_get_index(sci_port); 3162 task_context->logical_port_index = scic_sds_port_get_index(iport);
3164 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; 3163 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP;
3165 task_context->abort = 0; 3164 task_context->abort = 0;
3166 task_context->valid = SCU_TASK_CONTEXT_VALID; 3165 task_context->valid = SCU_TASK_CONTEXT_VALID;
@@ -3204,7 +3203,7 @@ scic_io_request_construct_smp(struct device *dev,
3204 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 3203 ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
3205 (scic_sds_controller_get_protocol_engine_group(scic) << 3204 (scic_sds_controller_get_protocol_engine_group(scic) <<
3206 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | 3205 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
3207 (scic_sds_port_get_index(sci_port) << 3206 (scic_sds_port_get_index(iport) <<
3208 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | 3207 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
3209 ISCI_TAG_TCI(ireq->io_tag)); 3208 ISCI_TAG_TCI(ireq->io_tag));
3210 /* 3209 /*