aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/remote_device.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-01 17:05:57 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:44 -0400
commiteb229671b1310c996dba7b78e21a9a9474edccdc (patch)
tree0e9a06eadb442ed9015dbfd8e89ce32388ed690e /drivers/scsi/isci/remote_device.c
parentf619fffb4070a577524fd9eb68cea484d86d2b97 (diff)
isci: unify remote_device start_handlers
Implement all states in scic_remote_device_start() and delete the state handler. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/remote_device.c')
-rw-r--r--drivers/scsi/isci/remote_device.c77
1 files changed, 21 insertions, 56 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 3e567bf84c74..80eccdc1090f 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -291,7 +291,7 @@ static void scic_sds_cb_remote_device_rnc_destruct_complete(void *_dev)
291 * ready state. This is the indication that the remote device object can also 291 * ready state. This is the indication that the remote device object can also
292 * transition to ready. 292 * transition to ready.
293 */ 293 */
294static void scic_sds_remote_device_resume_complete_handler(void *_dev) 294static void remote_device_resume_done(void *_dev)
295{ 295{
296 struct scic_sds_remote_device *sci_dev = _dev; 296 struct scic_sds_remote_device *sci_dev = _dev;
297 enum scic_sds_remote_device_states state; 297 enum scic_sds_remote_device_states state;
@@ -409,12 +409,6 @@ default_device_handler(struct scic_sds_remote_device *sci_dev,
409 return SCI_FAILURE_INVALID_STATE; 409 return SCI_FAILURE_INVALID_STATE;
410} 410}
411 411
412static enum sci_status scic_sds_remote_device_default_start_handler(
413 struct scic_sds_remote_device *sci_dev)
414{
415 return default_device_handler(sci_dev, __func__);
416}
417
418static enum sci_status scic_sds_remote_device_default_stop_handler( 412static enum sci_status scic_sds_remote_device_default_stop_handler(
419 struct scic_sds_remote_device *sci_dev) 413 struct scic_sds_remote_device *sci_dev)
420{ 414{
@@ -652,38 +646,6 @@ static enum sci_status scic_sds_remote_device_general_event_handler(
652 true); 646 true);
653} 647}
654 648
655/*
656 * *****************************************************************************
657 * * STOPPED STATE HANDLERS
658 * ***************************************************************************** */
659
660/**
661 *
662 * @device:
663 *
664 * This method takes the struct scic_sds_remote_device from a stopped state and
665 * attempts to start it. The RNC buffer for the device is constructed and the
666 * device state machine is transitioned to the
667 * SCIC_BASE_REMOTE_DEVICE_STATE_STARTING. enum sci_status SCI_SUCCESS if there is
668 * an RNC buffer available to construct the remote device.
669 * SCI_FAILURE_INSUFFICIENT_RESOURCES if there is no RNC buffer available in
670 * which to construct the remote device.
671 */
672static enum sci_status scic_sds_remote_device_stopped_state_start_handler(
673 struct scic_sds_remote_device *sci_dev)
674{
675 enum sci_status status;
676
677 status = scic_sds_remote_node_context_resume(&sci_dev->rnc,
678 scic_sds_remote_device_resume_complete_handler, sci_dev);
679
680 if (status == SCI_SUCCESS)
681 sci_base_state_machine_change_state(&sci_dev->state_machine,
682 SCI_BASE_REMOTE_DEVICE_STATE_STARTING);
683
684 return status;
685}
686
687static enum sci_status scic_sds_remote_device_stopped_state_stop_handler( 649static enum sci_status scic_sds_remote_device_stopped_state_stop_handler(
688 struct scic_sds_remote_device *sci_dev) 650 struct scic_sds_remote_device *sci_dev)
689{ 651{
@@ -1373,7 +1335,6 @@ static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_frame_handl
1373 1335
1374static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { 1336static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = {
1375 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { 1337 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = {
1376 .start_handler = scic_sds_remote_device_default_start_handler,
1377 .stop_handler = scic_sds_remote_device_default_stop_handler, 1338 .stop_handler = scic_sds_remote_device_default_stop_handler,
1378 .fail_handler = scic_sds_remote_device_default_fail_handler, 1339 .fail_handler = scic_sds_remote_device_default_fail_handler,
1379 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1340 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1390,7 +1351,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1390 .frame_handler = scic_sds_remote_device_default_frame_handler 1351 .frame_handler = scic_sds_remote_device_default_frame_handler
1391 }, 1352 },
1392 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { 1353 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = {
1393 .start_handler = scic_sds_remote_device_stopped_state_start_handler,
1394 .stop_handler = scic_sds_remote_device_stopped_state_stop_handler, 1354 .stop_handler = scic_sds_remote_device_stopped_state_stop_handler,
1395 .fail_handler = scic_sds_remote_device_default_fail_handler, 1355 .fail_handler = scic_sds_remote_device_default_fail_handler,
1396 .destruct_handler = scic_sds_remote_device_stopped_state_destruct_handler, 1356 .destruct_handler = scic_sds_remote_device_stopped_state_destruct_handler,
@@ -1407,7 +1367,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1407 .frame_handler = scic_sds_remote_device_default_frame_handler 1367 .frame_handler = scic_sds_remote_device_default_frame_handler
1408 }, 1368 },
1409 [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { 1369 [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = {
1410 .start_handler = scic_sds_remote_device_default_start_handler,
1411 .stop_handler = scic_sds_remote_device_starting_state_stop_handler, 1370 .stop_handler = scic_sds_remote_device_starting_state_stop_handler,
1412 .fail_handler = scic_sds_remote_device_default_fail_handler, 1371 .fail_handler = scic_sds_remote_device_default_fail_handler,
1413 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1372 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1424,7 +1383,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1424 .frame_handler = scic_sds_remote_device_default_frame_handler 1383 .frame_handler = scic_sds_remote_device_default_frame_handler
1425 }, 1384 },
1426 [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { 1385 [SCI_BASE_REMOTE_DEVICE_STATE_READY] = {
1427 .start_handler = scic_sds_remote_device_default_start_handler,
1428 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1386 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1429 .fail_handler = scic_sds_remote_device_default_fail_handler, 1387 .fail_handler = scic_sds_remote_device_default_fail_handler,
1430 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1388 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1441,7 +1399,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1441 .frame_handler = scic_sds_remote_device_general_frame_handler, 1399 .frame_handler = scic_sds_remote_device_general_frame_handler,
1442 }, 1400 },
1443 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 1401 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
1444 .start_handler = scic_sds_remote_device_default_start_handler,
1445 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1402 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1446 .fail_handler = scic_sds_remote_device_default_fail_handler, 1403 .fail_handler = scic_sds_remote_device_default_fail_handler,
1447 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1404 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1458,7 +1415,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1458 .frame_handler = scic_sds_remote_device_default_frame_handler 1415 .frame_handler = scic_sds_remote_device_default_frame_handler
1459 }, 1416 },
1460 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { 1417 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = {
1461 .start_handler = scic_sds_remote_device_default_start_handler,
1462 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1418 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1463 .fail_handler = scic_sds_remote_device_default_fail_handler, 1419 .fail_handler = scic_sds_remote_device_default_fail_handler,
1464 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1420 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1475,7 +1431,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1475 .frame_handler = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler 1431 .frame_handler = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler
1476 }, 1432 },
1477 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { 1433 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = {
1478 .start_handler = scic_sds_remote_device_default_start_handler,
1479 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1434 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1480 .fail_handler = scic_sds_remote_device_default_fail_handler, 1435 .fail_handler = scic_sds_remote_device_default_fail_handler,
1481 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1436 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1492,7 +1447,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1492 .frame_handler = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler 1447 .frame_handler = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler
1493 }, 1448 },
1494 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { 1449 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = {
1495 .start_handler = scic_sds_remote_device_default_start_handler,
1496 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1450 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1497 .fail_handler = scic_sds_remote_device_default_fail_handler, 1451 .fail_handler = scic_sds_remote_device_default_fail_handler,
1498 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1452 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1509,7 +1463,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1509 .frame_handler = scic_sds_remote_device_general_frame_handler 1463 .frame_handler = scic_sds_remote_device_general_frame_handler
1510 }, 1464 },
1511 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { 1465 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = {
1512 .start_handler = scic_sds_remote_device_default_start_handler,
1513 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1466 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1514 .fail_handler = scic_sds_remote_device_default_fail_handler, 1467 .fail_handler = scic_sds_remote_device_default_fail_handler,
1515 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1468 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1526,7 +1479,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1526 .frame_handler = scic_sds_remote_device_general_frame_handler 1479 .frame_handler = scic_sds_remote_device_general_frame_handler
1527 }, 1480 },
1528 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 1481 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
1529 .start_handler = scic_sds_remote_device_default_start_handler,
1530 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1482 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1531 .fail_handler = scic_sds_remote_device_default_fail_handler, 1483 .fail_handler = scic_sds_remote_device_default_fail_handler,
1532 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1484 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1543,7 +1495,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1543 .frame_handler = scic_sds_remote_device_default_frame_handler 1495 .frame_handler = scic_sds_remote_device_default_frame_handler
1544 }, 1496 },
1545 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { 1497 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = {
1546 .start_handler = scic_sds_remote_device_default_start_handler,
1547 .stop_handler = scic_sds_remote_device_ready_state_stop_handler, 1498 .stop_handler = scic_sds_remote_device_ready_state_stop_handler,
1548 .fail_handler = scic_sds_remote_device_default_fail_handler, 1499 .fail_handler = scic_sds_remote_device_default_fail_handler,
1549 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1500 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1560,7 +1511,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1560 .frame_handler = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler 1511 .frame_handler = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler
1561 }, 1512 },
1562 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { 1513 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = {
1563 .start_handler = scic_sds_remote_device_default_start_handler,
1564 .stop_handler = scic_sds_remote_device_stopping_state_stop_handler, 1514 .stop_handler = scic_sds_remote_device_stopping_state_stop_handler,
1565 .fail_handler = scic_sds_remote_device_default_fail_handler, 1515 .fail_handler = scic_sds_remote_device_default_fail_handler,
1566 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1516 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1577,7 +1527,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1577 .frame_handler = scic_sds_remote_device_general_frame_handler 1527 .frame_handler = scic_sds_remote_device_general_frame_handler
1578 }, 1528 },
1579 [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { 1529 [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = {
1580 .start_handler = scic_sds_remote_device_default_start_handler,
1581 .stop_handler = scic_sds_remote_device_default_stop_handler, 1530 .stop_handler = scic_sds_remote_device_default_stop_handler,
1582 .fail_handler = scic_sds_remote_device_default_fail_handler, 1531 .fail_handler = scic_sds_remote_device_default_fail_handler,
1583 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1532 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1594,7 +1543,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1594 .frame_handler = scic_sds_remote_device_general_frame_handler 1543 .frame_handler = scic_sds_remote_device_general_frame_handler
1595 }, 1544 },
1596 [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { 1545 [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = {
1597 .start_handler = scic_sds_remote_device_default_start_handler,
1598 .stop_handler = scic_sds_remote_device_resetting_state_stop_handler, 1546 .stop_handler = scic_sds_remote_device_resetting_state_stop_handler,
1599 .fail_handler = scic_sds_remote_device_default_fail_handler, 1547 .fail_handler = scic_sds_remote_device_default_fail_handler,
1600 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1548 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -1611,7 +1559,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_
1611 .frame_handler = scic_sds_remote_device_general_frame_handler 1559 .frame_handler = scic_sds_remote_device_general_frame_handler
1612 }, 1560 },
1613 [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { 1561 [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = {
1614 .start_handler = scic_sds_remote_device_default_start_handler,
1615 .stop_handler = scic_sds_remote_device_default_stop_handler, 1562 .stop_handler = scic_sds_remote_device_default_stop_handler,
1616 .fail_handler = scic_sds_remote_device_default_fail_handler, 1563 .fail_handler = scic_sds_remote_device_default_fail_handler,
1617 .destruct_handler = scic_sds_remote_device_default_destruct_handler, 1564 .destruct_handler = scic_sds_remote_device_default_destruct_handler,
@@ -2129,9 +2076,27 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
2129 * the device when there have been no phys added to it. 2076 * the device when there have been no phys added to it.
2130 */ 2077 */
2131static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev, 2078static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev,
2132 u32 timeout) 2079 u32 timeout)
2133{ 2080{
2134 return sci_dev->state_handlers->start_handler(sci_dev); 2081 struct sci_base_state_machine *sm = &sci_dev->state_machine;
2082 enum scic_sds_remote_device_states state = sm->current_state_id;
2083 enum sci_status status;
2084
2085 if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) {
2086 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
2087 __func__, state);
2088 return SCI_FAILURE_INVALID_STATE;
2089 }
2090
2091 status = scic_sds_remote_node_context_resume(&sci_dev->rnc,
2092 remote_device_resume_done,
2093 sci_dev);
2094 if (status != SCI_SUCCESS)
2095 return status;
2096
2097 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STARTING);
2098
2099 return SCI_SUCCESS;
2135} 2100}
2136 2101
2137static enum sci_status isci_remote_device_construct(struct isci_port *iport, 2102static enum sci_status isci_remote_device_construct(struct isci_port *iport,