aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2011-02-23 18:57:27 -0500
committerDan Williams <dan.j.williams@intel.com>2011-07-03 06:55:28 -0400
commit6389a77596f36cf04ad8b1c7d43ec1d6cdfe89cb (patch)
tree71790cd9538bed25e1e448f83c6d92269993b2ae /drivers/scsi
parent103a00c200ab3bb9e598923eb7ba3354fcb3de8d (diff)
isci: have the driver use native SG calls and DMA-API
Remove abstraction for SG building and get rid of callbacks for getting DMA memory mapping. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/isci/core/sci_util.c15
-rw-r--r--drivers/scsi/isci/core/sci_util.h3
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.c208
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.h9
-rw-r--r--drivers/scsi/isci/core/scic_sds_smp_request.c119
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_packet_request.c20
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_request.c99
7 files changed, 245 insertions, 228 deletions
diff --git a/drivers/scsi/isci/core/sci_util.c b/drivers/scsi/isci/core/sci_util.c
index 03f919ffb413..cb3e9f73828d 100644
--- a/drivers/scsi/isci/core/sci_util.c
+++ b/drivers/scsi/isci/core/sci_util.c
@@ -84,3 +84,18 @@ void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, dma_addr_t ph
84 return (char *)ireq + offset; 84 return (char *)ireq + offset;
85} 85}
86 86
87dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sds_request,
88 void *virt_addr)
89{
90 struct isci_request *isci_request =
91 (struct isci_request *)sci_object_get_association(sds_request);
92
93 char *requested_addr = (char *)virt_addr;
94 char *base_addr = (char *)isci_request;
95
96 BUG_ON(requested_addr < base_addr);
97 BUG_ON((requested_addr - base_addr) >=
98 isci_request->request_alloc_size);
99
100 return isci_request->request_daddr + (requested_addr - base_addr);
101}
diff --git a/drivers/scsi/isci/core/sci_util.h b/drivers/scsi/isci/core/sci_util.h
index 50c272ebcdef..b6f43e27c615 100644
--- a/drivers/scsi/isci/core/sci_util.h
+++ b/drivers/scsi/isci/core/sci_util.h
@@ -102,4 +102,7 @@ void scic_word_copy_with_swap(u32 *destination, u32 *source, u32 word_count);
102void *scic_request_get_virt_addr(struct scic_sds_request *sds_request, 102void *scic_request_get_virt_addr(struct scic_sds_request *sds_request,
103 dma_addr_t phys_addr); 103 dma_addr_t phys_addr);
104 104
105dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sds_request,
106 void *virt_addr);
107
105#endif /* _SCI_UTIL_H_ */ 108#endif /* _SCI_UTIL_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index 9fa45cd0fc46..3bad0bcdf840 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -259,56 +259,70 @@ static struct scu_sgl_element_pair *scic_sds_request_get_sgl_element_pair(
259 * the Scatter-Gather List. 259 * the Scatter-Gather List.
260 * 260 *
261 */ 261 */
262void scic_sds_request_build_sgl( 262void scic_sds_request_build_sgl(struct scic_sds_request *sds_request)
263 struct scic_sds_request *this_request)
264{ 263{
265 void *os_sge; 264 struct isci_request *isci_request =
266 void *os_handle; 265 (struct isci_request *)sci_object_get_association(sds_request);
267 dma_addr_t physical_address; 266 struct isci_host *isci_host = isci_request->isci_host;
268 u32 sgl_pair_index = 0; 267 struct sas_task *task = isci_request_access_task(isci_request);
269 struct scu_sgl_element_pair *scu_sgl_list = NULL; 268 struct scatterlist *sg = NULL;
270 struct scu_sgl_element_pair *previous_pair = NULL; 269 dma_addr_t dma_addr;
271 270 u32 sg_idx = 0;
272 os_handle = scic_sds_request_get_user_request(this_request); 271 struct scu_sgl_element_pair *scu_sg = NULL;
273 scic_cb_io_request_get_next_sge(os_handle, NULL, &os_sge); 272 struct scu_sgl_element_pair *prev_sg = NULL;
274 273
275 while (os_sge != NULL) { 274 if (task->num_scatter > 0) {
276 scu_sgl_list = 275 sg = task->scatter;
277 scic_sds_request_get_sgl_element_pair(this_request, sgl_pair_index); 276
278 277 while (sg) {
279 SCU_SGL_COPY(os_handle, scu_sgl_list->A, os_sge); 278 scu_sg = scic_sds_request_get_sgl_element_pair(
280 279 sds_request,
281 scic_cb_io_request_get_next_sge(os_handle, os_sge, &os_sge); 280 sg_idx);
282 281
283 if (os_sge != NULL) { 282 SCU_SGL_COPY(scu_sg->A, sg);
284 SCU_SGL_COPY(os_handle, scu_sgl_list->B, os_sge); 283
285 284 sg = sg_next(sg);
286 scic_cb_io_request_get_next_sge(os_handle, os_sge, &os_sge); 285
287 } else { 286 if (sg) {
288 SCU_SGL_ZERO(scu_sgl_list->B); 287 SCU_SGL_COPY(scu_sg->B, sg);
288 sg = sg_next(sg);
289 } else
290 SCU_SGL_ZERO(scu_sg->B);
291
292 if (prev_sg) {
293 dma_addr =
294 scic_io_request_get_dma_addr(
295 sds_request,
296 scu_sg);
297
298 prev_sg->next_pair_upper =
299 upper_32_bits(dma_addr);
300 prev_sg->next_pair_lower =
301 lower_32_bits(dma_addr);
302 }
303
304 prev_sg = scu_sg;
305 sg_idx++;
289 } 306 }
307 } else { /* handle when no sg */
308 scu_sg = scic_sds_request_get_sgl_element_pair(sds_request,
309 sg_idx);
290 310
291 if (previous_pair != NULL) { 311 dma_addr = dma_map_single(&isci_host->pdev->dev,
292 scic_cb_io_request_get_physical_address( 312 task->scatter,
293 scic_sds_request_get_controller(this_request), 313 task->total_xfer_len,
294 this_request, 314 task->data_dir);
295 scu_sgl_list,
296 &physical_address
297 );
298 315
299 previous_pair->next_pair_upper = 316 isci_request->zero_scatter_daddr = dma_addr;
300 upper_32_bits(physical_address);
301 previous_pair->next_pair_lower =
302 lower_32_bits(physical_address);
303 }
304 317
305 previous_pair = scu_sgl_list; 318 scu_sg->A.length = task->total_xfer_len;
306 sgl_pair_index++; 319 scu_sg->A.address_upper = upper_32_bits(dma_addr);
320 scu_sg->A.address_lower = lower_32_bits(dma_addr);
307 } 321 }
308 322
309 if (scu_sgl_list != NULL) { 323 if (scu_sg) {
310 scu_sgl_list->next_pair_upper = 0; 324 scu_sg->next_pair_upper = 0;
311 scu_sgl_list->next_pair_lower = 0; 325 scu_sg->next_pair_lower = 0;
312 } 326 }
313} 327}
314 328
@@ -473,17 +487,17 @@ static void scic_sds_task_request_build_ssp_task_iu(
473 * 487 *
474 */ 488 */
475static void scu_ssp_reqeust_construct_task_context( 489static void scu_ssp_reqeust_construct_task_context(
476 struct scic_sds_request *this_request, 490 struct scic_sds_request *sds_request,
477 struct scu_task_context *task_context) 491 struct scu_task_context *task_context)
478{ 492{
479 dma_addr_t physical_address; 493 dma_addr_t dma_addr;
480 struct scic_sds_controller *owning_controller; 494 struct scic_sds_controller *controller;
481 struct scic_sds_remote_device *target_device; 495 struct scic_sds_remote_device *target_device;
482 struct scic_sds_port *target_port; 496 struct scic_sds_port *target_port;
483 497
484 owning_controller = scic_sds_request_get_controller(this_request); 498 controller = scic_sds_request_get_controller(sds_request);
485 target_device = scic_sds_request_get_device(this_request); 499 target_device = scic_sds_request_get_device(sds_request);
486 target_port = scic_sds_request_get_port(this_request); 500 target_port = scic_sds_request_get_port(sds_request);
487 501
488 /* Fill in the TC with the its required data */ 502 /* Fill in the TC with the its required data */
489 task_context->abort = 0; 503 task_context->abort = 0;
@@ -492,7 +506,7 @@ static void scu_ssp_reqeust_construct_task_context(
492 task_context->connection_rate = 506 task_context->connection_rate =
493 scic_remote_device_get_connection_rate(target_device); 507 scic_remote_device_get_connection_rate(target_device);
494 task_context->protocol_engine_index = 508 task_context->protocol_engine_index =
495 scic_sds_controller_get_protocol_engine_group(owning_controller); 509 scic_sds_controller_get_protocol_engine_group(controller);
496 task_context->logical_port_index = 510 task_context->logical_port_index =
497 scic_sds_port_get_index(target_port); 511 scic_sds_port_get_index(target_port);
498 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; 512 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP;
@@ -500,7 +514,7 @@ static void scu_ssp_reqeust_construct_task_context(
500 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 514 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
501 515
502 task_context->remote_node_index = 516 task_context->remote_node_index =
503 scic_sds_remote_device_get_index(this_request->target_device); 517 scic_sds_remote_device_get_index(sds_request->target_device);
504 task_context->command_code = 0; 518 task_context->command_code = 0;
505 519
506 task_context->link_layer_control = 0; 520 task_context->link_layer_control = 0;
@@ -515,61 +529,55 @@ static void scu_ssp_reqeust_construct_task_context(
515 /* task_context->type.ssp.tag = this_request->io_tag; */ 529 /* task_context->type.ssp.tag = this_request->io_tag; */
516 task_context->task_phase = 0x01; 530 task_context->task_phase = 0x01;
517 531
518 if (this_request->was_tag_assigned_by_user) { 532 if (sds_request->was_tag_assigned_by_user) {
519 /* Build the task context now since we have already read the data */ 533 /*
520 this_request->post_context = ( 534 * Build the task context now since we have already read
521 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 535 * the data
522 | ( 536 */
523 scic_sds_controller_get_protocol_engine_group(owning_controller) 537 sds_request->post_context =
524 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 538 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
525 ) 539 (scic_sds_controller_get_protocol_engine_group(
526 | ( 540 controller) <<
527 scic_sds_port_get_index(target_port) 541 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
528 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 542 (scic_sds_port_get_index(target_port) <<
529 ) 543 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
530 | scic_sds_io_tag_get_index(this_request->io_tag) 544 scic_sds_io_tag_get_index(sds_request->io_tag));
531 );
532 } else { 545 } else {
533 /* Build the task context now since we have already read the data */ 546 /*
534 this_request->post_context = ( 547 * Build the task context now since we have already read
535 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 548 * the data
536 | ( 549 *
537 scic_sds_controller_get_protocol_engine_group(owning_controller) 550 * I/O tag index is not assigned because we have to wait
538 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 551 * until we get a TCi
539 ) 552 */
540 | ( 553 sds_request->post_context =
541 scic_sds_port_get_index(target_port) 554 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
542 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 555 (scic_sds_controller_get_protocol_engine_group(
543 ) 556 owning_controller) <<
544 /* This is not assigned because we have to wait until we get a TCi */ 557 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
545 ); 558 (scic_sds_port_get_index(target_port) <<
559 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT));
546 } 560 }
547 561
548 /* Copy the physical address for the command buffer to the SCU Task Context */ 562 /*
549 scic_cb_io_request_get_physical_address( 563 * Copy the physical address for the command buffer to the
550 scic_sds_request_get_controller(this_request), 564 * SCU Task Context
551 this_request, 565 */
552 this_request->command_buffer, 566 dma_addr = scic_io_request_get_dma_addr(sds_request,
553 &physical_address 567 sds_request->command_buffer);
554 );
555 568
556 task_context->command_iu_upper = 569 task_context->command_iu_upper = upper_32_bits(dma_addr);
557 upper_32_bits(physical_address); 570 task_context->command_iu_lower = lower_32_bits(dma_addr);
558 task_context->command_iu_lower =
559 lower_32_bits(physical_address);
560 571
561 /* Copy the physical address for the response buffer to the SCU Task Context */ 572 /*
562 scic_cb_io_request_get_physical_address( 573 * Copy the physical address for the response buffer to the
563 scic_sds_request_get_controller(this_request), 574 * SCU Task Context
564 this_request, 575 */
565 this_request->response_buffer, 576 dma_addr = scic_io_request_get_dma_addr(sds_request,
566 &physical_address 577 sds_request->response_buffer);
567 );
568 578
569 task_context->response_iu_upper = 579 task_context->response_iu_upper = upper_32_bits(dma_addr);
570 upper_32_bits(physical_address); 580 task_context->response_iu_lower = lower_32_bits(dma_addr);
571 task_context->response_iu_lower =
572 lower_32_bits(physical_address);
573} 581}
574 582
575/** 583/**
diff --git a/drivers/scsi/isci/core/scic_sds_request.h b/drivers/scsi/isci/core/scic_sds_request.h
index 60337e6981c7..19b6feef373e 100644
--- a/drivers/scsi/isci/core/scic_sds_request.h
+++ b/drivers/scsi/isci/core/scic_sds_request.h
@@ -389,14 +389,13 @@ extern const struct scic_sds_io_request_state_handler scic_sds_smp_request_start
389 * This macro copys the SGL Element data from the host os to the hardware SGL 389 * This macro copys the SGL Element data from the host os to the hardware SGL
390 * elment data 390 * elment data
391 */ 391 */
392#define SCU_SGL_COPY(os_handle, scu_sge, os_sge) \ 392#define SCU_SGL_COPY(scu_sge, os_sge) \
393 { \ 393 { \
394 (scu_sge).length = \ 394 (scu_sge).length = sg_dma_len(sg); \
395 scic_cb_sge_get_length_field(os_handle, os_sge); \
396 (scu_sge).address_upper = \ 395 (scu_sge).address_upper = \
397 upper_32_bits(scic_cb_sge_get_address_field(os_handle, os_sge)); \ 396 upper_32_bits(sg_dma_address(sg)); \
398 (scu_sge).address_lower = \ 397 (scu_sge).address_lower = \
399 lower_32_bits(scic_cb_sge_get_address_field(os_handle, os_sge)); \ 398 lower_32_bits(sg_dma_address(sg)); \
400 (scu_sge).address_modifier = 0; \ 399 (scu_sge).address_modifier = 0; \
401 } 400 }
402 401
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.c b/drivers/scsi/isci/core/scic_sds_smp_request.c
index 949d23e7452a..85c890630d60 100644
--- a/drivers/scsi/isci/core/scic_sds_smp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_smp_request.c
@@ -234,37 +234,36 @@ enum sci_status scic_io_request_construct_smp(
234 * 234 *
235 */ 235 */
236static void scu_smp_request_construct_task_context( 236static void scu_smp_request_construct_task_context(
237 struct scic_sds_request *this_request, 237 struct scic_sds_request *sds_request,
238 struct smp_request *smp_request) 238 struct smp_request *smp_request)
239{ 239{
240 dma_addr_t physical_address; 240 dma_addr_t dma_addr;
241 struct scic_sds_controller *owning_controller; 241 struct scic_sds_controller *controller;
242 struct scic_sds_remote_device *target_device; 242 struct scic_sds_remote_device *target_device;
243 struct scic_sds_port *target_port; 243 struct scic_sds_port *target_port;
244 struct scu_task_context *task_context; 244 struct scu_task_context *task_context;
245 245
246 /* byte swap the smp request. */ 246 /* byte swap the smp request. */
247 scic_word_copy_with_swap( 247 scic_word_copy_with_swap(sds_request->command_buffer,
248 this_request->command_buffer, 248 (u32 *)smp_request,
249 (u32 *)smp_request, 249 sizeof(struct smp_request) / sizeof(u32));
250 sizeof(struct smp_request) / sizeof(u32)
251 );
252 250
253 task_context = scic_sds_request_get_task_context(this_request); 251 task_context = scic_sds_request_get_task_context(sds_request);
254 252
255 owning_controller = scic_sds_request_get_controller(this_request); 253 controller = scic_sds_request_get_controller(sds_request);
256 target_device = scic_sds_request_get_device(this_request); 254 target_device = scic_sds_request_get_device(sds_request);
257 target_port = scic_sds_request_get_port(this_request); 255 target_port = scic_sds_request_get_port(sds_request);
258 256
259 /* 257 /*
260 * Fill in the TC with the its required data 258 * Fill in the TC with the its required data
261 * 00h */ 259 * 00h
260 */
262 task_context->priority = 0; 261 task_context->priority = 0;
263 task_context->initiator_request = 1; 262 task_context->initiator_request = 1;
264 task_context->connection_rate = 263 task_context->connection_rate =
265 scic_remote_device_get_connection_rate(target_device); 264 scic_remote_device_get_connection_rate(target_device);
266 task_context->protocol_engine_index = 265 task_context->protocol_engine_index =
267 scic_sds_controller_get_protocol_engine_group(owning_controller); 266 scic_sds_controller_get_protocol_engine_group(controller);
268 task_context->logical_port_index = 267 task_context->logical_port_index =
269 scic_sds_port_get_index(target_port); 268 scic_sds_port_get_index(target_port);
270 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; 269 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP;
@@ -273,7 +272,8 @@ static void scu_smp_request_construct_task_context(
273 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 272 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
274 273
275 /* 04h */ 274 /* 04h */
276 task_context->remote_node_index = this_request->target_device->rnc->remote_node_index; 275 task_context->remote_node_index =
276 sds_request->target_device->rnc->remote_node_index;
277 task_context->command_code = 0; 277 task_context->command_code = 0;
278 task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST; 278 task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST;
279 279
@@ -289,7 +289,8 @@ static void scu_smp_request_construct_task_context(
289 task_context->address_modifier = 0; 289 task_context->address_modifier = 0;
290 290
291 /* 10h */ 291 /* 10h */
292 task_context->ssp_command_iu_length = smp_request->header.request_length; 292 task_context->ssp_command_iu_length =
293 smp_request->header.request_length;
293 294
294 /* 14h */ 295 /* 14h */
295 task_context->transfer_length_bytes = 0; 296 task_context->transfer_length_bytes = 0;
@@ -298,59 +299,57 @@ static void scu_smp_request_construct_task_context(
298 * 18h ~ 30h, protocol specific 299 * 18h ~ 30h, protocol specific
299 * since commandIU has been build by framework at this point, we just 300 * since commandIU has been build by framework at this point, we just
300 * copy the frist DWord from command IU to this location. */ 301 * copy the frist DWord from command IU to this location. */
301 memcpy((void *)(&task_context->type.smp), this_request->command_buffer, sizeof(u32)); 302 memcpy((void *)(&task_context->type.smp),
303 sds_request->command_buffer,
304 sizeof(u32));
302 305
303 /* 306 /*
304 * 40h 307 * 40h
305 * "For SMP you could program it to zero. We would prefer that way so that 308 * "For SMP you could program it to zero. We would prefer that way
306 * done code will be consistent." - Venki */ 309 * so that done code will be consistent." - Venki
310 */
307 task_context->task_phase = 0; 311 task_context->task_phase = 0;
308 312
309 if (this_request->was_tag_assigned_by_user) { 313 if (sds_request->was_tag_assigned_by_user) {
310 /* Build the task context now since we have already read the data */ 314 /*
311 this_request->post_context = ( 315 * Build the task context now since we have already read
312 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 316 * the data
313 | ( 317 */
314 scic_sds_controller_get_protocol_engine_group(owning_controller) 318 sds_request->post_context =
315 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 319 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
316 ) 320 (scic_sds_controller_get_protocol_engine_group(
317 | ( 321 controller) <<
318 scic_sds_port_get_index(target_port) 322 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
319 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 323 (scic_sds_port_get_index(target_port) <<
320 ) 324 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
321 | scic_sds_io_tag_get_index(this_request->io_tag) 325 scic_sds_io_tag_get_index(sds_request->io_tag));
322 );
323 } else { 326 } else {
324 /* Build the task context now since we have already read the data */ 327 /*
325 this_request->post_context = ( 328 * Build the task context now since we have already read
326 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 329 * the data.
327 | ( 330 * I/O tag index is not assigned because we have to wait
328 scic_sds_controller_get_protocol_engine_group(owning_controller) 331 * until we get a TCi.
329 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 332 */
330 ) 333 sds_request->post_context =
331 | ( 334 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
332 scic_sds_port_get_index(target_port) 335 (scic_sds_controller_get_protocol_engine_group(
333 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 336 controller) <<
334 ) 337 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
335 /* This is not assigned because we have to wait until we get a TCi */ 338 (scic_sds_port_get_index(target_port) <<
336 ); 339 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT));
337 } 340 }
338 341
339 /* 342 /*
340 * Copy the physical address for the command buffer to the SCU Task Context 343 * Copy the physical address for the command buffer to the SCU Task
341 * command buffer should not contain command header. */ 344 * Context command buffer should not contain command header.
342 scic_cb_io_request_get_physical_address( 345 */
343 scic_sds_request_get_controller(this_request), 346 dma_addr = scic_io_request_get_dma_addr(sds_request,
344 this_request, 347 (char *)
345 ((char *)(this_request->command_buffer) + sizeof(u32)), 348 (sds_request->command_buffer) +
346 &physical_address 349 sizeof(u32));
347 ); 350
348 351 task_context->command_iu_upper = upper_32_bits(dma_addr);
349 task_context->command_iu_upper = 352 task_context->command_iu_lower = lower_32_bits(dma_addr);
350 upper_32_bits(physical_address);
351 task_context->command_iu_lower =
352 lower_32_bits(physical_address);
353
354 353
355 /* SMP response comes as UF, so no need to set response IU address. */ 354 /* SMP response comes as UF, so no need to set response IU address. */
356 task_context->response_iu_upper = 0; 355 task_context->response_iu_upper = 0;
diff --git a/drivers/scsi/isci/core/scic_sds_stp_packet_request.c b/drivers/scsi/isci/core/scic_sds_stp_packet_request.c
index f52a8e32b48f..97dc9bfa7b9c 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_packet_request.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_packet_request.c
@@ -253,30 +253,26 @@ enum sci_status scic_sds_stp_packet_request_process_status_fis(
253 * 253 *
254 */ 254 */
255void scic_sds_stp_packet_internal_request_sense_build_sgl( 255void scic_sds_stp_packet_internal_request_sense_build_sgl(
256 struct scic_sds_request *this_request) 256 struct scic_sds_request *sds_request)
257{ 257{
258 void *sge; 258 void *sge;
259 struct scu_sgl_element_pair *scu_sgl_list = NULL; 259 struct scu_sgl_element_pair *scu_sgl_list = NULL;
260 struct scu_task_context *task_context; 260 struct scu_task_context *task_context;
261 dma_addr_t physical_address; 261 dma_addr_t dma_addr;
262 262
263 struct sci_ssp_response_iu *rsp_iu = 263 struct sci_ssp_response_iu *rsp_iu =
264 (struct sci_ssp_response_iu *)this_request->response_buffer; 264 (struct sci_ssp_response_iu *)sds_request->response_buffer;
265 265
266 sge = (void *)&rsp_iu->data[0]; 266 sge = (void *)&rsp_iu->data[0];
267 267
268 task_context = (struct scu_task_context *)this_request->task_context_buffer; 268 task_context =
269 (struct scu_task_context *)sds_request->task_context_buffer;
269 scu_sgl_list = &task_context->sgl_pair_ab; 270 scu_sgl_list = &task_context->sgl_pair_ab;
270 271
271 scic_cb_io_request_get_physical_address( 272 dma_addr = scic_io_request_get_dma_addr(sds_request, sge);
272 scic_sds_request_get_controller(this_request),
273 this_request,
274 ((char *)sge),
275 &physical_address
276 );
277 273
278 scu_sgl_list->A.address_upper = sci_cb_physical_address_upper(physical_address); 274 scu_sgl_list->A.address_upper = upper_32_bits(dma_addr);
279 scu_sgl_list->A.address_lower = sci_cb_physical_address_lower(physical_address); 275 scu_sgl_list->A.address_lower = lower_32_bits(dma_addr);
280 scu_sgl_list->A.length = task_context->transfer_length_bytes; 276 scu_sgl_list->A.length = task_context->transfer_length_bytes;
281 scu_sgl_list->A.address_modifier = 0; 277 scu_sgl_list->A.address_modifier = 0;
282 278
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/core/scic_sds_stp_request.c
index 10f160e6ab43..0a07207c8412 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.c
@@ -175,17 +175,17 @@ void scic_sds_stp_request_assign_buffers(
175 * determine what is common for SSP/SMP/STP task context structures. 175 * determine what is common for SSP/SMP/STP task context structures.
176 */ 176 */
177static void scu_sata_reqeust_construct_task_context( 177static void scu_sata_reqeust_construct_task_context(
178 struct scic_sds_request *this_request, 178 struct scic_sds_request *sds_request,
179 struct scu_task_context *task_context) 179 struct scu_task_context *task_context)
180{ 180{
181 dma_addr_t physical_address; 181 dma_addr_t dma_addr;
182 struct scic_sds_controller *owning_controller; 182 struct scic_sds_controller *controller;
183 struct scic_sds_remote_device *target_device; 183 struct scic_sds_remote_device *target_device;
184 struct scic_sds_port *target_port; 184 struct scic_sds_port *target_port;
185 185
186 owning_controller = scic_sds_request_get_controller(this_request); 186 controller = scic_sds_request_get_controller(sds_request);
187 target_device = scic_sds_request_get_device(this_request); 187 target_device = scic_sds_request_get_device(sds_request);
188 target_port = scic_sds_request_get_port(this_request); 188 target_port = scic_sds_request_get_port(sds_request);
189 189
190 /* Fill in the TC with the its required data */ 190 /* Fill in the TC with the its required data */
191 task_context->abort = 0; 191 task_context->abort = 0;
@@ -194,7 +194,7 @@ static void scu_sata_reqeust_construct_task_context(
194 task_context->connection_rate = 194 task_context->connection_rate =
195 scic_remote_device_get_connection_rate(target_device); 195 scic_remote_device_get_connection_rate(target_device);
196 task_context->protocol_engine_index = 196 task_context->protocol_engine_index =
197 scic_sds_controller_get_protocol_engine_group(owning_controller); 197 scic_sds_controller_get_protocol_engine_group(controller);
198 task_context->logical_port_index = 198 task_context->logical_port_index =
199 scic_sds_port_get_index(target_port); 199 scic_sds_port_get_index(target_port);
200 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP; 200 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP;
@@ -202,7 +202,7 @@ static void scu_sata_reqeust_construct_task_context(
202 task_context->context_type = SCU_TASK_CONTEXT_TYPE; 202 task_context->context_type = SCU_TASK_CONTEXT_TYPE;
203 203
204 task_context->remote_node_index = 204 task_context->remote_node_index =
205 scic_sds_remote_device_get_index(this_request->target_device); 205 scic_sds_remote_device_get_index(sds_request->target_device);
206 task_context->command_code = 0; 206 task_context->command_code = 0;
207 207
208 task_context->link_layer_control = 0; 208 task_context->link_layer_control = 0;
@@ -219,53 +219,50 @@ static void scu_sata_reqeust_construct_task_context(
219 (sizeof(struct sata_fis_reg_h2d) - sizeof(u32)) / sizeof(u32); 219 (sizeof(struct sata_fis_reg_h2d) - sizeof(u32)) / sizeof(u32);
220 220
221 /* Set the first word of the H2D REG FIS */ 221 /* Set the first word of the H2D REG FIS */
222 task_context->type.words[0] = *(u32 *)this_request->command_buffer; 222 task_context->type.words[0] = *(u32 *)sds_request->command_buffer;
223 223
224 if (this_request->was_tag_assigned_by_user) { 224 if (sds_request->was_tag_assigned_by_user) {
225 /* Build the task context now since we have already read the data */ 225 /*
226 this_request->post_context = ( 226 * Build the task context now since we have already read
227 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 227 * the data
228 | ( 228 */
229 scic_sds_controller_get_protocol_engine_group(owning_controller) 229 sds_request->post_context =
230 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 230 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
231 ) 231 (scic_sds_controller_get_protocol_engine_group(
232 | ( 232 controller) <<
233 scic_sds_port_get_index(target_port) 233 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
234 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 234 (scic_sds_port_get_index(target_port) <<
235 ) 235 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
236 | scic_sds_io_tag_get_index(this_request->io_tag) 236 scic_sds_io_tag_get_index(sds_request->io_tag));
237 );
238 } else { 237 } else {
239 /* Build the task context now since we have already read the data */ 238 /*
240 this_request->post_context = ( 239 * Build the task context now since we have already read
241 SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC 240 * the data.
242 | ( 241 * I/O tag index is not assigned because we have to wait
243 scic_sds_controller_get_protocol_engine_group(owning_controller) 242 * until we get a TCi.
244 << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 243 */
245 ) 244 sds_request->post_context =
246 | ( 245 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
247 scic_sds_port_get_index(target_port) 246 (scic_sds_controller_get_protocol_engine_group(
248 << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 247 controller) <<
249 ) 248 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
250 /* This is not assigned because we have to wait until we get a TCi */ 249 (scic_sds_port_get_index(target_port) <<
251 ); 250 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT));
252 } 251 }
253 252
254 /* 253 /*
255 * Copy the physical address for the command buffer to the SCU Task Context 254 * Copy the physical address for the command buffer to the SCU Task
256 * We must offset the command buffer by 4 bytes because the first 4 bytes are 255 * Context. We must offset the command buffer by 4 bytes because the
257 * transfered in the body of the TC */ 256 * first 4 bytes are transfered in the body of the TC.
258 scic_cb_io_request_get_physical_address( 257 */
259 scic_sds_request_get_controller(this_request), 258 dma_addr =
260 this_request, 259 scic_io_request_get_dma_addr(sds_request,
261 ((char *)this_request->command_buffer) + sizeof(u32), 260 (char *)sds_request->
262 &physical_address 261 command_buffer +
263 ); 262 sizeof(u32));
264 263
265 task_context->command_iu_upper = 264 task_context->command_iu_upper = upper_32_bits(dma_addr);
266 upper_32_bits(physical_address); 265 task_context->command_iu_lower = lower_32_bits(dma_addr);
267 task_context->command_iu_lower =
268 lower_32_bits(physical_address);
269 266
270 /* SATA Requests do not have a response buffer */ 267 /* SATA Requests do not have a response buffer */
271 task_context->response_iu_upper = 0; 268 task_context->response_iu_upper = 0;