Commit 037afc78 authored by Dan Williams's avatar Dan Williams

isci: cleanup isci_remote_device[_not]_ready interface

Require a valid isci_host in support of the general cleanup to not
re-lookup the host via potentially fragile methods when more robust
methods are available.  Also cleans up some more casting that should be
using container_of() to up-cast a base structure in a more type-safe
manner.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent ed8a72d1
...@@ -1513,23 +1513,18 @@ static void scic_sds_remote_device_stopped_state_enter( ...@@ -1513,23 +1513,18 @@ static void scic_sds_remote_device_stopped_state_enter(
* sets the starting state handlers, sets the device not ready, and posts the * sets the starting state handlers, sets the device not ready, and posts the
* remote node context to the hardware. none * remote node context to the hardware. none
*/ */
static void scic_sds_remote_device_starting_state_enter( static void scic_sds_remote_device_starting_state_enter(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_controller *scic; struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
struct scic_sds_remote_device *sci_dev = parent.parent);
(struct scic_sds_remote_device *)object; struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
scic = scic_sds_remote_device_get_controller(sci_dev); SET_STATE_HANDLER(sci_dev, scic_sds_remote_device_state_handler_table,
SET_STATE_HANDLER(
sci_dev,
scic_sds_remote_device_state_handler_table,
SCI_BASE_REMOTE_DEVICE_STATE_STARTING); SCI_BASE_REMOTE_DEVICE_STATE_STARTING);
isci_remote_device_not_ready( isci_remote_device_not_ready(ihost, idev,
idev,
SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED);
} }
...@@ -1556,14 +1551,13 @@ static void scic_sds_remote_device_starting_state_exit(struct sci_base_object *o ...@@ -1556,14 +1551,13 @@ static void scic_sds_remote_device_starting_state_exit(struct sci_base_object *o
* This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets * This is the enter function for the SCI_BASE_REMOTE_DEVICE_STATE_READY it sets
* the ready state handlers, and starts the ready substate machine. none * the ready state handlers, and starts the ready substate machine. none
*/ */
static void scic_sds_remote_device_ready_state_enter( static void scic_sds_remote_device_ready_state_enter(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)object; parent.parent);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
struct scic_sds_controller *scic
= scic_sds_remote_device_get_controller(sci_dev);
SET_STATE_HANDLER(sci_dev, SET_STATE_HANDLER(sci_dev,
scic_sds_remote_device_state_handler_table, scic_sds_remote_device_state_handler_table,
...@@ -1574,7 +1568,7 @@ static void scic_sds_remote_device_ready_state_enter( ...@@ -1574,7 +1568,7 @@ static void scic_sds_remote_device_ready_state_enter(
if (sci_dev->has_ready_substate_machine) if (sci_dev->has_ready_substate_machine)
sci_base_state_machine_start(&sci_dev->ready_substate_machine); sci_base_state_machine_start(&sci_dev->ready_substate_machine);
else else
isci_remote_device_ready(idev); isci_remote_device_ready(ihost, idev);
} }
/** /**
...@@ -1588,16 +1582,18 @@ static void scic_sds_remote_device_ready_state_enter( ...@@ -1588,16 +1582,18 @@ static void scic_sds_remote_device_ready_state_enter(
static void scic_sds_remote_device_ready_state_exit( static void scic_sds_remote_device_ready_state_exit(
struct sci_base_object *object) struct sci_base_object *object)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)object; parent.parent);
struct isci_remote_device *idev = sci_object_get_association(sci_dev);
if (sci_dev->has_ready_substate_machine) if (sci_dev->has_ready_substate_machine)
sci_base_state_machine_stop(&sci_dev->ready_substate_machine); sci_base_state_machine_stop(&sci_dev->ready_substate_machine);
else else {
isci_remote_device_not_ready( struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
idev, struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev);
isci_remote_device_not_ready(ihost, idev,
SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED); SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED);
}
} }
/** /**
......
...@@ -253,20 +253,19 @@ static const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev ...@@ -253,20 +253,19 @@ static const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev
* This function sets the ready cmd substate handlers and reports the device as * This function sets the ready cmd substate handlers and reports the device as
* ready. none * ready. none
*/ */
static inline void scic_sds_smp_remote_device_ready_idle_substate_enter( static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)object; parent.parent);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
SET_STATE_HANDLER(sci_dev,
SET_STATE_HANDLER(
sci_dev,
scic_sds_smp_remote_device_ready_substate_handler_table, scic_sds_smp_remote_device_ready_substate_handler_table,
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
isci_remote_device_ready(idev); isci_remote_device_ready(ihost, idev);
} }
/** /**
...@@ -281,19 +280,19 @@ static inline void scic_sds_smp_remote_device_ready_idle_substate_enter( ...@@ -281,19 +280,19 @@ static inline void scic_sds_smp_remote_device_ready_idle_substate_enter(
static void scic_sds_smp_remote_device_ready_cmd_substate_enter( static void scic_sds_smp_remote_device_ready_cmd_substate_enter(
struct sci_base_object *object) struct sci_base_object *object)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)object; parent.parent);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
SET_STATE_HANDLER( SET_STATE_HANDLER(sci_dev,
sci_dev,
scic_sds_smp_remote_device_ready_substate_handler_table, scic_sds_smp_remote_device_ready_substate_handler_table,
SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD); SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
isci_remote_device_not_ready( isci_remote_device_not_ready(ihost, idev,
idev,
SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED);
} }
...@@ -304,12 +303,11 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter( ...@@ -304,12 +303,11 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(
* *
* This is the SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_CMD exit method. none * This is the SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_CMD exit method. none
*/ */
static void scic_sds_smp_remote_device_ready_cmd_substate_exit( static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_object *object)
struct sci_base_object *object)
{ {
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)object; struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
parent.parent);
this_device->working_request = NULL; sci_dev->working_request = NULL;
} }
/* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */
......
...@@ -677,13 +677,13 @@ static const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_dev ...@@ -677,13 +677,13 @@ static const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_dev
* * STP REMOTE DEVICE READY SUBSTATE PRIVATE METHODS * * STP REMOTE DEVICE READY SUBSTATE PRIVATE METHODS
* ***************************************************************************** */ * ***************************************************************************** */
static inline void static void
scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler( scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *user_cookie)
void *user_cookie)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = user_cookie;
(struct scic_sds_remote_device *)user_cookie;
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
/* /*
* For NCQ operation we do not issue a * For NCQ operation we do not issue a
...@@ -692,7 +692,7 @@ scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler( ...@@ -692,7 +692,7 @@ scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(
*/ */
if (sci_dev->ready_substate_machine.previous_state_id != if (sci_dev->ready_substate_machine.previous_state_id !=
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ) SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ)
isci_remote_device_ready(idev); isci_remote_device_ready(ihost, idev);
} }
/* /*
...@@ -737,87 +737,48 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter( ...@@ -737,87 +737,48 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(
} }
} }
/* static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_object *object)
* *****************************************************************************
* * STP REMOTE DEVICE READY CMD SUBSTATE
* ***************************************************************************** */
/**
*
* @device: This is the SCI base object which is cast into a
* struct scic_sds_remote_device object.
*
*/
static inline void scic_sds_stp_remote_device_ready_cmd_substate_enter(
struct sci_base_object *device)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)device; parent.parent);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
SET_STATE_HANDLER( SET_STATE_HANDLER(sci_dev,
sci_dev,
scic_sds_stp_remote_device_ready_substate_handler_table, scic_sds_stp_remote_device_ready_substate_handler_table,
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD); SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
isci_remote_device_not_ready( isci_remote_device_not_ready(ihost, idev,
idev,
SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED);
} }
/* static void scic_sds_stp_remote_device_ready_ncq_substate_enter(struct sci_base_object *object)
* *****************************************************************************
* * STP REMOTE DEVICE READY NCQ SUBSTATE
* ***************************************************************************** */
/**
*
* @device: This is the SCI base object which is cast into a
* struct scic_sds_remote_device object.
*
*/
static void scic_sds_stp_remote_device_ready_ncq_substate_enter(
struct sci_base_object *device)
{ {
struct scic_sds_remote_device *this_device; struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
parent.parent);
this_device = (struct scic_sds_remote_device *)device; SET_STATE_HANDLER(sci_dev,
SET_STATE_HANDLER(
this_device,
scic_sds_stp_remote_device_ready_substate_handler_table, scic_sds_stp_remote_device_ready_substate_handler_table,
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ);
);
} }
/* static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_object *object)
* *****************************************************************************
* * STP REMOTE DEVICE READY NCQ ERROR SUBSTATE
* ***************************************************************************** */
/**
*
* @device: This is the SCI base object which is cast into a
* struct scic_sds_remote_device object.
*
*/
static inline void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(
struct sci_base_object *device)
{ {
struct scic_sds_remote_device *sci_dev = struct scic_sds_remote_device *sci_dev = container_of(object, typeof(*sci_dev),
(struct scic_sds_remote_device *)device; parent.parent);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = sci_object_get_association(scic);
struct isci_remote_device *idev = sci_object_get_association(sci_dev); struct isci_remote_device *idev = sci_object_get_association(sci_dev);
SET_STATE_HANDLER( SET_STATE_HANDLER(sci_dev,
sci_dev,
scic_sds_stp_remote_device_ready_substate_handler_table, scic_sds_stp_remote_device_ready_substate_handler_table,
SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR);
if (sci_dev->not_ready_reason == if (sci_dev->not_ready_reason ==
SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED) SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED)
isci_remote_device_not_ready(idev, sci_dev->not_ready_reason); isci_remote_device_not_ready(ihost, idev, sci_dev->not_ready_reason);
} }
/* /*
......
...@@ -281,13 +281,12 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport) ...@@ -281,13 +281,12 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport)
* isci_remote_device_ready() - This function is called by the scic when the * isci_remote_device_ready() - This function is called by the scic when the
* remote device is ready. We mark the isci device as ready and signal the * remote device is ready. We mark the isci device as ready and signal the
* waiting proccess. * waiting proccess.
* @idev: This parameter specifies the remote device * @ihost: our valid isci_host
* @idev: remote device
* *
*/ */
void isci_remote_device_ready(struct isci_remote_device *idev) void isci_remote_device_ready(struct isci_host *ihost, struct isci_remote_device *idev)
{ {
struct isci_host *ihost = idev->isci_port->isci_host;
dev_dbg(&ihost->pdev->dev, dev_dbg(&ihost->pdev->dev,
"%s: idev = %p\n", __func__, idev); "%s: idev = %p\n", __func__, idev);
...@@ -304,18 +303,17 @@ void isci_remote_device_ready(struct isci_remote_device *idev) ...@@ -304,18 +303,17 @@ void isci_remote_device_ready(struct isci_remote_device *idev)
* @isci_device: This parameter specifies the remote device * @isci_device: This parameter specifies the remote device
* *
*/ */
void isci_remote_device_not_ready( void isci_remote_device_not_ready(struct isci_host *ihost,
struct isci_remote_device *isci_device, struct isci_remote_device *idev, u32 reason)
u32 reason_code)
{ {
dev_dbg(&isci_device->isci_port->isci_host->pdev->dev, dev_dbg(&ihost->pdev->dev,
"%s: isci_device = %p\n", __func__, isci_device); "%s: isci_device = %p\n", __func__, idev);
if (reason_code == SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED) if (reason == SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED)
isci_remote_device_change_state(isci_device, isci_stopping); isci_remote_device_change_state(idev, isci_stopping);
else else
/* device ready is actually a "not ready for io" state. */ /* device ready is actually a "not ready for io" state. */
isci_remote_device_change_state(isci_device, isci_ready); isci_remote_device_change_state(idev, isci_ready);
} }
/** /**
......
...@@ -109,12 +109,11 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, ...@@ -109,12 +109,11 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost,
void isci_remote_device_nuke_requests( void isci_remote_device_nuke_requests(
struct isci_remote_device *isci_device); struct isci_remote_device *isci_device);
void isci_remote_device_ready( void isci_remote_device_ready(struct isci_host *ihost,
struct isci_remote_device *); struct isci_remote_device *idev);
void isci_remote_device_not_ready( void isci_remote_device_not_ready(struct isci_host *ihost,
struct isci_remote_device *, struct isci_remote_device *idev, u32 reason);
u32);
void isci_remote_device_gone( void isci_remote_device_gone(
struct domain_device *domain_dev); struct domain_device *domain_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment