Commit 57f20f4e authored by Dan Williams's avatar Dan Williams

isci: unify remote_device data structures

Make it explicit that isci_remote_device and scic_sds_remote_device are
one in the same object.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 9614395e
...@@ -86,18 +86,6 @@ enum scic_remote_device_not_ready_reason_code { ...@@ -86,18 +86,6 @@ enum scic_remote_device_not_ready_reason_code {
}; };
/**
* scic_remote_device_get_object_size() - This method simply returns the
* maximum memory space needed to store a remote device object.
*
* a positive integer value indicating the size (in bytes) of the remote device
* object.
*/
u32 scic_remote_device_get_object_size(
void);
struct scic_sds_port;
struct scic_sds_remote_device;
/** /**
* scic_remote_device_construct() - This method will perform the construction * scic_remote_device_construct() - This method will perform the construction
* common to all remote device objects. * common to all remote device objects.
......
...@@ -71,21 +71,6 @@ ...@@ -71,21 +71,6 @@
#define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000) #define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000)
/*
* *****************************************************************************
* * CORE REMOTE DEVICE PRIVATE METHODS
* ***************************************************************************** */
/*
* *****************************************************************************
* * CORE REMOTE DEVICE PUBLIC METHODS
* ***************************************************************************** */
u32 scic_remote_device_get_object_size(void)
{
return sizeof (struct scic_sds_remote_device);
}
enum sci_status scic_remote_device_da_construct( enum sci_status scic_remote_device_da_construct(
struct scic_sds_remote_device *sci_dev) struct scic_sds_remote_device *sci_dev)
{ {
......
...@@ -467,7 +467,7 @@ int isci_host_init(struct isci_host *isci_host) ...@@ -467,7 +467,7 @@ int isci_host_init(struct isci_host *isci_host)
isci_phy_init(&isci_host->phys[i], isci_host, i); isci_phy_init(&isci_host->phys[i], isci_host, i);
for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) {
struct isci_remote_device *idev = idev_by_id(isci_host, i); struct isci_remote_device *idev = &isci_host->devices[i];
INIT_LIST_HEAD(&idev->reqs_in_process); INIT_LIST_HEAD(&idev->reqs_in_process);
INIT_LIST_HEAD(&idev->node); INIT_LIST_HEAD(&idev->node);
......
...@@ -110,18 +110,9 @@ struct isci_host { ...@@ -110,18 +110,9 @@ struct isci_host {
struct list_head requests_to_errorback; struct list_head requests_to_errorback;
spinlock_t scic_lock; spinlock_t scic_lock;
/* careful only access this via idev_by_id */ struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES];
struct isci_remote_device devices[0];
}; };
static inline struct isci_remote_device *idev_by_id(struct isci_host *ihost, int i)
{
void *p = ihost->devices;
return p + i * (sizeof(struct isci_remote_device) +
scic_remote_device_get_object_size());
}
/** /**
* struct isci_pci_info - This class represents the pci function containing the * struct isci_pci_info - This class represents the pci function containing the
* controllers. Depending on PCI SKU, there could be up to 2 controllers in * controllers. Depending on PCI SKU, there could be up to 2 controllers in
......
...@@ -396,10 +396,7 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) ...@@ -396,10 +396,7 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
struct Scsi_Host *shost; struct Scsi_Host *shost;
int err; int err;
isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host) + isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host), GFP_KERNEL);
SCI_MAX_REMOTE_DEVICES *
(sizeof(struct isci_remote_device) +
scic_remote_device_get_object_size()), GFP_KERNEL);
if (!isci_host) if (!isci_host)
return NULL; return NULL;
......
...@@ -87,7 +87,7 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_ ...@@ -87,7 +87,7 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_
BUG(); BUG();
} }
scic_remote_device_destruct(to_sci_dev(idev)); scic_remote_device_destruct(&idev->sci);
idev->domain_dev->lldd_dev = NULL; idev->domain_dev->lldd_dev = NULL;
idev->domain_dev = NULL; idev->domain_dev = NULL;
idev->isci_port = NULL; idev->isci_port = NULL;
...@@ -117,7 +117,7 @@ static enum sci_status isci_remote_device_construct( ...@@ -117,7 +117,7 @@ static enum sci_status isci_remote_device_construct(
/* let the core do it's common constuction. */ /* let the core do it's common constuction. */
scic_remote_device_construct(port->sci_port_handle, scic_remote_device_construct(port->sci_port_handle,
to_sci_dev(isci_device)); &isci_device->sci);
/* let the core do it's device specific constuction. */ /* let the core do it's device specific constuction. */
if (isci_device->domain_dev->parent && if (isci_device->domain_dev->parent &&
...@@ -183,11 +183,11 @@ static enum sci_status isci_remote_device_construct( ...@@ -183,11 +183,11 @@ static enum sci_status isci_remote_device_construct(
"%s: parent->dev_type = EDGE_DEV\n", "%s: parent->dev_type = EDGE_DEV\n",
__func__); __func__);
status = scic_remote_device_ea_construct(to_sci_dev(isci_device), status = scic_remote_device_ea_construct(&isci_device->sci,
(struct smp_response_discover *)&discover_response); (struct smp_response_discover *)&discover_response);
} else } else
status = scic_remote_device_da_construct(to_sci_dev(isci_device)); status = scic_remote_device_da_construct(&isci_device->sci);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
...@@ -200,10 +200,11 @@ static enum sci_status isci_remote_device_construct( ...@@ -200,10 +200,11 @@ static enum sci_status isci_remote_device_construct(
return status; return status;
} }
sci_object_set_association(to_sci_dev(isci_device), isci_device); /* XXX will be killed with sci_base_object removal */
sci_object_set_association(&isci_device->sci, isci_device);
/* start the device. */ /* start the device. */
status = scic_remote_device_start(to_sci_dev(isci_device), status = scic_remote_device_start(&isci_device->sci,
ISCI_REMOTE_DEVICE_START_TIMEOUT); ISCI_REMOTE_DEVICE_START_TIMEOUT);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
...@@ -245,7 +246,7 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport) ...@@ -245,7 +246,7 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport)
int i; int i;
for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) {
idev = idev_by_id(ihost, i); idev = &ihost->devices[i];
if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags))
break; break;
} }
...@@ -374,7 +375,7 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_rem ...@@ -374,7 +375,7 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_rem
set_bit(IDEV_STOP_PENDING, &idev->flags); set_bit(IDEV_STOP_PENDING, &idev->flags);
spin_lock_irqsave(&ihost->scic_lock, flags); spin_lock_irqsave(&ihost->scic_lock, flags);
status = scic_remote_device_stop(to_sci_dev(idev), 50); status = scic_remote_device_stop(&idev->sci, 50);
spin_unlock_irqrestore(&ihost->scic_lock, flags); spin_unlock_irqrestore(&ihost->scic_lock, flags);
/* Wait for the stop complete callback. */ /* Wait for the stop complete callback. */
......
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
#if !defined(_ISCI_REMOTE_DEVICE_H_) #if !defined(_ISCI_REMOTE_DEVICE_H_)
#define _ISCI_REMOTE_DEVICE_H_ #define _ISCI_REMOTE_DEVICE_H_
#include "scic_sds_remote_device.h"
struct isci_host; struct isci_host;
struct scic_sds_remote_device;
struct isci_remote_device { struct isci_remote_device {
enum isci_status status; enum isci_status status;
...@@ -70,14 +70,9 @@ struct isci_remote_device { ...@@ -70,14 +70,9 @@ struct isci_remote_device {
struct list_head node; struct list_head node;
struct list_head reqs_in_process; struct list_head reqs_in_process;
spinlock_t state_lock; spinlock_t state_lock;
struct scic_sds_remote_device sci;
}; };
static inline struct scic_sds_remote_device *to_sci_dev(struct isci_remote_device *idev)
{
/* core data is an opaque buffer at the end of the idev */
return (struct scic_sds_remote_device *) &idev[1];
}
#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
void isci_remote_device_start_complete(struct isci_host *ihost, void isci_remote_device_start_complete(struct isci_host *ihost,
......
...@@ -179,7 +179,7 @@ static enum sci_status isci_io_request_build( ...@@ -179,7 +179,7 @@ static enum sci_status isci_io_request_build(
struct smp_discover_response_protocols dev_protocols; struct smp_discover_response_protocols dev_protocols;
enum sci_status status = SCI_SUCCESS; enum sci_status status = SCI_SUCCESS;
struct sas_task *task = isci_request_access_task(request); struct sas_task *task = isci_request_access_task(request);
struct scic_sds_remote_device *sci_device = to_sci_dev(isci_device); struct scic_sds_remote_device *sci_device = &isci_device->sci;
dev_dbg(&isci_host->pdev->dev, dev_dbg(&isci_host->pdev->dev,
"%s: isci_device = 0x%p; request = %p, " "%s: isci_device = 0x%p; request = %p, "
...@@ -380,7 +380,7 @@ int isci_request_execute( ...@@ -380,7 +380,7 @@ int isci_request_execute(
unsigned long flags; unsigned long flags;
isci_device = task->dev->lldd_dev; isci_device = task->dev->lldd_dev;
sci_device = to_sci_dev(isci_device); sci_device = &isci_device->sci;
/* do common allocation and init of request object. */ /* do common allocation and init of request object. */
ret = isci_request_alloc_io( ret = isci_request_alloc_io(
...@@ -1194,11 +1194,9 @@ void isci_request_io_request_complete( ...@@ -1194,11 +1194,9 @@ void isci_request_io_request_complete(
); );
/* complete the io request to the core. */ /* complete the io request to the core. */
scic_controller_complete_io( scic_controller_complete_io(isci_host->core_controller,
isci_host->core_controller, &isci_device->sci,
to_sci_dev(isci_device), request->sci_request_handle);
request->sci_request_handle
);
/* NULL the request handle so it cannot be completed or /* NULL the request handle so it cannot be completed or
* terminated again, and to cause any calls into abort * terminated again, and to cause any calls into abort
* task to recognize the already completed case. * task to recognize the already completed case.
......
...@@ -282,7 +282,7 @@ static enum sci_status isci_task_request_build( ...@@ -282,7 +282,7 @@ static enum sci_status isci_task_request_build(
"%s: isci_tmf = %p\n", __func__, isci_tmf); "%s: isci_tmf = %p\n", __func__, isci_tmf);
isci_device = isci_tmf->device; isci_device = isci_tmf->device;
sci_device = to_sci_dev(isci_device); sci_device = &isci_device->sci;
/* do common allocation and init of request object. */ /* do common allocation and init of request object. */
status = isci_request_alloc_tmf( status = isci_request_alloc_tmf(
...@@ -390,7 +390,7 @@ static void isci_tmf_timeout_cb(void *tmf_request_arg) ...@@ -390,7 +390,7 @@ static void isci_tmf_timeout_cb(void *tmf_request_arg)
/* Terminate the TMF transmit request. */ /* Terminate the TMF transmit request. */
status = scic_controller_terminate_request( status = scic_controller_terminate_request(
request->isci_host->core_controller, request->isci_host->core_controller,
to_sci_dev(request->isci_device), &request->isci_device->sci,
request->sci_request_handle request->sci_request_handle
); );
...@@ -448,7 +448,7 @@ int isci_task_execute_tmf( ...@@ -448,7 +448,7 @@ int isci_task_execute_tmf(
"%s: isci_device = %p\n", "%s: isci_device = %p\n",
__func__, isci_device); __func__, isci_device);
sci_device = to_sci_dev(isci_device); sci_device = &isci_device->sci;
/* Assign the pointer to the TMF's completion kernel wait structure. */ /* Assign the pointer to the TMF's completion kernel wait structure. */
tmf->complete = &completion; tmf->complete = &completion;
...@@ -784,9 +784,8 @@ static void isci_terminate_request_core( ...@@ -784,9 +784,8 @@ static void isci_terminate_request_core(
needs_cleanup_handling = true; needs_cleanup_handling = true;
status = scic_controller_terminate_request( status = scic_controller_terminate_request(
isci_host->core_controller, isci_host->core_controller,
to_sci_dev(isci_device), &isci_device->sci,
isci_request->sci_request_handle isci_request->sci_request_handle);
);
} }
spin_unlock_irqrestore(&isci_host->scic_lock, flags); spin_unlock_irqrestore(&isci_host->scic_lock, flags);
...@@ -1483,9 +1482,8 @@ void isci_task_request_complete( ...@@ -1483,9 +1482,8 @@ void isci_task_request_complete(
scic_controller_complete_io( scic_controller_complete_io(
isci_host->core_controller, isci_host->core_controller,
to_sci_dev(isci_device), &isci_device->sci,
request->sci_request_handle request->sci_request_handle);
);
/* NULL the request handle to make sure it cannot be terminated /* NULL the request handle to make sure it cannot be terminated
* or completed again. * or completed again.
*/ */
...@@ -1611,7 +1609,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd) ...@@ -1611,7 +1609,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd)
} }
spin_lock_irqsave(&isci_host->scic_lock, flags); spin_lock_irqsave(&isci_host->scic_lock, flags);
status = scic_remote_device_reset(to_sci_dev(isci_dev)); status = scic_remote_device_reset(&isci_dev->sci);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
spin_unlock_irqrestore(&isci_host->scic_lock, flags); spin_unlock_irqrestore(&isci_host->scic_lock, flags);
...@@ -1645,7 +1643,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd) ...@@ -1645,7 +1643,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd)
/* WHAT TO DO HERE IF sas_phy_reset FAILS? */ /* WHAT TO DO HERE IF sas_phy_reset FAILS? */
spin_lock_irqsave(&isci_host->scic_lock, flags); spin_lock_irqsave(&isci_host->scic_lock, flags);
status = scic_remote_device_reset_complete(to_sci_dev(isci_dev)); status = scic_remote_device_reset_complete(&isci_dev->sci);
spin_unlock_irqrestore(&isci_host->scic_lock, flags); spin_unlock_irqrestore(&isci_host->scic_lock, flags);
if (status != SCI_SUCCESS) { if (status != SCI_SUCCESS) {
......
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