aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-06-28 18:05:53 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:52 -0400
commit852809559e4680ba4768262a6c3d21454fcd460e (patch)
treea67170a9dd2a4c9f15d215f4b96e890cdb53a7e7 /drivers
parent5076a1a97e2fa61c847a5fdd4b1991faf7716da6 (diff)
isci: unify isci_phy and scic_sds_phy
They are one in the same object so remove the distinction. The near duplicate fields (owning_port, and isci_port) will be cleaned up after the scic_sds_port isci_port unification. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/isci/host.c92
-rw-r--r--drivers/scsi/isci/host.h17
-rw-r--r--drivers/scsi/isci/phy.c479
-rw-r--r--drivers/scsi/isci/phy.h112
-rw-r--r--drivers/scsi/isci/port.c299
-rw-r--r--drivers/scsi/isci/port.h16
-rw-r--r--drivers/scsi/isci/port_config.c135
-rw-r--r--drivers/scsi/isci/remote_device.c2
8 files changed, 500 insertions, 652 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index d91cd6d82747..c5c2733a5197 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -311,7 +311,7 @@ static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *sc
311 311
312 struct isci_host *ihost = scic_to_ihost(scic); 312 struct isci_host *ihost = scic_to_ihost(scic);
313 struct scu_unsolicited_frame_header *frame_header; 313 struct scu_unsolicited_frame_header *frame_header;
314 struct scic_sds_phy *phy; 314 struct isci_phy *iphy;
315 struct scic_sds_remote_device *device; 315 struct scic_sds_remote_device *device;
316 316
317 enum sci_status result = SCI_FAILURE; 317 enum sci_status result = SCI_FAILURE;
@@ -332,8 +332,8 @@ static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *sc
332 332
333 if (frame_header->is_address_frame) { 333 if (frame_header->is_address_frame) {
334 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry); 334 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
335 phy = &ihost->phys[index].sci; 335 iphy = &ihost->phys[index];
336 result = scic_sds_phy_frame_handler(phy, frame_index); 336 result = scic_sds_phy_frame_handler(iphy, frame_index);
337 } else { 337 } else {
338 338
339 index = SCU_GET_COMPLETION_INDEX(completion_entry); 339 index = SCU_GET_COMPLETION_INDEX(completion_entry);
@@ -344,8 +344,8 @@ static void scic_sds_controller_unsolicited_frame(struct scic_sds_controller *sc
344 * device that has not yet been created. In either case forwared 344 * device that has not yet been created. In either case forwared
345 * the frame to the PE and let it take care of the frame data. */ 345 * the frame to the PE and let it take care of the frame data. */
346 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry); 346 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
347 phy = &ihost->phys[index].sci; 347 iphy = &ihost->phys[index];
348 result = scic_sds_phy_frame_handler(phy, frame_index); 348 result = scic_sds_phy_frame_handler(iphy, frame_index);
349 } else { 349 } else {
350 if (index < scic->remote_node_entries) 350 if (index < scic->remote_node_entries)
351 device = scic->device_table[index]; 351 device = scic->device_table[index];
@@ -372,7 +372,7 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
372 struct isci_host *ihost = scic_to_ihost(scic); 372 struct isci_host *ihost = scic_to_ihost(scic);
373 struct scic_sds_remote_device *device; 373 struct scic_sds_remote_device *device;
374 struct isci_request *ireq; 374 struct isci_request *ireq;
375 struct scic_sds_phy *phy; 375 struct isci_phy *iphy;
376 u32 index; 376 u32 index;
377 377
378 index = SCU_GET_COMPLETION_INDEX(completion_entry); 378 index = SCU_GET_COMPLETION_INDEX(completion_entry);
@@ -452,8 +452,8 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
452 * we get the event notification. This is a type 4 event. */ 452 * we get the event notification. This is a type 4 event. */
453 case SCU_EVENT_TYPE_OSSP_EVENT: 453 case SCU_EVENT_TYPE_OSSP_EVENT:
454 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry); 454 index = SCU_GET_PROTOCOL_ENGINE_INDEX(completion_entry);
455 phy = &ihost->phys[index].sci; 455 iphy = &ihost->phys[index];
456 scic_sds_phy_event_handler(phy, completion_entry); 456 scic_sds_phy_event_handler(iphy, completion_entry);
457 break; 457 break;
458 458
459 case SCU_EVENT_TYPE_RNC_SUSPEND_TX: 459 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
@@ -862,11 +862,11 @@ static void scic_sds_controller_transition_to_ready(
862 } 862 }
863} 863}
864 864
865static bool is_phy_starting(struct scic_sds_phy *sci_phy) 865static bool is_phy_starting(struct isci_phy *iphy)
866{ 866{
867 enum scic_sds_phy_states state; 867 enum scic_sds_phy_states state;
868 868
869 state = sci_phy->sm.current_state_id; 869 state = iphy->sm.current_state_id;
870 switch (state) { 870 switch (state) {
871 case SCI_PHY_STARTING: 871 case SCI_PHY_STARTING:
872 case SCI_PHY_SUB_INITIAL: 872 case SCI_PHY_SUB_INITIAL:
@@ -896,7 +896,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
896{ 896{
897 struct isci_host *ihost = scic_to_ihost(scic); 897 struct isci_host *ihost = scic_to_ihost(scic);
898 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1; 898 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
899 struct scic_sds_phy *sci_phy; 899 struct isci_phy *iphy;
900 enum sci_status status; 900 enum sci_status status;
901 901
902 status = SCI_SUCCESS; 902 status = SCI_SUCCESS;
@@ -910,10 +910,10 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
910 u8 index; 910 u8 index;
911 911
912 for (index = 0; index < SCI_MAX_PHYS; index++) { 912 for (index = 0; index < SCI_MAX_PHYS; index++) {
913 sci_phy = &ihost->phys[index].sci; 913 iphy = &ihost->phys[index];
914 state = sci_phy->sm.current_state_id; 914 state = iphy->sm.current_state_id;
915 915
916 if (!phy_get_non_dummy_port(sci_phy)) 916 if (!phy_get_non_dummy_port(iphy))
917 continue; 917 continue;
918 918
919 /* The controller start operation is complete iff: 919 /* The controller start operation is complete iff:
@@ -922,9 +922,9 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
922 * - have an indication of a connected device and it has 922 * - have an indication of a connected device and it has
923 * finished the link training process. 923 * finished the link training process.
924 */ 924 */
925 if ((sci_phy->is_in_link_training == false && state == SCI_PHY_INITIAL) || 925 if ((iphy->is_in_link_training == false && state == SCI_PHY_INITIAL) ||
926 (sci_phy->is_in_link_training == false && state == SCI_PHY_STOPPED) || 926 (iphy->is_in_link_training == false && state == SCI_PHY_STOPPED) ||
927 (sci_phy->is_in_link_training == true && is_phy_starting(sci_phy))) { 927 (iphy->is_in_link_training == true && is_phy_starting(iphy))) {
928 is_controller_start_complete = false; 928 is_controller_start_complete = false;
929 break; 929 break;
930 } 930 }
@@ -939,10 +939,10 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
939 scic->phy_startup_timer_pending = false; 939 scic->phy_startup_timer_pending = false;
940 } 940 }
941 } else { 941 } else {
942 sci_phy = &ihost->phys[scic->next_phy_to_start].sci; 942 iphy = &ihost->phys[scic->next_phy_to_start];
943 943
944 if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { 944 if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) {
945 if (phy_get_non_dummy_port(sci_phy) == NULL) { 945 if (phy_get_non_dummy_port(iphy) == NULL) {
946 scic->next_phy_to_start++; 946 scic->next_phy_to_start++;
947 947
948 /* Caution recursion ahead be forwarned 948 /* Caution recursion ahead be forwarned
@@ -958,7 +958,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
958 } 958 }
959 } 959 }
960 960
961 status = scic_sds_phy_start(sci_phy); 961 status = scic_sds_phy_start(iphy);
962 962
963 if (status == SCI_SUCCESS) { 963 if (status == SCI_SUCCESS) {
964 sci_mod_timer(&scic->phy_timer, 964 sci_mod_timer(&scic->phy_timer,
@@ -970,7 +970,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
970 "to stop phy %d because of status " 970 "to stop phy %d because of status "
971 "%d.\n", 971 "%d.\n",
972 __func__, 972 __func__,
973 ihost->phys[scic->next_phy_to_start].sci.phy_index, 973 ihost->phys[scic->next_phy_to_start].phy_index,
974 status); 974 status);
975 } 975 }
976 976
@@ -1312,8 +1312,8 @@ void isci_host_deinit(struct isci_host *ihost)
1312 1312
1313 /* Cancel any/all outstanding phy timers */ 1313 /* Cancel any/all outstanding phy timers */
1314 for (i = 0; i < SCI_MAX_PHYS; i++) { 1314 for (i = 0; i < SCI_MAX_PHYS; i++) {
1315 struct scic_sds_phy *sci_phy = &ihost->phys[i].sci; 1315 struct isci_phy *iphy = &ihost->phys[i];
1316 del_timer_sync(&sci_phy->sata_timer.timer); 1316 del_timer_sync(&iphy->sata_timer.timer);
1317 } 1317 }
1318 1318
1319 del_timer_sync(&ihost->sci.port_agent.timer.timer); 1319 del_timer_sync(&ihost->sci.port_agent.timer.timer);
@@ -1527,7 +1527,7 @@ static enum sci_status scic_sds_controller_stop_phys(struct scic_sds_controller
1527 status = SCI_SUCCESS; 1527 status = SCI_SUCCESS;
1528 1528
1529 for (index = 0; index < SCI_MAX_PHYS; index++) { 1529 for (index = 0; index < SCI_MAX_PHYS; index++) {
1530 phy_status = scic_sds_phy_stop(&ihost->phys[index].sci); 1530 phy_status = scic_sds_phy_stop(&ihost->phys[index]);
1531 1531
1532 if (phy_status != SCI_SUCCESS && 1532 if (phy_status != SCI_SUCCESS &&
1533 phy_status != SCI_FAILURE_INVALID_STATE) { 1533 phy_status != SCI_FAILURE_INVALID_STATE) {
@@ -1537,7 +1537,7 @@ static enum sci_status scic_sds_controller_stop_phys(struct scic_sds_controller
1537 "%s: Controller stop operation failed to stop " 1537 "%s: Controller stop operation failed to stop "
1538 "phy %d because of status %d.\n", 1538 "phy %d because of status %d.\n",
1539 __func__, 1539 __func__,
1540 ihost->phys[index].sci.phy_index, phy_status); 1540 ihost->phys[index].phy_index, phy_status);
1541 } 1541 }
1542 } 1542 }
1543 1543
@@ -1786,7 +1786,7 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
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].sci, 1789 scic_sds_phy_construct(&ihost->phys[i],
1790 &ihost->ports[SCI_MAX_PORTS].sci, i); 1790 &ihost->ports[SCI_MAX_PORTS].sci, i);
1791 } 1791 }
1792 1792
@@ -1865,7 +1865,7 @@ static void power_control_timeout(unsigned long data)
1865 struct sci_timer *tmr = (struct sci_timer *)data; 1865 struct sci_timer *tmr = (struct sci_timer *)data;
1866 struct scic_sds_controller *scic = container_of(tmr, typeof(*scic), power_control.timer); 1866 struct scic_sds_controller *scic = container_of(tmr, typeof(*scic), power_control.timer);
1867 struct isci_host *ihost = scic_to_ihost(scic); 1867 struct isci_host *ihost = scic_to_ihost(scic);
1868 struct scic_sds_phy *sci_phy; 1868 struct isci_phy *iphy;
1869 unsigned long flags; 1869 unsigned long flags;
1870 u8 i; 1870 u8 i;
1871 1871
@@ -1886,8 +1886,8 @@ static void power_control_timeout(unsigned long data)
1886 if (scic->power_control.phys_waiting == 0) 1886 if (scic->power_control.phys_waiting == 0)
1887 break; 1887 break;
1888 1888
1889 sci_phy = scic->power_control.requesters[i]; 1889 iphy = scic->power_control.requesters[i];
1890 if (sci_phy == NULL) 1890 if (iphy == NULL)
1891 continue; 1891 continue;
1892 1892
1893 if (scic->power_control.phys_granted_power >= 1893 if (scic->power_control.phys_granted_power >=
@@ -1897,7 +1897,7 @@ static void power_control_timeout(unsigned long data)
1897 scic->power_control.requesters[i] = NULL; 1897 scic->power_control.requesters[i] = NULL;
1898 scic->power_control.phys_waiting--; 1898 scic->power_control.phys_waiting--;
1899 scic->power_control.phys_granted_power++; 1899 scic->power_control.phys_granted_power++;
1900 scic_sds_phy_consume_power_handler(sci_phy); 1900 scic_sds_phy_consume_power_handler(iphy);
1901 } 1901 }
1902 1902
1903 /* 1903 /*
@@ -1919,14 +1919,14 @@ done:
1919 */ 1919 */
1920void scic_sds_controller_power_control_queue_insert( 1920void scic_sds_controller_power_control_queue_insert(
1921 struct scic_sds_controller *scic, 1921 struct scic_sds_controller *scic,
1922 struct scic_sds_phy *sci_phy) 1922 struct isci_phy *iphy)
1923{ 1923{
1924 BUG_ON(sci_phy == NULL); 1924 BUG_ON(iphy == NULL);
1925 1925
1926 if (scic->power_control.phys_granted_power < 1926 if (scic->power_control.phys_granted_power <
1927 scic->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) { 1927 scic->oem_parameters.sds1.controller.max_concurrent_dev_spin_up) {
1928 scic->power_control.phys_granted_power++; 1928 scic->power_control.phys_granted_power++;
1929 scic_sds_phy_consume_power_handler(sci_phy); 1929 scic_sds_phy_consume_power_handler(iphy);
1930 1930
1931 /* 1931 /*
1932 * stop and start the power_control timer. When the timer fires, the 1932 * stop and start the power_control timer. When the timer fires, the
@@ -1941,7 +1941,7 @@ void scic_sds_controller_power_control_queue_insert(
1941 1941
1942 } else { 1942 } else {
1943 /* Add the phy in the waiting list */ 1943 /* Add the phy in the waiting list */
1944 scic->power_control.requesters[sci_phy->phy_index] = sci_phy; 1944 scic->power_control.requesters[iphy->phy_index] = iphy;
1945 scic->power_control.phys_waiting++; 1945 scic->power_control.phys_waiting++;
1946 } 1946 }
1947} 1947}
@@ -1954,15 +1954,15 @@ void scic_sds_controller_power_control_queue_insert(
1954 */ 1954 */
1955void scic_sds_controller_power_control_queue_remove( 1955void scic_sds_controller_power_control_queue_remove(
1956 struct scic_sds_controller *scic, 1956 struct scic_sds_controller *scic,
1957 struct scic_sds_phy *sci_phy) 1957 struct isci_phy *iphy)
1958{ 1958{
1959 BUG_ON(sci_phy == NULL); 1959 BUG_ON(iphy == NULL);
1960 1960
1961 if (scic->power_control.requesters[sci_phy->phy_index] != NULL) { 1961 if (scic->power_control.requesters[iphy->phy_index] != NULL) {
1962 scic->power_control.phys_waiting--; 1962 scic->power_control.phys_waiting--;
1963 } 1963 }
1964 1964
1965 scic->power_control.requesters[sci_phy->phy_index] = NULL; 1965 scic->power_control.requesters[iphy->phy_index] = NULL;
1966} 1966}
1967 1967
1968#define AFE_REGISTER_WRITE_DELAY 10 1968#define AFE_REGISTER_WRITE_DELAY 10
@@ -2225,7 +2225,7 @@ static enum sci_status scic_controller_initialize(struct scic_sds_controller *sc
2225 * are accessed during the port initialization. 2225 * are accessed during the port initialization.
2226 */ 2226 */
2227 for (i = 0; i < SCI_MAX_PHYS; i++) { 2227 for (i = 0; i < SCI_MAX_PHYS; i++) {
2228 result = scic_sds_phy_initialize(&ihost->phys[i].sci, 2228 result = scic_sds_phy_initialize(&ihost->phys[i],
2229 &scic->scu_registers->peg0.pe[i].tl, 2229 &scic->scu_registers->peg0.pe[i].tl,
2230 &scic->scu_registers->peg0.pe[i].ll); 2230 &scic->scu_registers->peg0.pe[i].ll);
2231 if (result != SCI_SUCCESS) 2231 if (result != SCI_SUCCESS)
@@ -2484,43 +2484,43 @@ 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 scic_sds_phy *phy) 2487 struct scic_sds_port *port, 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, phy); 2494 port, 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, phy); 2499 port, iphy);
2500 break; 2500 break;
2501 default: 2501 default:
2502 dev_dbg(scic_to_dev(scic), 2502 dev_dbg(scic_to_dev(scic),
2503 "%s: SCIC Controller linkup event from phy %d in " 2503 "%s: SCIC Controller linkup event from phy %d in "
2504 "unexpected state %d\n", __func__, phy->phy_index, 2504 "unexpected state %d\n", __func__, iphy->phy_index,
2505 scic->sm.current_state_id); 2505 scic->sm.current_state_id);
2506 } 2506 }
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 scic_sds_phy *phy) 2510 struct scic_sds_port *port, 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, phy); 2516 port, iphy);
2517 break; 2517 break;
2518 default: 2518 default:
2519 dev_dbg(scic_to_dev(scic), 2519 dev_dbg(scic_to_dev(scic),
2520 "%s: SCIC Controller linkdown event from phy %d in " 2520 "%s: SCIC Controller linkdown event from phy %d in "
2521 "unexpected state %d\n", 2521 "unexpected state %d\n",
2522 __func__, 2522 __func__,
2523 phy->phy_index, 2523 iphy->phy_index,
2524 scic->sm.current_state_id); 2524 scic->sm.current_state_id);
2525 } 2525 }
2526} 2526}
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index 0b26d25c19a9..1edd13535c24 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -101,14 +101,14 @@ struct scic_power_control {
101 * This field is an array of phys that we are waiting on. The phys are direct 101 * This field is an array of phys that we are waiting on. The phys are direct
102 * mapped into requesters via struct scic_sds_phy.phy_index 102 * mapped into requesters via struct scic_sds_phy.phy_index
103 */ 103 */
104 struct scic_sds_phy *requesters[SCI_MAX_PHYS]; 104 struct isci_phy *requesters[SCI_MAX_PHYS];
105 105
106}; 106};
107 107
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 scic_sds_phy *); 111 struct scic_sds_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;
@@ -523,9 +523,8 @@ static inline struct device *scic_to_dev(struct scic_sds_controller *scic)
523 return &scic_to_ihost(scic)->pdev->dev; 523 return &scic_to_ihost(scic)->pdev->dev;
524} 524}
525 525
526static inline struct device *sciphy_to_dev(struct scic_sds_phy *sci_phy) 526static inline struct device *sciphy_to_dev(struct isci_phy *iphy)
527{ 527{
528 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
529 528
530 if (!iphy || !iphy->isci_port || !iphy->isci_port->isci_host) 529 if (!iphy || !iphy->isci_port || !iphy->isci_port->isci_host)
531 return NULL; 530 return NULL;
@@ -606,21 +605,21 @@ struct isci_request *scic_request_by_tag(struct scic_sds_controller *scic,
606 605
607void scic_sds_controller_power_control_queue_insert( 606void scic_sds_controller_power_control_queue_insert(
608 struct scic_sds_controller *scic, 607 struct scic_sds_controller *scic,
609 struct scic_sds_phy *sci_phy); 608 struct isci_phy *iphy);
610 609
611void scic_sds_controller_power_control_queue_remove( 610void scic_sds_controller_power_control_queue_remove(
612 struct scic_sds_controller *scic, 611 struct scic_sds_controller *scic,
613 struct scic_sds_phy *sci_phy); 612 struct isci_phy *iphy);
614 613
615void scic_sds_controller_link_up( 614void scic_sds_controller_link_up(
616 struct scic_sds_controller *scic, 615 struct scic_sds_controller *scic,
617 struct scic_sds_port *sci_port, 616 struct scic_sds_port *sci_port,
618 struct scic_sds_phy *sci_phy); 617 struct isci_phy *iphy);
619 618
620void scic_sds_controller_link_down( 619void scic_sds_controller_link_down(
621 struct scic_sds_controller *scic, 620 struct scic_sds_controller *scic,
622 struct scic_sds_port *sci_port, 621 struct scic_sds_port *sci_port,
623 struct scic_sds_phy *sci_phy); 622 struct isci_phy *iphy);
624 623
625void scic_sds_controller_remote_device_stopped( 624void scic_sds_controller_remote_device_stopped(
626 struct scic_sds_controller *scic, 625 struct scic_sds_controller *scic,
@@ -651,7 +650,7 @@ void isci_host_deinit(
651void isci_host_port_link_up( 650void isci_host_port_link_up(
652 struct isci_host *, 651 struct isci_host *,
653 struct scic_sds_port *, 652 struct scic_sds_port *,
654 struct scic_sds_phy *); 653 struct isci_phy *);
655int isci_host_dev_found(struct domain_device *); 654int isci_host_dev_found(struct domain_device *);
656 655
657void isci_host_remote_device_start_complete( 656void isci_host_remote_device_start_complete(
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 98d93aeea75d..0e60fb7bc1ab 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -62,9 +62,9 @@
62/* Maximum arbitration wait time in micro-seconds */ 62/* Maximum arbitration wait time in micro-seconds */
63#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700) 63#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
64 64
65enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy) 65enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy)
66{ 66{
67 return sci_phy->max_negotiated_speed; 67 return iphy->max_negotiated_speed;
68} 68}
69 69
70/* 70/*
@@ -80,23 +80,23 @@ enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy)
80 * enum sci_status 80 * enum sci_status
81 */ 81 */
82static enum sci_status scic_sds_phy_transport_layer_initialization( 82static enum sci_status scic_sds_phy_transport_layer_initialization(
83 struct scic_sds_phy *sci_phy, 83 struct isci_phy *iphy,
84 struct scu_transport_layer_registers __iomem *transport_layer_registers) 84 struct scu_transport_layer_registers __iomem *transport_layer_registers)
85{ 85{
86 u32 tl_control; 86 u32 tl_control;
87 87
88 sci_phy->transport_layer_registers = transport_layer_registers; 88 iphy->transport_layer_registers = transport_layer_registers;
89 89
90 writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX, 90 writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX,
91 &sci_phy->transport_layer_registers->stp_rni); 91 &iphy->transport_layer_registers->stp_rni);
92 92
93 /* 93 /*
94 * Hardware team recommends that we enable the STP prefetch for all 94 * Hardware team recommends that we enable the STP prefetch for all
95 * transports 95 * transports
96 */ 96 */
97 tl_control = readl(&sci_phy->transport_layer_registers->control); 97 tl_control = readl(&iphy->transport_layer_registers->control);
98 tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH); 98 tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH);
99 writel(tl_control, &sci_phy->transport_layer_registers->control); 99 writel(tl_control, &iphy->transport_layer_registers->control);
100 100
101 return SCI_SUCCESS; 101 return SCI_SUCCESS;
102} 102}
@@ -109,12 +109,12 @@ static enum sci_status scic_sds_phy_transport_layer_initialization(
109 * enum sci_status 109 * enum sci_status
110 */ 110 */
111static enum sci_status 111static enum sci_status
112scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, 112scic_sds_phy_link_layer_initialization(struct isci_phy *iphy,
113 struct scu_link_layer_registers __iomem *link_layer_registers) 113 struct scu_link_layer_registers __iomem *link_layer_registers)
114{ 114{
115 struct scic_sds_controller *scic = 115 struct scic_sds_controller *scic =
116 sci_phy->owning_port->owning_controller; 116 iphy->owning_port->owning_controller;
117 int phy_idx = sci_phy->phy_index; 117 int phy_idx = iphy->phy_index;
118 struct sci_phy_user_params *phy_user = 118 struct sci_phy_user_params *phy_user =
119 &scic->user_parameters.sds1.phys[phy_idx]; 119 &scic->user_parameters.sds1.phys[phy_idx];
120 struct sci_phy_oem_params *phy_oem = 120 struct sci_phy_oem_params *phy_oem =
@@ -126,7 +126,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
126 u32 llctl, link_rate; 126 u32 llctl, link_rate;
127 u32 clksm_value = 0; 127 u32 clksm_value = 0;
128 128
129 sci_phy->link_layer_registers = link_layer_registers; 129 iphy->link_layer_registers = link_layer_registers;
130 130
131 /* Set our IDENTIFY frame data */ 131 /* Set our IDENTIFY frame data */
132 #define SCI_END_DEVICE 0x01 132 #define SCI_END_DEVICE 0x01
@@ -136,32 +136,32 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
136 SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | 136 SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) |
137 SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | 137 SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) |
138 SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE), 138 SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE),
139 &sci_phy->link_layer_registers->transmit_identification); 139 &iphy->link_layer_registers->transmit_identification);
140 140
141 /* Write the device SAS Address */ 141 /* Write the device SAS Address */
142 writel(0xFEDCBA98, 142 writel(0xFEDCBA98,
143 &sci_phy->link_layer_registers->sas_device_name_high); 143 &iphy->link_layer_registers->sas_device_name_high);
144 writel(phy_idx, &sci_phy->link_layer_registers->sas_device_name_low); 144 writel(phy_idx, &iphy->link_layer_registers->sas_device_name_low);
145 145
146 /* Write the source SAS Address */ 146 /* Write the source SAS Address */
147 writel(phy_oem->sas_address.high, 147 writel(phy_oem->sas_address.high,
148 &sci_phy->link_layer_registers->source_sas_address_high); 148 &iphy->link_layer_registers->source_sas_address_high);
149 writel(phy_oem->sas_address.low, 149 writel(phy_oem->sas_address.low,
150 &sci_phy->link_layer_registers->source_sas_address_low); 150 &iphy->link_layer_registers->source_sas_address_low);
151 151
152 /* Clear and Set the PHY Identifier */ 152 /* Clear and Set the PHY Identifier */
153 writel(0, &sci_phy->link_layer_registers->identify_frame_phy_id); 153 writel(0, &iphy->link_layer_registers->identify_frame_phy_id);
154 writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx), 154 writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx),
155 &sci_phy->link_layer_registers->identify_frame_phy_id); 155 &iphy->link_layer_registers->identify_frame_phy_id);
156 156
157 /* Change the initial state of the phy configuration register */ 157 /* Change the initial state of the phy configuration register */
158 phy_configuration = 158 phy_configuration =
159 readl(&sci_phy->link_layer_registers->phy_configuration); 159 readl(&iphy->link_layer_registers->phy_configuration);
160 160
161 /* Hold OOB state machine in reset */ 161 /* Hold OOB state machine in reset */
162 phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); 162 phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
163 writel(phy_configuration, 163 writel(phy_configuration,
164 &sci_phy->link_layer_registers->phy_configuration); 164 &iphy->link_layer_registers->phy_configuration);
165 165
166 /* Configure the SNW capabilities */ 166 /* Configure the SNW capabilities */
167 phy_cap.all = 0; 167 phy_cap.all = 0;
@@ -191,14 +191,14 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
191 if ((parity_count % 2) != 0) 191 if ((parity_count % 2) != 0)
192 phy_cap.parity = 1; 192 phy_cap.parity = 1;
193 193
194 writel(phy_cap.all, &sci_phy->link_layer_registers->phy_capabilities); 194 writel(phy_cap.all, &iphy->link_layer_registers->phy_capabilities);
195 195
196 /* Set the enable spinup period but disable the ability to send 196 /* Set the enable spinup period but disable the ability to send
197 * notify enable spinup 197 * notify enable spinup
198 */ 198 */
199 writel(SCU_ENSPINUP_GEN_VAL(COUNT, 199 writel(SCU_ENSPINUP_GEN_VAL(COUNT,
200 phy_user->notify_enable_spin_up_insertion_frequency), 200 phy_user->notify_enable_spin_up_insertion_frequency),
201 &sci_phy->link_layer_registers->notify_enable_spinup_control); 201 &iphy->link_layer_registers->notify_enable_spinup_control);
202 202
203 /* Write the ALIGN Insertion Ferequency for connected phy and 203 /* Write the ALIGN Insertion Ferequency for connected phy and
204 * inpendent of connected state 204 * inpendent of connected state
@@ -209,11 +209,11 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
209 clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, 209 clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL,
210 phy_user->align_insertion_frequency); 210 phy_user->align_insertion_frequency);
211 211
212 writel(clksm_value, &sci_phy->link_layer_registers->clock_skew_management); 212 writel(clksm_value, &iphy->link_layer_registers->clock_skew_management);
213 213
214 /* @todo Provide a way to write this register correctly */ 214 /* @todo Provide a way to write this register correctly */
215 writel(0x02108421, 215 writel(0x02108421,
216 &sci_phy->link_layer_registers->afe_lookup_table_control); 216 &iphy->link_layer_registers->afe_lookup_table_control);
217 217
218 llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT, 218 llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT,
219 (u8)scic->user_parameters.sds1.no_outbound_task_timeout); 219 (u8)scic->user_parameters.sds1.no_outbound_task_timeout);
@@ -230,7 +230,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
230 break; 230 break;
231 } 231 }
232 llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate); 232 llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
233 writel(llctl, &sci_phy->link_layer_registers->link_layer_control); 233 writel(llctl, &iphy->link_layer_registers->link_layer_control);
234 234
235 if (is_a0() || is_a2()) { 235 if (is_a0() || is_a2()) {
236 /* Program the max ARB time for the PHY to 700us so we inter-operate with 236 /* Program the max ARB time for the PHY to 700us so we inter-operate with
@@ -239,14 +239,14 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
239 * generate the break. 239 * generate the break.
240 */ 240 */
241 writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME, 241 writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME,
242 &sci_phy->link_layer_registers->maximum_arbitration_wait_timer_timeout); 242 &iphy->link_layer_registers->maximum_arbitration_wait_timer_timeout);
243 } 243 }
244 244
245 /* Disable link layer hang detection, rely on the OS timeout for I/O timeouts. */ 245 /* Disable link layer hang detection, rely on the OS timeout for I/O timeouts. */
246 writel(0, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout); 246 writel(0, &iphy->link_layer_registers->link_layer_hang_detection_timeout);
247 247
248 /* We can exit the initial state to the stopped state */ 248 /* We can exit the initial state to the stopped state */
249 sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED); 249 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
250 250
251 return SCI_SUCCESS; 251 return SCI_SUCCESS;
252} 252}
@@ -254,8 +254,8 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
254static void phy_sata_timeout(unsigned long data) 254static void phy_sata_timeout(unsigned long data)
255{ 255{
256 struct sci_timer *tmr = (struct sci_timer *)data; 256 struct sci_timer *tmr = (struct sci_timer *)data;
257 struct scic_sds_phy *sci_phy = container_of(tmr, typeof(*sci_phy), sata_timer); 257 struct isci_phy *iphy = container_of(tmr, typeof(*iphy), sata_timer);
258 struct isci_host *ihost = scic_to_ihost(sci_phy->owning_port->owning_controller); 258 struct isci_host *ihost = scic_to_ihost(iphy->owning_port->owning_controller);
259 unsigned long flags; 259 unsigned long flags;
260 260
261 spin_lock_irqsave(&ihost->scic_lock, flags); 261 spin_lock_irqsave(&ihost->scic_lock, flags);
@@ -263,13 +263,13 @@ static void phy_sata_timeout(unsigned long data)
263 if (tmr->cancel) 263 if (tmr->cancel)
264 goto done; 264 goto done;
265 265
266 dev_dbg(sciphy_to_dev(sci_phy), 266 dev_dbg(sciphy_to_dev(iphy),
267 "%s: SCIC SDS Phy 0x%p did not receive signature fis before " 267 "%s: SCIC SDS Phy 0x%p did not receive signature fis before "
268 "timeout.\n", 268 "timeout.\n",
269 __func__, 269 __func__,
270 sci_phy); 270 iphy);
271 271
272 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 272 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
273done: 273done:
274 spin_unlock_irqrestore(&ihost->scic_lock, flags); 274 spin_unlock_irqrestore(&ihost->scic_lock, flags);
275} 275}
@@ -287,30 +287,30 @@ done:
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 scic_sds_port *phy_get_non_dummy_port(
290 struct scic_sds_phy *sci_phy) 290 struct isci_phy *iphy)
291{ 291{
292 if (scic_sds_port_get_index(sci_phy->owning_port) == SCIC_SDS_DUMMY_PORT) 292 if (scic_sds_port_get_index(iphy->owning_port) == SCIC_SDS_DUMMY_PORT)
293 return NULL; 293 return NULL;
294 294
295 return sci_phy->owning_port; 295 return iphy->owning_port;
296} 296}
297 297
298/** 298/**
299 * This method will assign a port to the phy object. 299 * This method will assign a port to the phy object.
300 * @out]: sci_phy This parameter specifies the phy for which to assign a port 300 * @out]: iphy This parameter specifies the phy for which to assign a port
301 * object. 301 * object.
302 * 302 *
303 * 303 *
304 */ 304 */
305void scic_sds_phy_set_port( 305void scic_sds_phy_set_port(
306 struct scic_sds_phy *sci_phy, 306 struct isci_phy *iphy,
307 struct scic_sds_port *sci_port) 307 struct scic_sds_port *sci_port)
308{ 308{
309 sci_phy->owning_port = sci_port; 309 iphy->owning_port = sci_port;
310 310
311 if (sci_phy->bcn_received_while_port_unassigned) { 311 if (iphy->bcn_received_while_port_unassigned) {
312 sci_phy->bcn_received_while_port_unassigned = false; 312 iphy->bcn_received_while_port_unassigned = false;
313 scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); 313 scic_sds_port_broadcast_change_received(iphy->owning_port, iphy);
314 } 314 }
315} 315}
316 316
@@ -322,22 +322,22 @@ void scic_sds_phy_set_port(
322 * enum sci_status 322 * enum sci_status
323 */ 323 */
324enum sci_status scic_sds_phy_initialize( 324enum sci_status scic_sds_phy_initialize(
325 struct scic_sds_phy *sci_phy, 325 struct isci_phy *iphy,
326 struct scu_transport_layer_registers __iomem *transport_layer_registers, 326 struct scu_transport_layer_registers __iomem *transport_layer_registers,
327 struct scu_link_layer_registers __iomem *link_layer_registers) 327 struct scu_link_layer_registers __iomem *link_layer_registers)
328{ 328{
329 /* Perfrom the initialization of the TL hardware */ 329 /* Perfrom the initialization of the TL hardware */
330 scic_sds_phy_transport_layer_initialization( 330 scic_sds_phy_transport_layer_initialization(
331 sci_phy, 331 iphy,
332 transport_layer_registers); 332 transport_layer_registers);
333 333
334 /* Perofrm the initialization of the PE hardware */ 334 /* Perofrm the initialization of the PE hardware */
335 scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers); 335 scic_sds_phy_link_layer_initialization(iphy, link_layer_registers);
336 336
337 /* 337 /*
338 * There is nothing that needs to be done in this state just 338 * There is nothing that needs to be done in this state just
339 * transition to the stopped state. */ 339 * transition to the stopped state. */
340 sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED); 340 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
341 341
342 return SCI_SUCCESS; 342 return SCI_SUCCESS;
343} 343}
@@ -345,27 +345,27 @@ enum sci_status scic_sds_phy_initialize(
345/** 345/**
346 * This method assigns the direct attached device ID for this phy. 346 * This method assigns the direct attached device ID for this phy.
347 * 347 *
348 * @sci_phy The phy for which the direct attached device id is to 348 * @iphy The phy for which the direct attached device id is to
349 * be assigned. 349 * be assigned.
350 * @device_id The direct attached device ID to assign to the phy. 350 * @device_id The direct attached device ID to assign to the phy.
351 * This will either be the RNi for the device or an invalid RNi if there 351 * This will either be the RNi for the device or an invalid RNi if there
352 * is no current device assigned to the phy. 352 * is no current device assigned to the phy.
353 */ 353 */
354void scic_sds_phy_setup_transport( 354void scic_sds_phy_setup_transport(
355 struct scic_sds_phy *sci_phy, 355 struct isci_phy *iphy,
356 u32 device_id) 356 u32 device_id)
357{ 357{
358 u32 tl_control; 358 u32 tl_control;
359 359
360 writel(device_id, &sci_phy->transport_layer_registers->stp_rni); 360 writel(device_id, &iphy->transport_layer_registers->stp_rni);
361 361
362 /* 362 /*
363 * The read should guarantee that the first write gets posted 363 * The read should guarantee that the first write gets posted
364 * before the next write 364 * before the next write
365 */ 365 */
366 tl_control = readl(&sci_phy->transport_layer_registers->control); 366 tl_control = readl(&iphy->transport_layer_registers->control);
367 tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE); 367 tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE);
368 writel(tl_control, &sci_phy->transport_layer_registers->control); 368 writel(tl_control, &iphy->transport_layer_registers->control);
369} 369}
370 370
371/** 371/**
@@ -376,75 +376,74 @@ void scic_sds_phy_setup_transport(
376 * hardware protocol engine. none 376 * hardware protocol engine. none
377 */ 377 */
378static void scic_sds_phy_suspend( 378static void scic_sds_phy_suspend(
379 struct scic_sds_phy *sci_phy) 379 struct isci_phy *iphy)
380{ 380{
381 u32 scu_sas_pcfg_value; 381 u32 scu_sas_pcfg_value;
382 382
383 scu_sas_pcfg_value = 383 scu_sas_pcfg_value =
384 readl(&sci_phy->link_layer_registers->phy_configuration); 384 readl(&iphy->link_layer_registers->phy_configuration);
385 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); 385 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
386 writel(scu_sas_pcfg_value, 386 writel(scu_sas_pcfg_value,
387 &sci_phy->link_layer_registers->phy_configuration); 387 &iphy->link_layer_registers->phy_configuration);
388 388
389 scic_sds_phy_setup_transport( 389 scic_sds_phy_setup_transport(
390 sci_phy, 390 iphy,
391 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); 391 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
392} 392}
393 393
394void scic_sds_phy_resume(struct scic_sds_phy *sci_phy) 394void scic_sds_phy_resume(struct isci_phy *iphy)
395{ 395{
396 u32 scu_sas_pcfg_value; 396 u32 scu_sas_pcfg_value;
397 397
398 scu_sas_pcfg_value = 398 scu_sas_pcfg_value =
399 readl(&sci_phy->link_layer_registers->phy_configuration); 399 readl(&iphy->link_layer_registers->phy_configuration);
400 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); 400 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
401 writel(scu_sas_pcfg_value, 401 writel(scu_sas_pcfg_value,
402 &sci_phy->link_layer_registers->phy_configuration); 402 &iphy->link_layer_registers->phy_configuration);
403} 403}
404 404
405void scic_sds_phy_get_sas_address(struct scic_sds_phy *sci_phy, 405void scic_sds_phy_get_sas_address(struct isci_phy *iphy,
406 struct sci_sas_address *sas_address) 406 struct sci_sas_address *sas_address)
407{ 407{
408 sas_address->high = readl(&sci_phy->link_layer_registers->source_sas_address_high); 408 sas_address->high = readl(&iphy->link_layer_registers->source_sas_address_high);
409 sas_address->low = readl(&sci_phy->link_layer_registers->source_sas_address_low); 409 sas_address->low = readl(&iphy->link_layer_registers->source_sas_address_low);
410} 410}
411 411
412void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy, 412void scic_sds_phy_get_attached_sas_address(struct isci_phy *iphy,
413 struct sci_sas_address *sas_address) 413 struct sci_sas_address *sas_address)
414{ 414{
415 struct sas_identify_frame *iaf; 415 struct sas_identify_frame *iaf;
416 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
417 416
418 iaf = &iphy->frame_rcvd.iaf; 417 iaf = &iphy->frame_rcvd.iaf;
419 memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE); 418 memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE);
420} 419}
421 420
422void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy, 421void scic_sds_phy_get_protocols(struct isci_phy *iphy,
423 struct scic_phy_proto *protocols) 422 struct scic_phy_proto *protocols)
424{ 423{
425 protocols->all = 424 protocols->all =
426 (u16)(readl(&sci_phy-> 425 (u16)(readl(&iphy->
427 link_layer_registers->transmit_identification) & 426 link_layer_registers->transmit_identification) &
428 0x0000FFFF); 427 0x0000FFFF);
429} 428}
430 429
431enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy) 430enum sci_status scic_sds_phy_start(struct isci_phy *iphy)
432{ 431{
433 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 432 enum scic_sds_phy_states state = iphy->sm.current_state_id;
434 433
435 if (state != SCI_PHY_STOPPED) { 434 if (state != SCI_PHY_STOPPED) {
436 dev_dbg(sciphy_to_dev(sci_phy), 435 dev_dbg(sciphy_to_dev(iphy),
437 "%s: in wrong state: %d\n", __func__, state); 436 "%s: in wrong state: %d\n", __func__, state);
438 return SCI_FAILURE_INVALID_STATE; 437 return SCI_FAILURE_INVALID_STATE;
439 } 438 }
440 439
441 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 440 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
442 return SCI_SUCCESS; 441 return SCI_SUCCESS;
443} 442}
444 443
445enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) 444enum sci_status scic_sds_phy_stop(struct isci_phy *iphy)
446{ 445{
447 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 446 enum scic_sds_phy_states state = iphy->sm.current_state_id;
448 447
449 switch (state) { 448 switch (state) {
450 case SCI_PHY_SUB_INITIAL: 449 case SCI_PHY_SUB_INITIAL:
@@ -459,43 +458,43 @@ enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
459 case SCI_PHY_READY: 458 case SCI_PHY_READY:
460 break; 459 break;
461 default: 460 default:
462 dev_dbg(sciphy_to_dev(sci_phy), 461 dev_dbg(sciphy_to_dev(iphy),
463 "%s: in wrong state: %d\n", __func__, state); 462 "%s: in wrong state: %d\n", __func__, state);
464 return SCI_FAILURE_INVALID_STATE; 463 return SCI_FAILURE_INVALID_STATE;
465 } 464 }
466 465
467 sci_change_state(&sci_phy->sm, SCI_PHY_STOPPED); 466 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
468 return SCI_SUCCESS; 467 return SCI_SUCCESS;
469} 468}
470 469
471enum sci_status scic_sds_phy_reset(struct scic_sds_phy *sci_phy) 470enum sci_status scic_sds_phy_reset(struct isci_phy *iphy)
472{ 471{
473 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 472 enum scic_sds_phy_states state = iphy->sm.current_state_id;
474 473
475 if (state != SCI_PHY_READY) { 474 if (state != SCI_PHY_READY) {
476 dev_dbg(sciphy_to_dev(sci_phy), 475 dev_dbg(sciphy_to_dev(iphy),
477 "%s: in wrong state: %d\n", __func__, state); 476 "%s: in wrong state: %d\n", __func__, state);
478 return SCI_FAILURE_INVALID_STATE; 477 return SCI_FAILURE_INVALID_STATE;
479 } 478 }
480 479
481 sci_change_state(&sci_phy->sm, SCI_PHY_RESETTING); 480 sci_change_state(&iphy->sm, SCI_PHY_RESETTING);
482 return SCI_SUCCESS; 481 return SCI_SUCCESS;
483} 482}
484 483
485enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy) 484enum sci_status scic_sds_phy_consume_power_handler(struct isci_phy *iphy)
486{ 485{
487 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 486 enum scic_sds_phy_states state = iphy->sm.current_state_id;
488 487
489 switch (state) { 488 switch (state) {
490 case SCI_PHY_SUB_AWAIT_SAS_POWER: { 489 case SCI_PHY_SUB_AWAIT_SAS_POWER: {
491 u32 enable_spinup; 490 u32 enable_spinup;
492 491
493 enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); 492 enable_spinup = readl(&iphy->link_layer_registers->notify_enable_spinup_control);
494 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); 493 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
495 writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control); 494 writel(enable_spinup, &iphy->link_layer_registers->notify_enable_spinup_control);
496 495
497 /* Change state to the final state this substate machine has run to completion */ 496 /* Change state to the final state this substate machine has run to completion */
498 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_FINAL); 497 sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL);
499 498
500 return SCI_SUCCESS; 499 return SCI_SUCCESS;
501 } 500 }
@@ -504,26 +503,26 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
504 503
505 /* Release the spinup hold state and reset the OOB state machine */ 504 /* Release the spinup hold state and reset the OOB state machine */
506 scu_sas_pcfg_value = 505 scu_sas_pcfg_value =
507 readl(&sci_phy->link_layer_registers->phy_configuration); 506 readl(&iphy->link_layer_registers->phy_configuration);
508 scu_sas_pcfg_value &= 507 scu_sas_pcfg_value &=
509 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); 508 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
510 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); 509 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
511 writel(scu_sas_pcfg_value, 510 writel(scu_sas_pcfg_value,
512 &sci_phy->link_layer_registers->phy_configuration); 511 &iphy->link_layer_registers->phy_configuration);
513 512
514 /* Now restart the OOB operation */ 513 /* Now restart the OOB operation */
515 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); 514 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
516 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); 515 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
517 writel(scu_sas_pcfg_value, 516 writel(scu_sas_pcfg_value,
518 &sci_phy->link_layer_registers->phy_configuration); 517 &iphy->link_layer_registers->phy_configuration);
519 518
520 /* Change state to the final state this substate machine has run to completion */ 519 /* Change state to the final state this substate machine has run to completion */
521 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_PHY_EN); 520 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_PHY_EN);
522 521
523 return SCI_SUCCESS; 522 return SCI_SUCCESS;
524 } 523 }
525 default: 524 default:
526 dev_dbg(sciphy_to_dev(sci_phy), 525 dev_dbg(sciphy_to_dev(iphy),
527 "%s: in wrong state: %d\n", __func__, state); 526 "%s: in wrong state: %d\n", __func__, state);
528 return SCI_FAILURE_INVALID_STATE; 527 return SCI_FAILURE_INVALID_STATE;
529 } 528 }
@@ -545,19 +544,19 @@ enum sci_status scic_sds_phy_consume_power_handler(struct scic_sds_phy *sci_phy)
545 * none 544 * none
546 */ 545 */
547static void scic_sds_phy_start_sas_link_training( 546static void scic_sds_phy_start_sas_link_training(
548 struct scic_sds_phy *sci_phy) 547 struct isci_phy *iphy)
549{ 548{
550 u32 phy_control; 549 u32 phy_control;
551 550
552 phy_control = 551 phy_control =
553 readl(&sci_phy->link_layer_registers->phy_configuration); 552 readl(&iphy->link_layer_registers->phy_configuration);
554 phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD); 553 phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD);
555 writel(phy_control, 554 writel(phy_control,
556 &sci_phy->link_layer_registers->phy_configuration); 555 &iphy->link_layer_registers->phy_configuration);
557 556
558 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN); 557 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN);
559 558
560 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS; 559 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
561} 560}
562 561
563/** 562/**
@@ -569,11 +568,11 @@ static void scic_sds_phy_start_sas_link_training(
569 * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none 568 * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none
570 */ 569 */
571static void scic_sds_phy_start_sata_link_training( 570static void scic_sds_phy_start_sata_link_training(
572 struct scic_sds_phy *sci_phy) 571 struct isci_phy *iphy)
573{ 572{
574 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_POWER); 573 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_POWER);
575 574
576 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; 575 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
577} 576}
578 577
579/** 578/**
@@ -588,33 +587,33 @@ static void scic_sds_phy_start_sata_link_training(
588 * 587 *
589 */ 588 */
590static void scic_sds_phy_complete_link_training( 589static void scic_sds_phy_complete_link_training(
591 struct scic_sds_phy *sci_phy, 590 struct isci_phy *iphy,
592 enum sas_linkrate max_link_rate, 591 enum sas_linkrate max_link_rate,
593 u32 next_state) 592 u32 next_state)
594{ 593{
595 sci_phy->max_negotiated_speed = max_link_rate; 594 iphy->max_negotiated_speed = max_link_rate;
596 595
597 sci_change_state(&sci_phy->sm, next_state); 596 sci_change_state(&iphy->sm, next_state);
598} 597}
599 598
600enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy, 599enum sci_status scic_sds_phy_event_handler(struct isci_phy *iphy,
601 u32 event_code) 600 u32 event_code)
602{ 601{
603 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 602 enum scic_sds_phy_states state = iphy->sm.current_state_id;
604 603
605 switch (state) { 604 switch (state) {
606 case SCI_PHY_SUB_AWAIT_OSSP_EN: 605 case SCI_PHY_SUB_AWAIT_OSSP_EN:
607 switch (scu_get_event_code(event_code)) { 606 switch (scu_get_event_code(event_code)) {
608 case SCU_EVENT_SAS_PHY_DETECTED: 607 case SCU_EVENT_SAS_PHY_DETECTED:
609 scic_sds_phy_start_sas_link_training(sci_phy); 608 scic_sds_phy_start_sas_link_training(iphy);
610 sci_phy->is_in_link_training = true; 609 iphy->is_in_link_training = true;
611 break; 610 break;
612 case SCU_EVENT_SATA_SPINUP_HOLD: 611 case SCU_EVENT_SATA_SPINUP_HOLD:
613 scic_sds_phy_start_sata_link_training(sci_phy); 612 scic_sds_phy_start_sata_link_training(iphy);
614 sci_phy->is_in_link_training = true; 613 iphy->is_in_link_training = true;
615 break; 614 break;
616 default: 615 default:
617 dev_dbg(sciphy_to_dev(sci_phy), 616 dev_dbg(sciphy_to_dev(iphy),
618 "%s: PHY starting substate machine received " 617 "%s: PHY starting substate machine received "
619 "unexpected event_code %x\n", 618 "unexpected event_code %x\n",
620 __func__, 619 __func__,
@@ -632,21 +631,21 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
632 case SCU_EVENT_SAS_15: 631 case SCU_EVENT_SAS_15:
633 case SCU_EVENT_SAS_15_SSC: 632 case SCU_EVENT_SAS_15_SSC:
634 scic_sds_phy_complete_link_training( 633 scic_sds_phy_complete_link_training(
635 sci_phy, 634 iphy,
636 SAS_LINK_RATE_1_5_GBPS, 635 SAS_LINK_RATE_1_5_GBPS,
637 SCI_PHY_SUB_AWAIT_IAF_UF); 636 SCI_PHY_SUB_AWAIT_IAF_UF);
638 break; 637 break;
639 case SCU_EVENT_SAS_30: 638 case SCU_EVENT_SAS_30:
640 case SCU_EVENT_SAS_30_SSC: 639 case SCU_EVENT_SAS_30_SSC:
641 scic_sds_phy_complete_link_training( 640 scic_sds_phy_complete_link_training(
642 sci_phy, 641 iphy,
643 SAS_LINK_RATE_3_0_GBPS, 642 SAS_LINK_RATE_3_0_GBPS,
644 SCI_PHY_SUB_AWAIT_IAF_UF); 643 SCI_PHY_SUB_AWAIT_IAF_UF);
645 break; 644 break;
646 case SCU_EVENT_SAS_60: 645 case SCU_EVENT_SAS_60:
647 case SCU_EVENT_SAS_60_SSC: 646 case SCU_EVENT_SAS_60_SSC:
648 scic_sds_phy_complete_link_training( 647 scic_sds_phy_complete_link_training(
649 sci_phy, 648 iphy,
650 SAS_LINK_RATE_6_0_GBPS, 649 SAS_LINK_RATE_6_0_GBPS,
651 SCI_PHY_SUB_AWAIT_IAF_UF); 650 SCI_PHY_SUB_AWAIT_IAF_UF);
652 break; 651 break;
@@ -654,14 +653,14 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
654 /* 653 /*
655 * We were doing SAS PHY link training and received a SATA PHY event 654 * We were doing SAS PHY link training and received a SATA PHY event
656 * continue OOB/SN as if this were a SATA PHY */ 655 * continue OOB/SN as if this were a SATA PHY */
657 scic_sds_phy_start_sata_link_training(sci_phy); 656 scic_sds_phy_start_sata_link_training(iphy);
658 break; 657 break;
659 case SCU_EVENT_LINK_FAILURE: 658 case SCU_EVENT_LINK_FAILURE:
660 /* Link failure change state back to the starting state */ 659 /* Link failure change state back to the starting state */
661 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 660 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
662 break; 661 break;
663 default: 662 default:
664 dev_warn(sciphy_to_dev(sci_phy), 663 dev_warn(sciphy_to_dev(iphy),
665 "%s: PHY starting substate machine received " 664 "%s: PHY starting substate machine received "
666 "unexpected event_code %x\n", 665 "unexpected event_code %x\n",
667 __func__, event_code); 666 __func__, event_code);
@@ -674,23 +673,23 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
674 switch (scu_get_event_code(event_code)) { 673 switch (scu_get_event_code(event_code)) {
675 case SCU_EVENT_SAS_PHY_DETECTED: 674 case SCU_EVENT_SAS_PHY_DETECTED:
676 /* Backup the state machine */ 675 /* Backup the state machine */
677 scic_sds_phy_start_sas_link_training(sci_phy); 676 scic_sds_phy_start_sas_link_training(iphy);
678 break; 677 break;
679 case SCU_EVENT_SATA_SPINUP_HOLD: 678 case SCU_EVENT_SATA_SPINUP_HOLD:
680 /* We were doing SAS PHY link training and received a 679 /* We were doing SAS PHY link training and received a
681 * SATA PHY event continue OOB/SN as if this were a 680 * SATA PHY event continue OOB/SN as if this were a
682 * SATA PHY 681 * SATA PHY
683 */ 682 */
684 scic_sds_phy_start_sata_link_training(sci_phy); 683 scic_sds_phy_start_sata_link_training(iphy);
685 break; 684 break;
686 case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT: 685 case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
687 case SCU_EVENT_LINK_FAILURE: 686 case SCU_EVENT_LINK_FAILURE:
688 case SCU_EVENT_HARD_RESET_RECEIVED: 687 case SCU_EVENT_HARD_RESET_RECEIVED:
689 /* Start the oob/sn state machine over again */ 688 /* Start the oob/sn state machine over again */
690 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 689 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
691 break; 690 break;
692 default: 691 default:
693 dev_warn(sciphy_to_dev(sci_phy), 692 dev_warn(sciphy_to_dev(iphy),
694 "%s: PHY starting substate machine received " 693 "%s: PHY starting substate machine received "
695 "unexpected event_code %x\n", 694 "unexpected event_code %x\n",
696 __func__, event_code); 695 __func__, event_code);
@@ -701,10 +700,10 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
701 switch (scu_get_event_code(event_code)) { 700 switch (scu_get_event_code(event_code)) {
702 case SCU_EVENT_LINK_FAILURE: 701 case SCU_EVENT_LINK_FAILURE:
703 /* Link failure change state back to the starting state */ 702 /* Link failure change state back to the starting state */
704 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 703 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
705 break; 704 break;
706 default: 705 default:
707 dev_warn(sciphy_to_dev(sci_phy), 706 dev_warn(sciphy_to_dev(iphy),
708 "%s: PHY starting substate machine received unexpected " 707 "%s: PHY starting substate machine received unexpected "
709 "event_code %x\n", 708 "event_code %x\n",
710 __func__, 709 __func__,
@@ -716,7 +715,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
716 switch (scu_get_event_code(event_code)) { 715 switch (scu_get_event_code(event_code)) {
717 case SCU_EVENT_LINK_FAILURE: 716 case SCU_EVENT_LINK_FAILURE:
718 /* Link failure change state back to the starting state */ 717 /* Link failure change state back to the starting state */
719 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 718 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
720 break; 719 break;
721 case SCU_EVENT_SATA_SPINUP_HOLD: 720 case SCU_EVENT_SATA_SPINUP_HOLD:
722 /* These events are received every 10ms and are 721 /* These events are received every 10ms and are
@@ -728,11 +727,11 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
728 /* There has been a change in the phy type before OOB/SN for the 727 /* There has been a change in the phy type before OOB/SN for the
729 * SATA finished start down the SAS link traning path. 728 * SATA finished start down the SAS link traning path.
730 */ 729 */
731 scic_sds_phy_start_sas_link_training(sci_phy); 730 scic_sds_phy_start_sas_link_training(iphy);
732 break; 731 break;
733 732
734 default: 733 default:
735 dev_warn(sciphy_to_dev(sci_phy), 734 dev_warn(sciphy_to_dev(iphy),
736 "%s: PHY starting substate machine received " 735 "%s: PHY starting substate machine received "
737 "unexpected event_code %x\n", 736 "unexpected event_code %x\n",
738 __func__, event_code); 737 __func__, event_code);
@@ -744,7 +743,7 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
744 switch (scu_get_event_code(event_code)) { 743 switch (scu_get_event_code(event_code)) {
745 case SCU_EVENT_LINK_FAILURE: 744 case SCU_EVENT_LINK_FAILURE:
746 /* Link failure change state back to the starting state */ 745 /* Link failure change state back to the starting state */
747 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 746 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
748 break; 747 break;
749 case SCU_EVENT_SATA_SPINUP_HOLD: 748 case SCU_EVENT_SATA_SPINUP_HOLD:
750 /* These events might be received since we dont know how many may be in 749 /* These events might be received since we dont know how many may be in
@@ -752,19 +751,19 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
752 */ 751 */
753 break; 752 break;
754 case SCU_EVENT_SATA_PHY_DETECTED: 753 case SCU_EVENT_SATA_PHY_DETECTED:
755 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; 754 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
756 755
757 /* We have received the SATA PHY notification change state */ 756 /* We have received the SATA PHY notification change state */
758 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN); 757 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
759 break; 758 break;
760 case SCU_EVENT_SAS_PHY_DETECTED: 759 case SCU_EVENT_SAS_PHY_DETECTED:
761 /* There has been a change in the phy type before OOB/SN for the 760 /* There has been a change in the phy type before OOB/SN for the
762 * SATA finished start down the SAS link traning path. 761 * SATA finished start down the SAS link traning path.
763 */ 762 */
764 scic_sds_phy_start_sas_link_training(sci_phy); 763 scic_sds_phy_start_sas_link_training(iphy);
765 break; 764 break;
766 default: 765 default:
767 dev_warn(sciphy_to_dev(sci_phy), 766 dev_warn(sciphy_to_dev(iphy),
768 "%s: PHY starting substate machine received " 767 "%s: PHY starting substate machine received "
769 "unexpected event_code %x\n", 768 "unexpected event_code %x\n",
770 __func__, 769 __func__,
@@ -783,36 +782,36 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
783 case SCU_EVENT_SATA_15: 782 case SCU_EVENT_SATA_15:
784 case SCU_EVENT_SATA_15_SSC: 783 case SCU_EVENT_SATA_15_SSC:
785 scic_sds_phy_complete_link_training( 784 scic_sds_phy_complete_link_training(
786 sci_phy, 785 iphy,
787 SAS_LINK_RATE_1_5_GBPS, 786 SAS_LINK_RATE_1_5_GBPS,
788 SCI_PHY_SUB_AWAIT_SIG_FIS_UF); 787 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
789 break; 788 break;
790 case SCU_EVENT_SATA_30: 789 case SCU_EVENT_SATA_30:
791 case SCU_EVENT_SATA_30_SSC: 790 case SCU_EVENT_SATA_30_SSC:
792 scic_sds_phy_complete_link_training( 791 scic_sds_phy_complete_link_training(
793 sci_phy, 792 iphy,
794 SAS_LINK_RATE_3_0_GBPS, 793 SAS_LINK_RATE_3_0_GBPS,
795 SCI_PHY_SUB_AWAIT_SIG_FIS_UF); 794 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
796 break; 795 break;
797 case SCU_EVENT_SATA_60: 796 case SCU_EVENT_SATA_60:
798 case SCU_EVENT_SATA_60_SSC: 797 case SCU_EVENT_SATA_60_SSC:
799 scic_sds_phy_complete_link_training( 798 scic_sds_phy_complete_link_training(
800 sci_phy, 799 iphy,
801 SAS_LINK_RATE_6_0_GBPS, 800 SAS_LINK_RATE_6_0_GBPS,
802 SCI_PHY_SUB_AWAIT_SIG_FIS_UF); 801 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
803 break; 802 break;
804 case SCU_EVENT_LINK_FAILURE: 803 case SCU_EVENT_LINK_FAILURE:
805 /* Link failure change state back to the starting state */ 804 /* Link failure change state back to the starting state */
806 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 805 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
807 break; 806 break;
808 case SCU_EVENT_SAS_PHY_DETECTED: 807 case SCU_EVENT_SAS_PHY_DETECTED:
809 /* 808 /*
810 * There has been a change in the phy type before OOB/SN for the 809 * There has been a change in the phy type before OOB/SN for the
811 * SATA finished start down the SAS link traning path. */ 810 * SATA finished start down the SAS link traning path. */
812 scic_sds_phy_start_sas_link_training(sci_phy); 811 scic_sds_phy_start_sas_link_training(iphy);
813 break; 812 break;
814 default: 813 default:
815 dev_warn(sciphy_to_dev(sci_phy), 814 dev_warn(sciphy_to_dev(iphy),
816 "%s: PHY starting substate machine received " 815 "%s: PHY starting substate machine received "
817 "unexpected event_code %x\n", 816 "unexpected event_code %x\n",
818 __func__, event_code); 817 __func__, event_code);
@@ -825,16 +824,16 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
825 switch (scu_get_event_code(event_code)) { 824 switch (scu_get_event_code(event_code)) {
826 case SCU_EVENT_SATA_PHY_DETECTED: 825 case SCU_EVENT_SATA_PHY_DETECTED:
827 /* Backup the state machine */ 826 /* Backup the state machine */
828 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN); 827 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
829 break; 828 break;
830 829
831 case SCU_EVENT_LINK_FAILURE: 830 case SCU_EVENT_LINK_FAILURE:
832 /* Link failure change state back to the starting state */ 831 /* Link failure change state back to the starting state */
833 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 832 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
834 break; 833 break;
835 834
836 default: 835 default:
837 dev_warn(sciphy_to_dev(sci_phy), 836 dev_warn(sciphy_to_dev(iphy),
838 "%s: PHY starting substate machine received " 837 "%s: PHY starting substate machine received "
839 "unexpected event_code %x\n", 838 "unexpected event_code %x\n",
840 __func__, 839 __func__,
@@ -847,20 +846,20 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
847 switch (scu_get_event_code(event_code)) { 846 switch (scu_get_event_code(event_code)) {
848 case SCU_EVENT_LINK_FAILURE: 847 case SCU_EVENT_LINK_FAILURE:
849 /* Link failure change state back to the starting state */ 848 /* Link failure change state back to the starting state */
850 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 849 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
851 break; 850 break;
852 case SCU_EVENT_BROADCAST_CHANGE: 851 case SCU_EVENT_BROADCAST_CHANGE:
853 /* Broadcast change received. Notify the port. */ 852 /* Broadcast change received. Notify the port. */
854 if (phy_get_non_dummy_port(sci_phy) != NULL) 853 if (phy_get_non_dummy_port(iphy) != NULL)
855 scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy); 854 scic_sds_port_broadcast_change_received(iphy->owning_port, iphy);
856 else 855 else
857 sci_phy->bcn_received_while_port_unassigned = true; 856 iphy->bcn_received_while_port_unassigned = true;
858 break; 857 break;
859 default: 858 default:
860 dev_warn(sciphy_to_dev(sci_phy), 859 dev_warn(sciphy_to_dev(iphy),
861 "%sP SCIC PHY 0x%p ready state machine received " 860 "%sP SCIC PHY 0x%p ready state machine received "
862 "unexpected event_code %x\n", 861 "unexpected event_code %x\n",
863 __func__, sci_phy, event_code); 862 __func__, iphy, event_code);
864 return SCI_FAILURE_INVALID_STATE; 863 return SCI_FAILURE_INVALID_STATE;
865 } 864 }
866 return SCI_SUCCESS; 865 return SCI_SUCCESS;
@@ -868,30 +867,30 @@ enum sci_status scic_sds_phy_event_handler(struct scic_sds_phy *sci_phy,
868 switch (scu_get_event_code(event_code)) { 867 switch (scu_get_event_code(event_code)) {
869 case SCU_EVENT_HARD_RESET_TRANSMITTED: 868 case SCU_EVENT_HARD_RESET_TRANSMITTED:
870 /* Link failure change state back to the starting state */ 869 /* Link failure change state back to the starting state */
871 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 870 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
872 break; 871 break;
873 default: 872 default:
874 dev_warn(sciphy_to_dev(sci_phy), 873 dev_warn(sciphy_to_dev(iphy),
875 "%s: SCIC PHY 0x%p resetting state machine received " 874 "%s: SCIC PHY 0x%p resetting state machine received "
876 "unexpected event_code %x\n", 875 "unexpected event_code %x\n",
877 __func__, sci_phy, event_code); 876 __func__, iphy, event_code);
878 877
879 return SCI_FAILURE_INVALID_STATE; 878 return SCI_FAILURE_INVALID_STATE;
880 break; 879 break;
881 } 880 }
882 return SCI_SUCCESS; 881 return SCI_SUCCESS;
883 default: 882 default:
884 dev_dbg(sciphy_to_dev(sci_phy), 883 dev_dbg(sciphy_to_dev(iphy),
885 "%s: in wrong state: %d\n", __func__, state); 884 "%s: in wrong state: %d\n", __func__, state);
886 return SCI_FAILURE_INVALID_STATE; 885 return SCI_FAILURE_INVALID_STATE;
887 } 886 }
888} 887}
889 888
890enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy, 889enum sci_status scic_sds_phy_frame_handler(struct isci_phy *iphy,
891 u32 frame_index) 890 u32 frame_index)
892{ 891{
893 enum scic_sds_phy_states state = sci_phy->sm.current_state_id; 892 enum scic_sds_phy_states state = iphy->sm.current_state_id;
894 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 893 struct scic_sds_controller *scic = iphy->owning_port->owning_controller;
895 enum sci_status result; 894 enum sci_status result;
896 unsigned long flags; 895 unsigned long flags;
897 896
@@ -899,7 +898,6 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
899 case SCI_PHY_SUB_AWAIT_IAF_UF: { 898 case SCI_PHY_SUB_AWAIT_IAF_UF: {
900 u32 *frame_words; 899 u32 *frame_words;
901 struct sas_identify_frame iaf; 900 struct sas_identify_frame iaf;
902 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
903 901
904 result = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control, 902 result = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
905 frame_index, 903 frame_index,
@@ -927,10 +925,10 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
927 */ 925 */
928 state = SCI_PHY_SUB_AWAIT_SAS_POWER; 926 state = SCI_PHY_SUB_AWAIT_SAS_POWER;
929 } 927 }
930 sci_change_state(&sci_phy->sm, state); 928 sci_change_state(&iphy->sm, state);
931 result = SCI_SUCCESS; 929 result = SCI_SUCCESS;
932 } else 930 } else
933 dev_warn(sciphy_to_dev(sci_phy), 931 dev_warn(sciphy_to_dev(iphy),
934 "%s: PHY starting substate machine received " 932 "%s: PHY starting substate machine received "
935 "unexpected frame id %x\n", 933 "unexpected frame id %x\n",
936 __func__, frame_index); 934 __func__, frame_index);
@@ -941,10 +939,9 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
941 case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: { 939 case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: {
942 struct dev_to_host_fis *frame_header; 940 struct dev_to_host_fis *frame_header;
943 u32 *fis_frame_data; 941 u32 *fis_frame_data;
944 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
945 942
946 result = scic_sds_unsolicited_frame_control_get_header( 943 result = scic_sds_unsolicited_frame_control_get_header(
947 &(scic_sds_phy_get_controller(sci_phy)->uf_control), 944 &(scic_sds_phy_get_controller(iphy)->uf_control),
948 frame_index, 945 frame_index,
949 (void **)&frame_header); 946 (void **)&frame_header);
950 947
@@ -964,11 +961,11 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
964 spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags); 961 spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags);
965 962
966 /* got IAF we can now go to the await spinup semaphore state */ 963 /* got IAF we can now go to the await spinup semaphore state */
967 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_FINAL); 964 sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL);
968 965
969 result = SCI_SUCCESS; 966 result = SCI_SUCCESS;
970 } else 967 } else
971 dev_warn(sciphy_to_dev(sci_phy), 968 dev_warn(sciphy_to_dev(iphy),
972 "%s: PHY starting substate machine received " 969 "%s: PHY starting substate machine received "
973 "unexpected frame id %x\n", 970 "unexpected frame id %x\n",
974 __func__, frame_index); 971 __func__, frame_index);
@@ -979,7 +976,7 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
979 return result; 976 return result;
980 } 977 }
981 default: 978 default:
982 dev_dbg(sciphy_to_dev(sci_phy), 979 dev_dbg(sciphy_to_dev(iphy),
983 "%s: in wrong state: %d\n", __func__, state); 980 "%s: in wrong state: %d\n", __func__, state);
984 return SCI_FAILURE_INVALID_STATE; 981 return SCI_FAILURE_INVALID_STATE;
985 } 982 }
@@ -988,77 +985,77 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
988 985
989static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm) 986static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm)
990{ 987{
991 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 988 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
992 989
993 /* This is just an temporary state go off to the starting state */ 990 /* This is just an temporary state go off to the starting state */
994 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_AWAIT_OSSP_EN); 991 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_OSSP_EN);
995} 992}
996 993
997static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm) 994static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm)
998{ 995{
999 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 996 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1000 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 997 struct scic_sds_controller *scic = iphy->owning_port->owning_controller;
1001 998
1002 scic_sds_controller_power_control_queue_insert(scic, sci_phy); 999 scic_sds_controller_power_control_queue_insert(scic, iphy);
1003} 1000}
1004 1001
1005static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm) 1002static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm)
1006{ 1003{
1007 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1004 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1008 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1005 struct scic_sds_controller *scic = iphy->owning_port->owning_controller;
1009 1006
1010 scic_sds_controller_power_control_queue_remove(scic, sci_phy); 1007 scic_sds_controller_power_control_queue_remove(scic, iphy);
1011} 1008}
1012 1009
1013static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm) 1010static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm)
1014{ 1011{
1015 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1012 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1016 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1013 struct scic_sds_controller *scic = iphy->owning_port->owning_controller;
1017 1014
1018 scic_sds_controller_power_control_queue_insert(scic, sci_phy); 1015 scic_sds_controller_power_control_queue_insert(scic, iphy);
1019} 1016}
1020 1017
1021static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm) 1018static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm)
1022{ 1019{
1023 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1020 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1024 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1021 struct scic_sds_controller *scic = iphy->owning_port->owning_controller;
1025 1022
1026 scic_sds_controller_power_control_queue_remove(scic, sci_phy); 1023 scic_sds_controller_power_control_queue_remove(scic, iphy);
1027} 1024}
1028 1025
1029static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm) 1026static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm)
1030{ 1027{
1031 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1028 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1032 1029
1033 sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1030 sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1034} 1031}
1035 1032
1036static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm) 1033static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm)
1037{ 1034{
1038 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1035 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1039 1036
1040 sci_del_timer(&sci_phy->sata_timer); 1037 sci_del_timer(&iphy->sata_timer);
1041} 1038}
1042 1039
1043static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm) 1040static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm)
1044{ 1041{
1045 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1042 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1046 1043
1047 sci_mod_timer(&sci_phy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1044 sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1048} 1045}
1049 1046
1050static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm) 1047static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm)
1051{ 1048{
1052 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1049 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1053 1050
1054 sci_del_timer(&sci_phy->sata_timer); 1051 sci_del_timer(&iphy->sata_timer);
1055} 1052}
1056 1053
1057static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm) 1054static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm)
1058{ 1055{
1059 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1056 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1060 1057
1061 if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) { 1058 if (scic_sds_port_link_detected(iphy->owning_port, iphy)) {
1062 1059
1063 /* 1060 /*
1064 * Clear the PE suspend condition so we can actually 1061 * Clear the PE suspend condition so we can actually
@@ -1066,79 +1063,79 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_bas
1066 * The hardware will not respond to the XRDY until the PE 1063 * The hardware will not respond to the XRDY until the PE
1067 * suspend condition is cleared. 1064 * suspend condition is cleared.
1068 */ 1065 */
1069 scic_sds_phy_resume(sci_phy); 1066 scic_sds_phy_resume(iphy);
1070 1067
1071 sci_mod_timer(&sci_phy->sata_timer, 1068 sci_mod_timer(&iphy->sata_timer,
1072 SCIC_SDS_SIGNATURE_FIS_TIMEOUT); 1069 SCIC_SDS_SIGNATURE_FIS_TIMEOUT);
1073 } else 1070 } else
1074 sci_phy->is_in_link_training = false; 1071 iphy->is_in_link_training = false;
1075} 1072}
1076 1073
1077static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm) 1074static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm)
1078{ 1075{
1079 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1076 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1080 1077
1081 sci_del_timer(&sci_phy->sata_timer); 1078 sci_del_timer(&iphy->sata_timer);
1082} 1079}
1083 1080
1084static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm) 1081static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm)
1085{ 1082{
1086 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1083 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1087 1084
1088 /* State machine has run to completion so exit out and change 1085 /* State machine has run to completion so exit out and change
1089 * the base state machine to the ready state 1086 * the base state machine to the ready state
1090 */ 1087 */
1091 sci_change_state(&sci_phy->sm, SCI_PHY_READY); 1088 sci_change_state(&iphy->sm, SCI_PHY_READY);
1092} 1089}
1093 1090
1094/** 1091/**
1095 * 1092 *
1096 * @sci_phy: This is the struct scic_sds_phy object to stop. 1093 * @sci_phy: This is the struct isci_phy object to stop.
1097 * 1094 *
1098 * This method will stop the struct scic_sds_phy object. This does not reset the 1095 * This method will stop the struct isci_phy object. This does not reset the
1099 * protocol engine it just suspends it and places it in a state where it will 1096 * protocol engine it just suspends it and places it in a state where it will
1100 * not cause the end device to power up. none 1097 * not cause the end device to power up. none
1101 */ 1098 */
1102static void scu_link_layer_stop_protocol_engine( 1099static void scu_link_layer_stop_protocol_engine(
1103 struct scic_sds_phy *sci_phy) 1100 struct isci_phy *iphy)
1104{ 1101{
1105 u32 scu_sas_pcfg_value; 1102 u32 scu_sas_pcfg_value;
1106 u32 enable_spinup_value; 1103 u32 enable_spinup_value;
1107 1104
1108 /* Suspend the protocol engine and place it in a sata spinup hold state */ 1105 /* Suspend the protocol engine and place it in a sata spinup hold state */
1109 scu_sas_pcfg_value = 1106 scu_sas_pcfg_value =
1110 readl(&sci_phy->link_layer_registers->phy_configuration); 1107 readl(&iphy->link_layer_registers->phy_configuration);
1111 scu_sas_pcfg_value |= 1108 scu_sas_pcfg_value |=
1112 (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | 1109 (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
1113 SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) | 1110 SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) |
1114 SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD)); 1111 SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD));
1115 writel(scu_sas_pcfg_value, 1112 writel(scu_sas_pcfg_value,
1116 &sci_phy->link_layer_registers->phy_configuration); 1113 &iphy->link_layer_registers->phy_configuration);
1117 1114
1118 /* Disable the notify enable spinup primitives */ 1115 /* Disable the notify enable spinup primitives */
1119 enable_spinup_value = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control); 1116 enable_spinup_value = readl(&iphy->link_layer_registers->notify_enable_spinup_control);
1120 enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE); 1117 enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE);
1121 writel(enable_spinup_value, &sci_phy->link_layer_registers->notify_enable_spinup_control); 1118 writel(enable_spinup_value, &iphy->link_layer_registers->notify_enable_spinup_control);
1122} 1119}
1123 1120
1124/** 1121/**
1125 * 1122 *
1126 * 1123 *
1127 * This method will start the OOB/SN state machine for this struct scic_sds_phy object. 1124 * This method will start the OOB/SN state machine for this struct isci_phy object.
1128 */ 1125 */
1129static void scu_link_layer_start_oob( 1126static void scu_link_layer_start_oob(
1130 struct scic_sds_phy *sci_phy) 1127 struct isci_phy *iphy)
1131{ 1128{
1132 u32 scu_sas_pcfg_value; 1129 u32 scu_sas_pcfg_value;
1133 1130
1134 scu_sas_pcfg_value = 1131 scu_sas_pcfg_value =
1135 readl(&sci_phy->link_layer_registers->phy_configuration); 1132 readl(&iphy->link_layer_registers->phy_configuration);
1136 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); 1133 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
1137 scu_sas_pcfg_value &= 1134 scu_sas_pcfg_value &=
1138 ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | 1135 ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
1139 SCU_SAS_PCFG_GEN_BIT(HARD_RESET)); 1136 SCU_SAS_PCFG_GEN_BIT(HARD_RESET));
1140 writel(scu_sas_pcfg_value, 1137 writel(scu_sas_pcfg_value,
1141 &sci_phy->link_layer_registers->phy_configuration); 1138 &iphy->link_layer_registers->phy_configuration);
1142} 1139}
1143 1140
1144/** 1141/**
@@ -1150,7 +1147,7 @@ static void scu_link_layer_start_oob(
1150 * hard reset bit set. 1147 * hard reset bit set.
1151 */ 1148 */
1152static void scu_link_layer_tx_hard_reset( 1149static void scu_link_layer_tx_hard_reset(
1153 struct scic_sds_phy *sci_phy) 1150 struct isci_phy *iphy)
1154{ 1151{
1155 u32 phy_configuration_value; 1152 u32 phy_configuration_value;
1156 1153
@@ -1158,91 +1155,91 @@ static void scu_link_layer_tx_hard_reset(
1158 * SAS Phys must wait for the HARD_RESET_TX event notification to transition 1155 * SAS Phys must wait for the HARD_RESET_TX event notification to transition
1159 * to the starting state. */ 1156 * to the starting state. */
1160 phy_configuration_value = 1157 phy_configuration_value =
1161 readl(&sci_phy->link_layer_registers->phy_configuration); 1158 readl(&iphy->link_layer_registers->phy_configuration);
1162 phy_configuration_value |= 1159 phy_configuration_value |=
1163 (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) | 1160 (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) |
1164 SCU_SAS_PCFG_GEN_BIT(OOB_RESET)); 1161 SCU_SAS_PCFG_GEN_BIT(OOB_RESET));
1165 writel(phy_configuration_value, 1162 writel(phy_configuration_value,
1166 &sci_phy->link_layer_registers->phy_configuration); 1163 &iphy->link_layer_registers->phy_configuration);
1167 1164
1168 /* Now take the OOB state machine out of reset */ 1165 /* Now take the OOB state machine out of reset */
1169 phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); 1166 phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
1170 phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); 1167 phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
1171 writel(phy_configuration_value, 1168 writel(phy_configuration_value,
1172 &sci_phy->link_layer_registers->phy_configuration); 1169 &iphy->link_layer_registers->phy_configuration);
1173} 1170}
1174 1171
1175static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm) 1172static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
1176{ 1173{
1177 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1174 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1178 1175
1179 /* 1176 /*
1180 * @todo We need to get to the controller to place this PE in a 1177 * @todo We need to get to the controller to place this PE in a
1181 * reset state 1178 * reset state
1182 */ 1179 */
1183 sci_del_timer(&sci_phy->sata_timer); 1180 sci_del_timer(&iphy->sata_timer);
1184 1181
1185 scu_link_layer_stop_protocol_engine(sci_phy); 1182 scu_link_layer_stop_protocol_engine(iphy);
1186 1183
1187 if (sci_phy->sm.previous_state_id != SCI_PHY_INITIAL) 1184 if (iphy->sm.previous_state_id != SCI_PHY_INITIAL)
1188 scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy), 1185 scic_sds_controller_link_down(scic_sds_phy_get_controller(iphy),
1189 phy_get_non_dummy_port(sci_phy), 1186 phy_get_non_dummy_port(iphy),
1190 sci_phy); 1187 iphy);
1191} 1188}
1192 1189
1193static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm) 1190static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm)
1194{ 1191{
1195 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1192 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1196 1193
1197 scu_link_layer_stop_protocol_engine(sci_phy); 1194 scu_link_layer_stop_protocol_engine(iphy);
1198 scu_link_layer_start_oob(sci_phy); 1195 scu_link_layer_start_oob(iphy);
1199 1196
1200 /* We don't know what kind of phy we are going to be just yet */ 1197 /* We don't know what kind of phy we are going to be just yet */
1201 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; 1198 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
1202 sci_phy->bcn_received_while_port_unassigned = false; 1199 iphy->bcn_received_while_port_unassigned = false;
1203 1200
1204 if (sci_phy->sm.previous_state_id == SCI_PHY_READY) 1201 if (iphy->sm.previous_state_id == SCI_PHY_READY)
1205 scic_sds_controller_link_down(scic_sds_phy_get_controller(sci_phy), 1202 scic_sds_controller_link_down(scic_sds_phy_get_controller(iphy),
1206 phy_get_non_dummy_port(sci_phy), 1203 phy_get_non_dummy_port(iphy),
1207 sci_phy); 1204 iphy);
1208 1205
1209 sci_change_state(&sci_phy->sm, SCI_PHY_SUB_INITIAL); 1206 sci_change_state(&iphy->sm, SCI_PHY_SUB_INITIAL);
1210} 1207}
1211 1208
1212static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm) 1209static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm)
1213{ 1210{
1214 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1211 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1215 1212
1216 scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy), 1213 scic_sds_controller_link_up(scic_sds_phy_get_controller(iphy),
1217 phy_get_non_dummy_port(sci_phy), 1214 phy_get_non_dummy_port(iphy),
1218 sci_phy); 1215 iphy);
1219 1216
1220} 1217}
1221 1218
1222static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm) 1219static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm)
1223{ 1220{
1224 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1221 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1225 1222
1226 scic_sds_phy_suspend(sci_phy); 1223 scic_sds_phy_suspend(iphy);
1227} 1224}
1228 1225
1229static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm) 1226static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm)
1230{ 1227{
1231 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), sm); 1228 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
1232 1229
1233 /* The phy is being reset, therefore deactivate it from the port. In 1230 /* The phy is being reset, therefore deactivate it from the port. In
1234 * the resetting state we don't notify the user regarding link up and 1231 * the resetting state we don't notify the user regarding link up and
1235 * link down notifications 1232 * link down notifications
1236 */ 1233 */
1237 scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false); 1234 scic_sds_port_deactivate_phy(iphy->owning_port, iphy, false);
1238 1235
1239 if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { 1236 if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
1240 scu_link_layer_tx_hard_reset(sci_phy); 1237 scu_link_layer_tx_hard_reset(iphy);
1241 } else { 1238 } else {
1242 /* The SCU does not need to have a discrete reset state so 1239 /* The SCU does not need to have a discrete reset state so
1243 * just go back to the starting state. 1240 * just go back to the starting state.
1244 */ 1241 */
1245 sci_change_state(&sci_phy->sm, SCI_PHY_STARTING); 1242 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
1246 } 1243 }
1247} 1244}
1248 1245
@@ -1293,21 +1290,21 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
1293 [SCI_PHY_FINAL] = { }, 1290 [SCI_PHY_FINAL] = { },
1294}; 1291};
1295 1292
1296void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, 1293void scic_sds_phy_construct(struct isci_phy *iphy,
1297 struct scic_sds_port *owning_port, u8 phy_index) 1294 struct scic_sds_port *owning_port, u8 phy_index)
1298{ 1295{
1299 sci_init_sm(&sci_phy->sm, scic_sds_phy_state_table, SCI_PHY_INITIAL); 1296 sci_init_sm(&iphy->sm, scic_sds_phy_state_table, SCI_PHY_INITIAL);
1300 1297
1301 /* Copy the rest of the input data to our locals */ 1298 /* Copy the rest of the input data to our locals */
1302 sci_phy->owning_port = owning_port; 1299 iphy->owning_port = owning_port;
1303 sci_phy->phy_index = phy_index; 1300 iphy->phy_index = phy_index;
1304 sci_phy->bcn_received_while_port_unassigned = false; 1301 iphy->bcn_received_while_port_unassigned = false;
1305 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; 1302 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
1306 sci_phy->link_layer_registers = NULL; 1303 iphy->link_layer_registers = NULL;
1307 sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; 1304 iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
1308 1305
1309 /* Create the SIGNATURE FIS Timeout timer for this phy */ 1306 /* Create the SIGNATURE FIS Timeout timer for this phy */
1310 sci_init_timer(&sci_phy->sata_timer, phy_sata_timeout); 1307 sci_init_timer(&iphy->sata_timer, phy_sata_timeout);
1311} 1308}
1312 1309
1313void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) 1310void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index)
@@ -1368,14 +1365,14 @@ int isci_phy_control(struct asd_sas_phy *sas_phy,
1368 switch (func) { 1365 switch (func) {
1369 case PHY_FUNC_DISABLE: 1366 case PHY_FUNC_DISABLE:
1370 spin_lock_irqsave(&ihost->scic_lock, flags); 1367 spin_lock_irqsave(&ihost->scic_lock, flags);
1371 scic_sds_phy_stop(&iphy->sci); 1368 scic_sds_phy_stop(iphy);
1372 spin_unlock_irqrestore(&ihost->scic_lock, flags); 1369 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1373 break; 1370 break;
1374 1371
1375 case PHY_FUNC_LINK_RESET: 1372 case PHY_FUNC_LINK_RESET:
1376 spin_lock_irqsave(&ihost->scic_lock, flags); 1373 spin_lock_irqsave(&ihost->scic_lock, flags);
1377 scic_sds_phy_stop(&iphy->sci); 1374 scic_sds_phy_stop(iphy);
1378 scic_sds_phy_start(&iphy->sci); 1375 scic_sds_phy_start(iphy);
1379 spin_unlock_irqrestore(&ihost->scic_lock, flags); 1376 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1380 break; 1377 break;
1381 1378
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h
index 97ebee16f4b3..345fbeacb5cf 100644
--- a/drivers/scsi/isci/phy.h
+++ b/drivers/scsi/isci/phy.h
@@ -84,102 +84,40 @@ enum scic_sds_phy_protocol {
84}; 84};
85 85
86/** 86/**
87 * struct scic_sds_phy - This structure contains or references all of the data 87 * isci_phy - hba local phy infrastructure
88 * necessary to represent the core phy object and SCU harware protocol 88 * @sm:
89 * engine. 89 * @protocol: attached device protocol
90 * 90 * @phy_index: physical index relative to the controller (0-3)
91 * 91 * @bcn_received_while_port_unassigned: bcn to report after port association
92 * @sata_timer: timeout SATA signature FIS arrival
92 */ 93 */
93struct scic_sds_phy { 94struct isci_phy {
94 /**
95 * This field contains the information for the base phy state machine.
96 */
97 struct sci_base_state_machine sm; 95 struct sci_base_state_machine sm;
98
99 /**
100 * This field specifies the port object that owns/contains this phy.
101 */
102 struct scic_sds_port *owning_port; 96 struct scic_sds_port *owning_port;
103
104 /**
105 * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s,
106 * or 6.0 Gb/s operation.
107 */
108 enum sas_linkrate max_negotiated_speed; 97 enum sas_linkrate max_negotiated_speed;
109
110 /**
111 * This member specifies the protocol being utilized on this phy. This
112 * field contains a legitamite value once the PHY has link trained with
113 * a remote phy.
114 */
115 enum scic_sds_phy_protocol protocol; 98 enum scic_sds_phy_protocol protocol;
116
117 /**
118 * This field specifies the index with which this phy is associated (0-3).
119 */
120 u8 phy_index; 99 u8 phy_index;
121
122 /**
123 * This member indicates if this particular PHY has received a BCN while
124 * it had no port assignement. This BCN will be reported once the phy is
125 * assigned to a port.
126 */
127 bool bcn_received_while_port_unassigned; 100 bool bcn_received_while_port_unassigned;
128
129 /**
130 * This field indicates if this PHY is currently in the process of
131 * link training (i.e. it has started OOB, but has yet to perform
132 * IAF exchange/Signature FIS reception).
133 */
134 bool is_in_link_training; 101 bool is_in_link_training;
135 102 struct sci_timer sata_timer;
136 /**
137 * Timer to detect when a signature FIS timeout has occurred. The
138 * signature FIS is the first FIS sent by an attached SATA device
139 * after OOB/SN.
140 */
141 struct sci_timer sata_timer;
142
143 /**
144 * This field is the pointer to the transport layer register for the SCU
145 * hardware.
146 */
147 struct scu_transport_layer_registers __iomem *transport_layer_registers; 103 struct scu_transport_layer_registers __iomem *transport_layer_registers;
148
149 /**
150 * This field points to the link layer register set within the SCU.
151 */
152 struct scu_link_layer_registers __iomem *link_layer_registers; 104 struct scu_link_layer_registers __iomem *link_layer_registers;
153
154};
155
156
157struct isci_phy {
158 struct scic_sds_phy sci;
159 struct asd_sas_phy sas_phy; 105 struct asd_sas_phy sas_phy;
160 struct isci_port *isci_port; 106 struct isci_port *isci_port;
161 u8 sas_addr[SAS_ADDR_SIZE]; 107 u8 sas_addr[SAS_ADDR_SIZE];
162
163 union { 108 union {
164 struct sas_identify_frame iaf; 109 struct sas_identify_frame iaf;
165 struct dev_to_host_fis fis; 110 struct dev_to_host_fis fis;
166 } frame_rcvd; 111 } frame_rcvd;
167}; 112};
168 113
169static inline struct isci_phy *to_isci_phy(struct asd_sas_phy *sas_phy) 114static inline struct isci_phy *to_iphy(struct asd_sas_phy *sas_phy)
170{ 115{
171 struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy); 116 struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy);
172 117
173 return iphy; 118 return iphy;
174} 119}
175 120
176static inline struct isci_phy *sci_phy_to_iphy(struct scic_sds_phy *sci_phy)
177{
178 struct isci_phy *iphy = container_of(sci_phy, typeof(*iphy), sci);
179
180 return iphy;
181}
182
183struct scic_phy_cap { 121struct scic_phy_cap {
184 union { 122 union {
185 struct { 123 struct {
@@ -520,61 +458,61 @@ enum scic_sds_phy_states {
520 (scic_sds_port_get_controller((phy)->owning_port)) 458 (scic_sds_port_get_controller((phy)->owning_port))
521 459
522void scic_sds_phy_construct( 460void scic_sds_phy_construct(
523 struct scic_sds_phy *this_phy, 461 struct isci_phy *iphy,
524 struct scic_sds_port *owning_port, 462 struct scic_sds_port *owning_port,
525 u8 phy_index); 463 u8 phy_index);
526 464
527struct scic_sds_port *phy_get_non_dummy_port(struct scic_sds_phy *sci_phy); 465struct scic_sds_port *phy_get_non_dummy_port(struct isci_phy *iphy);
528 466
529void scic_sds_phy_set_port( 467void scic_sds_phy_set_port(
530 struct scic_sds_phy *this_phy, 468 struct isci_phy *iphy,
531 struct scic_sds_port *owning_port); 469 struct scic_sds_port *owning_port);
532 470
533enum sci_status scic_sds_phy_initialize( 471enum sci_status scic_sds_phy_initialize(
534 struct scic_sds_phy *this_phy, 472 struct isci_phy *iphy,
535 struct scu_transport_layer_registers __iomem *transport_layer_registers, 473 struct scu_transport_layer_registers __iomem *transport_layer_registers,
536 struct scu_link_layer_registers __iomem *link_layer_registers); 474 struct scu_link_layer_registers __iomem *link_layer_registers);
537 475
538enum sci_status scic_sds_phy_start( 476enum sci_status scic_sds_phy_start(
539 struct scic_sds_phy *this_phy); 477 struct isci_phy *iphy);
540 478
541enum sci_status scic_sds_phy_stop( 479enum sci_status scic_sds_phy_stop(
542 struct scic_sds_phy *this_phy); 480 struct isci_phy *iphy);
543 481
544enum sci_status scic_sds_phy_reset( 482enum sci_status scic_sds_phy_reset(
545 struct scic_sds_phy *this_phy); 483 struct isci_phy *iphy);
546 484
547void scic_sds_phy_resume( 485void scic_sds_phy_resume(
548 struct scic_sds_phy *this_phy); 486 struct isci_phy *iphy);
549 487
550void scic_sds_phy_setup_transport( 488void scic_sds_phy_setup_transport(
551 struct scic_sds_phy *this_phy, 489 struct isci_phy *iphy,
552 u32 device_id); 490 u32 device_id);
553 491
554enum sci_status scic_sds_phy_event_handler( 492enum sci_status scic_sds_phy_event_handler(
555 struct scic_sds_phy *this_phy, 493 struct isci_phy *iphy,
556 u32 event_code); 494 u32 event_code);
557 495
558enum sci_status scic_sds_phy_frame_handler( 496enum sci_status scic_sds_phy_frame_handler(
559 struct scic_sds_phy *this_phy, 497 struct isci_phy *iphy,
560 u32 frame_index); 498 u32 frame_index);
561 499
562enum sci_status scic_sds_phy_consume_power_handler( 500enum sci_status scic_sds_phy_consume_power_handler(
563 struct scic_sds_phy *this_phy); 501 struct isci_phy *iphy);
564 502
565void scic_sds_phy_get_sas_address( 503void scic_sds_phy_get_sas_address(
566 struct scic_sds_phy *this_phy, 504 struct isci_phy *iphy,
567 struct sci_sas_address *sas_address); 505 struct sci_sas_address *sas_address);
568 506
569void scic_sds_phy_get_attached_sas_address( 507void scic_sds_phy_get_attached_sas_address(
570 struct scic_sds_phy *this_phy, 508 struct isci_phy *iphy,
571 struct sci_sas_address *sas_address); 509 struct sci_sas_address *sas_address);
572 510
573struct scic_phy_proto; 511struct scic_phy_proto;
574void scic_sds_phy_get_protocols( 512void scic_sds_phy_get_protocols(
575 struct scic_sds_phy *sci_phy, 513 struct isci_phy *iphy,
576 struct scic_phy_proto *protocols); 514 struct scic_phy_proto *protocols);
577enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy); 515enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy);
578 516
579struct isci_host; 517struct isci_host;
580void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index); 518void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index);
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index bd091549b4f7..d53c0b1748e7 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -154,17 +154,17 @@ static enum sci_status scic_port_get_properties(struct scic_sds_port *port,
154 154
155static void scic_port_bcn_enable(struct scic_sds_port *sci_port) 155static void scic_port_bcn_enable(struct scic_sds_port *sci_port)
156{ 156{
157 struct scic_sds_phy *sci_phy; 157 struct isci_phy *iphy;
158 u32 val; 158 u32 val;
159 int i; 159 int i;
160 160
161 for (i = 0; i < ARRAY_SIZE(sci_port->phy_table); i++) { 161 for (i = 0; i < ARRAY_SIZE(sci_port->phy_table); i++) {
162 sci_phy = sci_port->phy_table[i]; 162 iphy = sci_port->phy_table[i];
163 if (!sci_phy) 163 if (!iphy)
164 continue; 164 continue;
165 val = readl(&sci_phy->link_layer_registers->link_layer_control); 165 val = readl(&iphy->link_layer_registers->link_layer_control);
166 /* clear the bit by writing 1. */ 166 /* clear the bit by writing 1. */
167 writel(val, &sci_phy->link_layer_registers->link_layer_control); 167 writel(val, &iphy->link_layer_registers->link_layer_control);
168 } 168 }
169} 169}
170 170
@@ -180,10 +180,9 @@ void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport)
180 return; 180 return;
181 181
182 for (i = 0; i < ARRAY_SIZE(iport->sci.phy_table); i++) { 182 for (i = 0; i < ARRAY_SIZE(iport->sci.phy_table); i++) {
183 struct scic_sds_phy *sci_phy = iport->sci.phy_table[i]; 183 struct isci_phy *iphy = iport->sci.phy_table[i];
184 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
185 184
186 if (!sci_phy) 185 if (!iphy)
187 continue; 186 continue;
188 187
189 ihost->sas_ha.notify_port_event(&iphy->sas_phy, 188 ihost->sas_ha.notify_port_event(&iphy->sas_phy,
@@ -194,9 +193,8 @@ void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport)
194 193
195void isci_port_bc_change_received(struct isci_host *ihost, 194void isci_port_bc_change_received(struct isci_host *ihost,
196 struct scic_sds_port *sci_port, 195 struct scic_sds_port *sci_port,
197 struct scic_sds_phy *sci_phy) 196 struct isci_phy *iphy)
198{ 197{
199 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
200 struct isci_port *iport = iphy->isci_port; 198 struct isci_port *iport = iphy->isci_port;
201 199
202 if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) { 200 if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) {
@@ -219,33 +217,32 @@ void isci_port_bc_change_received(struct isci_host *ihost,
219 217
220static void isci_port_link_up(struct isci_host *isci_host, 218static void isci_port_link_up(struct isci_host *isci_host,
221 struct scic_sds_port *port, 219 struct scic_sds_port *port,
222 struct scic_sds_phy *phy) 220 struct isci_phy *iphy)
223{ 221{
224 unsigned long flags; 222 unsigned long flags;
225 struct scic_port_properties properties; 223 struct scic_port_properties properties;
226 struct isci_phy *isci_phy = sci_phy_to_iphy(phy);
227 struct isci_port *isci_port = sci_port_to_iport(port); 224 struct isci_port *isci_port = sci_port_to_iport(port);
228 unsigned long success = true; 225 unsigned long success = true;
229 226
230 BUG_ON(isci_phy->isci_port != NULL); 227 BUG_ON(iphy->isci_port != NULL);
231 228
232 isci_phy->isci_port = isci_port; 229 iphy->isci_port = isci_port;
233 230
234 dev_dbg(&isci_host->pdev->dev, 231 dev_dbg(&isci_host->pdev->dev,
235 "%s: isci_port = %p\n", 232 "%s: isci_port = %p\n",
236 __func__, isci_port); 233 __func__, isci_port);
237 234
238 spin_lock_irqsave(&isci_phy->sas_phy.frame_rcvd_lock, flags); 235 spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags);
239 236
240 isci_port_change_state(isci_phy->isci_port, isci_starting); 237 isci_port_change_state(iphy->isci_port, isci_starting);
241 238
242 scic_port_get_properties(port, &properties); 239 scic_port_get_properties(port, &properties);
243 240
244 if (phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) { 241 if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) {
245 u64 attached_sas_address; 242 u64 attached_sas_address;
246 243
247 isci_phy->sas_phy.oob_mode = SATA_OOB_MODE; 244 iphy->sas_phy.oob_mode = SATA_OOB_MODE;
248 isci_phy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis); 245 iphy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis);
249 246
250 /* 247 /*
251 * For direct-attached SATA devices, the SCI core will 248 * For direct-attached SATA devices, the SCI core will
@@ -259,28 +256,28 @@ static void isci_port_link_up(struct isci_host *isci_host,
259 attached_sas_address |= properties.remote.sas_address.low; 256 attached_sas_address |= properties.remote.sas_address.low;
260 swab64s(&attached_sas_address); 257 swab64s(&attached_sas_address);
261 258
262 memcpy(&isci_phy->sas_phy.attached_sas_addr, 259 memcpy(&iphy->sas_phy.attached_sas_addr,
263 &attached_sas_address, sizeof(attached_sas_address)); 260 &attached_sas_address, sizeof(attached_sas_address));
264 } else if (phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { 261 } else if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
265 isci_phy->sas_phy.oob_mode = SAS_OOB_MODE; 262 iphy->sas_phy.oob_mode = SAS_OOB_MODE;
266 isci_phy->sas_phy.frame_rcvd_size = sizeof(struct sas_identify_frame); 263 iphy->sas_phy.frame_rcvd_size = sizeof(struct sas_identify_frame);
267 264
268 /* Copy the attached SAS address from the IAF */ 265 /* Copy the attached SAS address from the IAF */
269 memcpy(isci_phy->sas_phy.attached_sas_addr, 266 memcpy(iphy->sas_phy.attached_sas_addr,
270 isci_phy->frame_rcvd.iaf.sas_addr, SAS_ADDR_SIZE); 267 iphy->frame_rcvd.iaf.sas_addr, SAS_ADDR_SIZE);
271 } else { 268 } else {
272 dev_err(&isci_host->pdev->dev, "%s: unkown target\n", __func__); 269 dev_err(&isci_host->pdev->dev, "%s: unkown target\n", __func__);
273 success = false; 270 success = false;
274 } 271 }
275 272
276 isci_phy->sas_phy.phy->negotiated_linkrate = sci_phy_linkrate(phy); 273 iphy->sas_phy.phy->negotiated_linkrate = sci_phy_linkrate(iphy);
277 274
278 spin_unlock_irqrestore(&isci_phy->sas_phy.frame_rcvd_lock, flags); 275 spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags);
279 276
280 /* Notify libsas that we have an address frame, if indeed 277 /* Notify libsas that we have an address frame, if indeed
281 * we've found an SSP, SMP, or STP target */ 278 * we've found an SSP, SMP, or STP target */
282 if (success) 279 if (success)
283 isci_host->sas_ha.notify_port_event(&isci_phy->sas_phy, 280 isci_host->sas_ha.notify_port_event(&iphy->sas_phy,
284 PORTE_BYTES_DMAED); 281 PORTE_BYTES_DMAED);
285} 282}
286 283
@@ -495,11 +492,7 @@ static bool scic_sds_port_is_phy_mask_valid(
495 return false; 492 return false;
496} 493}
497 494
498/** 495/*
499 *
500 * @sci_port: This parameter specifies the port from which to return a
501 * connected phy.
502 *
503 * This method retrieves a currently active (i.e. connected) phy contained in 496 * This method retrieves a currently active (i.e. connected) phy contained in
504 * the port. Currently, the lowest order phy that is connected is returned. 497 * the port. Currently, the lowest order phy that is connected is returned.
505 * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is 498 * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is
@@ -507,58 +500,38 @@ static bool scic_sds_port_is_phy_mask_valid(
507 * point) phys contained in the port. All other values specify a struct scic_sds_phy 500 * point) phys contained in the port. All other values specify a struct scic_sds_phy
508 * object that is active in the port. 501 * object that is active in the port.
509 */ 502 */
510static struct scic_sds_phy *scic_sds_port_get_a_connected_phy( 503static struct isci_phy *scic_sds_port_get_a_connected_phy(struct scic_sds_port *sci_port)
511 struct scic_sds_port *sci_port 504{
512 ) {
513 u32 index; 505 u32 index;
514 struct scic_sds_phy *phy; 506 struct isci_phy *iphy;
515 507
516 for (index = 0; index < SCI_MAX_PHYS; index++) { 508 for (index = 0; index < SCI_MAX_PHYS; index++) {
517 /* 509 /* Ensure that the phy is both part of the port and currently
518 * Ensure that the phy is both part of the port and currently 510 * connected to the remote end-point.
519 * connected to the remote end-point. */ 511 */
520 phy = sci_port->phy_table[index]; 512 iphy = sci_port->phy_table[index];
521 if ( 513 if (iphy && scic_sds_port_active_phy(sci_port, iphy))
522 (phy != NULL) 514 return iphy;
523 && scic_sds_port_active_phy(sci_port, phy)
524 ) {
525 return phy;
526 }
527 } 515 }
528 516
529 return NULL; 517 return NULL;
530} 518}
531 519
532/** 520static enum sci_status scic_sds_port_set_phy(struct scic_sds_port *port, struct isci_phy *iphy)
533 * scic_sds_port_set_phy() -
534 * @out]: port The port object to which the phy assignement is being made.
535 * @out]: phy The phy which is being assigned to the port.
536 *
537 * This method attempts to make the assignment of the phy to the port. If
538 * successful the phy is assigned to the ports phy table. bool true if the phy
539 * assignment can be made. false if the phy assignement can not be made. This
540 * is a functional test that only fails if the phy is currently assigned to a
541 * different port.
542 */
543static enum sci_status scic_sds_port_set_phy(
544 struct scic_sds_port *port,
545 struct scic_sds_phy *phy)
546{ 521{
547 /* 522 /* Check to see if we can add this phy to a port
548 * Check to see if we can add this phy to a port
549 * that means that the phy is not part of a port and that the port does 523 * that means that the phy is not part of a port and that the port does
550 * not already have a phy assinged to the phy index. */ 524 * not already have a phy assinged to the phy index.
551 if ( 525 */
552 (port->phy_table[phy->phy_index] == NULL) 526 if (!port->phy_table[iphy->phy_index] &&
553 && (phy_get_non_dummy_port(phy) == NULL) 527 !phy_get_non_dummy_port(iphy) &&
554 && scic_sds_port_is_valid_phy_assignment(port, phy->phy_index) 528 scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index)) {
555 ) { 529 /* Phy is being added in the stopped state so we are in MPC mode
556 /* 530 * make logical port index = physical port index
557 * Phy is being added in the stopped state so we are in MPC mode 531 */
558 * make logical port index = physical port index */
559 port->logical_port_index = port->physical_port_index; 532 port->logical_port_index = port->physical_port_index;
560 port->phy_table[phy->phy_index] = phy; 533 port->phy_table[iphy->phy_index] = iphy;
561 scic_sds_phy_set_port(phy, port); 534 scic_sds_phy_set_port(iphy, port);
562 535
563 return SCI_SUCCESS; 536 return SCI_SUCCESS;
564 } 537 }
@@ -566,28 +539,18 @@ static enum sci_status scic_sds_port_set_phy(
566 return SCI_FAILURE; 539 return SCI_FAILURE;
567} 540}
568 541
569/** 542static enum sci_status scic_sds_port_clear_phy(struct scic_sds_port *port,
570 * scic_sds_port_clear_phy() - 543 struct isci_phy *iphy)
571 * @out]: port The port from which the phy is being cleared.
572 * @out]: phy The phy being cleared from the port.
573 *
574 * This method will clear the phy assigned to this port. This method fails if
575 * this phy is not currently assinged to this port. bool true if the phy is
576 * removed from the port. false if this phy is not assined to this port.
577 */
578static enum sci_status scic_sds_port_clear_phy(
579 struct scic_sds_port *port,
580 struct scic_sds_phy *phy)
581{ 544{
582 /* Make sure that this phy is part of this port */ 545 /* Make sure that this phy is part of this port */
583 if (port->phy_table[phy->phy_index] == phy && 546 if (port->phy_table[iphy->phy_index] == iphy &&
584 phy_get_non_dummy_port(phy) == port) { 547 phy_get_non_dummy_port(iphy) == port) {
585 struct scic_sds_controller *scic = port->owning_controller; 548 struct scic_sds_controller *scic = port->owning_controller;
586 struct isci_host *ihost = scic_to_ihost(scic); 549 struct isci_host *ihost = scic_to_ihost(scic);
587 550
588 /* Yep it is assigned to this port so remove it */ 551 /* Yep it is assigned to this port so remove it */
589 scic_sds_phy_set_port(phy, &ihost->ports[SCI_MAX_PORTS].sci); 552 scic_sds_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS].sci);
590 port->phy_table[phy->phy_index] = NULL; 553 port->phy_table[iphy->phy_index] = NULL;
591 return SCI_SUCCESS; 554 return SCI_SUCCESS;
592 } 555 }
593 556
@@ -634,20 +597,20 @@ void scic_sds_port_get_attached_sas_address(
634 struct scic_sds_port *sci_port, 597 struct scic_sds_port *sci_port,
635 struct sci_sas_address *sas_address) 598 struct sci_sas_address *sas_address)
636{ 599{
637 struct scic_sds_phy *sci_phy; 600 struct isci_phy *iphy;
638 601
639 /* 602 /*
640 * Ensure that the phy is both part of the port and currently 603 * Ensure that the phy is both part of the port and currently
641 * connected to the remote end-point. 604 * connected to the remote end-point.
642 */ 605 */
643 sci_phy = scic_sds_port_get_a_connected_phy(sci_port); 606 iphy = scic_sds_port_get_a_connected_phy(sci_port);
644 if (sci_phy) { 607 if (iphy) {
645 if (sci_phy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) { 608 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) {
646 scic_sds_phy_get_attached_sas_address(sci_phy, 609 scic_sds_phy_get_attached_sas_address(iphy,
647 sas_address); 610 sas_address);
648 } else { 611 } else {
649 scic_sds_phy_get_sas_address(sci_phy, sas_address); 612 scic_sds_phy_get_sas_address(iphy, sas_address);
650 sas_address->low += sci_phy->phy_index; 613 sas_address->low += iphy->phy_index;
651 } 614 }
652 } else { 615 } else {
653 sas_address->high = 0; 616 sas_address->high = 0;
@@ -787,39 +750,38 @@ void scic_sds_port_setup_transports(
787 * notifying the user that the link is up. none 750 * notifying the user that the link is up. none
788 */ 751 */
789static void scic_sds_port_activate_phy(struct scic_sds_port *sci_port, 752static void scic_sds_port_activate_phy(struct scic_sds_port *sci_port,
790 struct scic_sds_phy *sci_phy, 753 struct isci_phy *iphy,
791 bool do_notify_user) 754 bool do_notify_user)
792{ 755{
793 struct scic_sds_controller *scic = sci_port->owning_controller; 756 struct scic_sds_controller *scic = sci_port->owning_controller;
794 struct isci_host *ihost = scic_to_ihost(scic); 757 struct isci_host *ihost = scic_to_ihost(scic);
795 758
796 if (sci_phy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) 759 if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA)
797 scic_sds_phy_resume(sci_phy); 760 scic_sds_phy_resume(iphy);
798 761
799 sci_port->active_phy_mask |= 1 << sci_phy->phy_index; 762 sci_port->active_phy_mask |= 1 << iphy->phy_index;
800 763
801 scic_sds_controller_clear_invalid_phy(scic, sci_phy); 764 scic_sds_controller_clear_invalid_phy(scic, iphy);
802 765
803 if (do_notify_user == true) 766 if (do_notify_user == true)
804 isci_port_link_up(ihost, sci_port, sci_phy); 767 isci_port_link_up(ihost, sci_port, iphy);
805} 768}
806 769
807void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port, 770void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
808 struct scic_sds_phy *sci_phy, 771 struct isci_phy *iphy,
809 bool do_notify_user) 772 bool do_notify_user)
810{ 773{
811 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port); 774 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
812 struct isci_port *iport = sci_port_to_iport(sci_port); 775 struct isci_port *iport = sci_port_to_iport(sci_port);
813 struct isci_host *ihost = scic_to_ihost(scic); 776 struct isci_host *ihost = scic_to_ihost(scic);
814 struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
815 777
816 sci_port->active_phy_mask &= ~(1 << sci_phy->phy_index); 778 sci_port->active_phy_mask &= ~(1 << iphy->phy_index);
817 779
818 sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; 780 iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
819 781
820 /* Re-assign the phy back to the LP as if it were a narrow port */ 782 /* Re-assign the phy back to the LP as if it were a narrow port */
821 writel(sci_phy->phy_index, 783 writel(iphy->phy_index,
822 &sci_port->port_pe_configuration_register[sci_phy->phy_index]); 784 &sci_port->port_pe_configuration_register[iphy->phy_index]);
823 785
824 if (do_notify_user == true) 786 if (do_notify_user == true)
825 isci_port_link_down(ihost, iphy, iport); 787 isci_port_link_down(ihost, iphy, iport);
@@ -834,7 +796,7 @@ void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
834 * this port object. None 796 * this port object. None
835 */ 797 */
836static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port, 798static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port,
837 struct scic_sds_phy *sci_phy) 799 struct isci_phy *iphy)
838{ 800{
839 struct scic_sds_controller *scic = sci_port->owning_controller; 801 struct scic_sds_controller *scic = sci_port->owning_controller;
840 802
@@ -843,8 +805,8 @@ static void scic_sds_port_invalid_link_up(struct scic_sds_port *sci_port,
843 * not go ahead and tell the SCI_USER that we have discovered an 805 * not go ahead and tell the SCI_USER that we have discovered an
844 * invalid link. 806 * invalid link.
845 */ 807 */
846 if ((scic->invalid_phy_mask & (1 << sci_phy->phy_index)) == 0) { 808 if ((scic->invalid_phy_mask & (1 << iphy->phy_index)) == 0) {
847 scic_sds_controller_set_invalid_phy(scic, sci_phy); 809 scic_sds_controller_set_invalid_phy(scic, iphy);
848 dev_warn(&scic_to_ihost(scic)->pdev->dev, "Invalid link up!\n"); 810 dev_warn(&scic_to_ihost(scic)->pdev->dev, "Invalid link up!\n");
849 } 811 }
850} 812}
@@ -879,7 +841,7 @@ static void port_state_machine_change(struct scic_sds_port *sci_port,
879/** 841/**
880 * scic_sds_port_general_link_up_handler - phy can be assigned to port? 842 * scic_sds_port_general_link_up_handler - phy can be assigned to port?
881 * @sci_port: scic_sds_port object for which has a phy that has gone link up. 843 * @sci_port: scic_sds_port object for which has a phy that has gone link up.
882 * @sci_phy: This is the struct scic_sds_phy object that has gone link up. 844 * @sci_phy: This is the struct isci_phy object that has gone link up.
883 * @do_notify_user: This parameter specifies whether to inform the user (via 845 * @do_notify_user: This parameter specifies whether to inform the user (via
884 * scic_cb_port_link_up()) as to the fact that a new phy as become ready. 846 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
885 * 847 *
@@ -890,14 +852,14 @@ static void port_state_machine_change(struct scic_sds_port *sci_port,
890 * the same port. none 852 * the same port. none
891 */ 853 */
892static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port, 854static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port,
893 struct scic_sds_phy *sci_phy, 855 struct isci_phy *iphy,
894 bool do_notify_user) 856 bool do_notify_user)
895{ 857{
896 struct sci_sas_address port_sas_address; 858 struct sci_sas_address port_sas_address;
897 struct sci_sas_address phy_sas_address; 859 struct sci_sas_address phy_sas_address;
898 860
899 scic_sds_port_get_attached_sas_address(sci_port, &port_sas_address); 861 scic_sds_port_get_attached_sas_address(sci_port, &port_sas_address);
900 scic_sds_phy_get_attached_sas_address(sci_phy, &phy_sas_address); 862 scic_sds_phy_get_attached_sas_address(iphy, &phy_sas_address);
901 863
902 /* If the SAS address of the new phy matches the SAS address of 864 /* If the SAS address of the new phy matches the SAS address of
903 * other phys in the port OR this is the first phy in the port, 865 * other phys in the port OR this is the first phy in the port,
@@ -909,11 +871,11 @@ static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port
909 sci_port->active_phy_mask == 0) { 871 sci_port->active_phy_mask == 0) {
910 struct sci_base_state_machine *sm = &sci_port->sm; 872 struct sci_base_state_machine *sm = &sci_port->sm;
911 873
912 scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user); 874 scic_sds_port_activate_phy(sci_port, iphy, do_notify_user);
913 if (sm->current_state_id == SCI_PORT_RESETTING) 875 if (sm->current_state_id == SCI_PORT_RESETTING)
914 port_state_machine_change(sci_port, SCI_PORT_READY); 876 port_state_machine_change(sci_port, SCI_PORT_READY);
915 } else 877 } else
916 scic_sds_port_invalid_link_up(sci_port, sci_phy); 878 scic_sds_port_invalid_link_up(sci_port, iphy);
917} 879}
918 880
919 881
@@ -957,12 +919,12 @@ static bool scic_sds_port_is_wide(struct scic_sds_port *sci_port)
957 */ 919 */
958bool scic_sds_port_link_detected( 920bool scic_sds_port_link_detected(
959 struct scic_sds_port *sci_port, 921 struct scic_sds_port *sci_port,
960 struct scic_sds_phy *sci_phy) 922 struct isci_phy *iphy)
961{ 923{
962 if ((sci_port->logical_port_index != SCIC_SDS_DUMMY_PORT) && 924 if ((sci_port->logical_port_index != SCIC_SDS_DUMMY_PORT) &&
963 (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) && 925 (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) &&
964 scic_sds_port_is_wide(sci_port)) { 926 scic_sds_port_is_wide(sci_port)) {
965 scic_sds_port_invalid_link_up(sci_port, sci_phy); 927 scic_sds_port_invalid_link_up(sci_port, iphy);
966 928
967 return false; 929 return false;
968 } 930 }
@@ -1045,47 +1007,26 @@ static void scic_sds_port_update_viit_entry(struct scic_sds_port *sci_port)
1045 &sci_port->viit_registers->status); 1007 &sci_port->viit_registers->status);
1046} 1008}
1047 1009
1048/** 1010enum sas_linkrate scic_sds_port_get_max_allowed_speed(struct scic_sds_port *sci_port)
1049 * This method returns the maximum allowed speed for data transfers on this
1050 * port. This maximum allowed speed evaluates to the maximum speed of the
1051 * slowest phy in the port.
1052 * @sci_port: This parameter specifies the port for which to retrieve the
1053 * maximum allowed speed.
1054 *
1055 * This method returns the maximum negotiated speed of the slowest phy in the
1056 * port.
1057 */
1058enum sas_linkrate scic_sds_port_get_max_allowed_speed(
1059 struct scic_sds_port *sci_port)
1060{ 1011{
1061 u16 index; 1012 u16 index;
1013 struct isci_phy *iphy;
1062 enum sas_linkrate max_allowed_speed = SAS_LINK_RATE_6_0_GBPS; 1014 enum sas_linkrate max_allowed_speed = SAS_LINK_RATE_6_0_GBPS;
1063 struct scic_sds_phy *phy = NULL;
1064 1015
1065 /* 1016 /*
1066 * Loop through all of the phys in this port and find the phy with the 1017 * Loop through all of the phys in this port and find the phy with the
1067 * lowest maximum link rate. */ 1018 * lowest maximum link rate. */
1068 for (index = 0; index < SCI_MAX_PHYS; index++) { 1019 for (index = 0; index < SCI_MAX_PHYS; index++) {
1069 phy = sci_port->phy_table[index]; 1020 iphy = sci_port->phy_table[index];
1070 if ( 1021 if (iphy && scic_sds_port_active_phy(sci_port, iphy) &&
1071 (phy != NULL) 1022 iphy->max_negotiated_speed < max_allowed_speed)
1072 && (scic_sds_port_active_phy(sci_port, phy) == true) 1023 max_allowed_speed = iphy->max_negotiated_speed;
1073 && (phy->max_negotiated_speed < max_allowed_speed)
1074 )
1075 max_allowed_speed = phy->max_negotiated_speed;
1076 } 1024 }
1077 1025
1078 return max_allowed_speed; 1026 return max_allowed_speed;
1079} 1027}
1080 1028
1081/** 1029static void scic_sds_port_suspend_port_task_scheduler(struct scic_sds_port *port)
1082 *
1083 * @sci_port: This is the struct scic_sds_port object to suspend.
1084 *
1085 * This method will susped the port task scheduler for this port object. none
1086 */
1087static void
1088scic_sds_port_suspend_port_task_scheduler(struct scic_sds_port *port)
1089{ 1030{
1090 u32 pts_control_value; 1031 u32 pts_control_value;
1091 1032
@@ -1377,7 +1318,7 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port)
1377static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 timeout) 1318static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 timeout)
1378{ 1319{
1379 enum sci_status status = SCI_FAILURE_INVALID_PHY; 1320 enum sci_status status = SCI_FAILURE_INVALID_PHY;
1380 struct scic_sds_phy *selected_phy = NULL; 1321 struct isci_phy *iphy = NULL;
1381 enum scic_sds_port_states state; 1322 enum scic_sds_port_states state;
1382 u32 phy_index; 1323 u32 phy_index;
1383 1324
@@ -1389,22 +1330,21 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
1389 } 1330 }
1390 1331
1391 /* Select a phy on which we can send the hard reset request. */ 1332 /* Select a phy on which we can send the hard reset request. */
1392 for (phy_index = 0; phy_index < SCI_MAX_PHYS && !selected_phy; phy_index++) { 1333 for (phy_index = 0; phy_index < SCI_MAX_PHYS && !iphy; phy_index++) {
1393 selected_phy = sci_port->phy_table[phy_index]; 1334 iphy = sci_port->phy_table[phy_index];
1394 if (selected_phy && 1335 if (iphy && !scic_sds_port_active_phy(sci_port, iphy)) {
1395 !scic_sds_port_active_phy(sci_port, selected_phy)) {
1396 /* 1336 /*
1397 * We found a phy but it is not ready select 1337 * We found a phy but it is not ready select
1398 * different phy 1338 * different phy
1399 */ 1339 */
1400 selected_phy = NULL; 1340 iphy = NULL;
1401 } 1341 }
1402 } 1342 }
1403 1343
1404 /* If we have a phy then go ahead and start the reset procedure */ 1344 /* If we have a phy then go ahead and start the reset procedure */
1405 if (!selected_phy) 1345 if (!iphy)
1406 return status; 1346 return status;
1407 status = scic_sds_phy_reset(selected_phy); 1347 status = scic_sds_phy_reset(iphy);
1408 1348
1409 if (status != SCI_SUCCESS) 1349 if (status != SCI_SUCCESS)
1410 return status; 1350 return status;
@@ -1412,8 +1352,7 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
1412 sci_mod_timer(&sci_port->timer, timeout); 1352 sci_mod_timer(&sci_port->timer, timeout);
1413 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; 1353 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
1414 1354
1415 port_state_machine_change(sci_port, 1355 port_state_machine_change(sci_port, SCI_PORT_RESETTING);
1416 SCI_PORT_RESETTING);
1417 return SCI_SUCCESS; 1356 return SCI_SUCCESS;
1418} 1357}
1419 1358
@@ -1427,7 +1366,7 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32
1427 * status is a failure to add the phy to the port. 1366 * status is a failure to add the phy to the port.
1428 */ 1367 */
1429enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, 1368enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1430 struct scic_sds_phy *sci_phy) 1369 struct isci_phy *iphy)
1431{ 1370{
1432 enum sci_status status; 1371 enum sci_status status;
1433 enum scic_sds_port_states state; 1372 enum scic_sds_port_states state;
@@ -1446,32 +1385,32 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1446 /* Make sure that the PHY SAS Address matches the SAS Address 1385 /* Make sure that the PHY SAS Address matches the SAS Address
1447 * for this port 1386 * for this port
1448 */ 1387 */
1449 scic_sds_phy_get_sas_address(sci_phy, &phy_sas_address); 1388 scic_sds_phy_get_sas_address(iphy, &phy_sas_address);
1450 1389
1451 if (port_sas_address.high != phy_sas_address.high || 1390 if (port_sas_address.high != phy_sas_address.high ||
1452 port_sas_address.low != phy_sas_address.low) 1391 port_sas_address.low != phy_sas_address.low)
1453 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 1392 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
1454 } 1393 }
1455 return scic_sds_port_set_phy(sci_port, sci_phy); 1394 return scic_sds_port_set_phy(sci_port, iphy);
1456 } 1395 }
1457 case SCI_PORT_SUB_WAITING: 1396 case SCI_PORT_SUB_WAITING:
1458 case SCI_PORT_SUB_OPERATIONAL: 1397 case SCI_PORT_SUB_OPERATIONAL:
1459 status = scic_sds_port_set_phy(sci_port, sci_phy); 1398 status = scic_sds_port_set_phy(sci_port, iphy);
1460 1399
1461 if (status != SCI_SUCCESS) 1400 if (status != SCI_SUCCESS)
1462 return status; 1401 return status;
1463 1402
1464 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); 1403 scic_sds_port_general_link_up_handler(sci_port, iphy, true);
1465 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1404 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1466 port_state_machine_change(sci_port, SCI_PORT_SUB_CONFIGURING); 1405 port_state_machine_change(sci_port, SCI_PORT_SUB_CONFIGURING);
1467 1406
1468 return status; 1407 return status;
1469 case SCI_PORT_SUB_CONFIGURING: 1408 case SCI_PORT_SUB_CONFIGURING:
1470 status = scic_sds_port_set_phy(sci_port, sci_phy); 1409 status = scic_sds_port_set_phy(sci_port, iphy);
1471 1410
1472 if (status != SCI_SUCCESS) 1411 if (status != SCI_SUCCESS)
1473 return status; 1412 return status;
1474 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); 1413 scic_sds_port_general_link_up_handler(sci_port, iphy, true);
1475 1414
1476 /* Re-enter the configuring state since this may be the last phy in 1415 /* Re-enter the configuring state since this may be the last phy in
1477 * the port. 1416 * the port.
@@ -1496,7 +1435,7 @@ enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port,
1496 * other status is a failure to add the phy to the port. 1435 * other status is a failure to add the phy to the port.
1497 */ 1436 */
1498enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, 1437enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
1499 struct scic_sds_phy *sci_phy) 1438 struct isci_phy *iphy)
1500{ 1439{
1501 enum sci_status status; 1440 enum sci_status status;
1502 enum scic_sds_port_states state; 1441 enum scic_sds_port_states state;
@@ -1505,23 +1444,23 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
1505 1444
1506 switch (state) { 1445 switch (state) {
1507 case SCI_PORT_STOPPED: 1446 case SCI_PORT_STOPPED:
1508 return scic_sds_port_clear_phy(sci_port, sci_phy); 1447 return scic_sds_port_clear_phy(sci_port, iphy);
1509 case SCI_PORT_SUB_OPERATIONAL: 1448 case SCI_PORT_SUB_OPERATIONAL:
1510 status = scic_sds_port_clear_phy(sci_port, sci_phy); 1449 status = scic_sds_port_clear_phy(sci_port, iphy);
1511 if (status != SCI_SUCCESS) 1450 if (status != SCI_SUCCESS)
1512 return status; 1451 return status;
1513 1452
1514 scic_sds_port_deactivate_phy(sci_port, sci_phy, true); 1453 scic_sds_port_deactivate_phy(sci_port, iphy, true);
1515 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1454 sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1516 port_state_machine_change(sci_port, 1455 port_state_machine_change(sci_port,
1517 SCI_PORT_SUB_CONFIGURING); 1456 SCI_PORT_SUB_CONFIGURING);
1518 return SCI_SUCCESS; 1457 return SCI_SUCCESS;
1519 case SCI_PORT_SUB_CONFIGURING: 1458 case SCI_PORT_SUB_CONFIGURING:
1520 status = scic_sds_port_clear_phy(sci_port, sci_phy); 1459 status = scic_sds_port_clear_phy(sci_port, iphy);
1521 1460
1522 if (status != SCI_SUCCESS) 1461 if (status != SCI_SUCCESS)
1523 return status; 1462 return status;
1524 scic_sds_port_deactivate_phy(sci_port, sci_phy, true); 1463 scic_sds_port_deactivate_phy(sci_port, iphy, true);
1525 1464
1526 /* Re-enter the configuring state since this may be the last phy in 1465 /* Re-enter the configuring state since this may be the last phy in
1527 * the port 1466 * the port
@@ -1537,7 +1476,7 @@ enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port,
1537} 1476}
1538 1477
1539enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port, 1478enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1540 struct scic_sds_phy *sci_phy) 1479 struct isci_phy *iphy)
1541{ 1480{
1542 enum scic_sds_port_states state; 1481 enum scic_sds_port_states state;
1543 1482
@@ -1547,13 +1486,13 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1547 /* Since this is the first phy going link up for the port we 1486 /* Since this is the first phy going link up for the port we
1548 * can just enable it and continue 1487 * can just enable it and continue
1549 */ 1488 */
1550 scic_sds_port_activate_phy(sci_port, sci_phy, true); 1489 scic_sds_port_activate_phy(sci_port, iphy, true);
1551 1490
1552 port_state_machine_change(sci_port, 1491 port_state_machine_change(sci_port,
1553 SCI_PORT_SUB_OPERATIONAL); 1492 SCI_PORT_SUB_OPERATIONAL);
1554 return SCI_SUCCESS; 1493 return SCI_SUCCESS;
1555 case SCI_PORT_SUB_OPERATIONAL: 1494 case SCI_PORT_SUB_OPERATIONAL:
1556 scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); 1495 scic_sds_port_general_link_up_handler(sci_port, iphy, true);
1557 return SCI_SUCCESS; 1496 return SCI_SUCCESS;
1558 case SCI_PORT_RESETTING: 1497 case SCI_PORT_RESETTING:
1559 /* TODO We should make sure that the phy that has gone 1498 /* TODO We should make sure that the phy that has gone
@@ -1570,7 +1509,7 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1570 /* In the resetting state we don't notify the user regarding 1509 /* In the resetting state we don't notify the user regarding
1571 * link up and link down notifications. 1510 * link up and link down notifications.
1572 */ 1511 */
1573 scic_sds_port_general_link_up_handler(sci_port, sci_phy, false); 1512 scic_sds_port_general_link_up_handler(sci_port, iphy, false);
1574 return SCI_SUCCESS; 1513 return SCI_SUCCESS;
1575 default: 1514 default:
1576 dev_warn(sciport_to_dev(sci_port), 1515 dev_warn(sciport_to_dev(sci_port),
@@ -1580,14 +1519,14 @@ enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
1580} 1519}
1581 1520
1582enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, 1521enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
1583 struct scic_sds_phy *sci_phy) 1522 struct isci_phy *iphy)
1584{ 1523{
1585 enum scic_sds_port_states state; 1524 enum scic_sds_port_states state;
1586 1525
1587 state = sci_port->sm.current_state_id; 1526 state = sci_port->sm.current_state_id;
1588 switch (state) { 1527 switch (state) {
1589 case SCI_PORT_SUB_OPERATIONAL: 1528 case SCI_PORT_SUB_OPERATIONAL:
1590 scic_sds_port_deactivate_phy(sci_port, sci_phy, true); 1529 scic_sds_port_deactivate_phy(sci_port, iphy, true);
1591 1530
1592 /* If there are no active phys left in the port, then 1531 /* If there are no active phys left in the port, then
1593 * transition the port to the WAITING state until such time 1532 * transition the port to the WAITING state until such time
@@ -1600,7 +1539,7 @@ enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
1600 case SCI_PORT_RESETTING: 1539 case SCI_PORT_RESETTING:
1601 /* In the resetting state we don't notify the user regarding 1540 /* In the resetting state we don't notify the user regarding
1602 * link up and link down notifications. */ 1541 * link up and link down notifications. */
1603 scic_sds_port_deactivate_phy(sci_port, sci_phy, false); 1542 scic_sds_port_deactivate_phy(sci_port, iphy, false);
1604 return SCI_SUCCESS; 1543 return SCI_SUCCESS;
1605 default: 1544 default:
1606 dev_warn(sciport_to_dev(sci_port), 1545 dev_warn(sciport_to_dev(sci_port),
@@ -1879,13 +1818,13 @@ enum isci_status isci_port_get_state(
1879 1818
1880void scic_sds_port_broadcast_change_received( 1819void scic_sds_port_broadcast_change_received(
1881 struct scic_sds_port *sci_port, 1820 struct scic_sds_port *sci_port,
1882 struct scic_sds_phy *sci_phy) 1821 struct isci_phy *iphy)
1883{ 1822{
1884 struct scic_sds_controller *scic = sci_port->owning_controller; 1823 struct scic_sds_controller *scic = sci_port->owning_controller;
1885 struct isci_host *ihost = scic_to_ihost(scic); 1824 struct isci_host *ihost = scic_to_ihost(scic);
1886 1825
1887 /* notify the user. */ 1826 /* notify the user. */
1888 isci_port_bc_change_received(ihost, sci_port, sci_phy); 1827 isci_port_bc_change_received(ihost, sci_port, iphy);
1889} 1828}
1890 1829
1891int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport, 1830int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport,
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h
index 668f3a14cd70..b6ce56a6c11d 100644
--- a/drivers/scsi/isci/port.h
+++ b/drivers/scsi/isci/port.h
@@ -131,7 +131,7 @@ struct scic_sds_port {
131 /** 131 /**
132 * This field is the table of phys assigned to the port. 132 * This field is the table of phys assigned to the port.
133 */ 133 */
134 struct scic_sds_phy *phy_table[SCI_MAX_PHYS]; 134 struct isci_phy *phy_table[SCI_MAX_PHYS];
135 135
136 /** 136 /**
137 * This field is a pointer back to the controller that owns this 137 * This field is a pointer back to the controller that owns this
@@ -328,11 +328,11 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port);
328 328
329enum sci_status scic_sds_port_add_phy( 329enum sci_status scic_sds_port_add_phy(
330 struct scic_sds_port *sci_port, 330 struct scic_sds_port *sci_port,
331 struct scic_sds_phy *sci_phy); 331 struct isci_phy *iphy);
332 332
333enum sci_status scic_sds_port_remove_phy( 333enum sci_status scic_sds_port_remove_phy(
334 struct scic_sds_port *sci_port, 334 struct scic_sds_port *sci_port,
335 struct scic_sds_phy *sci_phy); 335 struct isci_phy *iphy);
336 336
337void scic_sds_port_setup_transports( 337void scic_sds_port_setup_transports(
338 struct scic_sds_port *sci_port, 338 struct scic_sds_port *sci_port,
@@ -342,17 +342,17 @@ void isci_port_bcn_enable(struct isci_host *, struct isci_port *);
342 342
343void scic_sds_port_deactivate_phy( 343void scic_sds_port_deactivate_phy(
344 struct scic_sds_port *sci_port, 344 struct scic_sds_port *sci_port,
345 struct scic_sds_phy *sci_phy, 345 struct isci_phy *iphy,
346 bool do_notify_user); 346 bool do_notify_user);
347 347
348bool scic_sds_port_link_detected( 348bool scic_sds_port_link_detected(
349 struct scic_sds_port *sci_port, 349 struct scic_sds_port *sci_port,
350 struct scic_sds_phy *sci_phy); 350 struct isci_phy *iphy);
351 351
352enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port, 352enum sci_status scic_sds_port_link_up(struct scic_sds_port *sci_port,
353 struct scic_sds_phy *sci_phy); 353 struct isci_phy *iphy);
354enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port, 354enum sci_status scic_sds_port_link_down(struct scic_sds_port *sci_port,
355 struct scic_sds_phy *sci_phy); 355 struct isci_phy *iphy);
356 356
357struct isci_request; 357struct isci_request;
358struct scic_sds_remote_device; 358struct scic_sds_remote_device;
@@ -371,7 +371,7 @@ enum sas_linkrate scic_sds_port_get_max_allowed_speed(
371 371
372void scic_sds_port_broadcast_change_received( 372void scic_sds_port_broadcast_change_received(
373 struct scic_sds_port *sci_port, 373 struct scic_sds_port *sci_port,
374 struct scic_sds_phy *sci_phy); 374 struct isci_phy *iphy);
375 375
376bool scic_sds_port_is_valid_phy_assignment( 376bool scic_sds_port_is_valid_phy_assignment(
377 struct scic_sds_port *sci_port, 377 struct scic_sds_port *sci_port,
diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c
index fcb8f030b7ae..8444fd8219dd 100644
--- a/drivers/scsi/isci/port_config.c
+++ b/drivers/scsi/isci/port_config.c
@@ -114,7 +114,7 @@ static s32 sci_sas_address_compare(
114 */ 114 */
115static struct scic_sds_port *scic_sds_port_configuration_agent_find_port( 115static struct scic_sds_port *scic_sds_port_configuration_agent_find_port(
116 struct scic_sds_controller *scic, 116 struct scic_sds_controller *scic,
117 struct scic_sds_phy *phy) 117 struct isci_phy *iphy)
118{ 118{
119 u8 i; 119 u8 i;
120 struct sci_sas_address port_sas_address; 120 struct sci_sas_address port_sas_address;
@@ -127,8 +127,8 @@ static struct scic_sds_port *scic_sds_port_configuration_agent_find_port(
127 * more phys match the sent and received SAS address as this phy in which 127 * more phys match the sent and received SAS address as this phy in which
128 * case it should participate in the same port. 128 * case it should participate in the same port.
129 */ 129 */
130 scic_sds_phy_get_sas_address(phy, &phy_sas_address); 130 scic_sds_phy_get_sas_address(iphy, &phy_sas_address);
131 scic_sds_phy_get_attached_sas_address(phy, &phy_attached_device_address); 131 scic_sds_phy_get_attached_sas_address(iphy, &phy_attached_device_address);
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);
@@ -196,8 +196,8 @@ static enum sci_status scic_sds_port_configuration_agent_validate_ports(
196 * PE0 and PE3 can never have the same SAS Address unless they 196 * PE0 and PE3 can never have the same SAS Address unless they
197 * are part of the same x4 wide port and we have already checked 197 * are part of the same x4 wide port and we have already checked
198 * for this condition. */ 198 * for this condition. */
199 scic_sds_phy_get_sas_address(&ihost->phys[0].sci, &first_address); 199 scic_sds_phy_get_sas_address(&ihost->phys[0], &first_address);
200 scic_sds_phy_get_sas_address(&ihost->phys[3].sci, &second_address); 200 scic_sds_phy_get_sas_address(&ihost->phys[3], &second_address);
201 201
202 if (sci_sas_address_compare(first_address, second_address) == 0) { 202 if (sci_sas_address_compare(first_address, second_address) == 0) {
203 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 203 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
@@ -209,8 +209,8 @@ static enum sci_status scic_sds_port_configuration_agent_validate_ports(
209 * part of the same port. */ 209 * part of the same port. */
210 if (port_agent->phy_valid_port_range[0].min_index == 0 && 210 if (port_agent->phy_valid_port_range[0].min_index == 0 &&
211 port_agent->phy_valid_port_range[1].min_index == 1) { 211 port_agent->phy_valid_port_range[1].min_index == 1) {
212 scic_sds_phy_get_sas_address(&ihost->phys[0].sci, &first_address); 212 scic_sds_phy_get_sas_address(&ihost->phys[0], &first_address);
213 scic_sds_phy_get_sas_address(&ihost->phys[2].sci, &second_address); 213 scic_sds_phy_get_sas_address(&ihost->phys[2], &second_address);
214 214
215 if (sci_sas_address_compare(first_address, second_address) == 0) { 215 if (sci_sas_address_compare(first_address, second_address) == 0) {
216 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 216 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
@@ -223,8 +223,8 @@ static enum sci_status scic_sds_port_configuration_agent_validate_ports(
223 * part of the same port. */ 223 * part of the same port. */
224 if (port_agent->phy_valid_port_range[2].min_index == 2 && 224 if (port_agent->phy_valid_port_range[2].min_index == 2 &&
225 port_agent->phy_valid_port_range[3].min_index == 3) { 225 port_agent->phy_valid_port_range[3].min_index == 3) {
226 scic_sds_phy_get_sas_address(&ihost->phys[1].sci, &first_address); 226 scic_sds_phy_get_sas_address(&ihost->phys[1], &first_address);
227 scic_sds_phy_get_sas_address(&ihost->phys[3].sci, &second_address); 227 scic_sds_phy_get_sas_address(&ihost->phys[3], &second_address);
228 228
229 if (sci_sas_address_compare(first_address, second_address) == 0) { 229 if (sci_sas_address_compare(first_address, second_address) == 0) {
230 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; 230 return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION;
@@ -277,7 +277,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
277 for (phy_index = 0; phy_index < SCI_MAX_PHYS; phy_index++) { 277 for (phy_index = 0; phy_index < SCI_MAX_PHYS; phy_index++) {
278 if ((phy_mask & (1 << phy_index)) == 0) 278 if ((phy_mask & (1 << phy_index)) == 0)
279 continue; 279 continue;
280 scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, 280 scic_sds_phy_get_sas_address(&ihost->phys[phy_index],
281 &sas_address); 281 &sas_address);
282 282
283 /* 283 /*
@@ -302,7 +302,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
302 while (phy_index < SCI_MAX_PHYS) { 302 while (phy_index < SCI_MAX_PHYS) {
303 if ((phy_mask & (1 << phy_index)) == 0) 303 if ((phy_mask & (1 << phy_index)) == 0)
304 continue; 304 continue;
305 scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, 305 scic_sds_phy_get_sas_address(&ihost->phys[phy_index],
306 &phy_assigned_address); 306 &phy_assigned_address);
307 307
308 if (sci_sas_address_compare(sas_address, phy_assigned_address) != 0) { 308 if (sci_sas_address_compare(sas_address, phy_assigned_address) != 0) {
@@ -316,7 +316,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
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].sci,
319 &ihost->phys[phy_index].sci); 319 &ihost->phys[phy_index]);
320 320
321 assigned_phy_mask |= (1 << phy_index); 321 assigned_phy_mask |= (1 << phy_index);
322 } 322 }
@@ -352,12 +352,12 @@ static void mpc_agent_timeout(unsigned long data)
352 configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; 352 configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask;
353 353
354 for (index = 0; index < SCI_MAX_PHYS; index++) { 354 for (index = 0; index < SCI_MAX_PHYS; index++) {
355 struct scic_sds_phy *sci_phy = &ihost->phys[index].sci; 355 struct isci_phy *iphy = &ihost->phys[index];
356 356
357 if (configure_phy_mask & (1 << index)) { 357 if (configure_phy_mask & (1 << index)) {
358 port_agent->link_up_handler(scic, port_agent, 358 port_agent->link_up_handler(scic, port_agent,
359 phy_get_non_dummy_port(sci_phy), 359 phy_get_non_dummy_port(iphy),
360 sci_phy); 360 iphy);
361 } 361 }
362 } 362 }
363 363
@@ -365,37 +365,22 @@ done:
365 spin_unlock_irqrestore(&ihost->scic_lock, flags); 365 spin_unlock_irqrestore(&ihost->scic_lock, flags);
366} 366}
367 367
368/** 368static void scic_sds_mpc_agent_link_up(struct scic_sds_controller *controller,
369 * 369 struct scic_sds_port_configuration_agent *port_agent,
370 * @controller: This is the controller object that receives the link up 370 struct scic_sds_port *port,
371 * notification. 371 struct isci_phy *iphy)
372 * @port: This is the port object associated with the phy. If the is no
373 * associated port this is an NULL.
374 * @phy: This is the phy object which has gone ready.
375 *
376 * This method handles the manual port configuration link up notifications.
377 * Since all ports and phys are associate at initialization time we just turn
378 * around and notifiy the port object that there is a link up. If this PHY is
379 * not associated with a port there is no action taken. Is it possible to get a
380 * link up notification from a phy that has no assocoated port?
381 */
382static void scic_sds_mpc_agent_link_up(
383 struct scic_sds_controller *controller,
384 struct scic_sds_port_configuration_agent *port_agent,
385 struct scic_sds_port *port,
386 struct scic_sds_phy *phy)
387{ 372{
388 /* 373 /* If the port has an invalid handle then the phy was not assigned to
389 * If the port has an invalid handle then the phy was not assigned to
390 * a port. This is because the phy was not given the same SAS Address 374 * a port. This is because the phy was not given the same SAS Address
391 * as the other PHYs in the port. */ 375 * as the other PHYs in the port.
376 */
392 if (port != NULL) { 377 if (port != NULL) {
393 port_agent->phy_ready_mask |= (1 << scic_sds_phy_get_index(phy)); 378 port_agent->phy_ready_mask |= (1 << scic_sds_phy_get_index(iphy));
394 379
395 scic_sds_port_link_up(port, phy); 380 scic_sds_port_link_up(port, iphy);
396 381
397 if ((port->active_phy_mask & (1 << scic_sds_phy_get_index(phy))) != 0) { 382 if ((port->active_phy_mask & (1 << scic_sds_phy_get_index(iphy))) != 0) {
398 port_agent->phy_configured_mask |= (1 << scic_sds_phy_get_index(phy)); 383 port_agent->phy_configured_mask |= (1 << scic_sds_phy_get_index(iphy));
399 } 384 }
400 } 385 }
401} 386}
@@ -421,7 +406,7 @@ static void scic_sds_mpc_agent_link_down(
421 struct scic_sds_controller *scic, 406 struct scic_sds_controller *scic,
422 struct scic_sds_port_configuration_agent *port_agent, 407 struct scic_sds_port_configuration_agent *port_agent,
423 struct scic_sds_port *sci_port, 408 struct scic_sds_port *sci_port,
424 struct scic_sds_phy *sci_phy) 409 struct isci_phy *iphy)
425{ 410{
426 if (sci_port != NULL) { 411 if (sci_port != NULL) {
427 /* 412 /*
@@ -432,9 +417,9 @@ static void scic_sds_mpc_agent_link_down(
432 * state. 417 * state.
433 */ 418 */
434 port_agent->phy_ready_mask &= 419 port_agent->phy_ready_mask &=
435 ~(1 << scic_sds_phy_get_index(sci_phy)); 420 ~(1 << scic_sds_phy_get_index(iphy));
436 port_agent->phy_configured_mask &= 421 port_agent->phy_configured_mask &=
437 ~(1 << scic_sds_phy_get_index(sci_phy)); 422 ~(1 << scic_sds_phy_get_index(iphy));
438 423
439 /* 424 /*
440 * Check to see if there are more phys waiting to be 425 * Check to see if there are more phys waiting to be
@@ -451,7 +436,7 @@ static void scic_sds_mpc_agent_link_down(
451 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT); 436 SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT);
452 } 437 }
453 438
454 scic_sds_port_link_down(sci_port, sci_phy); 439 scic_sds_port_link_down(sci_port, iphy);
455 } 440 }
456} 441}
457 442
@@ -482,11 +467,11 @@ static enum sci_status scic_sds_apc_agent_validate_phy_configuration(
482 port_index = phy_index; 467 port_index = phy_index;
483 468
484 /* Get the assigned SAS Address for the first PHY on the controller. */ 469 /* Get the assigned SAS Address for the first PHY on the controller. */
485 scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, 470 scic_sds_phy_get_sas_address(&ihost->phys[phy_index],
486 &sas_address); 471 &sas_address);
487 472
488 while (++phy_index < SCI_MAX_PHYS) { 473 while (++phy_index < SCI_MAX_PHYS) {
489 scic_sds_phy_get_sas_address(&ihost->phys[phy_index].sci, 474 scic_sds_phy_get_sas_address(&ihost->phys[phy_index],
490 &phy_assigned_address); 475 &phy_assigned_address);
491 476
492 /* Verify each of the SAS address are all the same for every PHY */ 477 /* Verify each of the SAS address are all the same for every PHY */
@@ -504,20 +489,10 @@ static enum sci_status scic_sds_apc_agent_validate_phy_configuration(
504 return scic_sds_port_configuration_agent_validate_ports(controller, port_agent); 489 return scic_sds_port_configuration_agent_validate_ports(controller, port_agent);
505} 490}
506 491
507/** 492static void scic_sds_apc_agent_configure_ports(struct scic_sds_controller *controller,
508 * 493 struct scic_sds_port_configuration_agent *port_agent,
509 * @controller: This is the controller object that receives the link up 494 struct isci_phy *iphy,
510 * notification. 495 bool start_timer)
511 * @phy: This is the phy object which has gone link up.
512 *
513 * This method handles the automatic port configuration for link up
514 * notifications.
515 */
516static void scic_sds_apc_agent_configure_ports(
517 struct scic_sds_controller *controller,
518 struct scic_sds_port_configuration_agent *port_agent,
519 struct scic_sds_phy *phy,
520 bool start_timer)
521{ 496{
522 u8 port_index; 497 u8 port_index;
523 enum sci_status status; 498 enum sci_status status;
@@ -525,10 +500,10 @@ static void scic_sds_apc_agent_configure_ports(
525 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY; 500 enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY;
526 struct isci_host *ihost = scic_to_ihost(controller); 501 struct isci_host *ihost = scic_to_ihost(controller);
527 502
528 port = scic_sds_port_configuration_agent_find_port(controller, phy); 503 port = scic_sds_port_configuration_agent_find_port(controller, iphy);
529 504
530 if (port != NULL) { 505 if (port != NULL) {
531 if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) 506 if (scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index))
532 apc_activity = SCIC_SDS_APC_ADD_PHY; 507 apc_activity = SCIC_SDS_APC_ADD_PHY;
533 else 508 else
534 apc_activity = SCIC_SDS_APC_SKIP_PHY; 509 apc_activity = SCIC_SDS_APC_SKIP_PHY;
@@ -540,20 +515,20 @@ static void scic_sds_apc_agent_configure_ports(
540 * 515 *
541 * Note the break when we reach the condition of the port id == phy id */ 516 * Note the break when we reach the condition of the port id == phy id */
542 for ( 517 for (
543 port_index = port_agent->phy_valid_port_range[phy->phy_index].min_index; 518 port_index = port_agent->phy_valid_port_range[iphy->phy_index].min_index;
544 port_index <= port_agent->phy_valid_port_range[phy->phy_index].max_index; 519 port_index <= port_agent->phy_valid_port_range[iphy->phy_index].max_index;
545 port_index++ 520 port_index++
546 ) { 521 ) {
547 522
548 port = &ihost->ports[port_index].sci; 523 port = &ihost->ports[port_index].sci;
549 524
550 /* First we must make sure that this PHY can be added to this Port. */ 525 /* First we must make sure that this PHY can be added to this Port. */
551 if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) { 526 if (scic_sds_port_is_valid_phy_assignment(port, iphy->phy_index)) {
552 /* 527 /*
553 * Port contains a PHY with a greater PHY ID than the current 528 * Port contains a PHY with a greater PHY ID than the current
554 * PHY that has gone link up. This phy can not be part of any 529 * PHY that has gone link up. This phy can not be part of any
555 * port so skip it and move on. */ 530 * port so skip it and move on. */
556 if (port->active_phy_mask > (1 << phy->phy_index)) { 531 if (port->active_phy_mask > (1 << iphy->phy_index)) {
557 apc_activity = SCIC_SDS_APC_SKIP_PHY; 532 apc_activity = SCIC_SDS_APC_SKIP_PHY;
558 break; 533 break;
559 } 534 }
@@ -562,7 +537,7 @@ static void scic_sds_apc_agent_configure_ports(
562 * We have reached the end of our Port list and have not found 537 * We have reached the end of our Port list and have not found
563 * any reason why we should not either add the PHY to the port 538 * any reason why we should not either add the PHY to the port
564 * or wait for more phys to become active. */ 539 * or wait for more phys to become active. */
565 if (port->physical_port_index == phy->phy_index) { 540 if (port->physical_port_index == iphy->phy_index) {
566 /* 541 /*
567 * The Port either has no active PHYs. 542 * The Port either has no active PHYs.
568 * Consider that if the port had any active PHYs we would have 543 * Consider that if the port had any active PHYs we would have
@@ -608,10 +583,10 @@ static void scic_sds_apc_agent_configure_ports(
608 583
609 switch (apc_activity) { 584 switch (apc_activity) {
610 case SCIC_SDS_APC_ADD_PHY: 585 case SCIC_SDS_APC_ADD_PHY:
611 status = scic_sds_port_add_phy(port, phy); 586 status = scic_sds_port_add_phy(port, iphy);
612 587
613 if (status == SCI_SUCCESS) { 588 if (status == SCI_SUCCESS) {
614 port_agent->phy_configured_mask |= (1 << phy->phy_index); 589 port_agent->phy_configured_mask |= (1 << iphy->phy_index);
615 } 590 }
616 break; 591 break;
617 592
@@ -651,14 +626,14 @@ static void scic_sds_apc_agent_configure_ports(
651static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic, 626static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
652 struct scic_sds_port_configuration_agent *port_agent, 627 struct scic_sds_port_configuration_agent *port_agent,
653 struct scic_sds_port *sci_port, 628 struct scic_sds_port *sci_port,
654 struct scic_sds_phy *sci_phy) 629 struct isci_phy *iphy)
655{ 630{
656 u8 phy_index = sci_phy->phy_index; 631 u8 phy_index = iphy->phy_index;
657 632
658 if (!sci_port) { 633 if (!sci_port) {
659 /* the phy is not the part of this port */ 634 /* the phy is not the part of this port */
660 port_agent->phy_ready_mask |= 1 << phy_index; 635 port_agent->phy_ready_mask |= 1 << phy_index;
661 scic_sds_apc_agent_configure_ports(scic, port_agent, sci_phy, true); 636 scic_sds_apc_agent_configure_ports(scic, port_agent, iphy, true);
662 } else { 637 } else {
663 /* the phy is already the part of the port */ 638 /* the phy is already the part of the port */
664 u32 port_state = sci_port->sm.current_state_id; 639 u32 port_state = sci_port->sm.current_state_id;
@@ -669,7 +644,7 @@ static void scic_sds_apc_agent_link_up(struct scic_sds_controller *scic,
669 */ 644 */
670 BUG_ON(port_state != SCI_PORT_RESETTING); 645 BUG_ON(port_state != SCI_PORT_RESETTING);
671 port_agent->phy_ready_mask |= 1 << phy_index; 646 port_agent->phy_ready_mask |= 1 << phy_index;
672 scic_sds_port_link_up(sci_port, sci_phy); 647 scic_sds_port_link_up(sci_port, iphy);
673 } 648 }
674} 649}
675 650
@@ -690,18 +665,18 @@ static void scic_sds_apc_agent_link_down(
690 struct scic_sds_controller *controller, 665 struct scic_sds_controller *controller,
691 struct scic_sds_port_configuration_agent *port_agent, 666 struct scic_sds_port_configuration_agent *port_agent,
692 struct scic_sds_port *port, 667 struct scic_sds_port *port,
693 struct scic_sds_phy *phy) 668 struct isci_phy *iphy)
694{ 669{
695 port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(phy)); 670 port_agent->phy_ready_mask &= ~(1 << scic_sds_phy_get_index(iphy));
696 671
697 if (port != NULL) { 672 if (port != NULL) {
698 if (port_agent->phy_configured_mask & (1 << phy->phy_index)) { 673 if (port_agent->phy_configured_mask & (1 << iphy->phy_index)) {
699 enum sci_status status; 674 enum sci_status status;
700 675
701 status = scic_sds_port_remove_phy(port, phy); 676 status = scic_sds_port_remove_phy(port, iphy);
702 677
703 if (status == SCI_SUCCESS) { 678 if (status == SCI_SUCCESS) {
704 port_agent->phy_configured_mask &= ~(1 << phy->phy_index); 679 port_agent->phy_configured_mask &= ~(1 << iphy->phy_index);
705 } 680 }
706 } 681 }
707 } 682 }
@@ -739,7 +714,7 @@ static void apc_agent_timeout(unsigned long data)
739 continue; 714 continue;
740 715
741 scic_sds_apc_agent_configure_ports(scic, port_agent, 716 scic_sds_apc_agent_configure_ports(scic, port_agent,
742 &ihost->phys[index].sci, false); 717 &ihost->phys[index], false);
743 } 718 }
744 719
745done: 720done:
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index c7cb0c54df57..a81a864d35c4 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -1389,7 +1389,7 @@ int isci_remote_device_found(struct domain_device *domain_dev)
1389 sas_port = domain_dev->port; 1389 sas_port = domain_dev->port;
1390 sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy, 1390 sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy,
1391 port_phy_el); 1391 port_phy_el);
1392 isci_phy = to_isci_phy(sas_phy); 1392 isci_phy = to_iphy(sas_phy);
1393 isci_port = isci_phy->isci_port; 1393 isci_port = isci_phy->isci_port;
1394 1394
1395 /* we are being called for a device on this port, 1395 /* we are being called for a device on this port,