diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-25 16:04:08 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-31 18:11:55 -0400 |
commit | 155d98f072bbb4ffb5cefc7cecbba06df37699ab (patch) | |
tree | 7fecabeefb7a6a7e2f5f2a57305badb77f1e1080 /drivers | |
parent | 3f6270ef76f2ce5c134615a470685d6c2a66c07e (diff) |
[SCSI] megaraid_sas: convert to use the data buffer accessors
- remove the unnecessary map_single path.
- convert to use the new accessors for the sg lists and the
parameters.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Sumant Patro <sumant.patro@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 112 |
1 files changed, 17 insertions, 95 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index e2cf12ef3688..b7f2e613c903 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -433,34 +433,15 @@ megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp, | |||
433 | int sge_count; | 433 | int sge_count; |
434 | struct scatterlist *os_sgl; | 434 | struct scatterlist *os_sgl; |
435 | 435 | ||
436 | /* | 436 | sge_count = scsi_dma_map(scp); |
437 | * Return 0 if there is no data transfer | 437 | BUG_ON(sge_count < 0); |
438 | */ | ||
439 | if (!scp->request_buffer || !scp->request_bufflen) | ||
440 | return 0; | ||
441 | 438 | ||
442 | if (!scp->use_sg) { | 439 | if (sge_count) { |
443 | mfi_sgl->sge32[0].phys_addr = pci_map_single(instance->pdev, | 440 | scsi_for_each_sg(scp, os_sgl, sge_count, i) { |
444 | scp-> | 441 | mfi_sgl->sge32[i].length = sg_dma_len(os_sgl); |
445 | request_buffer, | 442 | mfi_sgl->sge32[i].phys_addr = sg_dma_address(os_sgl); |
446 | scp-> | 443 | } |
447 | request_bufflen, | ||
448 | scp-> | ||
449 | sc_data_direction); | ||
450 | mfi_sgl->sge32[0].length = scp->request_bufflen; | ||
451 | |||
452 | return 1; | ||
453 | } | ||
454 | |||
455 | os_sgl = (struct scatterlist *)scp->request_buffer; | ||
456 | sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg, | ||
457 | scp->sc_data_direction); | ||
458 | |||
459 | for (i = 0; i < sge_count; i++, os_sgl++) { | ||
460 | mfi_sgl->sge32[i].length = sg_dma_len(os_sgl); | ||
461 | mfi_sgl->sge32[i].phys_addr = sg_dma_address(os_sgl); | ||
462 | } | 444 | } |
463 | |||
464 | return sge_count; | 445 | return sge_count; |
465 | } | 446 | } |
466 | 447 | ||
@@ -481,35 +462,15 @@ megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp, | |||
481 | int sge_count; | 462 | int sge_count; |
482 | struct scatterlist *os_sgl; | 463 | struct scatterlist *os_sgl; |
483 | 464 | ||
484 | /* | 465 | sge_count = scsi_dma_map(scp); |
485 | * Return 0 if there is no data transfer | 466 | BUG_ON(sge_count < 0); |
486 | */ | ||
487 | if (!scp->request_buffer || !scp->request_bufflen) | ||
488 | return 0; | ||
489 | |||
490 | if (!scp->use_sg) { | ||
491 | mfi_sgl->sge64[0].phys_addr = pci_map_single(instance->pdev, | ||
492 | scp-> | ||
493 | request_buffer, | ||
494 | scp-> | ||
495 | request_bufflen, | ||
496 | scp-> | ||
497 | sc_data_direction); | ||
498 | |||
499 | mfi_sgl->sge64[0].length = scp->request_bufflen; | ||
500 | |||
501 | return 1; | ||
502 | } | ||
503 | |||
504 | os_sgl = (struct scatterlist *)scp->request_buffer; | ||
505 | sge_count = pci_map_sg(instance->pdev, os_sgl, scp->use_sg, | ||
506 | scp->sc_data_direction); | ||
507 | 467 | ||
508 | for (i = 0; i < sge_count; i++, os_sgl++) { | 468 | if (sge_count) { |
509 | mfi_sgl->sge64[i].length = sg_dma_len(os_sgl); | 469 | scsi_for_each_sg(scp, os_sgl, sge_count, i) { |
510 | mfi_sgl->sge64[i].phys_addr = sg_dma_address(os_sgl); | 470 | mfi_sgl->sge64[i].length = sg_dma_len(os_sgl); |
471 | mfi_sgl->sge64[i].phys_addr = sg_dma_address(os_sgl); | ||
472 | } | ||
511 | } | 473 | } |
512 | |||
513 | return sge_count; | 474 | return sge_count; |
514 | } | 475 | } |
515 | 476 | ||
@@ -593,7 +554,7 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, | |||
593 | pthru->cdb_len = scp->cmd_len; | 554 | pthru->cdb_len = scp->cmd_len; |
594 | pthru->timeout = 0; | 555 | pthru->timeout = 0; |
595 | pthru->flags = flags; | 556 | pthru->flags = flags; |
596 | pthru->data_xfer_len = scp->request_bufflen; | 557 | pthru->data_xfer_len = scsi_bufflen(scp); |
597 | 558 | ||
598 | memcpy(pthru->cdb, scp->cmnd, scp->cmd_len); | 559 | memcpy(pthru->cdb, scp->cmnd, scp->cmd_len); |
599 | 560 | ||
@@ -1195,45 +1156,6 @@ megasas_complete_abort(struct megasas_instance *instance, | |||
1195 | } | 1156 | } |
1196 | 1157 | ||
1197 | /** | 1158 | /** |
1198 | * megasas_unmap_sgbuf - Unmap SG buffers | ||
1199 | * @instance: Adapter soft state | ||
1200 | * @cmd: Completed command | ||
1201 | */ | ||
1202 | static void | ||
1203 | megasas_unmap_sgbuf(struct megasas_instance *instance, struct megasas_cmd *cmd) | ||
1204 | { | ||
1205 | dma_addr_t buf_h; | ||
1206 | u8 opcode; | ||
1207 | |||
1208 | if (cmd->scmd->use_sg) { | ||
1209 | pci_unmap_sg(instance->pdev, cmd->scmd->request_buffer, | ||
1210 | cmd->scmd->use_sg, cmd->scmd->sc_data_direction); | ||
1211 | return; | ||
1212 | } | ||
1213 | |||
1214 | if (!cmd->scmd->request_bufflen) | ||
1215 | return; | ||
1216 | |||
1217 | opcode = cmd->frame->hdr.cmd; | ||
1218 | |||
1219 | if ((opcode == MFI_CMD_LD_READ) || (opcode == MFI_CMD_LD_WRITE)) { | ||
1220 | if (IS_DMA64) | ||
1221 | buf_h = cmd->frame->io.sgl.sge64[0].phys_addr; | ||
1222 | else | ||
1223 | buf_h = cmd->frame->io.sgl.sge32[0].phys_addr; | ||
1224 | } else { | ||
1225 | if (IS_DMA64) | ||
1226 | buf_h = cmd->frame->pthru.sgl.sge64[0].phys_addr; | ||
1227 | else | ||
1228 | buf_h = cmd->frame->pthru.sgl.sge32[0].phys_addr; | ||
1229 | } | ||
1230 | |||
1231 | pci_unmap_single(instance->pdev, buf_h, cmd->scmd->request_bufflen, | ||
1232 | cmd->scmd->sc_data_direction); | ||
1233 | return; | ||
1234 | } | ||
1235 | |||
1236 | /** | ||
1237 | * megasas_complete_cmd - Completes a command | 1159 | * megasas_complete_cmd - Completes a command |
1238 | * @instance: Adapter soft state | 1160 | * @instance: Adapter soft state |
1239 | * @cmd: Command to be completed | 1161 | * @cmd: Command to be completed |
@@ -1281,7 +1203,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, | |||
1281 | 1203 | ||
1282 | atomic_dec(&instance->fw_outstanding); | 1204 | atomic_dec(&instance->fw_outstanding); |
1283 | 1205 | ||
1284 | megasas_unmap_sgbuf(instance, cmd); | 1206 | scsi_dma_unmap(cmd->scmd); |
1285 | cmd->scmd->scsi_done(cmd->scmd); | 1207 | cmd->scmd->scsi_done(cmd->scmd); |
1286 | megasas_return_cmd(instance, cmd); | 1208 | megasas_return_cmd(instance, cmd); |
1287 | 1209 | ||
@@ -1329,7 +1251,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, | |||
1329 | 1251 | ||
1330 | atomic_dec(&instance->fw_outstanding); | 1252 | atomic_dec(&instance->fw_outstanding); |
1331 | 1253 | ||
1332 | megasas_unmap_sgbuf(instance, cmd); | 1254 | scsi_dma_unmap(cmd->scmd); |
1333 | cmd->scmd->scsi_done(cmd->scmd); | 1255 | cmd->scmd->scsi_done(cmd->scmd); |
1334 | megasas_return_cmd(instance, cmd); | 1256 | megasas_return_cmd(instance, cmd); |
1335 | 1257 | ||