aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2012-02-10 04:18:44 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-02-29 17:23:15 -0500
commitd7a0ccdd9bd78b5b74d2963ec7ab67c9d896902a (patch)
tree9fc59d3303e7453006c767b0f4daadbf3d4ed5c1 /drivers
parent16d3db1b298529e6aec4a4cf0f56225d9e0bc641 (diff)
[SCSI] isci: debug, provide state-enum-to-string conversions
Debugging the driver requires tracing the state transtions and tracing state names is less work than decoding numbers. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/isci/phy.c34
-rw-r--r--drivers/scsi/isci/phy.h154
-rw-r--r--drivers/scsi/isci/port.c46
-rw-r--r--drivers/scsi/isci/port.h103
-rw-r--r--drivers/scsi/isci/remote_device.c50
-rw-r--r--drivers/scsi/isci/remote_device.h205
-rw-r--r--drivers/scsi/isci/remote_node_context.c19
-rw-r--r--drivers/scsi/isci/remote_node_context.h97
-rw-r--r--drivers/scsi/isci/request.c25
-rw-r--r--drivers/scsi/isci/request.h219
10 files changed, 432 insertions, 520 deletions
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 8d412ca689a..87064f13f8f 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -59,6 +59,16 @@
59#include "scu_event_codes.h" 59#include "scu_event_codes.h"
60#include "probe_roms.h" 60#include "probe_roms.h"
61 61
62#undef C
63#define C(a) (#a)
64static const char *phy_state_name(enum sci_phy_states state)
65{
66 static const char * const strings[] = PHY_STATES;
67
68 return strings[state];
69}
70#undef C
71
62/* Maximum arbitration wait time in micro-seconds */ 72/* Maximum arbitration wait time in micro-seconds */
63#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700) 73#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
64 74
@@ -454,8 +464,8 @@ enum sci_status sci_phy_start(struct isci_phy *iphy)
454 enum sci_phy_states state = iphy->sm.current_state_id; 464 enum sci_phy_states state = iphy->sm.current_state_id;
455 465
456 if (state != SCI_PHY_STOPPED) { 466 if (state != SCI_PHY_STOPPED) {
457 dev_dbg(sciphy_to_dev(iphy), 467 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
458 "%s: in wrong state: %d\n", __func__, state); 468 __func__, phy_state_name(state));
459 return SCI_FAILURE_INVALID_STATE; 469 return SCI_FAILURE_INVALID_STATE;
460 } 470 }
461 471
@@ -480,8 +490,8 @@ enum sci_status sci_phy_stop(struct isci_phy *iphy)
480 case SCI_PHY_READY: 490 case SCI_PHY_READY:
481 break; 491 break;
482 default: 492 default:
483 dev_dbg(sciphy_to_dev(iphy), 493 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
484 "%s: in wrong state: %d\n", __func__, state); 494 __func__, phy_state_name(state));
485 return SCI_FAILURE_INVALID_STATE; 495 return SCI_FAILURE_INVALID_STATE;
486 } 496 }
487 497
@@ -494,8 +504,8 @@ enum sci_status sci_phy_reset(struct isci_phy *iphy)
494 enum sci_phy_states state = iphy->sm.current_state_id; 504 enum sci_phy_states state = iphy->sm.current_state_id;
495 505
496 if (state != SCI_PHY_READY) { 506 if (state != SCI_PHY_READY) {
497 dev_dbg(sciphy_to_dev(iphy), 507 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
498 "%s: in wrong state: %d\n", __func__, state); 508 __func__, phy_state_name(state));
499 return SCI_FAILURE_INVALID_STATE; 509 return SCI_FAILURE_INVALID_STATE;
500 } 510 }
501 511
@@ -544,8 +554,8 @@ enum sci_status sci_phy_consume_power_handler(struct isci_phy *iphy)
544 return SCI_SUCCESS; 554 return SCI_SUCCESS;
545 } 555 }
546 default: 556 default:
547 dev_dbg(sciphy_to_dev(iphy), 557 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
548 "%s: in wrong state: %d\n", __func__, state); 558 __func__, phy_state_name(state));
549 return SCI_FAILURE_INVALID_STATE; 559 return SCI_FAILURE_INVALID_STATE;
550 } 560 }
551} 561}
@@ -870,8 +880,8 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
870 } 880 }
871 return SCI_SUCCESS; 881 return SCI_SUCCESS;
872 default: 882 default:
873 dev_dbg(sciphy_to_dev(iphy), 883 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
874 "%s: in wrong state: %d\n", __func__, state); 884 __func__, phy_state_name(state));
875 return SCI_FAILURE_INVALID_STATE; 885 return SCI_FAILURE_INVALID_STATE;
876 } 886 }
877} 887}
@@ -964,8 +974,8 @@ enum sci_status sci_phy_frame_handler(struct isci_phy *iphy, u32 frame_index)
964 return result; 974 return result;
965 } 975 }
966 default: 976 default:
967 dev_dbg(sciphy_to_dev(iphy), 977 dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
968 "%s: in wrong state: %d\n", __func__, state); 978 __func__, phy_state_name(state));
969 return SCI_FAILURE_INVALID_STATE; 979 return SCI_FAILURE_INVALID_STATE;
970 } 980 }
971 981
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h
index a5e1a9e577b..0e45833ba06 100644
--- a/drivers/scsi/isci/phy.h
+++ b/drivers/scsi/isci/phy.h
@@ -343,101 +343,65 @@ enum sci_phy_counter_id {
343 SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR 343 SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR
344}; 344};
345 345
346enum sci_phy_states { 346/**
347 /** 347 * enum sci_phy_states - phy state machine states
348 * Simply the initial state for the base domain state machine. 348 * @SCI_PHY_INITIAL: Simply the initial state for the base domain state
349 */ 349 * machine.
350 SCI_PHY_INITIAL, 350 * @SCI_PHY_STOPPED: phy has successfully been stopped. In this state
351 351 * no new IO operations are permitted on this phy.
352 /** 352 * @SCI_PHY_STARTING: the phy is in the process of becomming ready. In
353 * This state indicates that the phy has successfully been stopped. 353 * this state no new IO operations are permitted on
354 * In this state no new IO operations are permitted on this phy. 354 * this phy.
355 * This state is entered from the INITIAL state. 355 * @SCI_PHY_SUB_INITIAL: Initial state
356 * This state is entered from the STARTING state. 356 * @SCI_PHY_SUB_AWAIT_OSSP_EN: Wait state for the hardware OSSP event
357 * This state is entered from the READY state. 357 * type notification
358 * This state is entered from the RESETTING state. 358 * @SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: Wait state for the PHY speed
359 */ 359 * notification
360 SCI_PHY_STOPPED, 360 * @SCI_PHY_SUB_AWAIT_IAF_UF: Wait state for the IAF Unsolicited frame
361 361 * notification
362 /** 362 * @SCI_PHY_SUB_AWAIT_SAS_POWER: Wait state for the request to consume
363 * This state indicates that the phy is in the process of becomming 363 * power
364 * ready. In this state no new IO operations are permitted on this phy. 364 * @SCI_PHY_SUB_AWAIT_SATA_POWER: Wait state for request to consume
365 * This state is entered from the STOPPED state. 365 * power
366 * This state is entered from the READY state. 366 * @SCI_PHY_SUB_AWAIT_SATA_PHY_EN: Wait state for the SATA PHY
367 * This state is entered from the RESETTING state. 367 * notification
368 */ 368 * @SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: Wait for the SATA PHY speed
369 SCI_PHY_STARTING, 369 * notification
370 370 * @SCI_PHY_SUB_AWAIT_SIG_FIS_UF: Wait state for the SIGNATURE FIS
371 /** 371 * unsolicited frame notification
372 * Initial state 372 * @SCI_PHY_SUB_FINAL: Exit state for this state machine
373 */ 373 * @SCI_PHY_READY: phy is now ready. Thus, the user is able to perform
374 SCI_PHY_SUB_INITIAL, 374 * IO operations utilizing this phy as long as it is
375 375 * currently part of a valid port. This state is
376 /** 376 * entered from the STARTING state.
377 * Wait state for the hardware OSSP event type notification 377 * @SCI_PHY_RESETTING: phy is in the process of being reset. In this
378 */ 378 * state no new IO operations are permitted on this
379 SCI_PHY_SUB_AWAIT_OSSP_EN, 379 * phy. This state is entered from the READY state.
380 380 * @SCI_PHY_FINAL: Simply the final state for the base phy state
381 /** 381 * machine.
382 * Wait state for the PHY speed notification 382 */
383 */ 383#define PHY_STATES {\
384 SCI_PHY_SUB_AWAIT_SAS_SPEED_EN, 384 C(PHY_INITIAL),\
385 385 C(PHY_STOPPED),\
386 /** 386 C(PHY_STARTING),\
387 * Wait state for the IAF Unsolicited frame notification 387 C(PHY_SUB_INITIAL),\
388 */ 388 C(PHY_SUB_AWAIT_OSSP_EN),\
389 SCI_PHY_SUB_AWAIT_IAF_UF, 389 C(PHY_SUB_AWAIT_SAS_SPEED_EN),\
390 390 C(PHY_SUB_AWAIT_IAF_UF),\
391 /** 391 C(PHY_SUB_AWAIT_SAS_POWER),\
392 * Wait state for the request to consume power 392 C(PHY_SUB_AWAIT_SATA_POWER),\
393 */ 393 C(PHY_SUB_AWAIT_SATA_PHY_EN),\
394 SCI_PHY_SUB_AWAIT_SAS_POWER, 394 C(PHY_SUB_AWAIT_SATA_SPEED_EN),\
395 395 C(PHY_SUB_AWAIT_SIG_FIS_UF),\
396 /** 396 C(PHY_SUB_FINAL),\
397 * Wait state for request to consume power 397 C(PHY_READY),\
398 */ 398 C(PHY_RESETTING),\
399 SCI_PHY_SUB_AWAIT_SATA_POWER, 399 C(PHY_FINAL),\
400 400 }
401 /** 401#undef C
402 * Wait state for the SATA PHY notification 402#define C(a) SCI_##a
403 */ 403enum sci_phy_states PHY_STATES;
404 SCI_PHY_SUB_AWAIT_SATA_PHY_EN, 404#undef C
405
406 /**
407 * Wait for the SATA PHY speed notification
408 */
409 SCI_PHY_SUB_AWAIT_SATA_SPEED_EN,
410
411 /**
412 * Wait state for the SIGNATURE FIS unsolicited frame notification
413 */
414 SCI_PHY_SUB_AWAIT_SIG_FIS_UF,
415
416 /**
417 * Exit state for this state machine
418 */
419 SCI_PHY_SUB_FINAL,
420
421 /**
422 * This state indicates the the phy is now ready. Thus, the user
423 * is able to perform IO operations utilizing this phy as long as it
424 * is currently part of a valid port.
425 * This state is entered from the STARTING state.
426 */
427 SCI_PHY_READY,
428
429 /**
430 * This state indicates that the phy is in the process of being reset.
431 * In this state no new IO operations are permitted on this phy.
432 * This state is entered from the READY state.
433 */
434 SCI_PHY_RESETTING,
435
436 /**
437 * Simply the final state for the base phy state machine.
438 */
439 SCI_PHY_FINAL,
440};
441 405
442void sci_phy_construct( 406void sci_phy_construct(
443 struct isci_phy *iphy, 407 struct isci_phy *iphy,
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index c5ae94dbef4..5fada73b71f 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -60,6 +60,16 @@
60#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) 60#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
61#define SCU_DUMMY_INDEX (0xFFFF) 61#define SCU_DUMMY_INDEX (0xFFFF)
62 62
63#undef C
64#define C(a) (#a)
65const char *port_state_name(enum sci_port_states state)
66{
67 static const char * const strings[] = PORT_STATES;
68
69 return strings[state];
70}
71#undef C
72
63static struct device *sciport_to_dev(struct isci_port *iport) 73static struct device *sciport_to_dev(struct isci_port *iport)
64{ 74{
65 int i = iport->physical_port_index; 75 int i = iport->physical_port_index;
@@ -1054,8 +1064,8 @@ enum sci_status sci_port_start(struct isci_port *iport)
1054 1064
1055 state = iport->sm.current_state_id; 1065 state = iport->sm.current_state_id;
1056 if (state != SCI_PORT_STOPPED) { 1066 if (state != SCI_PORT_STOPPED) {
1057 dev_warn(sciport_to_dev(iport), 1067 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1058 "%s: in wrong state: %d\n", __func__, state); 1068 __func__, port_state_name(state));
1059 return SCI_FAILURE_INVALID_STATE; 1069 return SCI_FAILURE_INVALID_STATE;
1060 } 1070 }
1061 1071
@@ -1129,8 +1139,8 @@ enum sci_status sci_port_stop(struct isci_port *iport)
1129 SCI_PORT_STOPPING); 1139 SCI_PORT_STOPPING);
1130 return SCI_SUCCESS; 1140 return SCI_SUCCESS;
1131 default: 1141 default:
1132 dev_warn(sciport_to_dev(iport), 1142 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1133 "%s: in wrong state: %d\n", __func__, state); 1143 __func__, port_state_name(state));
1134 return SCI_FAILURE_INVALID_STATE; 1144 return SCI_FAILURE_INVALID_STATE;
1135 } 1145 }
1136} 1146}
@@ -1144,8 +1154,8 @@ static enum sci_status sci_port_hard_reset(struct isci_port *iport, u32 timeout)
1144 1154
1145 state = iport->sm.current_state_id; 1155 state = iport->sm.current_state_id;
1146 if (state != SCI_PORT_SUB_OPERATIONAL) { 1156 if (state != SCI_PORT_SUB_OPERATIONAL) {
1147 dev_warn(sciport_to_dev(iport), 1157 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1148 "%s: in wrong state: %d\n", __func__, state); 1158 __func__, port_state_name(state));
1149 return SCI_FAILURE_INVALID_STATE; 1159 return SCI_FAILURE_INVALID_STATE;
1150 } 1160 }
1151 1161
@@ -1239,8 +1249,8 @@ enum sci_status sci_port_add_phy(struct isci_port *iport,
1239 SCI_PORT_SUB_CONFIGURING); 1249 SCI_PORT_SUB_CONFIGURING);
1240 return SCI_SUCCESS; 1250 return SCI_SUCCESS;
1241 default: 1251 default:
1242 dev_warn(sciport_to_dev(iport), 1252 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1243 "%s: in wrong state: %d\n", __func__, state); 1253 __func__, port_state_name(state));
1244 return SCI_FAILURE_INVALID_STATE; 1254 return SCI_FAILURE_INVALID_STATE;
1245 } 1255 }
1246} 1256}
@@ -1289,8 +1299,8 @@ enum sci_status sci_port_remove_phy(struct isci_port *iport,
1289 SCI_PORT_SUB_CONFIGURING); 1299 SCI_PORT_SUB_CONFIGURING);
1290 return SCI_SUCCESS; 1300 return SCI_SUCCESS;
1291 default: 1301 default:
1292 dev_warn(sciport_to_dev(iport), 1302 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1293 "%s: in wrong state: %d\n", __func__, state); 1303 __func__, port_state_name(state));
1294 return SCI_FAILURE_INVALID_STATE; 1304 return SCI_FAILURE_INVALID_STATE;
1295 } 1305 }
1296} 1306}
@@ -1332,8 +1342,8 @@ enum sci_status sci_port_link_up(struct isci_port *iport,
1332 sci_port_general_link_up_handler(iport, iphy, PF_RESUME); 1342 sci_port_general_link_up_handler(iport, iphy, PF_RESUME);
1333 return SCI_SUCCESS; 1343 return SCI_SUCCESS;
1334 default: 1344 default:
1335 dev_warn(sciport_to_dev(iport), 1345 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1336 "%s: in wrong state: %d\n", __func__, state); 1346 __func__, port_state_name(state));
1337 return SCI_FAILURE_INVALID_STATE; 1347 return SCI_FAILURE_INVALID_STATE;
1338 } 1348 }
1339} 1349}
@@ -1362,8 +1372,8 @@ enum sci_status sci_port_link_down(struct isci_port *iport,
1362 sci_port_deactivate_phy(iport, iphy, false); 1372 sci_port_deactivate_phy(iport, iphy, false);
1363 return SCI_SUCCESS; 1373 return SCI_SUCCESS;
1364 default: 1374 default:
1365 dev_warn(sciport_to_dev(iport), 1375 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1366 "%s: in wrong state: %d\n", __func__, state); 1376 __func__, port_state_name(state));
1367 return SCI_FAILURE_INVALID_STATE; 1377 return SCI_FAILURE_INVALID_STATE;
1368 } 1378 }
1369} 1379}
@@ -1382,8 +1392,8 @@ enum sci_status sci_port_start_io(struct isci_port *iport,
1382 iport->started_request_count++; 1392 iport->started_request_count++;
1383 return SCI_SUCCESS; 1393 return SCI_SUCCESS;
1384 default: 1394 default:
1385 dev_warn(sciport_to_dev(iport), 1395 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1386 "%s: in wrong state: %d\n", __func__, state); 1396 __func__, port_state_name(state));
1387 return SCI_FAILURE_INVALID_STATE; 1397 return SCI_FAILURE_INVALID_STATE;
1388 } 1398 }
1389} 1399}
@@ -1397,8 +1407,8 @@ enum sci_status sci_port_complete_io(struct isci_port *iport,
1397 state = iport->sm.current_state_id; 1407 state = iport->sm.current_state_id;
1398 switch (state) { 1408 switch (state) {
1399 case SCI_PORT_STOPPED: 1409 case SCI_PORT_STOPPED:
1400 dev_warn(sciport_to_dev(iport), 1410 dev_warn(sciport_to_dev(iport), "%s: in wrong state: %s\n",
1401 "%s: in wrong state: %d\n", __func__, state); 1411 __func__, port_state_name(state));
1402 return SCI_FAILURE_INVALID_STATE; 1412 return SCI_FAILURE_INVALID_STATE;
1403 case SCI_PORT_STOPPING: 1413 case SCI_PORT_STOPPING:
1404 sci_port_decrement_request_count(iport); 1414 sci_port_decrement_request_count(iport);
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h
index 321b987d582..6b56240c205 100644
--- a/drivers/scsi/isci/port.h
+++ b/drivers/scsi/isci/port.h
@@ -144,70 +144,47 @@ struct sci_port_properties {
144}; 144};
145 145
146/** 146/**
147 * enum sci_port_states - This enumeration depicts all the states for the 147 * enum sci_port_states - port state machine states
148 * common port state machine. 148 * @SCI_PORT_STOPPED: port has successfully been stopped. In this state
149 * 149 * no new IO operations are permitted. This state is
150 * 150 * entered from the STOPPING state.
151 * @SCI_PORT_STOPPING: port is in the process of stopping. In this
152 * state no new IO operations are permitted, but
153 * existing IO operations are allowed to complete.
154 * This state is entered from the READY state.
155 * @SCI_PORT_READY: port is now ready. Thus, the user is able to
156 * perform IO operations on this port. This state is
157 * entered from the STARTING state.
158 * @SCI_PORT_SUB_WAITING: port is started and ready but has no active
159 * phys.
160 * @SCI_PORT_SUB_OPERATIONAL: port is started and ready and there is at
161 * least one phy operational.
162 * @SCI_PORT_SUB_CONFIGURING: port is started and there was an
163 * add/remove phy event. This state is only
164 * used in Automatic Port Configuration Mode
165 * (APC)
166 * @SCI_PORT_RESETTING: port is in the process of performing a hard
167 * reset. Thus, the user is unable to perform IO
168 * operations on this port. This state is entered
169 * from the READY state.
170 * @SCI_PORT_FAILED: port has failed a reset request. This state is
171 * entered when a port reset request times out. This
172 * state is entered from the RESETTING state.
151 */ 173 */
152enum sci_port_states { 174#define PORT_STATES {\
153 /** 175 C(PORT_STOPPED),\
154 * This state indicates that the port has successfully been stopped. 176 C(PORT_STOPPING),\
155 * In this state no new IO operations are permitted. 177 C(PORT_READY),\
156 * This state is entered from the STOPPING state. 178 C(PORT_SUB_WAITING),\
157 */ 179 C(PORT_SUB_OPERATIONAL),\
158 SCI_PORT_STOPPED, 180 C(PORT_SUB_CONFIGURING),\
159 181 C(PORT_RESETTING),\
160 /** 182 C(PORT_FAILED),\
161 * This state indicates that the port is in the process of stopping. 183 }
162 * In this state no new IO operations are permitted, but existing IO 184#undef C
163 * operations are allowed to complete. 185#define C(a) SCI_##a
164 * This state is entered from the READY state. 186enum sci_port_states PORT_STATES;
165 */ 187#undef C
166 SCI_PORT_STOPPING,
167
168 /**
169 * This state indicates the port is now ready. Thus, the user is
170 * able to perform IO operations on this port.
171 * This state is entered from the STARTING state.
172 */
173 SCI_PORT_READY,
174
175 /**
176 * The substate where the port is started and ready but has no
177 * active phys.
178 */
179 SCI_PORT_SUB_WAITING,
180
181 /**
182 * The substate where the port is started and ready and there is
183 * at least one phy operational.
184 */
185 SCI_PORT_SUB_OPERATIONAL,
186
187 /**
188 * The substate where the port is started and there was an
189 * add/remove phy event. This state is only used in Automatic
190 * Port Configuration Mode (APC)
191 */
192 SCI_PORT_SUB_CONFIGURING,
193
194 /**
195 * This state indicates the port is in the process of performing a hard
196 * reset. Thus, the user is unable to perform IO operations on this
197 * port.
198 * This state is entered from the READY state.
199 */
200 SCI_PORT_RESETTING,
201
202 /**
203 * This state indicates the port has failed a reset request. This state
204 * is entered when a port reset request times out.
205 * This state is entered from the RESETTING state.
206 */
207 SCI_PORT_FAILED,
208
209
210};
211 188
212static inline void sci_port_decrement_request_count(struct isci_port *iport) 189static inline void sci_port_decrement_request_count(struct isci_port *iport)
213{ 190{
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 934d21ea14e..8f501b0a81d 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -62,6 +62,16 @@
62#include "scu_event_codes.h" 62#include "scu_event_codes.h"
63#include "task.h" 63#include "task.h"
64 64
65#undef C
66#define C(a) (#a)
67const char *dev_state_name(enum sci_remote_device_states state)
68{
69 static const char * const strings[] = REMOTE_DEV_STATES;
70
71 return strings[state];
72}
73#undef C
74
65/** 75/**
66 * isci_remote_device_not_ready() - This function is called by the ihost when 76 * isci_remote_device_not_ready() - This function is called by the ihost when
67 * the remote device is not ready. We mark the isci device as ready (not 77 * the remote device is not ready. We mark the isci device as ready (not
@@ -167,8 +177,8 @@ enum sci_status sci_remote_device_stop(struct isci_remote_device *idev,
167 case SCI_DEV_FAILED: 177 case SCI_DEV_FAILED:
168 case SCI_DEV_FINAL: 178 case SCI_DEV_FINAL:
169 default: 179 default:
170 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 180 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
171 __func__, state); 181 __func__, dev_state_name(state));
172 return SCI_FAILURE_INVALID_STATE; 182 return SCI_FAILURE_INVALID_STATE;
173 case SCI_DEV_STOPPED: 183 case SCI_DEV_STOPPED:
174 return SCI_SUCCESS; 184 return SCI_SUCCESS;
@@ -226,8 +236,8 @@ enum sci_status sci_remote_device_reset(struct isci_remote_device *idev)
226 case SCI_DEV_RESETTING: 236 case SCI_DEV_RESETTING:
227 case SCI_DEV_FINAL: 237 case SCI_DEV_FINAL:
228 default: 238 default:
229 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 239 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
230 __func__, state); 240 __func__, dev_state_name(state));
231 return SCI_FAILURE_INVALID_STATE; 241 return SCI_FAILURE_INVALID_STATE;
232 case SCI_DEV_READY: 242 case SCI_DEV_READY:
233 case SCI_STP_DEV_IDLE: 243 case SCI_STP_DEV_IDLE:
@@ -246,8 +256,8 @@ enum sci_status sci_remote_device_reset_complete(struct isci_remote_device *idev
246 enum sci_remote_device_states state = sm->current_state_id; 256 enum sci_remote_device_states state = sm->current_state_id;
247 257
248 if (state != SCI_DEV_RESETTING) { 258 if (state != SCI_DEV_RESETTING) {
249 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 259 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
250 __func__, state); 260 __func__, dev_state_name(state));
251 return SCI_FAILURE_INVALID_STATE; 261 return SCI_FAILURE_INVALID_STATE;
252 } 262 }
253 263
@@ -262,8 +272,8 @@ enum sci_status sci_remote_device_suspend(struct isci_remote_device *idev,
262 enum sci_remote_device_states state = sm->current_state_id; 272 enum sci_remote_device_states state = sm->current_state_id;
263 273
264 if (state != SCI_STP_DEV_CMD) { 274 if (state != SCI_STP_DEV_CMD) {
265 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 275 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
266 __func__, state); 276 __func__, dev_state_name(state));
267 return SCI_FAILURE_INVALID_STATE; 277 return SCI_FAILURE_INVALID_STATE;
268 } 278 }
269 279
@@ -287,8 +297,8 @@ enum sci_status sci_remote_device_frame_handler(struct isci_remote_device *idev,
287 case SCI_SMP_DEV_IDLE: 297 case SCI_SMP_DEV_IDLE:
288 case SCI_DEV_FINAL: 298 case SCI_DEV_FINAL:
289 default: 299 default:
290 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 300 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
291 __func__, state); 301 __func__, dev_state_name(state));
292 /* Return the frame back to the controller */ 302 /* Return the frame back to the controller */
293 sci_controller_release_frame(ihost, frame_index); 303 sci_controller_release_frame(ihost, frame_index);
294 return SCI_FAILURE_INVALID_STATE; 304 return SCI_FAILURE_INVALID_STATE;
@@ -502,8 +512,8 @@ enum sci_status sci_remote_device_start_io(struct isci_host *ihost,
502 case SCI_DEV_RESETTING: 512 case SCI_DEV_RESETTING:
503 case SCI_DEV_FINAL: 513 case SCI_DEV_FINAL:
504 default: 514 default:
505 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 515 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
506 __func__, state); 516 __func__, dev_state_name(state));
507 return SCI_FAILURE_INVALID_STATE; 517 return SCI_FAILURE_INVALID_STATE;
508 case SCI_DEV_READY: 518 case SCI_DEV_READY:
509 /* attempt to start an io request for this device object. The remote 519 /* attempt to start an io request for this device object. The remote
@@ -637,8 +647,8 @@ enum sci_status sci_remote_device_complete_io(struct isci_host *ihost,
637 case SCI_DEV_FAILED: 647 case SCI_DEV_FAILED:
638 case SCI_DEV_FINAL: 648 case SCI_DEV_FINAL:
639 default: 649 default:
640 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 650 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
641 __func__, state); 651 __func__, dev_state_name(state));
642 return SCI_FAILURE_INVALID_STATE; 652 return SCI_FAILURE_INVALID_STATE;
643 case SCI_DEV_READY: 653 case SCI_DEV_READY:
644 case SCI_STP_DEV_AWAIT_RESET: 654 case SCI_STP_DEV_AWAIT_RESET:
@@ -721,8 +731,8 @@ enum sci_status sci_remote_device_start_task(struct isci_host *ihost,
721 case SCI_DEV_RESETTING: 731 case SCI_DEV_RESETTING:
722 case SCI_DEV_FINAL: 732 case SCI_DEV_FINAL:
723 default: 733 default:
724 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 734 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
725 __func__, state); 735 __func__, dev_state_name(state));
726 return SCI_FAILURE_INVALID_STATE; 736 return SCI_FAILURE_INVALID_STATE;
727 case SCI_STP_DEV_IDLE: 737 case SCI_STP_DEV_IDLE:
728 case SCI_STP_DEV_CMD: 738 case SCI_STP_DEV_CMD:
@@ -853,8 +863,8 @@ static enum sci_status sci_remote_device_destruct(struct isci_remote_device *ide
853 struct isci_host *ihost; 863 struct isci_host *ihost;
854 864
855 if (state != SCI_DEV_STOPPED) { 865 if (state != SCI_DEV_STOPPED) {
856 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 866 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
857 __func__, state); 867 __func__, dev_state_name(state));
858 return SCI_FAILURE_INVALID_STATE; 868 return SCI_FAILURE_INVALID_STATE;
859 } 869 }
860 870
@@ -1204,8 +1214,8 @@ static enum sci_status sci_remote_device_start(struct isci_remote_device *idev,
1204 enum sci_status status; 1214 enum sci_status status;
1205 1215
1206 if (state != SCI_DEV_STOPPED) { 1216 if (state != SCI_DEV_STOPPED) {
1207 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", 1217 dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %s\n",
1208 __func__, state); 1218 __func__, dev_state_name(state));
1209 return SCI_FAILURE_INVALID_STATE; 1219 return SCI_FAILURE_INVALID_STATE;
1210 } 1220 }
1211 1221
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h
index 98c2801ed08..58637ee08f5 100644
--- a/drivers/scsi/isci/remote_device.h
+++ b/drivers/scsi/isci/remote_device.h
@@ -179,122 +179,101 @@ enum sci_status sci_remote_device_reset_complete(
179/** 179/**
180 * enum sci_remote_device_states - This enumeration depicts all the states 180 * enum sci_remote_device_states - This enumeration depicts all the states
181 * for the common remote device state machine. 181 * for the common remote device state machine.
182 * @SCI_DEV_INITIAL: Simply the initial state for the base remote device
183 * state machine.
182 * 184 *
185 * @SCI_DEV_STOPPED: This state indicates that the remote device has
186 * successfully been stopped. In this state no new IO operations are
187 * permitted. This state is entered from the INITIAL state. This state
188 * is entered from the STOPPING state.
183 * 189 *
190 * @SCI_DEV_STARTING: This state indicates the the remote device is in
191 * the process of becoming ready (i.e. starting). In this state no new
192 * IO operations are permitted. This state is entered from the STOPPED
193 * state.
194 *
195 * @SCI_DEV_READY: This state indicates the remote device is now ready.
196 * Thus, the user is able to perform IO operations on the remote device.
197 * This state is entered from the STARTING state.
198 *
199 * @SCI_STP_DEV_IDLE: This is the idle substate for the stp remote
200 * device. When there are no active IO for the device it is is in this
201 * state.
202 *
203 * @SCI_STP_DEV_CMD: This is the command state for for the STP remote
204 * device. This state is entered when the device is processing a
205 * non-NCQ command. The device object will fail any new start IO
206 * requests until this command is complete.
207 *
208 * @SCI_STP_DEV_NCQ: This is the NCQ state for the STP remote device.
209 * This state is entered when the device is processing an NCQ reuqest.
210 * It will remain in this state so long as there is one or more NCQ
211 * requests being processed.
212 *
213 * @SCI_STP_DEV_NCQ_ERROR: This is the NCQ error state for the STP
214 * remote device. This state is entered when an SDB error FIS is
215 * received by the device object while in the NCQ state. The device
216 * object will only accept a READ LOG command while in this state.
217 *
218 * @SCI_STP_DEV_ATAPI_ERROR: This is the ATAPI error state for the STP
219 * ATAPI remote device. This state is entered when ATAPI device sends
220 * error status FIS without data while the device object is in CMD
221 * state. A suspension event is expected in this state. The device
222 * object will resume right away.
223 *
224 * @SCI_STP_DEV_AWAIT_RESET: This is the READY substate indicates the
225 * device is waiting for the RESET task coming to be recovered from
226 * certain hardware specific error.
227 *
228 * @SCI_SMP_DEV_IDLE: This is the ready operational substate for the
229 * remote device. This is the normal operational state for a remote
230 * device.
231 *
232 * @SCI_SMP_DEV_CMD: This is the suspended state for the remote device.
233 * This is the state that the device is placed in when a RNC suspend is
234 * received by the SCU hardware.
235 *
236 * @SCI_DEV_STOPPING: This state indicates that the remote device is in
237 * the process of stopping. In this state no new IO operations are
238 * permitted, but existing IO operations are allowed to complete. This
239 * state is entered from the READY state. This state is entered from
240 * the FAILED state.
241 *
242 * @SCI_DEV_FAILED: This state indicates that the remote device has
243 * failed. In this state no new IO operations are permitted. This
244 * state is entered from the INITIALIZING state. This state is entered
245 * from the READY state.
246 *
247 * @SCI_DEV_RESETTING: This state indicates the device is being reset.
248 * In this state no new IO operations are permitted. This state is
249 * entered from the READY state.
250 *
251 * @SCI_DEV_FINAL: Simply the final state for the base remote device
252 * state machine.
184 */ 253 */
185enum sci_remote_device_states { 254#define REMOTE_DEV_STATES {\
186 /** 255 C(DEV_INITIAL),\
187 * Simply the initial state for the base remote device state machine. 256 C(DEV_STOPPED),\
188 */ 257 C(DEV_STARTING),\
189 SCI_DEV_INITIAL, 258 C(DEV_READY),\
190 259 C(STP_DEV_IDLE),\
191 /** 260 C(STP_DEV_CMD),\
192 * This state indicates that the remote device has successfully been 261 C(STP_DEV_NCQ),\
193 * stopped. In this state no new IO operations are permitted. 262 C(STP_DEV_NCQ_ERROR),\
194 * This state is entered from the INITIAL state. 263 C(STP_DEV_ATAPI_ERROR),\
195 * This state is entered from the STOPPING state. 264 C(STP_DEV_AWAIT_RESET),\
196 */ 265 C(SMP_DEV_IDLE),\
197 SCI_DEV_STOPPED, 266 C(SMP_DEV_CMD),\
198 267 C(DEV_STOPPING),\
199 /** 268 C(DEV_FAILED),\
200 * This state indicates the the remote device is in the process of 269 C(DEV_RESETTING),\
201 * becoming ready (i.e. starting). In this state no new IO operations 270 C(DEV_FINAL),\
202 * are permitted. 271 }
203 * This state is entered from the STOPPED state. 272#undef C
204 */ 273#define C(a) SCI_##a
205 SCI_DEV_STARTING, 274enum sci_remote_device_states REMOTE_DEV_STATES;
206 275#undef C
207 /** 276const char *dev_state_name(enum sci_remote_device_states state);
208 * This state indicates the remote device is now ready. Thus, the user
209 * is able to perform IO operations on the remote device.
210 * This state is entered from the STARTING state.
211 */
212 SCI_DEV_READY,
213
214 /**
215 * This is the idle substate for the stp remote device. When there are no
216 * active IO for the device it is is in this state.
217 */
218 SCI_STP_DEV_IDLE,
219
220 /**
221 * This is the command state for for the STP remote device. This state is
222 * entered when the device is processing a non-NCQ command. The device object
223 * will fail any new start IO requests until this command is complete.
224 */
225 SCI_STP_DEV_CMD,
226
227 /**
228 * This is the NCQ state for the STP remote device. This state is entered
229 * when the device is processing an NCQ reuqest. It will remain in this state
230 * so long as there is one or more NCQ requests being processed.
231 */
232 SCI_STP_DEV_NCQ,
233
234 /**
235 * This is the NCQ error state for the STP remote device. This state is
236 * entered when an SDB error FIS is received by the device object while in the
237 * NCQ state. The device object will only accept a READ LOG command while in
238 * this state.
239 */
240 SCI_STP_DEV_NCQ_ERROR,
241
242 /**
243 * This is the ATAPI error state for the STP ATAPI remote device.
244 * This state is entered when ATAPI device sends error status FIS
245 * without data while the device object is in CMD state.
246 * A suspension event is expected in this state.
247 * The device object will resume right away.
248 */
249 SCI_STP_DEV_ATAPI_ERROR,
250
251 /**
252 * This is the READY substate indicates the device is waiting for the RESET task
253 * coming to be recovered from certain hardware specific error.
254 */
255 SCI_STP_DEV_AWAIT_RESET,
256
257 /**
258 * This is the ready operational substate for the remote device. This is the
259 * normal operational state for a remote device.
260 */
261 SCI_SMP_DEV_IDLE,
262
263 /**
264 * This is the suspended state for the remote device. This is the state that
265 * the device is placed in when a RNC suspend is received by the SCU hardware.
266 */
267 SCI_SMP_DEV_CMD,
268
269 /**
270 * This state indicates that the remote device is in the process of
271 * stopping. In this state no new IO operations are permitted, but
272 * existing IO operations are allowed to complete.
273 * This state is entered from the READY state.
274 * This state is entered from the FAILED state.
275 */
276 SCI_DEV_STOPPING,
277
278 /**
279 * This state indicates that the remote device has failed.
280 * In this state no new IO operations are permitted.
281 * This state is entered from the INITIALIZING state.
282 * This state is entered from the READY state.
283 */
284 SCI_DEV_FAILED,
285
286 /**
287 * This state indicates the device is being reset.
288 * In this state no new IO operations are permitted.
289 * This state is entered from the READY state.
290 */
291 SCI_DEV_RESETTING,
292
293 /**
294 * Simply the final state for the base remote device state machine.
295 */
296 SCI_DEV_FINAL,
297};
298 277
299static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc) 278static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc)
300{ 279{
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 748e8339d1e..3a9463481f3 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -60,18 +60,15 @@
60#include "scu_event_codes.h" 60#include "scu_event_codes.h"
61#include "scu_task_context.h" 61#include "scu_task_context.h"
62 62
63#undef C
64#define C(a) (#a)
65const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
66{
67 static const char * const strings[] = RNC_STATES;
63 68
64/** 69 return strings[state];
65 * 70}
66 * @sci_rnc: The RNC for which the is posted request is being made. 71#undef C
67 *
68 * This method will return true if the RNC is not in the initial state. In all
69 * other states the RNC is considered active and this will return true. The
70 * destroy request of the state machine drives the RNC back to the initial
71 * state. If the state machine changes then this routine will also have to be
72 * changed. bool true if the state machine is not in the initial state false if
73 * the state machine is in the initial state
74 */
75 72
76/** 73/**
77 * 74 *
diff --git a/drivers/scsi/isci/remote_node_context.h b/drivers/scsi/isci/remote_node_context.h
index 41580ad1252..a241e0f4c86 100644
--- a/drivers/scsi/isci/remote_node_context.h
+++ b/drivers/scsi/isci/remote_node_context.h
@@ -85,61 +85,50 @@ struct sci_remote_node_context;
85typedef void (*scics_sds_remote_node_context_callback)(void *); 85typedef void (*scics_sds_remote_node_context_callback)(void *);
86 86
87/** 87/**
88 * This is the enumeration of the remote node context states. 88 * enum sci_remote_node_context_states
89 * @SCI_RNC_INITIAL initial state for a remote node context. On a resume
90 * request the remote node context will transition to the posting state.
91 *
92 * @SCI_RNC_POSTING: transition state that posts the RNi to the hardware. Once
93 * the RNC is posted the remote node context will be made ready.
94 *
95 * @SCI_RNC_INVALIDATING: transition state that will post an RNC invalidate to
96 * the hardware. Once the invalidate is complete the remote node context will
97 * transition to the posting state.
98 *
99 * @SCI_RNC_RESUMING: transition state that will post an RNC resume to the
100 * hardare. Once the event notification of resume complete is received the
101 * remote node context will transition to the ready state.
102 *
103 * @SCI_RNC_READY: state that the remote node context must be in to accept io
104 * request operations.
105 *
106 * @SCI_RNC_TX_SUSPENDED: state that the remote node context transitions to when
107 * it gets a TX suspend notification from the hardware.
108 *
109 * @SCI_RNC_TX_RX_SUSPENDED: state that the remote node context transitions to
110 * when it gets a TX RX suspend notification from the hardware.
111 *
112 * @SCI_RNC_AWAIT_SUSPENSION: wait state for the remote node context that waits
113 * for a suspend notification from the hardware. This state is entered when
114 * either there is a request to supend the remote node context or when there is
115 * a TC completion where the remote node will be suspended by the hardware.
89 */ 116 */
90enum scis_sds_remote_node_context_states { 117#define RNC_STATES {\
91 /** 118 C(RNC_INITIAL),\
92 * This state is the initial state for a remote node context. On a resume 119 C(RNC_POSTING),\
93 * request the remote node context will transition to the posting state. 120 C(RNC_INVALIDATING),\
94 */ 121 C(RNC_RESUMING),\
95 SCI_RNC_INITIAL, 122 C(RNC_READY),\
96 123 C(RNC_TX_SUSPENDED),\
97 /** 124 C(RNC_TX_RX_SUSPENDED),\
98 * This is a transition state that posts the RNi to the hardware. Once the RNC 125 C(RNC_AWAIT_SUSPENSION),\
99 * is posted the remote node context will be made ready. 126 }
100 */ 127#undef C
101 SCI_RNC_POSTING, 128#define C(a) SCI_##a
102 129enum scis_sds_remote_node_context_states RNC_STATES;
103 /** 130#undef C
104 * This is a transition state that will post an RNC invalidate to the 131const char *rnc_state_name(enum scis_sds_remote_node_context_states state);
105 * hardware. Once the invalidate is complete the remote node context will
106 * transition to the posting state.
107 */
108 SCI_RNC_INVALIDATING,
109
110 /**
111 * This is a transition state that will post an RNC resume to the hardare.
112 * Once the event notification of resume complete is received the remote node
113 * context will transition to the ready state.
114 */
115 SCI_RNC_RESUMING,
116
117 /**
118 * This is the state that the remote node context must be in to accept io
119 * request operations.
120 */
121 SCI_RNC_READY,
122
123 /**
124 * This is the state that the remote node context transitions to when it gets
125 * a TX suspend notification from the hardware.
126 */
127 SCI_RNC_TX_SUSPENDED,
128
129 /**
130 * This is the state that the remote node context transitions to when it gets
131 * a TX RX suspend notification from the hardware.
132 */
133 SCI_RNC_TX_RX_SUSPENDED,
134
135 /**
136 * This state is a wait state for the remote node context that waits for a
137 * suspend notification from the hardware. This state is entered when either
138 * there is a request to supend the remote node context or when there is a TC
139 * completion where the remote node will be suspended by the hardware.
140 */
141 SCI_RNC_AWAIT_SUSPENSION
142};
143 132
144/** 133/**
145 * 134 *
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 1a39ce50529..ab18ee0fe24 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -61,6 +61,16 @@
61#include "scu_event_codes.h" 61#include "scu_event_codes.h"
62#include "sas.h" 62#include "sas.h"
63 63
64#undef C
65#define C(a) (#a)
66const char *req_state_name(enum sci_base_request_states state)
67{
68 static const char * const strings[] = REQUEST_STATES;
69
70 return strings[state];
71}
72#undef C
73
64static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq, 74static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq,
65 int idx) 75 int idx)
66{ 76{
@@ -910,7 +920,8 @@ enum sci_status sci_request_complete(struct isci_request *ireq)
910 920
911 state = ireq->sm.current_state_id; 921 state = ireq->sm.current_state_id;
912 if (WARN_ONCE(state != SCI_REQ_COMPLETED, 922 if (WARN_ONCE(state != SCI_REQ_COMPLETED,
913 "isci: request completion from wrong state (%d)\n", state)) 923 "isci: request completion from wrong state (%s)\n",
924 req_state_name(state)))
914 return SCI_FAILURE_INVALID_STATE; 925 return SCI_FAILURE_INVALID_STATE;
915 926
916 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) 927 if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX)
@@ -931,8 +942,8 @@ enum sci_status sci_io_request_event_handler(struct isci_request *ireq,
931 state = ireq->sm.current_state_id; 942 state = ireq->sm.current_state_id;
932 943
933 if (state != SCI_REQ_STP_PIO_DATA_IN) { 944 if (state != SCI_REQ_STP_PIO_DATA_IN) {
934 dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %d\n", 945 dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %s\n",
935 __func__, event_code, state); 946 __func__, event_code, req_state_name(state));
936 947
937 return SCI_FAILURE_INVALID_STATE; 948 return SCI_FAILURE_INVALID_STATE;
938 } 949 }
@@ -2306,12 +2317,8 @@ sci_io_request_tc_completion(struct isci_request *ireq,
2306 return atapi_data_tc_completion_handler(ireq, completion_code); 2317 return atapi_data_tc_completion_handler(ireq, completion_code);
2307 2318
2308 default: 2319 default:
2309 dev_warn(&ihost->pdev->dev, 2320 dev_warn(&ihost->pdev->dev, "%s: %x in wrong state %s\n",
2310 "%s: SCIC IO Request given task completion " 2321 __func__, completion_code, req_state_name(state));
2311 "notification %x while in wrong state %d\n",
2312 __func__,
2313 completion_code,
2314 state);
2315 return SCI_FAILURE_INVALID_STATE; 2322 return SCI_FAILURE_INVALID_STATE;
2316 } 2323 }
2317} 2324}
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h
index bcf2f37f23e..057f2378452 100644
--- a/drivers/scsi/isci/request.h
+++ b/drivers/scsi/isci/request.h
@@ -182,134 +182,103 @@ static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req)
182} 182}
183 183
184/** 184/**
185 * enum sci_base_request_states - This enumeration depicts all the states for 185 * enum sci_base_request_states - request state machine states
186 * the common request state machine.
187 * 186 *
187 * @SCI_REQ_INIT: Simply the initial state for the base request state machine.
188 * 188 *
189 * @SCI_REQ_CONSTRUCTED: This state indicates that the request has been
190 * constructed. This state is entered from the INITIAL state.
191 *
192 * @SCI_REQ_STARTED: This state indicates that the request has been started.
193 * This state is entered from the CONSTRUCTED state.
194 *
195 * @SCI_REQ_STP_UDMA_WAIT_TC_COMP:
196 * @SCI_REQ_STP_UDMA_WAIT_D2H:
197 * @SCI_REQ_STP_NON_DATA_WAIT_H2D:
198 * @SCI_REQ_STP_NON_DATA_WAIT_D2H:
199 *
200 * @SCI_REQ_STP_PIO_WAIT_H2D: While in this state the IO request object is
201 * waiting for the TC completion notification for the H2D Register FIS
202 *
203 * @SCI_REQ_STP_PIO_WAIT_FRAME: While in this state the IO request object is
204 * waiting for either a PIO Setup FIS or a D2H register FIS. The type of frame
205 * received is based on the result of the prior frame and line conditions.
206 *
207 * @SCI_REQ_STP_PIO_DATA_IN: While in this state the IO request object is
208 * waiting for a DATA frame from the device.
209 *
210 * @SCI_REQ_STP_PIO_DATA_OUT: While in this state the IO request object is
211 * waiting to transmit the next data frame to the device.
212 *
213 * @SCI_REQ_ATAPI_WAIT_H2D: While in this state the IO request object is
214 * waiting for the TC completion notification for the H2D Register FIS
215 *
216 * @SCI_REQ_ATAPI_WAIT_PIO_SETUP: While in this state the IO request object is
217 * waiting for either a PIO Setup.
218 *
219 * @SCI_REQ_ATAPI_WAIT_D2H: The non-data IO transit to this state in this state
220 * after receiving TC completion. While in this state IO request object is
221 * waiting for D2H status frame as UF.
222 *
223 * @SCI_REQ_ATAPI_WAIT_TC_COMP: When transmitting raw frames hardware reports
224 * task context completion after every frame submission, so in the
225 * non-accelerated case we need to expect the completion for the "cdb" frame.
226 *
227 * @SCI_REQ_TASK_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
228 * the started raw task management request is waiting for the transmission of
229 * the initial frame (i.e. command, task, etc.).
230 *
231 * @SCI_REQ_TASK_WAIT_TC_RESP: This sub-state indicates that the started task
232 * management request is waiting for the reception of an unsolicited frame
233 * (i.e. response IU).
234 *
235 * @SCI_REQ_SMP_WAIT_RESP: This sub-state indicates that the started task
236 * management request is waiting for the reception of an unsolicited frame
237 * (i.e. response IU).
238 *
239 * @SCI_REQ_SMP_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
240 * the started SMP request is waiting for the transmission of the initial frame
241 * (i.e. command, task, etc.).
242 *
243 * @SCI_REQ_COMPLETED: This state indicates that the request has completed.
244 * This state is entered from the STARTED state. This state is entered from the
245 * ABORTING state.
246 *
247 * @SCI_REQ_ABORTING: This state indicates that the request is in the process
248 * of being terminated/aborted. This state is entered from the CONSTRUCTED
249 * state. This state is entered from the STARTED state.
250 *
251 * @SCI_REQ_FINAL: Simply the final state for the base request state machine.
189 */ 252 */
190enum sci_base_request_states { 253#define REQUEST_STATES {\
191 /* 254 C(REQ_INIT),\
192 * Simply the initial state for the base request state machine. 255 C(REQ_CONSTRUCTED),\
193 */ 256 C(REQ_STARTED),\
194 SCI_REQ_INIT, 257 C(REQ_STP_UDMA_WAIT_TC_COMP),\
195 258 C(REQ_STP_UDMA_WAIT_D2H),\
196 /* 259 C(REQ_STP_NON_DATA_WAIT_H2D),\
197 * This state indicates that the request has been constructed. 260 C(REQ_STP_NON_DATA_WAIT_D2H),\
198 * This state is entered from the INITIAL state. 261 C(REQ_STP_PIO_WAIT_H2D),\
199 */ 262 C(REQ_STP_PIO_WAIT_FRAME),\
200 SCI_REQ_CONSTRUCTED, 263 C(REQ_STP_PIO_DATA_IN),\
201 264 C(REQ_STP_PIO_DATA_OUT),\
202 /* 265 C(REQ_ATAPI_WAIT_H2D),\
203 * This state indicates that the request has been started. This state 266 C(REQ_ATAPI_WAIT_PIO_SETUP),\
204 * is entered from the CONSTRUCTED state. 267 C(REQ_ATAPI_WAIT_D2H),\
205 */ 268 C(REQ_ATAPI_WAIT_TC_COMP),\
206 SCI_REQ_STARTED, 269 C(REQ_TASK_WAIT_TC_COMP),\
207 270 C(REQ_TASK_WAIT_TC_RESP),\
208 SCI_REQ_STP_UDMA_WAIT_TC_COMP, 271 C(REQ_SMP_WAIT_RESP),\
209 SCI_REQ_STP_UDMA_WAIT_D2H, 272 C(REQ_SMP_WAIT_TC_COMP),\
210 273 C(REQ_COMPLETED),\
211 SCI_REQ_STP_NON_DATA_WAIT_H2D, 274 C(REQ_ABORTING),\
212 SCI_REQ_STP_NON_DATA_WAIT_D2H, 275 C(REQ_FINAL),\
213 276 }
214 /* 277#undef C
215 * While in this state the IO request object is waiting for the TC 278#define C(a) SCI_##a
216 * completion notification for the H2D Register FIS 279enum sci_base_request_states REQUEST_STATES;
217 */ 280#undef C
218 SCI_REQ_STP_PIO_WAIT_H2D, 281const char *req_state_name(enum sci_base_request_states state);
219
220 /*
221 * While in this state the IO request object is waiting for either a
222 * PIO Setup FIS or a D2H register FIS. The type of frame received is
223 * based on the result of the prior frame and line conditions.
224 */
225 SCI_REQ_STP_PIO_WAIT_FRAME,
226
227 /*
228 * While in this state the IO request object is waiting for a DATA
229 * frame from the device.
230 */
231 SCI_REQ_STP_PIO_DATA_IN,
232
233 /*
234 * While in this state the IO request object is waiting to transmit
235 * the next data frame to the device.
236 */
237 SCI_REQ_STP_PIO_DATA_OUT,
238
239 /*
240 * While in this state the IO request object is waiting for the TC
241 * completion notification for the H2D Register FIS
242 */
243 SCI_REQ_ATAPI_WAIT_H2D,
244
245 /*
246 * While in this state the IO request object is waiting for either a
247 * PIO Setup.
248 */
249 SCI_REQ_ATAPI_WAIT_PIO_SETUP,
250
251 /*
252 * The non-data IO transit to this state in this state after receiving
253 * TC completion. While in this state IO request object is waiting for
254 * D2H status frame as UF.
255 */
256 SCI_REQ_ATAPI_WAIT_D2H,
257
258 /*
259 * When transmitting raw frames hardware reports task context completion
260 * after every frame submission, so in the non-accelerated case we need
261 * to expect the completion for the "cdb" frame.
262 */
263 SCI_REQ_ATAPI_WAIT_TC_COMP,
264
265 /*
266 * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
267 * task management request is waiting for the transmission of the
268 * initial frame (i.e. command, task, etc.).
269 */
270 SCI_REQ_TASK_WAIT_TC_COMP,
271
272 /*
273 * This sub-state indicates that the started task management request
274 * is waiting for the reception of an unsolicited frame
275 * (i.e. response IU).
276 */
277 SCI_REQ_TASK_WAIT_TC_RESP,
278
279 /*
280 * This sub-state indicates that the started task management request
281 * is waiting for the reception of an unsolicited frame
282 * (i.e. response IU).
283 */
284 SCI_REQ_SMP_WAIT_RESP,
285
286 /*
287 * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
288 * request is waiting for the transmission of the initial frame
289 * (i.e. command, task, etc.).
290 */
291 SCI_REQ_SMP_WAIT_TC_COMP,
292
293 /*
294 * This state indicates that the request has completed.
295 * This state is entered from the STARTED state. This state is entered
296 * from the ABORTING state.
297 */
298 SCI_REQ_COMPLETED,
299
300 /*
301 * This state indicates that the request is in the process of being
302 * terminated/aborted.
303 * This state is entered from the CONSTRUCTED state.
304 * This state is entered from the STARTED state.
305 */
306 SCI_REQ_ABORTING,
307
308 /*
309 * Simply the final state for the base request state machine.
310 */
311 SCI_REQ_FINAL,
312};
313 282
314enum sci_status sci_request_start(struct isci_request *ireq); 283enum sci_status sci_request_start(struct isci_request *ireq);
315enum sci_status sci_io_request_terminate(struct isci_request *ireq); 284enum sci_status sci_io_request_terminate(struct isci_request *ireq);