aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Trela <maciej.trela@intel.com>2011-04-12 20:28:39 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:00:37 -0400
commitd857d9a0adf49e332413d918322405192aafc766 (patch)
treed3fac2520d4823fabf5728e9c3438f5e66574766
parent41e2b90584695cf5ae3a29eaa115e31913fbefe0 (diff)
isci: remove base_phy abstraction
Merge struct sci_base_phy into scic_sds_phy. Until now sci_base_phy was referenced using scic_sds_phy->parent field. 'sci_base_phy' state machine handlers were also merged into scic_sds_phy state handlers. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Maciej Trela <Maciej.Trela@intel.com> Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/core/sci_base_phy.h200
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.c324
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.h91
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c50
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.h5
6 files changed, 260 insertions, 412 deletions
diff --git a/drivers/scsi/isci/core/sci_base_phy.h b/drivers/scsi/isci/core/sci_base_phy.h
deleted file mode 100644
index 7e2c7e331437..000000000000
--- a/drivers/scsi/isci/core/sci_base_phy.h
+++ /dev/null
@@ -1,200 +0,0 @@
1/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#ifndef _SCI_BASE_PHY_H_
57#define _SCI_BASE_PHY_H_
58
59/**
60 * This file contains all of the structures, constants, and methods common to
61 * all phy object definitions.
62 *
63 *
64 */
65
66#include "sci_base_state_machine.h"
67
68/**
69 * enum sci_base_phy_states - This enumeration depicts the standard states
70 * common to all phy state machine implementations.
71 *
72 *
73 */
74enum sci_base_phy_states {
75 /**
76 * Simply the initial state for the base domain state machine.
77 */
78 SCI_BASE_PHY_STATE_INITIAL,
79
80 /**
81 * This state indicates that the phy has successfully been stopped.
82 * In this state no new IO operations are permitted on this phy.
83 * This state is entered from the INITIAL state.
84 * This state is entered from the STARTING state.
85 * This state is entered from the READY state.
86 * This state is entered from the RESETTING state.
87 */
88 SCI_BASE_PHY_STATE_STOPPED,
89
90 /**
91 * This state indicates that the phy is in the process of becomming
92 * ready. In this state no new IO operations are permitted on this phy.
93 * This state is entered from the STOPPED state.
94 * This state is entered from the READY state.
95 * This state is entered from the RESETTING state.
96 */
97 SCI_BASE_PHY_STATE_STARTING,
98
99 /**
100 * This state indicates the the phy is now ready. Thus, the user
101 * is able to perform IO operations utilizing this phy as long as it
102 * is currently part of a valid port.
103 * This state is entered from the STARTING state.
104 */
105 SCI_BASE_PHY_STATE_READY,
106
107 /**
108 * This state indicates that the phy is in the process of being reset.
109 * In this state no new IO operations are permitted on this phy.
110 * This state is entered from the READY state.
111 */
112 SCI_BASE_PHY_STATE_RESETTING,
113
114 /**
115 * Simply the final state for the base phy state machine.
116 */
117 SCI_BASE_PHY_STATE_FINAL,
118};
119
120/**
121 * struct sci_base_phy - This structure defines all of the fields common to PHY
122 * objects.
123 *
124 *
125 */
126struct sci_base_phy {
127 /**
128 * This field depicts the parent object (struct sci_base_object) for the phy.
129 */
130 struct sci_base_object parent;
131
132 /**
133 * This field contains the information for the base phy state machine.
134 */
135 struct sci_base_state_machine state_machine;
136};
137
138typedef enum sci_status (*sci_base_phy_handler_t)(struct sci_base_phy *);
139
140/**
141 * struct sci_base_phy_state_handler - This structure contains all of the state
142 * handler methods common to base phy state machines. Handler methods
143 * provide the ability to change the behavior for user requests or
144 * transitions depending on the state the machine is in.
145 *
146 *
147 */
148struct sci_base_phy_state_handler {
149 /**
150 * The start_handler specifies the method invoked when there is an
151 * attempt to start a phy.
152 */
153 sci_base_phy_handler_t start_handler;
154
155 /**
156 * The stop_handler specifies the method invoked when there is an
157 * attempt to stop a phy.
158 */
159 sci_base_phy_handler_t stop_handler;
160
161 /**
162 * The reset_handler specifies the method invoked when there is an
163 * attempt to reset a phy.
164 */
165 sci_base_phy_handler_t reset_handler;
166
167 /**
168 * The destruct_handler specifies the method invoked when attempting to
169 * destruct a phy.
170 */
171 sci_base_phy_handler_t destruct_handler;
172
173};
174
175/**
176 * sci_base_phy_construct() - Construct the base phy
177 * @this_phy: This parameter specifies the base phy to be constructed.
178 * @state_table: This parameter specifies the table of state definitions to be
179 * utilized for the phy state machine.
180 *
181 */
182static inline void sci_base_phy_construct(
183 struct sci_base_phy *base_phy,
184 const struct sci_base_state *state_table)
185{
186 base_phy->parent.private = NULL;
187 sci_base_state_machine_construct(
188 &base_phy->state_machine,
189 &base_phy->parent,
190 state_table,
191 SCI_BASE_PHY_STATE_INITIAL
192 );
193
194 sci_base_state_machine_start(
195 &base_phy->state_machine
196 );
197}
198
199
200#endif /* _SCI_BASE_PHY_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index 577d1df2cfd2..78b2e6f76d1a 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -679,7 +679,7 @@ static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_contro
679 679
680 for (index = 0; index < SCI_MAX_PHYS; index++) { 680 for (index = 0; index < SCI_MAX_PHYS; index++) {
681 sci_phy = &scic->phy_table[index]; 681 sci_phy = &scic->phy_table[index];
682 state = sci_phy->parent.state_machine.current_state_id; 682 state = sci_phy->state_machine.current_state_id;
683 683
684 if (!scic_sds_phy_get_port(sci_phy)) 684 if (!scic_sds_phy_get_port(sci_phy))
685 continue; 685 continue;
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c
index c26e5df18142..d5bbc220ab84 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.c
+++ b/drivers/scsi/isci/core/scic_sds_phy.c
@@ -253,7 +253,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
253 writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout); 253 writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout);
254 254
255 /* We can exit the initial state to the stopped state */ 255 /* We can exit the initial state to the stopped state */
256 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 256 sci_base_state_machine_change_state(&sci_phy->state_machine,
257 SCI_BASE_PHY_STATE_STOPPED); 257 SCI_BASE_PHY_STATE_STOPPED);
258 258
259 return SCI_SUCCESS; 259 return SCI_SUCCESS;
@@ -276,7 +276,7 @@ static void scic_sds_phy_sata_timeout(void *phy)
276 276
277 sci_base_state_machine_stop(&sci_phy->starting_substate_machine); 277 sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
278 278
279 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 279 sci_base_state_machine_change_state(&sci_phy->state_machine,
280 SCI_BASE_PHY_STATE_STARTING); 280 SCI_BASE_PHY_STATE_STARTING);
281} 281}
282 282
@@ -353,7 +353,7 @@ enum sci_status scic_sds_phy_initialize(
353 /* 353 /*
354 * There is nothing that needs to be done in this state just 354 * There is nothing that needs to be done in this state just
355 * transition to the stopped state. */ 355 * transition to the stopped state. */
356 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 356 sci_base_state_machine_change_state(&sci_phy->state_machine,
357 SCI_BASE_PHY_STATE_STOPPED); 357 SCI_BASE_PHY_STATE_STOPPED);
358 358
359 return SCI_SUCCESS; 359 return SCI_SUCCESS;
@@ -515,7 +515,7 @@ void scic_sds_phy_get_attached_phy_protocols(
515 */ 515 */
516enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy) 516enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy)
517{ 517{
518 return sci_phy->state_handlers->parent.start_handler(&sci_phy->parent); 518 return sci_phy->state_handlers->start_handler(sci_phy);
519} 519}
520 520
521/** 521/**
@@ -527,7 +527,7 @@ enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy)
527 */ 527 */
528enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy) 528enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
529{ 529{
530 return sci_phy->state_handlers->parent.stop_handler(&sci_phy->parent); 530 return sci_phy->state_handlers->stop_handler(sci_phy);
531} 531}
532 532
533/** 533/**
@@ -540,9 +540,7 @@ enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
540enum sci_status scic_sds_phy_reset( 540enum sci_status scic_sds_phy_reset(
541 struct scic_sds_phy *this_phy) 541 struct scic_sds_phy *this_phy)
542{ 542{
543 return this_phy->state_handlers->parent.reset_handler( 543 return this_phy->state_handlers->reset_handler(this_phy);
544 &this_phy->parent
545 );
546} 544}
547 545
548/** 546/**
@@ -714,7 +712,7 @@ static void scic_sds_phy_restart_starting_state(
714 sci_base_state_machine_stop(&sci_phy->starting_substate_machine); 712 sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
715 713
716 /* Re-enter the base state machine starting state */ 714 /* Re-enter the base state machine starting state */
717 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 715 sci_base_state_machine_change_state(&sci_phy->state_machine,
718 SCI_BASE_PHY_STATE_STARTING); 716 SCI_BASE_PHY_STATE_STARTING);
719} 717}
720 718
@@ -722,12 +720,9 @@ static void scic_sds_phy_restart_starting_state(
722 * SCIC SDS PHY general handlers 720 * SCIC SDS PHY general handlers
723 ************************************************************************** */ 721 ************************************************************************** */
724static enum sci_status scic_sds_phy_starting_substate_general_stop_handler( 722static enum sci_status scic_sds_phy_starting_substate_general_stop_handler(
725 struct sci_base_phy *phy) 723 struct scic_sds_phy *phy)
726{ 724{
727 struct scic_sds_phy *this_phy; 725 sci_base_state_machine_stop(&phy->starting_substate_machine);
728 this_phy = (struct scic_sds_phy *)phy;
729
730 sci_base_state_machine_stop(&this_phy->starting_substate_machine);
731 726
732 sci_base_state_machine_change_state(&phy->state_machine, 727 sci_base_state_machine_change_state(&phy->state_machine,
733 SCI_BASE_PHY_STATE_STOPPED); 728 SCI_BASE_PHY_STATE_STOPPED);
@@ -1331,11 +1326,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handle
1331 * * SCIC SDS PHY POWER_HANDLERS 1326 * * SCIC SDS PHY POWER_HANDLERS
1332 * ***************************************************************************** */ 1327 * ***************************************************************************** */
1333 1328
1334/** 1329/*
1335 * scic_sds_phy_starting_substate_await_sas_power_consume_power_handler -
1336 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
1337 * object.
1338 *
1339 * This method is called by the struct scic_sds_controller when the phy object is 1330 * This method is called by the struct scic_sds_controller when the phy object is
1340 * granted power. - The notify enable spinups are turned on for this phy object 1331 * granted power. - The notify enable spinups are turned on for this phy object
1341 * - The phy state machine is transitioned to the 1332 * - The phy state machine is transitioned to the
@@ -1357,11 +1348,7 @@ static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_po
1357 return SCI_SUCCESS; 1348 return SCI_SUCCESS;
1358} 1349}
1359 1350
1360/** 1351/*
1361 *
1362 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
1363 * object.
1364 *
1365 * This method is called by the struct scic_sds_controller when the phy object is 1352 * This method is called by the struct scic_sds_controller when the phy object is
1366 * granted power. - The phy state machine is transitioned to the 1353 * granted power. - The phy state machine is transitioned to the
1367 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS 1354 * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS
@@ -1393,148 +1380,153 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_p
1393 return SCI_SUCCESS; 1380 return SCI_SUCCESS;
1394} 1381}
1395 1382
1396static enum sci_status default_phy_handler(struct sci_base_phy *base_phy, const char *func) 1383static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy,
1384 const char *func)
1397{ 1385{
1398 struct scic_sds_phy *sci_phy;
1399
1400 sci_phy = container_of(base_phy, typeof(*sci_phy), parent);
1401 dev_dbg(sciphy_to_dev(sci_phy), 1386 dev_dbg(sciphy_to_dev(sci_phy),
1402 "%s: in wrong state: %d\n", func, 1387 "%s: in wrong state: %d\n", func,
1403 sci_base_state_machine_get_state(&base_phy->state_machine)); 1388 sci_base_state_machine_get_state(&sci_phy->state_machine));
1404 return SCI_FAILURE_INVALID_STATE; 1389 return SCI_FAILURE_INVALID_STATE;
1405} 1390}
1406 1391
1407static enum sci_status scic_sds_phy_default_start_handler(struct sci_base_phy *base_phy) 1392static enum sci_status
1393scic_sds_phy_default_start_handler(struct scic_sds_phy *sci_phy)
1408{ 1394{
1409 return default_phy_handler(base_phy, __func__); 1395 return default_phy_handler(sci_phy, __func__);
1410} 1396}
1411 1397
1412static enum sci_status scic_sds_phy_default_stop_handler(struct sci_base_phy *base_phy) 1398static enum sci_status
1399scic_sds_phy_default_stop_handler(struct scic_sds_phy *sci_phy)
1413{ 1400{
1414 return default_phy_handler(base_phy, __func__); 1401 return default_phy_handler(sci_phy, __func__);
1415} 1402}
1416 1403
1417static enum sci_status scic_sds_phy_default_reset_handler(struct sci_base_phy *base_phy) 1404static enum sci_status
1405scic_sds_phy_default_reset_handler(struct scic_sds_phy *sci_phy)
1418{ 1406{
1419 return default_phy_handler(base_phy, __func__); 1407 return default_phy_handler(sci_phy, __func__);
1420} 1408}
1421 1409
1422static enum sci_status scic_sds_phy_default_destroy_handler(struct sci_base_phy *base_phy) 1410static enum sci_status
1411scic_sds_phy_default_destroy_handler(struct scic_sds_phy *sci_phy)
1423{ 1412{
1424 return default_phy_handler(base_phy, __func__); 1413 return default_phy_handler(sci_phy, __func__);
1425} 1414}
1426 1415
1427static enum sci_status scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy, 1416static enum sci_status
1428 u32 frame_index) 1417scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy,
1418 u32 frame_index)
1429{ 1419{
1430 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy); 1420 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
1431 1421
1432 default_phy_handler(&sci_phy->parent, __func__); 1422 default_phy_handler(sci_phy, __func__);
1433 scic_sds_controller_release_frame(scic, frame_index); 1423 scic_sds_controller_release_frame(scic, frame_index);
1434 1424
1435 return SCI_FAILURE_INVALID_STATE; 1425 return SCI_FAILURE_INVALID_STATE;
1436} 1426}
1437 1427
1438static enum sci_status scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy, 1428static enum sci_status
1439 u32 event_code) 1429scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy,
1430 u32 event_code)
1440{ 1431{
1441 return default_phy_handler(&sci_phy->parent, __func__); 1432 return default_phy_handler(sci_phy, __func__);
1442} 1433}
1443 1434
1444static enum sci_status scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy) 1435static enum sci_status
1436scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy)
1445{ 1437{
1446 return default_phy_handler(&sci_phy->parent, __func__); 1438 return default_phy_handler(sci_phy, __func__);
1447} 1439}
1448 1440
1449 1441
1450 1442
1451static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = { 1443static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = {
1452 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { 1444 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1453 .parent.start_handler = scic_sds_phy_default_start_handler, 1445 .start_handler = scic_sds_phy_default_start_handler,
1454 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1446 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1455 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1447 .reset_handler = scic_sds_phy_default_reset_handler,
1456 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1448 .destruct_handler = scic_sds_phy_default_destroy_handler,
1457 .frame_handler = scic_sds_phy_default_frame_handler, 1449 .frame_handler = scic_sds_phy_default_frame_handler,
1458 .event_handler = scic_sds_phy_default_event_handler, 1450 .event_handler = scic_sds_phy_default_event_handler,
1459 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1451 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1460 }, 1452 },
1461 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = { 1453 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
1462 .parent.start_handler = scic_sds_phy_default_start_handler, 1454 .start_handler = scic_sds_phy_default_start_handler,
1463 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1455 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1464 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1456 .reset_handler = scic_sds_phy_default_reset_handler,
1465 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1457 .destruct_handler = scic_sds_phy_default_destroy_handler,
1466 .frame_handler = scic_sds_phy_default_frame_handler, 1458 .frame_handler = scic_sds_phy_default_frame_handler,
1467 .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler, 1459 .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler,
1468 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1460 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1469 }, 1461 },
1470 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = { 1462 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
1471 .parent.start_handler = scic_sds_phy_default_start_handler, 1463 .start_handler = scic_sds_phy_default_start_handler,
1472 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1464 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1473 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1465 .reset_handler = scic_sds_phy_default_reset_handler,
1474 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1466 .destruct_handler = scic_sds_phy_default_destroy_handler,
1475 .frame_handler = scic_sds_phy_default_frame_handler, 1467 .frame_handler = scic_sds_phy_default_frame_handler,
1476 .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler, 1468 .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
1477 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1469 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1478 }, 1470 },
1479 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = { 1471 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
1480 .parent.start_handler = scic_sds_phy_default_start_handler, 1472 .start_handler = scic_sds_phy_default_start_handler,
1481 .parent.stop_handler = scic_sds_phy_default_stop_handler, 1473 .stop_handler = scic_sds_phy_default_stop_handler,
1482 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1474 .reset_handler = scic_sds_phy_default_reset_handler,
1483 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1475 .destruct_handler = scic_sds_phy_default_destroy_handler,
1484 .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler, 1476 .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
1485 .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler, 1477 .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
1486 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1478 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1487 }, 1479 },
1488 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = { 1480 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
1489 .parent.start_handler = scic_sds_phy_default_start_handler, 1481 .start_handler = scic_sds_phy_default_start_handler,
1490 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1482 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1491 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1483 .reset_handler = scic_sds_phy_default_reset_handler,
1492 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1484 .destruct_handler = scic_sds_phy_default_destroy_handler,
1493 .frame_handler = scic_sds_phy_default_frame_handler, 1485 .frame_handler = scic_sds_phy_default_frame_handler,
1494 .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler, 1486 .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler,
1495 .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler 1487 .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
1496 }, 1488 },
1497 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = { 1489 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
1498 .parent.start_handler = scic_sds_phy_default_start_handler, 1490 .start_handler = scic_sds_phy_default_start_handler,
1499 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1491 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1500 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1492 .reset_handler = scic_sds_phy_default_reset_handler,
1501 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1493 .destruct_handler = scic_sds_phy_default_destroy_handler,
1502 .frame_handler = scic_sds_phy_default_frame_handler, 1494 .frame_handler = scic_sds_phy_default_frame_handler,
1503 .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler, 1495 .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler,
1504 .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler 1496 .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
1505 }, 1497 },
1506 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = { 1498 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
1507 .parent.start_handler = scic_sds_phy_default_start_handler, 1499 .start_handler = scic_sds_phy_default_start_handler,
1508 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1500 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1509 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1501 .reset_handler = scic_sds_phy_default_reset_handler,
1510 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1502 .destruct_handler = scic_sds_phy_default_destroy_handler,
1511 .frame_handler = scic_sds_phy_default_frame_handler, 1503 .frame_handler = scic_sds_phy_default_frame_handler,
1512 .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler, 1504 .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler,
1513 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1505 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1514 }, 1506 },
1515 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = { 1507 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
1516 .parent.start_handler = scic_sds_phy_default_start_handler, 1508 .start_handler = scic_sds_phy_default_start_handler,
1517 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1509 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1518 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1510 .reset_handler = scic_sds_phy_default_reset_handler,
1519 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1511 .destruct_handler = scic_sds_phy_default_destroy_handler,
1520 .frame_handler = scic_sds_phy_default_frame_handler, 1512 .frame_handler = scic_sds_phy_default_frame_handler,
1521 .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler, 1513 .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler,
1522 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1514 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1523 }, 1515 },
1524 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = { 1516 [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
1525 .parent.start_handler = scic_sds_phy_default_start_handler, 1517 .start_handler = scic_sds_phy_default_start_handler,
1526 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1518 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1527 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1519 .reset_handler = scic_sds_phy_default_reset_handler,
1528 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1520 .destruct_handler = scic_sds_phy_default_destroy_handler,
1529 .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler, 1521 .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
1530 .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler, 1522 .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler,
1531 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1523 .consume_power_handler = scic_sds_phy_default_consume_power_handler
1532 }, 1524 },
1533 [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = { 1525 [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
1534 .parent.start_handler = scic_sds_phy_default_start_handler, 1526 .start_handler = scic_sds_phy_default_start_handler,
1535 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1527 .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
1536 .parent.reset_handler = scic_sds_phy_default_reset_handler, 1528 .reset_handler = scic_sds_phy_default_reset_handler,
1537 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 1529 .destruct_handler = scic_sds_phy_default_destroy_handler,
1538 .frame_handler = scic_sds_phy_default_frame_handler, 1530 .frame_handler = scic_sds_phy_default_frame_handler,
1539 .event_handler = scic_sds_phy_default_event_handler, 1531 .event_handler = scic_sds_phy_default_event_handler,
1540 .consume_power_handler = scic_sds_phy_default_consume_power_handler 1532 .consume_power_handler = scic_sds_phy_default_consume_power_handler
@@ -1885,7 +1877,7 @@ static void scic_sds_phy_starting_final_substate_enter(struct sci_base_object *o
1885{ 1877{
1886 struct scic_sds_phy *sci_phy; 1878 struct scic_sds_phy *sci_phy;
1887 1879
1888 sci_phy = container_of(object, typeof(*sci_phy), parent.parent); 1880 sci_phy = container_of(object, typeof(*sci_phy), parent);
1889 1881
1890 scic_sds_phy_set_starting_substate_handlers(sci_phy, 1882 scic_sds_phy_set_starting_substate_handlers(sci_phy,
1891 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL); 1883 SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
@@ -1893,7 +1885,7 @@ static void scic_sds_phy_starting_final_substate_enter(struct sci_base_object *o
1893 /* State machine has run to completion so exit out and change 1885 /* State machine has run to completion so exit out and change
1894 * the base state machine to the ready state 1886 * the base state machine to the ready state
1895 */ 1887 */
1896 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 1888 sci_base_state_machine_change_state(&sci_phy->state_machine,
1897 SCI_BASE_PHY_STATE_READY); 1889 SCI_BASE_PHY_STATE_READY);
1898} 1890}
1899 1891
@@ -1937,22 +1929,17 @@ static const struct sci_base_state scic_sds_phy_starting_substates[] = {
1937 } 1929 }
1938}; 1930};
1939 1931
1940/** 1932/*
1941 *
1942 * @phy: This is the struct sci_base_phy object which is cast into a
1943 * struct scic_sds_phy object.
1944 *
1945 * This method takes the struct scic_sds_phy from a stopped state and 1933 * This method takes the struct scic_sds_phy from a stopped state and
1946 * attempts to start it. - The phy state machine is transitioned to the 1934 * attempts to start it. - The phy state machine is transitioned to the
1947 * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS 1935 * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
1948 */ 1936 */
1949static enum sci_status scic_sds_phy_stopped_state_start_handler(struct sci_base_phy *base_phy) 1937static enum sci_status
1938scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy)
1950{ 1939{
1951 struct isci_host *ihost; 1940 struct isci_host *ihost;
1952 struct scic_sds_phy *sci_phy;
1953 struct scic_sds_controller *scic; 1941 struct scic_sds_controller *scic;
1954 1942
1955 sci_phy = container_of(base_phy, typeof(*sci_phy), parent);
1956 scic = scic_sds_phy_get_controller(sci_phy), 1943 scic = scic_sds_phy_get_controller(sci_phy),
1957 ihost = sci_object_get_association(scic); 1944 ihost = sci_object_get_association(scic);
1958 1945
@@ -1961,28 +1948,31 @@ static enum sci_status scic_sds_phy_stopped_state_start_handler(struct sci_base_
1961 scic_sds_phy_sata_timeout); 1948 scic_sds_phy_sata_timeout);
1962 1949
1963 if (sci_phy->sata_timeout_timer) 1950 if (sci_phy->sata_timeout_timer)
1964 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 1951 sci_base_state_machine_change_state(&sci_phy->state_machine,
1965 SCI_BASE_PHY_STATE_STARTING); 1952 SCI_BASE_PHY_STATE_STARTING);
1966 1953
1967 return SCI_SUCCESS; 1954 return SCI_SUCCESS;
1968} 1955}
1969 1956
1970static enum sci_status scic_sds_phy_stopped_state_destroy_handler(struct sci_base_phy *base_phy) 1957static enum sci_status
1958scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy)
1971{ 1959{
1972 return SCI_SUCCESS; 1960 return SCI_SUCCESS;
1973} 1961}
1974 1962
1975static enum sci_status scic_sds_phy_ready_state_stop_handler(struct sci_base_phy *base_phy) 1963static enum sci_status
1964scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy)
1976{ 1965{
1977 sci_base_state_machine_change_state(&base_phy->state_machine, 1966 sci_base_state_machine_change_state(&sci_phy->state_machine,
1978 SCI_BASE_PHY_STATE_STOPPED); 1967 SCI_BASE_PHY_STATE_STOPPED);
1979 1968
1980 return SCI_SUCCESS; 1969 return SCI_SUCCESS;
1981} 1970}
1982 1971
1983static enum sci_status scic_sds_phy_ready_state_reset_handler(struct sci_base_phy *base_phy) 1972static enum sci_status
1973scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy)
1984{ 1974{
1985 sci_base_state_machine_change_state(&base_phy->state_machine, 1975 sci_base_state_machine_change_state(&sci_phy->state_machine,
1986 SCI_BASE_PHY_STATE_RESETTING); 1976 SCI_BASE_PHY_STATE_RESETTING);
1987 1977
1988 return SCI_SUCCESS; 1978 return SCI_SUCCESS;
@@ -2007,7 +1997,7 @@ static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_ph
2007 switch (scu_get_event_code(event_code)) { 1997 switch (scu_get_event_code(event_code)) {
2008 case SCU_EVENT_LINK_FAILURE: 1998 case SCU_EVENT_LINK_FAILURE:
2009 /* Link failure change state back to the starting state */ 1999 /* Link failure change state back to the starting state */
2010 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 2000 sci_base_state_machine_change_state(&sci_phy->state_machine,
2011 SCI_BASE_PHY_STATE_STARTING); 2001 SCI_BASE_PHY_STATE_STARTING);
2012 result = SCI_SUCCESS; 2002 result = SCI_SUCCESS;
2013 break; 2003 break;
@@ -2041,7 +2031,7 @@ static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sd
2041 switch (scu_get_event_code(event_code)) { 2031 switch (scu_get_event_code(event_code)) {
2042 case SCU_EVENT_HARD_RESET_TRANSMITTED: 2032 case SCU_EVENT_HARD_RESET_TRANSMITTED:
2043 /* Link failure change state back to the starting state */ 2033 /* Link failure change state back to the starting state */
2044 sci_base_state_machine_change_state(&sci_phy->parent.state_machine, 2034 sci_base_state_machine_change_state(&sci_phy->state_machine,
2045 SCI_BASE_PHY_STATE_STARTING); 2035 SCI_BASE_PHY_STATE_STARTING);
2046 result = SCI_SUCCESS; 2036 result = SCI_SUCCESS;
2047 break; 2037 break;
@@ -2063,55 +2053,55 @@ static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sd
2063 2053
2064static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { 2054static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
2065 [SCI_BASE_PHY_STATE_INITIAL] = { 2055 [SCI_BASE_PHY_STATE_INITIAL] = {
2066 .parent.start_handler = scic_sds_phy_default_start_handler, 2056 .start_handler = scic_sds_phy_default_start_handler,
2067 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2057 .stop_handler = scic_sds_phy_default_stop_handler,
2068 .parent.reset_handler = scic_sds_phy_default_reset_handler, 2058 .reset_handler = scic_sds_phy_default_reset_handler,
2069 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 2059 .destruct_handler = scic_sds_phy_default_destroy_handler,
2070 .frame_handler = scic_sds_phy_default_frame_handler, 2060 .frame_handler = scic_sds_phy_default_frame_handler,
2071 .event_handler = scic_sds_phy_default_event_handler, 2061 .event_handler = scic_sds_phy_default_event_handler,
2072 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2062 .consume_power_handler = scic_sds_phy_default_consume_power_handler
2073 }, 2063 },
2074 [SCI_BASE_PHY_STATE_STOPPED] = { 2064 [SCI_BASE_PHY_STATE_STOPPED] = {
2075 .parent.start_handler = scic_sds_phy_stopped_state_start_handler, 2065 .start_handler = scic_sds_phy_stopped_state_start_handler,
2076 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2066 .stop_handler = scic_sds_phy_default_stop_handler,
2077 .parent.reset_handler = scic_sds_phy_default_reset_handler, 2067 .reset_handler = scic_sds_phy_default_reset_handler,
2078 .parent.destruct_handler = scic_sds_phy_stopped_state_destroy_handler, 2068 .destruct_handler = scic_sds_phy_stopped_state_destroy_handler,
2079 .frame_handler = scic_sds_phy_default_frame_handler, 2069 .frame_handler = scic_sds_phy_default_frame_handler,
2080 .event_handler = scic_sds_phy_default_event_handler, 2070 .event_handler = scic_sds_phy_default_event_handler,
2081 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2071 .consume_power_handler = scic_sds_phy_default_consume_power_handler
2082 }, 2072 },
2083 [SCI_BASE_PHY_STATE_STARTING] = { 2073 [SCI_BASE_PHY_STATE_STARTING] = {
2084 .parent.start_handler = scic_sds_phy_default_start_handler, 2074 .start_handler = scic_sds_phy_default_start_handler,
2085 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2075 .stop_handler = scic_sds_phy_default_stop_handler,
2086 .parent.reset_handler = scic_sds_phy_default_reset_handler, 2076 .reset_handler = scic_sds_phy_default_reset_handler,
2087 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 2077 .destruct_handler = scic_sds_phy_default_destroy_handler,
2088 .frame_handler = scic_sds_phy_default_frame_handler, 2078 .frame_handler = scic_sds_phy_default_frame_handler,
2089 .event_handler = scic_sds_phy_default_event_handler, 2079 .event_handler = scic_sds_phy_default_event_handler,
2090 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2080 .consume_power_handler = scic_sds_phy_default_consume_power_handler
2091 }, 2081 },
2092 [SCI_BASE_PHY_STATE_READY] = { 2082 [SCI_BASE_PHY_STATE_READY] = {
2093 .parent.start_handler = scic_sds_phy_default_start_handler, 2083 .start_handler = scic_sds_phy_default_start_handler,
2094 .parent.stop_handler = scic_sds_phy_ready_state_stop_handler, 2084 .stop_handler = scic_sds_phy_ready_state_stop_handler,
2095 .parent.reset_handler = scic_sds_phy_ready_state_reset_handler, 2085 .reset_handler = scic_sds_phy_ready_state_reset_handler,
2096 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 2086 .destruct_handler = scic_sds_phy_default_destroy_handler,
2097 .frame_handler = scic_sds_phy_default_frame_handler, 2087 .frame_handler = scic_sds_phy_default_frame_handler,
2098 .event_handler = scic_sds_phy_ready_state_event_handler, 2088 .event_handler = scic_sds_phy_ready_state_event_handler,
2099 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2089 .consume_power_handler = scic_sds_phy_default_consume_power_handler
2100 }, 2090 },
2101 [SCI_BASE_PHY_STATE_RESETTING] = { 2091 [SCI_BASE_PHY_STATE_RESETTING] = {
2102 .parent.start_handler = scic_sds_phy_default_start_handler, 2092 .start_handler = scic_sds_phy_default_start_handler,
2103 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2093 .stop_handler = scic_sds_phy_default_stop_handler,
2104 .parent.reset_handler = scic_sds_phy_default_reset_handler, 2094 .reset_handler = scic_sds_phy_default_reset_handler,
2105 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 2095 .destruct_handler = scic_sds_phy_default_destroy_handler,
2106 .frame_handler = scic_sds_phy_default_frame_handler, 2096 .frame_handler = scic_sds_phy_default_frame_handler,
2107 .event_handler = scic_sds_phy_resetting_state_event_handler, 2097 .event_handler = scic_sds_phy_resetting_state_event_handler,
2108 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2098 .consume_power_handler = scic_sds_phy_default_consume_power_handler
2109 }, 2099 },
2110 [SCI_BASE_PHY_STATE_FINAL] = { 2100 [SCI_BASE_PHY_STATE_FINAL] = {
2111 .parent.start_handler = scic_sds_phy_default_start_handler, 2101 .start_handler = scic_sds_phy_default_start_handler,
2112 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2102 .stop_handler = scic_sds_phy_default_stop_handler,
2113 .parent.reset_handler = scic_sds_phy_default_reset_handler, 2103 .reset_handler = scic_sds_phy_default_reset_handler,
2114 .parent.destruct_handler = scic_sds_phy_default_destroy_handler, 2104 .destruct_handler = scic_sds_phy_default_destroy_handler,
2115 .frame_handler = scic_sds_phy_default_frame_handler, 2105 .frame_handler = scic_sds_phy_default_frame_handler,
2116 .event_handler = scic_sds_phy_default_event_handler, 2106 .event_handler = scic_sds_phy_default_event_handler,
2117 .consume_power_handler = scic_sds_phy_default_consume_power_handler 2107 .consume_power_handler = scic_sds_phy_default_consume_power_handler
@@ -2260,7 +2250,7 @@ static void scic_sds_phy_stopped_state_enter(struct sci_base_object *object)
2260 2250
2261 scu_link_layer_stop_protocol_engine(sci_phy); 2251 scu_link_layer_stop_protocol_engine(sci_phy);
2262 2252
2263 if (sci_phy->parent.state_machine.previous_state_id != 2253 if (sci_phy->state_machine.previous_state_id !=
2264 SCI_BASE_PHY_STATE_INITIAL) 2254 SCI_BASE_PHY_STATE_INITIAL)
2265 scic_sds_controller_link_down( 2255 scic_sds_controller_link_down(
2266 scic_sds_phy_get_controller(sci_phy), 2256 scic_sds_phy_get_controller(sci_phy),
@@ -2299,7 +2289,7 @@ static void scic_sds_phy_starting_state_enter(
2299 /* Change over to the starting substate machine to continue */ 2289 /* Change over to the starting substate machine to continue */
2300 sci_base_state_machine_start(&this_phy->starting_substate_machine); 2290 sci_base_state_machine_start(&this_phy->starting_substate_machine);
2301 2291
2302 if (this_phy->parent.state_machine.previous_state_id 2292 if (this_phy->state_machine.previous_state_id
2303 == SCI_BASE_PHY_STATE_READY) { 2293 == SCI_BASE_PHY_STATE_READY) {
2304 scic_sds_controller_link_down( 2294 scic_sds_controller_link_down(
2305 scic_sds_phy_get_controller(this_phy), 2295 scic_sds_phy_get_controller(this_phy),
@@ -2380,12 +2370,10 @@ static void scic_sds_phy_resetting_state_enter(
2380 scu_link_layer_tx_hard_reset(this_phy); 2370 scu_link_layer_tx_hard_reset(this_phy);
2381 } else { 2371 } else {
2382 /* 2372 /*
2383 * The SCU does not need to have a descrete reset state so just go back to 2373 * The SCU does not need to have a discrete reset state so just go back to
2384 * the starting state. */ 2374 * the starting state. */
2385 sci_base_state_machine_change_state( 2375 sci_base_state_machine_change_state(&this_phy->state_machine,
2386 &this_phy->parent.state_machine, 2376 SCI_BASE_PHY_STATE_STARTING);
2387 SCI_BASE_PHY_STATE_STARTING
2388 );
2389 } 2377 }
2390} 2378}
2391 2379
@@ -2436,10 +2424,14 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
2436void scic_sds_phy_construct(struct scic_sds_phy *sci_phy, 2424void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
2437 struct scic_sds_port *owning_port, u8 phy_index) 2425 struct scic_sds_port *owning_port, u8 phy_index)
2438{ 2426{
2439 /* 2427
2440 * Call the base constructor first 2428 sci_phy->parent.private = NULL;
2441 */ 2429 sci_base_state_machine_construct(&sci_phy->state_machine,
2442 sci_base_phy_construct(&sci_phy->parent, scic_sds_phy_state_table); 2430 &sci_phy->parent,
2431 scic_sds_phy_state_table,
2432 SCI_BASE_PHY_STATE_INITIAL);
2433
2434 sci_base_state_machine_start(&sci_phy->state_machine);
2443 2435
2444 /* Copy the rest of the input data to our locals */ 2436 /* Copy the rest of the input data to our locals */
2445 sci_phy->owning_port = owning_port; 2437 sci_phy->owning_port = owning_port;
@@ -2455,7 +2447,7 @@ void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
2455 2447
2456 /* Initialize the the substate machines */ 2448 /* Initialize the the substate machines */
2457 sci_base_state_machine_construct(&sci_phy->starting_substate_machine, 2449 sci_base_state_machine_construct(&sci_phy->starting_substate_machine,
2458 &sci_phy->parent.parent, 2450 &sci_phy->parent,
2459 scic_sds_phy_starting_substates, 2451 scic_sds_phy_starting_substates,
2460 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); 2452 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
2461} 2453}
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h
index 7f7a04542031..97c0476570ba 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.h
+++ b/drivers/scsi/isci/core/scic_sds_phy.h
@@ -56,17 +56,10 @@
56#ifndef _SCIC_SDS_PHY_H_ 56#ifndef _SCIC_SDS_PHY_H_
57#define _SCIC_SDS_PHY_H_ 57#define _SCIC_SDS_PHY_H_
58 58
59/**
60 * This file contains the structures, constants and prototypes for the
61 * struct scic_sds_phy object.
62 *
63 *
64 */
65
66#include "intel_sata.h" 59#include "intel_sata.h"
67#include "intel_sas.h" 60#include "intel_sas.h"
68#include "sci_base_phy.h"
69#include "scu_registers.h" 61#include "scu_registers.h"
62#include "sci_base_state_machine.h"
70 63
71struct scic_sds_port; 64struct scic_sds_port;
72/** 65/**
@@ -91,6 +84,53 @@ struct scic_sds_port;
91 */ 84 */
92#define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250 85#define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250
93 86
87enum scic_sds_phy_states {
88 /**
89 * Simply the initial state for the base domain state machine.
90 */
91 SCI_BASE_PHY_STATE_INITIAL,
92
93 /**
94 * This state indicates that the phy has successfully been stopped.
95 * In this state no new IO operations are permitted on this phy.
96 * This state is entered from the INITIAL state.
97 * This state is entered from the STARTING state.
98 * This state is entered from the READY state.
99 * This state is entered from the RESETTING state.
100 */
101 SCI_BASE_PHY_STATE_STOPPED,
102
103 /**
104 * This state indicates that the phy is in the process of becomming
105 * ready. In this state no new IO operations are permitted on this phy.
106 * This state is entered from the STOPPED state.
107 * This state is entered from the READY state.
108 * This state is entered from the RESETTING state.
109 */
110 SCI_BASE_PHY_STATE_STARTING,
111
112 /**
113 * This state indicates the the phy is now ready. Thus, the user
114 * is able to perform IO operations utilizing this phy as long as it
115 * is currently part of a valid port.
116 * This state is entered from the STARTING state.
117 */
118 SCI_BASE_PHY_STATE_READY,
119
120 /**
121 * This state indicates that the phy is in the process of being reset.
122 * In this state no new IO operations are permitted on this phy.
123 * This state is entered from the READY state.
124 */
125 SCI_BASE_PHY_STATE_RESETTING,
126
127 /**
128 * Simply the final state for the base phy state machine.
129 */
130 SCI_BASE_PHY_STATE_FINAL,
131};
132
133
94/** 134/**
95 * enum scic_sds_phy_starting_substates - 135 * enum scic_sds_phy_starting_substates -
96 * 136 *
@@ -184,7 +224,15 @@ enum scic_sds_phy_protocol {
184 * 224 *
185 */ 225 */
186struct scic_sds_phy { 226struct scic_sds_phy {
187 struct sci_base_phy parent; 227 /**
228 * This field depicts the parent object (struct sci_base_object) for the phy.
229 */
230 struct sci_base_object parent;
231
232 /**
233 * This field contains the information for the base phy state machine.
234 */
235 struct sci_base_state_machine state_machine;
188 236
189 /** 237 /**
190 * This field specifies the port object that owns/contains this phy. 238 * This field specifies the port object that owns/contains this phy.
@@ -260,7 +308,7 @@ struct scic_sds_phy {
260 308
261}; 309};
262 310
263 311typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *);
264typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32); 312typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32);
265typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32); 313typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32);
266typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *); 314typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
@@ -272,9 +320,28 @@ typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
272 */ 320 */
273struct scic_sds_phy_state_handler { 321struct scic_sds_phy_state_handler {
274 /** 322 /**
275 * This is the struct sci_base_phy object state handlers. 323 * The start_handler specifies the method invoked when there is an
324 * attempt to start a phy.
325 */
326 scic_sds_phy_handler_t start_handler;
327
328 /**
329 * The stop_handler specifies the method invoked when there is an
330 * attempt to stop a phy.
331 */
332 scic_sds_phy_handler_t stop_handler;
333
334 /**
335 * The reset_handler specifies the method invoked when there is an
336 * attempt to reset a phy.
337 */
338 scic_sds_phy_handler_t reset_handler;
339
340 /**
341 * The destruct_handler specifies the method invoked when attempting to
342 * destruct a phy.
276 */ 343 */
277 struct sci_base_phy_state_handler parent; 344 scic_sds_phy_handler_t destruct_handler;
278 345
279 /** 346 /**
280 * The state handler for unsolicited frames received from the SCU hardware. 347 * The state handler for unsolicited frames received from the SCU hardware.
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index ff9ac73927a4..ebbde7b3489f 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -316,7 +316,7 @@ enum sci_status scic_sds_port_add_phy(
316 struct scic_sds_phy *the_phy) 316 struct scic_sds_phy *the_phy)
317{ 317{
318 return this_port->state_handlers->add_phy_handler( 318 return this_port->state_handlers->add_phy_handler(
319 this_port, &the_phy->parent); 319 this_port, the_phy);
320} 320}
321 321
322 322
@@ -334,7 +334,7 @@ enum sci_status scic_sds_port_remove_phy(
334 struct scic_sds_phy *the_phy) 334 struct scic_sds_phy *the_phy)
335{ 335{
336 return this_port->state_handlers->remove_phy_handler( 336 return this_port->state_handlers->remove_phy_handler(
337 this_port, &the_phy->parent); 337 this_port, the_phy);
338} 338}
339 339
340/** 340/**
@@ -1084,15 +1084,14 @@ static enum sci_status scic_sds_port_ready_substate_complete_io_handler(
1084 1084
1085static enum sci_status scic_sds_port_ready_substate_add_phy_handler( 1085static enum sci_status scic_sds_port_ready_substate_add_phy_handler(
1086 struct scic_sds_port *port, 1086 struct scic_sds_port *port,
1087 struct sci_base_phy *phy) 1087 struct scic_sds_phy *phy)
1088{ 1088{
1089 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
1090 enum sci_status status; 1089 enum sci_status status;
1091 1090
1092 status = scic_sds_port_set_phy(port, this_phy); 1091 status = scic_sds_port_set_phy(port, phy);
1093 1092
1094 if (status == SCI_SUCCESS) { 1093 if (status == SCI_SUCCESS) {
1095 scic_sds_port_general_link_up_handler(port, this_phy, true); 1094 scic_sds_port_general_link_up_handler(port, phy, true);
1096 1095
1097 port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1096 port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1098 1097
@@ -1108,15 +1107,14 @@ static enum sci_status scic_sds_port_ready_substate_add_phy_handler(
1108 1107
1109static enum sci_status scic_sds_port_ready_substate_remove_phy_handler( 1108static enum sci_status scic_sds_port_ready_substate_remove_phy_handler(
1110 struct scic_sds_port *port, 1109 struct scic_sds_port *port,
1111 struct sci_base_phy *phy) 1110 struct scic_sds_phy *phy)
1112{ 1111{
1113 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
1114 enum sci_status status; 1112 enum sci_status status;
1115 1113
1116 status = scic_sds_port_clear_phy(port, this_phy); 1114 status = scic_sds_port_clear_phy(port, phy);
1117 1115
1118 if (status == SCI_SUCCESS) { 1116 if (status == SCI_SUCCESS) {
1119 scic_sds_port_deactivate_phy(port, this_phy, true); 1117 scic_sds_port_deactivate_phy(port, phy, true);
1120 1118
1121 port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; 1119 port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
1122 1120
@@ -1293,15 +1291,14 @@ static enum sci_status scic_sds_port_ready_operational_substate_start_io_handler
1293 */ 1291 */
1294static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler( 1292static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler(
1295 struct scic_sds_port *port, 1293 struct scic_sds_port *port,
1296 struct sci_base_phy *phy) 1294 struct scic_sds_phy *phy)
1297{ 1295{
1298 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
1299 enum sci_status status; 1296 enum sci_status status;
1300 1297
1301 status = scic_sds_port_set_phy(port, this_phy); 1298 status = scic_sds_port_set_phy(port, phy);
1302 1299
1303 if (status == SCI_SUCCESS) { 1300 if (status == SCI_SUCCESS) {
1304 scic_sds_port_general_link_up_handler(port, this_phy, true); 1301 scic_sds_port_general_link_up_handler(port, phy, true);
1305 1302
1306 /* 1303 /*
1307 * Re-enter the configuring state since this may be the last phy in 1304 * Re-enter the configuring state since this may be the last phy in
@@ -1321,15 +1318,14 @@ static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler(
1321 */ 1318 */
1322static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler( 1319static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler(
1323 struct scic_sds_port *port, 1320 struct scic_sds_port *port,
1324 struct sci_base_phy *phy) 1321 struct scic_sds_phy *phy)
1325{ 1322{
1326 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
1327 enum sci_status status; 1323 enum sci_status status;
1328 1324
1329 status = scic_sds_port_clear_phy(port, this_phy); 1325 status = scic_sds_port_clear_phy(port, phy);
1330 1326
1331 if (status == SCI_SUCCESS) { 1327 if (status == SCI_SUCCESS) {
1332 scic_sds_port_deactivate_phy(port, this_phy, true); 1328 scic_sds_port_deactivate_phy(port, phy, true);
1333 1329
1334 /* 1330 /*
1335 * Re-enter the configuring state since this may be the last phy in 1331 * Re-enter the configuring state since this may be the last phy in
@@ -1406,14 +1402,14 @@ scic_sds_port_default_reset_handler(struct scic_sds_port *sci_port,
1406 1402
1407static enum sci_status 1403static enum sci_status
1408scic_sds_port_default_add_phy_handler(struct scic_sds_port *sci_port, 1404scic_sds_port_default_add_phy_handler(struct scic_sds_port *sci_port,
1409 struct sci_base_phy *base_phy) 1405 struct scic_sds_phy *base_phy)
1410{ 1406{
1411 return default_port_handler(sci_port, __func__); 1407 return default_port_handler(sci_port, __func__);
1412} 1408}
1413 1409
1414static enum sci_status 1410static enum sci_status
1415scic_sds_port_default_remove_phy_handler(struct scic_sds_port *sci_port, 1411scic_sds_port_default_remove_phy_handler(struct scic_sds_port *sci_port,
1416 struct sci_base_phy *base_phy) 1412 struct scic_sds_phy *base_phy)
1417{ 1413{
1418 return default_port_handler(sci_port, __func__); 1414 return default_port_handler(sci_port, __func__);
1419} 1415}
@@ -1939,9 +1935,8 @@ static enum sci_status scic_sds_port_stopped_state_destruct_handler(
1939 */ 1935 */
1940static enum sci_status scic_sds_port_stopped_state_add_phy_handler( 1936static enum sci_status scic_sds_port_stopped_state_add_phy_handler(
1941 struct scic_sds_port *port, 1937 struct scic_sds_port *port,
1942 struct sci_base_phy *phy) 1938 struct scic_sds_phy *phy)
1943{ 1939{
1944 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
1945 struct sci_sas_address port_sas_address; 1940 struct sci_sas_address port_sas_address;
1946 1941
1947 /* Read the port assigned SAS Address if there is one */ 1942 /* Read the port assigned SAS Address if there is one */
@@ -1953,7 +1948,7 @@ static enum sci_status scic_sds_port_stopped_state_add_phy_handler(
1953 /* 1948 /*
1954 * Make sure that the PHY SAS Address matches the SAS Address 1949 * Make sure that the PHY SAS Address matches the SAS Address
1955 * for this port. */ 1950 * for this port. */
1956 scic_sds_phy_get_sas_address(this_phy, &phy_sas_address); 1951 scic_sds_phy_get_sas_address(phy, &phy_sas_address);
1957 1952
1958 if ( 1953 if (
1959 (port_sas_address.high != phy_sas_address.high) 1954 (port_sas_address.high != phy_sas_address.high)
@@ -1963,10 +1958,9 @@ static enum sci_status scic_sds_port_stopped_state_add_phy_handler(
1963 } 1958 }
1964 } 1959 }
1965 1960
1966 return scic_sds_port_set_phy(port, this_phy); 1961 return scic_sds_port_set_phy(port, phy);
1967} 1962}
1968 1963
1969
1970/* 1964/*
1971 * This method takes the struct scic_sds_port that is in a stopped state and handles 1965 * This method takes the struct scic_sds_port that is in a stopped state and handles
1972 * the remove phy request. In MPC mode the only time a phy can be removed from 1966 * the remove phy request. In MPC mode the only time a phy can be removed from
@@ -1976,11 +1970,9 @@ static enum sci_status scic_sds_port_stopped_state_add_phy_handler(
1976 */ 1970 */
1977static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( 1971static enum sci_status scic_sds_port_stopped_state_remove_phy_handler(
1978 struct scic_sds_port *port, 1972 struct scic_sds_port *port,
1979 struct sci_base_phy *phy) 1973 struct scic_sds_phy *phy)
1980{ 1974{
1981 struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy; 1975 return scic_sds_port_clear_phy(port, phy);
1982
1983 return scic_sds_port_clear_phy(port, this_phy);
1984} 1976}
1985 1977
1986/* 1978/*
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h
index 528c84d569a0..d79c5745e49a 100644
--- a/drivers/scsi/isci/core/scic_sds_port.h
+++ b/drivers/scsi/isci/core/scic_sds_port.h
@@ -59,7 +59,6 @@
59#include <linux/kernel.h> 59#include <linux/kernel.h>
60#include "sci_controller_constants.h" 60#include "sci_controller_constants.h"
61#include "intel_sas.h" 61#include "intel_sas.h"
62#include "sci_base_phy.h"
63#include "scu_registers.h" 62#include "scu_registers.h"
64 63
65#define SCIC_SDS_DUMMY_PORT 0xFF 64#define SCIC_SDS_DUMMY_PORT 0xFF
@@ -260,12 +259,10 @@ struct scic_sds_port {
260 259
261}; 260};
262 261
263struct sci_base_phy;
264
265typedef enum sci_status (*scic_sds_port_handler_t)(struct scic_sds_port *); 262typedef enum sci_status (*scic_sds_port_handler_t)(struct scic_sds_port *);
266 263
267typedef enum sci_status (*scic_sds_port_phy_handler_t)(struct scic_sds_port *, 264typedef enum sci_status (*scic_sds_port_phy_handler_t)(struct scic_sds_port *,
268 struct sci_base_phy *); 265 struct scic_sds_phy *);
269 266
270typedef enum sci_status (*scic_sds_port_reset_handler_t)(struct scic_sds_port *, 267typedef enum sci_status (*scic_sds_port_reset_handler_t)(struct scic_sds_port *,
271 u32 timeout); 268 u32 timeout);