aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-04-21 21:14:45 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:00:38 -0400
commit57f20f4ed6fb702339be2ef4dea9d15e6a7d0d07 (patch)
treed31db747f233d5ea790e82b64e233ee762cf2cdf /drivers/scsi/isci
parent9614395ea2eed076fa8341df422582b0017d330c (diff)
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: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r--drivers/scsi/isci/core/scic_remote_device.h12
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_device.c15
-rw-r--r--drivers/scsi/isci/host.c2
-rw-r--r--drivers/scsi/isci/host.h11
-rw-r--r--drivers/scsi/isci/init.c5
-rw-r--r--drivers/scsi/isci/remote_device.c17
-rw-r--r--drivers/scsi/isci/remote_device.h9
-rw-r--r--drivers/scsi/isci/request.c12
-rw-r--r--drivers/scsi/isci/task.c20
9 files changed, 28 insertions, 75 deletions
diff --git a/drivers/scsi/isci/core/scic_remote_device.h b/drivers/scsi/isci/core/scic_remote_device.h
index 62fa7fd572c..23e90af5a01 100644
--- a/drivers/scsi/isci/core/scic_remote_device.h
+++ b/drivers/scsi/isci/core/scic_remote_device.h
@@ -87,18 +87,6 @@ enum scic_remote_device_not_ready_reason_code {
87}; 87};
88 88
89/** 89/**
90 * scic_remote_device_get_object_size() - This method simply returns the
91 * maximum memory space needed to store a remote device object.
92 *
93 * a positive integer value indicating the size (in bytes) of the remote device
94 * object.
95 */
96u32 scic_remote_device_get_object_size(
97 void);
98
99struct scic_sds_port;
100struct scic_sds_remote_device;
101/**
102 * scic_remote_device_construct() - This method will perform the construction 90 * scic_remote_device_construct() - This method will perform the construction
103 * common to all remote device objects. 91 * common to all remote device objects.
104 * @sci_port: SAS/SATA port through which this device is accessed. 92 * @sci_port: SAS/SATA port through which this device is accessed.
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c
index 22788bfcf9c..d314e2b2088 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_remote_device.c
@@ -71,21 +71,6 @@
71 71
72#define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000) 72#define SCIC_SDS_REMOTE_DEVICE_RESET_TIMEOUT (1000)
73 73
74/*
75 * *****************************************************************************
76 * * CORE REMOTE DEVICE PRIVATE METHODS
77 * ***************************************************************************** */
78
79/*
80 * *****************************************************************************
81 * * CORE REMOTE DEVICE PUBLIC METHODS
82 * ***************************************************************************** */
83
84u32 scic_remote_device_get_object_size(void)
85{
86 return sizeof (struct scic_sds_remote_device);
87}
88
89enum sci_status scic_remote_device_da_construct( 74enum sci_status scic_remote_device_da_construct(
90 struct scic_sds_remote_device *sci_dev) 75 struct scic_sds_remote_device *sci_dev)
91{ 76{
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 0d706b2ce25..3aceb9219d7 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -467,7 +467,7 @@ int isci_host_init(struct isci_host *isci_host)
467 isci_phy_init(&isci_host->phys[i], isci_host, i); 467 isci_phy_init(&isci_host->phys[i], isci_host, i);
468 468
469 for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { 469 for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) {
470 struct isci_remote_device *idev = idev_by_id(isci_host, i); 470 struct isci_remote_device *idev = &isci_host->devices[i];
471 471
472 INIT_LIST_HEAD(&idev->reqs_in_process); 472 INIT_LIST_HEAD(&idev->reqs_in_process);
473 INIT_LIST_HEAD(&idev->node); 473 INIT_LIST_HEAD(&idev->node);
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h
index 6e660744d8d..21bd7d88e5d 100644
--- a/drivers/scsi/isci/host.h
+++ b/drivers/scsi/isci/host.h
@@ -110,18 +110,9 @@ struct isci_host {
110 struct list_head requests_to_errorback; 110 struct list_head requests_to_errorback;
111 spinlock_t scic_lock; 111 spinlock_t scic_lock;
112 112
113 /* careful only access this via idev_by_id */ 113 struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES];
114 struct isci_remote_device devices[0];
115}; 114};
116 115
117static inline struct isci_remote_device *idev_by_id(struct isci_host *ihost, int i)
118{
119 void *p = ihost->devices;
120
121 return p + i * (sizeof(struct isci_remote_device) +
122 scic_remote_device_get_object_size());
123}
124
125/** 116/**
126 * struct isci_pci_info - This class represents the pci function containing the 117 * struct isci_pci_info - This class represents the pci function containing the
127 * controllers. Depending on PCI SKU, there could be up to 2 controllers in 118 * controllers. Depending on PCI SKU, there could be up to 2 controllers in
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index 5a9cd5fbeab..a23ea2c1c7d 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -396,10 +396,7 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
396 struct Scsi_Host *shost; 396 struct Scsi_Host *shost;
397 int err; 397 int err;
398 398
399 isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host) + 399 isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host), GFP_KERNEL);
400 SCI_MAX_REMOTE_DEVICES *
401 (sizeof(struct isci_remote_device) +
402 scic_remote_device_get_object_size()), GFP_KERNEL);
403 if (!isci_host) 400 if (!isci_host)
404 return NULL; 401 return NULL;
405 402
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 9301e25dff3..1553221fe4d 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -87,7 +87,7 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_
87 BUG(); 87 BUG();
88 } 88 }
89 89
90 scic_remote_device_destruct(to_sci_dev(idev)); 90 scic_remote_device_destruct(&idev->sci);
91 idev->domain_dev->lldd_dev = NULL; 91 idev->domain_dev->lldd_dev = NULL;
92 idev->domain_dev = NULL; 92 idev->domain_dev = NULL;
93 idev->isci_port = NULL; 93 idev->isci_port = NULL;
@@ -117,7 +117,7 @@ static enum sci_status isci_remote_device_construct(
117 117
118 /* let the core do it's common constuction. */ 118 /* let the core do it's common constuction. */
119 scic_remote_device_construct(port->sci_port_handle, 119 scic_remote_device_construct(port->sci_port_handle,
120 to_sci_dev(isci_device)); 120 &isci_device->sci);
121 121
122 /* let the core do it's device specific constuction. */ 122 /* let the core do it's device specific constuction. */
123 if (isci_device->domain_dev->parent && 123 if (isci_device->domain_dev->parent &&
@@ -183,11 +183,11 @@ static enum sci_status isci_remote_device_construct(
183 "%s: parent->dev_type = EDGE_DEV\n", 183 "%s: parent->dev_type = EDGE_DEV\n",
184 __func__); 184 __func__);
185 185
186 status = scic_remote_device_ea_construct(to_sci_dev(isci_device), 186 status = scic_remote_device_ea_construct(&isci_device->sci,
187 (struct smp_response_discover *)&discover_response); 187 (struct smp_response_discover *)&discover_response);
188 188
189 } else 189 } else
190 status = scic_remote_device_da_construct(to_sci_dev(isci_device)); 190 status = scic_remote_device_da_construct(&isci_device->sci);
191 191
192 192
193 if (status != SCI_SUCCESS) { 193 if (status != SCI_SUCCESS) {
@@ -200,10 +200,11 @@ static enum sci_status isci_remote_device_construct(
200 return status; 200 return status;
201 } 201 }
202 202
203 sci_object_set_association(to_sci_dev(isci_device), isci_device); 203 /* XXX will be killed with sci_base_object removal */
204 sci_object_set_association(&isci_device->sci, isci_device);
204 205
205 /* start the device. */ 206 /* start the device. */
206 status = scic_remote_device_start(to_sci_dev(isci_device), 207 status = scic_remote_device_start(&isci_device->sci,
207 ISCI_REMOTE_DEVICE_START_TIMEOUT); 208 ISCI_REMOTE_DEVICE_START_TIMEOUT);
208 209
209 if (status != SCI_SUCCESS) { 210 if (status != SCI_SUCCESS) {
@@ -245,7 +246,7 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport)
245 int i; 246 int i;
246 247
247 for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { 248 for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) {
248 idev = idev_by_id(ihost, i); 249 idev = &ihost->devices[i];
249 if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) 250 if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags))
250 break; 251 break;
251 } 252 }
@@ -374,7 +375,7 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_rem
374 set_bit(IDEV_STOP_PENDING, &idev->flags); 375 set_bit(IDEV_STOP_PENDING, &idev->flags);
375 376
376 spin_lock_irqsave(&ihost->scic_lock, flags); 377 spin_lock_irqsave(&ihost->scic_lock, flags);
377 status = scic_remote_device_stop(to_sci_dev(idev), 50); 378 status = scic_remote_device_stop(&idev->sci, 50);
378 spin_unlock_irqrestore(&ihost->scic_lock, flags); 379 spin_unlock_irqrestore(&ihost->scic_lock, flags);
379 380
380 /* Wait for the stop complete callback. */ 381 /* Wait for the stop complete callback. */
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h
index 9925316ac55..aeda39568a1 100644
--- a/drivers/scsi/isci/remote_device.h
+++ b/drivers/scsi/isci/remote_device.h
@@ -55,9 +55,9 @@
55 55
56#if !defined(_ISCI_REMOTE_DEVICE_H_) 56#if !defined(_ISCI_REMOTE_DEVICE_H_)
57#define _ISCI_REMOTE_DEVICE_H_ 57#define _ISCI_REMOTE_DEVICE_H_
58#include "scic_sds_remote_device.h"
58 59
59struct isci_host; 60struct isci_host;
60struct scic_sds_remote_device;
61 61
62struct isci_remote_device { 62struct isci_remote_device {
63 enum isci_status status; 63 enum isci_status status;
@@ -70,14 +70,9 @@ struct isci_remote_device {
70 struct list_head node; 70 struct list_head node;
71 struct list_head reqs_in_process; 71 struct list_head reqs_in_process;
72 spinlock_t state_lock; 72 spinlock_t state_lock;
73 struct scic_sds_remote_device sci;
73}; 74};
74 75
75static inline struct scic_sds_remote_device *to_sci_dev(struct isci_remote_device *idev)
76{
77 /* core data is an opaque buffer at the end of the idev */
78 return (struct scic_sds_remote_device *) &idev[1];
79}
80
81#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 76#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
82 77
83void isci_remote_device_start_complete(struct isci_host *ihost, 78void isci_remote_device_start_complete(struct isci_host *ihost,
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index a90c299b723..8d2125b520e 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -179,7 +179,7 @@ static enum sci_status isci_io_request_build(
179 struct smp_discover_response_protocols dev_protocols; 179 struct smp_discover_response_protocols dev_protocols;
180 enum sci_status status = SCI_SUCCESS; 180 enum sci_status status = SCI_SUCCESS;
181 struct sas_task *task = isci_request_access_task(request); 181 struct sas_task *task = isci_request_access_task(request);
182 struct scic_sds_remote_device *sci_device = to_sci_dev(isci_device); 182 struct scic_sds_remote_device *sci_device = &isci_device->sci;
183 183
184 dev_dbg(&isci_host->pdev->dev, 184 dev_dbg(&isci_host->pdev->dev,
185 "%s: isci_device = 0x%p; request = %p, " 185 "%s: isci_device = 0x%p; request = %p, "
@@ -380,7 +380,7 @@ int isci_request_execute(
380 unsigned long flags; 380 unsigned long flags;
381 381
382 isci_device = task->dev->lldd_dev; 382 isci_device = task->dev->lldd_dev;
383 sci_device = to_sci_dev(isci_device); 383 sci_device = &isci_device->sci;
384 384
385 /* do common allocation and init of request object. */ 385 /* do common allocation and init of request object. */
386 ret = isci_request_alloc_io( 386 ret = isci_request_alloc_io(
@@ -1194,11 +1194,9 @@ void isci_request_io_request_complete(
1194 ); 1194 );
1195 1195
1196 /* complete the io request to the core. */ 1196 /* complete the io request to the core. */
1197 scic_controller_complete_io( 1197 scic_controller_complete_io(isci_host->core_controller,
1198 isci_host->core_controller, 1198 &isci_device->sci,
1199 to_sci_dev(isci_device), 1199 request->sci_request_handle);
1200 request->sci_request_handle
1201 );
1202 /* NULL the request handle so it cannot be completed or 1200 /* NULL the request handle so it cannot be completed or
1203 * terminated again, and to cause any calls into abort 1201 * terminated again, and to cause any calls into abort
1204 * task to recognize the already completed case. 1202 * task to recognize the already completed case.
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index c79968db871..f54f523b8d4 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -282,7 +282,7 @@ static enum sci_status isci_task_request_build(
282 "%s: isci_tmf = %p\n", __func__, isci_tmf); 282 "%s: isci_tmf = %p\n", __func__, isci_tmf);
283 283
284 isci_device = isci_tmf->device; 284 isci_device = isci_tmf->device;
285 sci_device = to_sci_dev(isci_device); 285 sci_device = &isci_device->sci;
286 286
287 /* do common allocation and init of request object. */ 287 /* do common allocation and init of request object. */
288 status = isci_request_alloc_tmf( 288 status = isci_request_alloc_tmf(
@@ -390,7 +390,7 @@ static void isci_tmf_timeout_cb(void *tmf_request_arg)
390 /* Terminate the TMF transmit request. */ 390 /* Terminate the TMF transmit request. */
391 status = scic_controller_terminate_request( 391 status = scic_controller_terminate_request(
392 request->isci_host->core_controller, 392 request->isci_host->core_controller,
393 to_sci_dev(request->isci_device), 393 &request->isci_device->sci,
394 request->sci_request_handle 394 request->sci_request_handle
395 ); 395 );
396 396
@@ -448,7 +448,7 @@ int isci_task_execute_tmf(
448 "%s: isci_device = %p\n", 448 "%s: isci_device = %p\n",
449 __func__, isci_device); 449 __func__, isci_device);
450 450
451 sci_device = to_sci_dev(isci_device); 451 sci_device = &isci_device->sci;
452 452
453 /* Assign the pointer to the TMF's completion kernel wait structure. */ 453 /* Assign the pointer to the TMF's completion kernel wait structure. */
454 tmf->complete = &completion; 454 tmf->complete = &completion;
@@ -784,9 +784,8 @@ static void isci_terminate_request_core(
784 needs_cleanup_handling = true; 784 needs_cleanup_handling = true;
785 status = scic_controller_terminate_request( 785 status = scic_controller_terminate_request(
786 isci_host->core_controller, 786 isci_host->core_controller,
787 to_sci_dev(isci_device), 787 &isci_device->sci,
788 isci_request->sci_request_handle 788 isci_request->sci_request_handle);
789 );
790 } 789 }
791 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 790 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
792 791
@@ -1483,9 +1482,8 @@ void isci_task_request_complete(
1483 1482
1484 scic_controller_complete_io( 1483 scic_controller_complete_io(
1485 isci_host->core_controller, 1484 isci_host->core_controller,
1486 to_sci_dev(isci_device), 1485 &isci_device->sci,
1487 request->sci_request_handle 1486 request->sci_request_handle);
1488 );
1489 /* NULL the request handle to make sure it cannot be terminated 1487 /* NULL the request handle to make sure it cannot be terminated
1490 * or completed again. 1488 * or completed again.
1491 */ 1489 */
@@ -1611,7 +1609,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd)
1611 } 1609 }
1612 1610
1613 spin_lock_irqsave(&isci_host->scic_lock, flags); 1611 spin_lock_irqsave(&isci_host->scic_lock, flags);
1614 status = scic_remote_device_reset(to_sci_dev(isci_dev)); 1612 status = scic_remote_device_reset(&isci_dev->sci);
1615 if (status != SCI_SUCCESS) { 1613 if (status != SCI_SUCCESS) {
1616 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 1614 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
1617 1615
@@ -1645,7 +1643,7 @@ int isci_bus_reset_handler(struct scsi_cmnd *cmd)
1645 1643
1646 /* WHAT TO DO HERE IF sas_phy_reset FAILS? */ 1644 /* WHAT TO DO HERE IF sas_phy_reset FAILS? */
1647 spin_lock_irqsave(&isci_host->scic_lock, flags); 1645 spin_lock_irqsave(&isci_host->scic_lock, flags);
1648 status = scic_remote_device_reset_complete(to_sci_dev(isci_dev)); 1646 status = scic_remote_device_reset_complete(&isci_dev->sci);
1649 spin_unlock_irqrestore(&isci_host->scic_lock, flags); 1647 spin_unlock_irqrestore(&isci_host->scic_lock, flags);
1650 1648
1651 if (status != SCI_SUCCESS) { 1649 if (status != SCI_SUCCESS) {