diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2007-05-14 06:25:56 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-27 23:28:21 -0400 |
commit | deff2627cda995c926788fd9192337ec3febe7b5 (patch) | |
tree | a343c6c2db67fdaff3bda9c2db8cdabb96ca2fc9 /drivers/scsi/arcmsr | |
parent | 22c1a6600af920f4fef6d5cc51a8f04b58e9db83 (diff) |
[SCSI] arcmsr: 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.
Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Nick Cheng <nick.cheng@areca.com.tw>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/arcmsr')
-rw-r--r-- | drivers/scsi/arcmsr/arcmsr_hba.c | 103 |
1 files changed, 31 insertions, 72 deletions
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 8b46158cc045..672df79d7e39 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -369,19 +369,9 @@ static void arcmsr_abort_allcmd(struct AdapterControlBlock *acb) | |||
369 | 369 | ||
370 | static void arcmsr_pci_unmap_dma(struct CommandControlBlock *ccb) | 370 | static void arcmsr_pci_unmap_dma(struct CommandControlBlock *ccb) |
371 | { | 371 | { |
372 | struct AdapterControlBlock *acb = ccb->acb; | ||
373 | struct scsi_cmnd *pcmd = ccb->pcmd; | 372 | struct scsi_cmnd *pcmd = ccb->pcmd; |
374 | 373 | ||
375 | if (pcmd->use_sg != 0) { | 374 | scsi_dma_unmap(pcmd); |
376 | struct scatterlist *sl; | ||
377 | |||
378 | sl = (struct scatterlist *)pcmd->request_buffer; | ||
379 | pci_unmap_sg(acb->pdev, sl, pcmd->use_sg, pcmd->sc_data_direction); | ||
380 | } | ||
381 | else if (pcmd->request_bufflen != 0) | ||
382 | pci_unmap_single(acb->pdev, | ||
383 | pcmd->SCp.dma_handle, | ||
384 | pcmd->request_bufflen, pcmd->sc_data_direction); | ||
385 | } | 375 | } |
386 | 376 | ||
387 | static void arcmsr_ccb_complete(struct CommandControlBlock *ccb, int stand_flag) | 377 | static void arcmsr_ccb_complete(struct CommandControlBlock *ccb, int stand_flag) |
@@ -551,6 +541,7 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
551 | int8_t *psge = (int8_t *)&arcmsr_cdb->u; | 541 | int8_t *psge = (int8_t *)&arcmsr_cdb->u; |
552 | uint32_t address_lo, address_hi; | 542 | uint32_t address_lo, address_hi; |
553 | int arccdbsize = 0x30; | 543 | int arccdbsize = 0x30; |
544 | int nseg; | ||
554 | 545 | ||
555 | ccb->pcmd = pcmd; | 546 | ccb->pcmd = pcmd; |
556 | memset(arcmsr_cdb, 0, sizeof (struct ARCMSR_CDB)); | 547 | memset(arcmsr_cdb, 0, sizeof (struct ARCMSR_CDB)); |
@@ -561,20 +552,20 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
561 | arcmsr_cdb->CdbLength = (uint8_t)pcmd->cmd_len; | 552 | arcmsr_cdb->CdbLength = (uint8_t)pcmd->cmd_len; |
562 | arcmsr_cdb->Context = (unsigned long)arcmsr_cdb; | 553 | arcmsr_cdb->Context = (unsigned long)arcmsr_cdb; |
563 | memcpy(arcmsr_cdb->Cdb, pcmd->cmnd, pcmd->cmd_len); | 554 | memcpy(arcmsr_cdb->Cdb, pcmd->cmnd, pcmd->cmd_len); |
564 | if (pcmd->use_sg) { | 555 | |
565 | int length, sgcount, i, cdb_sgcount = 0; | 556 | nseg = scsi_dma_map(pcmd); |
566 | struct scatterlist *sl; | 557 | BUG_ON(nseg < 0); |
567 | 558 | ||
568 | /* Get Scatter Gather List from scsiport. */ | 559 | if (nseg) { |
569 | sl = (struct scatterlist *) pcmd->request_buffer; | 560 | int length, i, cdb_sgcount = 0; |
570 | sgcount = pci_map_sg(acb->pdev, sl, pcmd->use_sg, | 561 | struct scatterlist *sg; |
571 | pcmd->sc_data_direction); | 562 | |
572 | /* map stor port SG list to our iop SG List. */ | 563 | /* map stor port SG list to our iop SG List. */ |
573 | for (i = 0; i < sgcount; i++) { | 564 | scsi_for_each_sg(pcmd, sg, nseg, i) { |
574 | /* Get the physical address of the current data pointer */ | 565 | /* Get the physical address of the current data pointer */ |
575 | length = cpu_to_le32(sg_dma_len(sl)); | 566 | length = cpu_to_le32(sg_dma_len(sg)); |
576 | address_lo = cpu_to_le32(dma_addr_lo32(sg_dma_address(sl))); | 567 | address_lo = cpu_to_le32(dma_addr_lo32(sg_dma_address(sg))); |
577 | address_hi = cpu_to_le32(dma_addr_hi32(sg_dma_address(sl))); | 568 | address_hi = cpu_to_le32(dma_addr_hi32(sg_dma_address(sg))); |
578 | if (address_hi == 0) { | 569 | if (address_hi == 0) { |
579 | struct SG32ENTRY *pdma_sg = (struct SG32ENTRY *)psge; | 570 | struct SG32ENTRY *pdma_sg = (struct SG32ENTRY *)psge; |
580 | 571 | ||
@@ -591,32 +582,12 @@ static void arcmsr_build_ccb(struct AdapterControlBlock *acb, | |||
591 | psge += sizeof (struct SG64ENTRY); | 582 | psge += sizeof (struct SG64ENTRY); |
592 | arccdbsize += sizeof (struct SG64ENTRY); | 583 | arccdbsize += sizeof (struct SG64ENTRY); |
593 | } | 584 | } |
594 | sl++; | ||
595 | cdb_sgcount++; | 585 | cdb_sgcount++; |
596 | } | 586 | } |
597 | arcmsr_cdb->sgcount = (uint8_t)cdb_sgcount; | 587 | arcmsr_cdb->sgcount = (uint8_t)cdb_sgcount; |
598 | arcmsr_cdb->DataLength = pcmd->request_bufflen; | 588 | arcmsr_cdb->DataLength = scsi_bufflen(pcmd); |
599 | if ( arccdbsize > 256) | 589 | if ( arccdbsize > 256) |
600 | arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE; | 590 | arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_SGL_BSIZE; |
601 | } else if (pcmd->request_bufflen) { | ||
602 | dma_addr_t dma_addr; | ||
603 | dma_addr = pci_map_single(acb->pdev, pcmd->request_buffer, | ||
604 | pcmd->request_bufflen, pcmd->sc_data_direction); | ||
605 | pcmd->SCp.dma_handle = dma_addr; | ||
606 | address_lo = cpu_to_le32(dma_addr_lo32(dma_addr)); | ||
607 | address_hi = cpu_to_le32(dma_addr_hi32(dma_addr)); | ||
608 | if (address_hi == 0) { | ||
609 | struct SG32ENTRY *pdma_sg = (struct SG32ENTRY *)psge; | ||
610 | pdma_sg->address = address_lo; | ||
611 | pdma_sg->length = pcmd->request_bufflen; | ||
612 | } else { | ||
613 | struct SG64ENTRY *pdma_sg = (struct SG64ENTRY *)psge; | ||
614 | pdma_sg->addresshigh = address_hi; | ||
615 | pdma_sg->address = address_lo; | ||
616 | pdma_sg->length = pcmd->request_bufflen|IS_SG64_ADDR; | ||
617 | } | ||
618 | arcmsr_cdb->sgcount = 1; | ||
619 | arcmsr_cdb->DataLength = pcmd->request_bufflen; | ||
620 | } | 591 | } |
621 | if (pcmd->sc_data_direction == DMA_TO_DEVICE ) { | 592 | if (pcmd->sc_data_direction == DMA_TO_DEVICE ) { |
622 | arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE; | 593 | arcmsr_cdb->Flags |= ARCMSR_CDB_FLAG_WRITE; |
@@ -848,24 +819,21 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, struct scsi_ | |||
848 | struct CMD_MESSAGE_FIELD *pcmdmessagefld; | 819 | struct CMD_MESSAGE_FIELD *pcmdmessagefld; |
849 | int retvalue = 0, transfer_len = 0; | 820 | int retvalue = 0, transfer_len = 0; |
850 | char *buffer; | 821 | char *buffer; |
822 | struct scatterlist *sg; | ||
851 | uint32_t controlcode = (uint32_t ) cmd->cmnd[5] << 24 | | 823 | uint32_t controlcode = (uint32_t ) cmd->cmnd[5] << 24 | |
852 | (uint32_t ) cmd->cmnd[6] << 16 | | 824 | (uint32_t ) cmd->cmnd[6] << 16 | |
853 | (uint32_t ) cmd->cmnd[7] << 8 | | 825 | (uint32_t ) cmd->cmnd[7] << 8 | |
854 | (uint32_t ) cmd->cmnd[8]; | 826 | (uint32_t ) cmd->cmnd[8]; |
855 | /* 4 bytes: Areca io control code */ | 827 | /* 4 bytes: Areca io control code */ |
856 | if (cmd->use_sg) { | ||
857 | struct scatterlist *sg = (struct scatterlist *)cmd->request_buffer; | ||
858 | 828 | ||
859 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 829 | sg = scsi_sglist(cmd); |
860 | if (cmd->use_sg > 1) { | 830 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; |
861 | retvalue = ARCMSR_MESSAGE_FAIL; | 831 | if (scsi_sg_count(cmd) > 1) { |
862 | goto message_out; | 832 | retvalue = ARCMSR_MESSAGE_FAIL; |
863 | } | 833 | goto message_out; |
864 | transfer_len += sg->length; | ||
865 | } else { | ||
866 | buffer = cmd->request_buffer; | ||
867 | transfer_len = cmd->request_bufflen; | ||
868 | } | 834 | } |
835 | transfer_len += sg->length; | ||
836 | |||
869 | if (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) { | 837 | if (transfer_len > sizeof(struct CMD_MESSAGE_FIELD)) { |
870 | retvalue = ARCMSR_MESSAGE_FAIL; | 838 | retvalue = ARCMSR_MESSAGE_FAIL; |
871 | goto message_out; | 839 | goto message_out; |
@@ -1057,12 +1025,9 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, struct scsi_ | |||
1057 | retvalue = ARCMSR_MESSAGE_FAIL; | 1025 | retvalue = ARCMSR_MESSAGE_FAIL; |
1058 | } | 1026 | } |
1059 | message_out: | 1027 | message_out: |
1060 | if (cmd->use_sg) { | 1028 | sg = scsi_sglist(cmd); |
1061 | struct scatterlist *sg; | 1029 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); |
1062 | 1030 | ||
1063 | sg = (struct scatterlist *) cmd->request_buffer; | ||
1064 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); | ||
1065 | } | ||
1066 | return retvalue; | 1031 | return retvalue; |
1067 | } | 1032 | } |
1068 | 1033 | ||
@@ -1085,6 +1050,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, | |||
1085 | case INQUIRY: { | 1050 | case INQUIRY: { |
1086 | unsigned char inqdata[36]; | 1051 | unsigned char inqdata[36]; |
1087 | char *buffer; | 1052 | char *buffer; |
1053 | struct scatterlist *sg; | ||
1088 | 1054 | ||
1089 | if (cmd->device->lun) { | 1055 | if (cmd->device->lun) { |
1090 | cmd->result = (DID_TIME_OUT << 16); | 1056 | cmd->result = (DID_TIME_OUT << 16); |
@@ -1104,21 +1070,14 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, | |||
1104 | strncpy(&inqdata[16], "RAID controller ", 16); | 1070 | strncpy(&inqdata[16], "RAID controller ", 16); |
1105 | /* Product Identification */ | 1071 | /* Product Identification */ |
1106 | strncpy(&inqdata[32], "R001", 4); /* Product Revision */ | 1072 | strncpy(&inqdata[32], "R001", 4); /* Product Revision */ |
1107 | if (cmd->use_sg) { | ||
1108 | struct scatterlist *sg; | ||
1109 | 1073 | ||
1110 | sg = (struct scatterlist *) cmd->request_buffer; | 1074 | sg = scsi_sglist(cmd); |
1111 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1075 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; |
1112 | } else { | 1076 | |
1113 | buffer = cmd->request_buffer; | ||
1114 | } | ||
1115 | memcpy(buffer, inqdata, sizeof(inqdata)); | 1077 | memcpy(buffer, inqdata, sizeof(inqdata)); |
1116 | if (cmd->use_sg) { | 1078 | sg = scsi_sglist(cmd); |
1117 | struct scatterlist *sg; | 1079 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); |
1118 | 1080 | ||
1119 | sg = (struct scatterlist *) cmd->request_buffer; | ||
1120 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); | ||
1121 | } | ||
1122 | cmd->scsi_done(cmd); | 1081 | cmd->scsi_done(cmd); |
1123 | } | 1082 | } |
1124 | break; | 1083 | break; |