aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-07 13:11:43 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:47 -0400
commite531381e2f8a68b8737c63c7bb890ad80b2470bd (patch)
treeb3f4deb3286269fa62e5c2ff94338dab4743f2c9
parent4b33981ade7cf723f3f32809e34192376c9a10f8 (diff)
isci: unify port data structures
Make scic_sds_port a member of isci_port and merge their lifetimes which means removing the port table from scic_sds_controller in favor of the one at the isci_host level. Merge ihost->sas_ports into ihost->ports. _ Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.c19
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.h7
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c44
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.h5
-rw-r--r--drivers/scsi/isci/core/scic_sds_port_configuration_agent.c18
-rw-r--r--drivers/scsi/isci/host.c6
-rw-r--r--drivers/scsi/isci/host.h7
-rw-r--r--drivers/scsi/isci/init.c4
-rw-r--r--drivers/scsi/isci/port.c41
-rw-r--r--drivers/scsi/isci/port.h25
-rw-r--r--drivers/scsi/isci/remote_device.c2
-rw-r--r--drivers/scsi/isci/sci_environment.h2
12 files changed, 67 insertions, 113 deletions
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index 4ad31550c8ae..4179bdf3eda7 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -623,9 +623,10 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller
623 u32 index; 623 u32 index;
624 enum sci_status port_status; 624 enum sci_status port_status;
625 enum sci_status status = SCI_SUCCESS; 625 enum sci_status status = SCI_SUCCESS;
626 struct isci_host *ihost = scic_to_ihost(scic);
626 627
627 for (index = 0; index < scic->logical_port_entries; index++) { 628 for (index = 0; index < scic->logical_port_entries; index++) {
628 struct scic_sds_port *sci_port = &scic->port_table[index]; 629 struct scic_sds_port *sci_port = &ihost->ports[index].sci;
629 scic_sds_port_handler_t stop; 630 scic_sds_port_handler_t stop;
630 631
631 stop = sci_port->state_handlers->stop_handler; 632 stop = sci_port->state_handlers->stop_handler;
@@ -2686,7 +2687,7 @@ enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
2686 (result == SCI_SUCCESS); 2687 (result == SCI_SUCCESS);
2687 index++) { 2688 index++) {
2688 result = scic_sds_port_initialize( 2689 result = scic_sds_port_initialize(
2689 &scic->port_table[index], 2690 &ihost->ports[index].sci,
2690 &scic->scu_registers->peg0.ptsg.port[index], 2691 &scic->scu_registers->peg0.ptsg.port[index],
2691 &scic->scu_registers->peg0.ptsg.protocol_engine, 2692 &scic->scu_registers->peg0.ptsg.protocol_engine,
2692 &scic->scu_registers->peg0.viit[index]); 2693 &scic->scu_registers->peg0.viit[index]);
@@ -2709,8 +2710,9 @@ enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
2709} 2710}
2710 2711
2711enum sci_status scic_controller_start(struct scic_sds_controller *scic, 2712enum sci_status scic_controller_start(struct scic_sds_controller *scic,
2712 u32 timeout) 2713 u32 timeout)
2713{ 2714{
2715 struct isci_host *ihost = scic_to_ihost(scic);
2714 enum sci_status result; 2716 enum sci_status result;
2715 u16 index; 2717 u16 index;
2716 2718
@@ -2752,10 +2754,9 @@ enum sci_status scic_controller_start(struct scic_sds_controller *scic,
2752 2754
2753 /* Start all of the ports on this controller */ 2755 /* Start all of the ports on this controller */
2754 for (index = 0; index < scic->logical_port_entries; index++) { 2756 for (index = 0; index < scic->logical_port_entries; index++) {
2755 struct scic_sds_port *sci_port = &scic->port_table[index]; 2757 struct scic_sds_port *sci_port = &ihost->ports[index].sci;
2756 2758
2757 result = sci_port->state_handlers->start_handler( 2759 result = sci_port->state_handlers->start_handler(sci_port);
2758 sci_port);
2759 if (result) 2760 if (result)
2760 return result; 2761 return result;
2761 } 2762 }
@@ -2944,14 +2945,14 @@ enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
2944 2945
2945 /* Construct the ports for this controller */ 2946 /* Construct the ports for this controller */
2946 for (i = 0; i < SCI_MAX_PORTS; i++) 2947 for (i = 0; i < SCI_MAX_PORTS; i++)
2947 scic_sds_port_construct(&scic->port_table[i], i, scic); 2948 scic_sds_port_construct(&ihost->ports[i].sci, i, scic);
2948 scic_sds_port_construct(&scic->port_table[i], SCIC_SDS_DUMMY_PORT, scic); 2949 scic_sds_port_construct(&ihost->ports[i].sci, SCIC_SDS_DUMMY_PORT, scic);
2949 2950
2950 /* Construct the phys for this controller */ 2951 /* Construct the phys for this controller */
2951 for (i = 0; i < SCI_MAX_PHYS; i++) { 2952 for (i = 0; i < SCI_MAX_PHYS; i++) {
2952 /* Add all the PHYs to the dummy port */ 2953 /* Add all the PHYs to the dummy port */
2953 scic_sds_phy_construct(&ihost->phys[i].sci, 2954 scic_sds_phy_construct(&ihost->phys[i].sci,
2954 &scic->port_table[SCI_MAX_PORTS], i); 2955 &ihost->ports[SCI_MAX_PORTS].sci, i);
2955 } 2956 }
2956 2957
2957 scic->invalid_phy_mask = 0; 2958 scic->invalid_phy_mask = 0;
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h
index aaaf15ab7cfb..0d5047319cbf 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.h
+++ b/drivers/scsi/isci/core/scic_sds_controller.h
@@ -161,13 +161,6 @@ struct scic_sds_controller {
161 struct scic_sds_port_configuration_agent port_agent; 161 struct scic_sds_port_configuration_agent port_agent;
162 162
163 /** 163 /**
164 * This field is the array of port objects that are controlled by this
165 * controller object. There is one dummy port object also contained within
166 * this controller object.
167 */
168 struct scic_sds_port port_table[SCI_MAX_PORTS + 1];
169
170 /**
171 * This field is the array of device objects that are currently constructed 164 * This field is the array of device objects that are currently constructed
172 * for this controller object. This table is used as a fast lookup of device 165 * for this controller object. This table is used as a fast lookup of device
173 * objects that need to handle device completion notifications from the 166 * objects that need to handle device completion notifications from the
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index 84b8abb421a3..01288dd44fb6 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -283,18 +283,14 @@ static enum sci_status scic_sds_port_clear_phy(
283 struct scic_sds_phy *phy) 283 struct scic_sds_phy *phy)
284{ 284{
285 /* Make sure that this phy is part of this port */ 285 /* Make sure that this phy is part of this port */
286 if ( 286 if (port->phy_table[phy->phy_index] == phy &&
287 (port->phy_table[phy->phy_index] == phy) 287 scic_sds_phy_get_port(phy) == port) {
288 && (scic_sds_phy_get_port(phy) == port) 288 struct scic_sds_controller *scic = port->owning_controller;
289 ) { 289 struct isci_host *ihost = scic_to_ihost(scic);
290 /* Yep it is assigned to this port so remove it */
291 scic_sds_phy_set_port(
292 phy,
293 &scic_sds_port_get_controller(port)->port_table[SCI_MAX_PORTS]
294 );
295 290
291 /* Yep it is assigned to this port so remove it */
292 scic_sds_phy_set_port(phy, &ihost->ports[SCI_MAX_PORTS].sci);
296 port->phy_table[phy->phy_index] = NULL; 293 port->phy_table[phy->phy_index] = NULL;
297
298 return SCI_SUCCESS; 294 return SCI_SUCCESS;
299 } 295 }
300 296
@@ -643,7 +639,7 @@ void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
643 bool do_notify_user) 639 bool do_notify_user)
644{ 640{
645 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); 641 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
646 struct isci_port *iport = sci_port->iport; 642 struct isci_port *iport = sci_port_to_iport(sci_port);
647 struct isci_host *ihost = scic_to_ihost(scic); 643 struct isci_host *ihost = scic_to_ihost(scic);
648 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy); 644 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
649 645
@@ -1620,10 +1616,9 @@ static void scic_sds_port_ready_substate_operational_enter(void *object)
1620{ 1616{
1621 u32 index; 1617 u32 index;
1622 struct scic_sds_port *sci_port = object; 1618 struct scic_sds_port *sci_port = object;
1623 struct scic_sds_controller *scic = 1619 struct scic_sds_controller *scic = sci_port->owning_controller;
1624 scic_sds_port_get_controller(sci_port);
1625 struct isci_host *ihost = scic_to_ihost(scic); 1620 struct isci_host *ihost = scic_to_ihost(scic);
1626 struct isci_port *iport = sci_port->iport; 1621 struct isci_port *iport = sci_port_to_iport(sci_port);
1627 1622
1628 scic_sds_port_set_ready_state_handlers( 1623 scic_sds_port_set_ready_state_handlers(
1629 sci_port, 1624 sci_port,
@@ -1661,10 +1656,9 @@ static void scic_sds_port_ready_substate_operational_enter(void *object)
1661static void scic_sds_port_ready_substate_operational_exit(void *object) 1656static void scic_sds_port_ready_substate_operational_exit(void *object)
1662{ 1657{
1663 struct scic_sds_port *sci_port = object; 1658 struct scic_sds_port *sci_port = object;
1664 struct scic_sds_controller *scic = 1659 struct scic_sds_controller *scic = sci_port->owning_controller;
1665 scic_sds_port_get_controller(sci_port);
1666 struct isci_host *ihost = scic_to_ihost(scic); 1660 struct isci_host *ihost = scic_to_ihost(scic);
1667 struct isci_port *iport = sci_port->iport; 1661 struct isci_port *iport = sci_port_to_iport(sci_port);
1668 1662
1669 /* 1663 /*
1670 * Kill the dummy task for this port if it has not yet posted 1664 * Kill the dummy task for this port if it has not yet posted
@@ -1692,10 +1686,9 @@ static void scic_sds_port_ready_substate_operational_exit(void *object)
1692static void scic_sds_port_ready_substate_configuring_enter(void *object) 1686static void scic_sds_port_ready_substate_configuring_enter(void *object)
1693{ 1687{
1694 struct scic_sds_port *sci_port = object; 1688 struct scic_sds_port *sci_port = object;
1695 struct scic_sds_controller *scic = 1689 struct scic_sds_controller *scic = sci_port->owning_controller;
1696 scic_sds_port_get_controller(sci_port);
1697 struct isci_host *ihost = scic_to_ihost(scic); 1690 struct isci_host *ihost = scic_to_ihost(scic);
1698 struct isci_port *iport = sci_port->iport; 1691 struct isci_port *iport = sci_port_to_iport(sci_port);
1699 1692
1700 scic_sds_port_set_ready_state_handlers( 1693 scic_sds_port_set_ready_state_handlers(
1701 sci_port, 1694 sci_port,
@@ -2259,7 +2252,7 @@ static void scic_sds_port_ready_state_enter(void *object)
2259 struct scic_sds_port *sci_port = object; 2252 struct scic_sds_port *sci_port = object;
2260 struct scic_sds_controller *scic = sci_port->owning_controller; 2253 struct scic_sds_controller *scic = sci_port->owning_controller;
2261 struct isci_host *ihost = scic_to_ihost(scic); 2254 struct isci_host *ihost = scic_to_ihost(scic);
2262 struct isci_port *iport = sci_port->iport; 2255 struct isci_port *iport = sci_port_to_iport(sci_port);
2263 u32 prev_state; 2256 u32 prev_state;
2264 2257
2265 /* Put the ready state handlers in place though they will not be there long */ 2258 /* Put the ready state handlers in place though they will not be there long */
@@ -2366,7 +2359,7 @@ scic_sds_port_stopping_state_exit(void *object)
2366static void scic_sds_port_failed_state_enter(void *object) 2359static void scic_sds_port_failed_state_enter(void *object)
2367{ 2360{
2368 struct scic_sds_port *sci_port = object; 2361 struct scic_sds_port *sci_port = object;
2369 struct isci_port *iport = sci_port->iport; 2362 struct isci_port *iport = sci_port_to_iport(sci_port);
2370 2363
2371 scic_sds_port_set_base_state_handlers(sci_port, 2364 scic_sds_port_set_base_state_handlers(sci_port,
2372 SCI_BASE_PORT_STATE_FAILED); 2365 SCI_BASE_PORT_STATE_FAILED);
@@ -2398,11 +2391,9 @@ static const struct sci_base_state scic_sds_port_state_table[] = {
2398 } 2391 }
2399}; 2392};
2400 2393
2401void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index, 2394void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
2402 struct scic_sds_controller *scic) 2395 struct scic_sds_controller *scic)
2403{ 2396{
2404 u32 index;
2405
2406 sci_base_state_machine_construct(&sci_port->state_machine, 2397 sci_base_state_machine_construct(&sci_port->state_machine,
2407 sci_port, 2398 sci_port,
2408 scic_sds_port_state_table, 2399 scic_sds_port_state_table,
@@ -2416,7 +2407,7 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
2416 SCIC_SDS_PORT_READY_SUBSTATE_WAITING); 2407 SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
2417 2408
2418 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT; 2409 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
2419 sci_port->physical_port_index = port_index; 2410 sci_port->physical_port_index = index;
2420 sci_port->active_phy_mask = 0; 2411 sci_port->active_phy_mask = 0;
2421 2412
2422 sci_port->owning_controller = scic; 2413 sci_port->owning_controller = scic;
@@ -2428,7 +2419,6 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
2428 sci_port->reserved_tci = SCU_DUMMY_INDEX; 2419 sci_port->reserved_tci = SCU_DUMMY_INDEX;
2429 2420
2430 sci_port->timer_handle = NULL; 2421 sci_port->timer_handle = NULL;
2431
2432 sci_port->port_task_scheduler_registers = NULL; 2422 sci_port->port_task_scheduler_registers = NULL;
2433 2423
2434 for (index = 0; index < SCI_MAX_PHYS; index++) 2424 for (index = 0; index < SCI_MAX_PHYS; index++)
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h
index 213d42330b4b..3633561b686a 100644
--- a/drivers/scsi/isci/core/scic_sds_port.h
+++ b/drivers/scsi/isci/core/scic_sds_port.h
@@ -151,17 +151,12 @@ enum scic_sds_port_states {
151 151
152}; 152};
153 153
154struct isci_port;
155/** 154/**
156 * struct scic_sds_port 155 * struct scic_sds_port
157 * 156 *
158 * The core port object provides the the abstraction for an SCU port. 157 * The core port object provides the the abstraction for an SCU port.
159 */ 158 */
160struct scic_sds_port { 159struct scic_sds_port {
161 /**
162 * The field specifies the peer object for the port.
163 */
164 struct isci_port *iport;
165 160
166 /** 161 /**
167 * This field contains the information for the base port state machine. 162 * This field contains the information for the base port state machine.
diff --git a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
index aa7ac95ecbc6..2d3d067396d3 100644
--- a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
+++ b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.c
@@ -141,14 +141,15 @@ static struct scic_sds_port *scic_sds_port_configuration_agent_find_port(
141 scic_sds_phy_get_attached_sas_address(phy, &phy_attached_device_address); 141 scic_sds_phy_get_attached_sas_address(phy, &phy_attached_device_address);
142 142
143 for (i = 0; i < scic->logical_port_entries; i++) { 143 for (i = 0; i < scic->logical_port_entries; i++) {
144 struct scic_sds_port *port = &scic->port_table[i]; 144 struct isci_host *ihost = scic_to_ihost(scic);
145 struct scic_sds_port *sci_port = &ihost->ports[i].sci;
145 146
146 scic_sds_port_get_sas_address(port, &port_sas_address); 147 scic_sds_port_get_sas_address(sci_port, &port_sas_address);
147 scic_sds_port_get_attached_sas_address(port, &port_attached_device_address); 148 scic_sds_port_get_attached_sas_address(sci_port, &port_attached_device_address);
148 149
149 if ((sci_sas_address_compare(port_sas_address, phy_sas_address) == 0) && 150 if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 &&
150 (sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0)) 151 sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0)
151 return port; 152 return sci_port;
152 } 153 }
153 154
154 return NULL; 155 return NULL;
@@ -324,7 +325,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
324 port_agent->phy_valid_port_range[phy_index].min_index = port_index; 325 port_agent->phy_valid_port_range[phy_index].min_index = port_index;
325 port_agent->phy_valid_port_range[phy_index].max_index = phy_index; 326 port_agent->phy_valid_port_range[phy_index].max_index = phy_index;
326 327
327 scic_sds_port_add_phy(&controller->port_table[port_index], 328 scic_sds_port_add_phy(&ihost->ports[port_index].sci,
328 &ihost->phys[phy_index].sci); 329 &ihost->phys[phy_index].sci);
329 330
330 assigned_phy_mask |= (1 << phy_index); 331 assigned_phy_mask |= (1 << phy_index);
@@ -550,6 +551,7 @@ static void scic_sds_apc_agent_configure_ports(
550 enum sci_status status; 551 enum sci_status status;
551 struct scic_sds_port *port; 552 struct scic_sds_port *port;
552 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY; 553 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY;
554 struct isci_host *ihost = scic_to_ihost(controller);
553 555
554 port = scic_sds_port_configuration_agent_find_port(controller, phy); 556 port = scic_sds_port_configuration_agent_find_port(controller, phy);
555 557
@@ -571,7 +573,7 @@ static void scic_sds_apc_agent_configure_ports(
571 port_index++ 573 port_index++
572 ) { 574 ) {
573 575
574 port = &controller->port_table[port_index]; 576 port = &ihost->ports[port_index].sci;
575 577
576 /* First we must make sure that this PHY can be added to this Port. */ 578 /* First we must make sure that this PHY can be added to this Port. */
577 if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) { 579 if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) {
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index d180ad8a8bcf..cdd99304c363 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -277,10 +277,10 @@ void isci_host_deinit(struct isci_host *ihost)
277 277
278 isci_host_change_state(ihost, isci_stopping); 278 isci_host_change_state(ihost, isci_stopping);
279 for (i = 0; i < SCI_MAX_PORTS; i++) { 279 for (i = 0; i < SCI_MAX_PORTS; i++) {
280 struct isci_port *port = &ihost->isci_ports[i]; 280 struct isci_port *iport = &ihost->ports[i];
281 struct isci_remote_device *idev, *d; 281 struct isci_remote_device *idev, *d;
282 282
283 list_for_each_entry_safe(idev, d, &port->remote_dev_list, node) { 283 list_for_each_entry_safe(idev, d, &iport->remote_dev_list, node) {
284 isci_remote_device_change_state(idev, isci_stopping); 284 isci_remote_device_change_state(idev, isci_stopping);
285 isci_remote_device_stop(ihost, idev); 285 isci_remote_device_stop(ihost, idev);
286 } 286 }
@@ -442,7 +442,7 @@ int isci_host_init(struct isci_host *isci_host)
442 return -ENOMEM; 442 return -ENOMEM;
443 443
444 for (i = 0; i < SCI_MAX_PORTS; i++) 444 for (i = 0; i < SCI_MAX_PORTS; i++)
445 isci_port_init(&isci_host->isci_ports[i], isci_host, i); 445 isci_port_init(&isci_host->ports[i], isci_host, i);
446 446
447 for (i = 0; i < SCI_MAX_PHYS; i++) 447 for (i = 0; i < SCI_MAX_PHYS; i++)
448 isci_phy_init(&isci_host->phys[i], isci_host, i); 448 isci_phy_init(&isci_host->phys[i], isci_host, i);
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index 00e4854e20d9..5a414c31a877 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -84,12 +84,7 @@ struct isci_host {
84 struct dma_pool *dma_pool; 84 struct dma_pool *dma_pool;
85 unsigned int dma_pool_alloc_size; 85 unsigned int dma_pool_alloc_size;
86 struct isci_phy phys[SCI_MAX_PHYS]; 86 struct isci_phy phys[SCI_MAX_PHYS];
87 87 struct isci_port ports[SCI_MAX_PORTS + 1]; /* includes dummy port */
88 /* isci_ports and sas_ports are implicitly parallel to the
89 * ports maintained by the core
90 */
91 struct isci_port isci_ports[SCI_MAX_PORTS];
92 struct asd_sas_port sas_ports[SCI_MAX_PORTS];
93 struct sas_ha_struct sas_ha; 88 struct sas_ha_struct sas_ha;
94 89
95 int can_queue; 90 int can_queue;
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index a5d5c0b97d00..522d39f9e132 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -221,8 +221,8 @@ static int isci_register_sas_ha(struct isci_host *isci_host)
221 221
222 /* set the array of phy and port structs. */ 222 /* set the array of phy and port structs. */
223 for (i = 0; i < SCI_MAX_PHYS; i++) { 223 for (i = 0; i < SCI_MAX_PHYS; i++) {
224 sas_phys[i] = &(isci_host->phys[i].sas_phy); 224 sas_phys[i] = &isci_host->phys[i].sas_phy;
225 sas_ports[i] = &(isci_host->sas_ports[i]); 225 sas_ports[i] = &isci_host->ports[i].sas_port;
226 } 226 }
227 227
228 sas_ha->sas_phy = sas_phys; 228 sas_ha->sas_phy = sas_phys;
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index 5e87fedb5676..35e2e517f671 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -70,29 +70,30 @@
70#include "request.h" 70#include "request.h"
71#include "core/scic_sds_controller.h" 71#include "core/scic_sds_controller.h"
72 72
73static void isci_port_change_state( 73static void isci_port_change_state(struct isci_port *iport, enum isci_status status)
74 struct isci_port *isci_port, 74{
75 enum isci_status status); 75 unsigned long flags;
76 76
77 dev_dbg(&iport->isci_host->pdev->dev,
78 "%s: iport = %p, state = 0x%x\n",
79 __func__, iport, status);
77 80
81 /* XXX pointless lock */
82 spin_lock_irqsave(&iport->state_lock, flags);
83 iport->status = status;
84 spin_unlock_irqrestore(&iport->state_lock, flags);
85}
78 86
79void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index) 87void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index)
80{ 88{
81 struct scic_sds_port *sci_port;
82
83 INIT_LIST_HEAD(&iport->remote_dev_list); 89 INIT_LIST_HEAD(&iport->remote_dev_list);
84 INIT_LIST_HEAD(&iport->domain_dev_list); 90 INIT_LIST_HEAD(&iport->domain_dev_list);
85 spin_lock_init(&iport->state_lock); 91 spin_lock_init(&iport->state_lock);
86 init_completion(&iport->start_complete); 92 init_completion(&iport->start_complete);
87 iport->isci_host = ihost; 93 iport->isci_host = ihost;
88 isci_port_change_state(iport, isci_freed); 94 isci_port_change_state(iport, isci_freed);
89
90 sci_port = &ihost->sci.port_table[index];
91 iport->sci_port_handle = sci_port;
92 sci_port->iport = iport;
93} 95}
94 96
95
96/** 97/**
97 * isci_port_get_state() - This function gets the status of the port object. 98 * isci_port_get_state() - This function gets the status of the port object.
98 * @isci_port: This parameter points to the isci_port object 99 * @isci_port: This parameter points to the isci_port object
@@ -105,21 +106,6 @@ enum isci_status isci_port_get_state(
105 return isci_port->status; 106 return isci_port->status;
106} 107}
107 108
108static void isci_port_change_state(
109 struct isci_port *isci_port,
110 enum isci_status status)
111{
112 unsigned long flags;
113
114 dev_dbg(&isci_port->isci_host->pdev->dev,
115 "%s: isci_port = %p, state = 0x%x\n",
116 __func__, isci_port, status);
117
118 spin_lock_irqsave(&isci_port->state_lock, flags);
119 isci_port->status = status;
120 spin_unlock_irqrestore(&isci_port->state_lock, flags);
121}
122
123void isci_port_bc_change_received(struct isci_host *ihost, 109void isci_port_bc_change_received(struct isci_host *ihost,
124 struct scic_sds_port *sci_port, 110 struct scic_sds_port *sci_port,
125 struct scic_sds_phy *sci_phy) 111 struct scic_sds_phy *sci_phy)
@@ -140,7 +126,7 @@ void isci_port_link_up(struct isci_host *isci_host,
140 unsigned long flags; 126 unsigned long flags;
141 struct scic_port_properties properties; 127 struct scic_port_properties properties;
142 struct isci_phy *isci_phy = sci_phy_to_iphy(phy); 128 struct isci_phy *isci_phy = sci_phy_to_iphy(phy);
143 struct isci_port *isci_port = port->iport; 129 struct isci_port *isci_port = sci_port_to_iport(port);
144 unsigned long success = true; 130 unsigned long success = true;
145 131
146 BUG_ON(isci_phy->isci_port != NULL); 132 BUG_ON(isci_phy->isci_port != NULL);
@@ -346,8 +332,7 @@ int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *ipor
346 spin_lock_irqsave(&ihost->scic_lock, flags); 332 spin_lock_irqsave(&ihost->scic_lock, flags);
347 333
348 #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT 334 #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT
349 status = scic_port_hard_reset(iport->sci_port_handle, 335 status = scic_port_hard_reset(&iport->sci, ISCI_PORT_RESET_TIMEOUT);
350 ISCI_PORT_RESET_TIMEOUT);
351 336
352 spin_unlock_irqrestore(&ihost->scic_lock, flags); 337 spin_unlock_irqrestore(&ihost->scic_lock, flags);
353 338
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h
index ac1ac86ead6f..355034542e4c 100644
--- a/drivers/scsi/isci/port.h
+++ b/drivers/scsi/isci/port.h
@@ -53,19 +53,12 @@
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */ 54 */
55 55
56/** 56#ifndef _ISCI_PORT_H_
57 * This file contains the isci_port object definition.
58 *
59 * port.h
60 */
61
62#if !defined(_ISCI_PORT_H_)
63#define _ISCI_PORT_H_ 57#define _ISCI_PORT_H_
58#include "scic_sds_port.h"
64 59
65struct isci_phy; 60struct isci_phy;
66struct isci_host; 61struct isci_host;
67struct scic_sds_phy;
68
69 62
70enum isci_status { 63enum isci_status {
71 isci_freed = 0x00, 64 isci_freed = 0x00,
@@ -84,9 +77,6 @@ enum isci_status {
84 * 77 *
85 */ 78 */
86struct isci_port { 79struct isci_port {
87
88 struct scic_sds_port *sci_port_handle;
89
90 enum isci_status status; 80 enum isci_status status;
91 struct isci_host *isci_host; 81 struct isci_host *isci_host;
92 struct asd_sas_port sas_port; 82 struct asd_sas_port sas_port;
@@ -96,16 +86,19 @@ struct isci_port {
96 struct completion start_complete; 86 struct completion start_complete;
97 struct completion hard_reset_complete; 87 struct completion hard_reset_complete;
98 enum sci_status hard_reset_status; 88 enum sci_status hard_reset_status;
89 struct scic_sds_port sci;
99}; 90};
100 91
101#define to_isci_port(p) \ 92static inline struct isci_port *sci_port_to_iport(struct scic_sds_port *sci_port)
102 container_of(p, struct isci_port, sas_port); 93{
94 struct isci_port *iport = container_of(sci_port, typeof(*iport), sci);
95
96 return iport;
97}
103 98
104enum isci_status isci_port_get_state( 99enum isci_status isci_port_get_state(
105 struct isci_port *isci_port); 100 struct isci_port *isci_port);
106 101
107
108
109void isci_port_formed( 102void isci_port_formed(
110 struct asd_sas_phy *); 103 struct asd_sas_phy *);
111 104
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 734d028448b0..a441c23b6859 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -1264,7 +1264,7 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s
1264static enum sci_status isci_remote_device_construct(struct isci_port *iport, 1264static enum sci_status isci_remote_device_construct(struct isci_port *iport,
1265 struct isci_remote_device *idev) 1265 struct isci_remote_device *idev)
1266{ 1266{
1267 struct scic_sds_port *sci_port = iport->sci_port_handle; 1267 struct scic_sds_port *sci_port = &iport->sci;
1268 struct isci_host *ihost = iport->isci_host; 1268 struct isci_host *ihost = iport->isci_host;
1269 struct domain_device *dev = idev->domain_dev; 1269 struct domain_device *dev = idev->domain_dev;
1270 enum sci_status status; 1270 enum sci_status status;
diff --git a/drivers/scsi/isci/sci_environment.h b/drivers/scsi/isci/sci_environment.h
index bb07ed31b51c..1806969fc435 100644
--- a/drivers/scsi/isci/sci_environment.h
+++ b/drivers/scsi/isci/sci_environment.h
@@ -77,7 +77,7 @@ static inline struct device *sciphy_to_dev(struct scic_sds_phy *sci_phy)
77 77
78static inline struct device *sciport_to_dev(struct scic_sds_port *sci_port) 78static inline struct device *sciport_to_dev(struct scic_sds_port *sci_port)
79{ 79{
80 struct isci_port *iport = sci_port->iport; 80 struct isci_port *iport = sci_port_to_iport(sci_port);
81 81
82 if (!iport || !iport->isci_host) 82 if (!iport || !iport->isci_host)
83 return NULL; 83 return NULL;