aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/message/fusion/mptscsih.c78
1 files changed, 19 insertions, 59 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index fa0f7761652a..561074a04b03 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -260,30 +260,13 @@ mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt,
260 /* Map the data portion, if any. 260 /* Map the data portion, if any.
261 * sges_left = 0 if no data transfer. 261 * sges_left = 0 if no data transfer.
262 */ 262 */
263 if ( (sges_left = SCpnt->use_sg) ) { 263 sges_left = scsi_dma_map(SCpnt);
264 sges_left = pci_map_sg(ioc->pcidev, 264 if (sges_left < 0)
265 (struct scatterlist *) SCpnt->request_buffer, 265 return FAILED;
266 SCpnt->use_sg,
267 SCpnt->sc_data_direction);
268 if (sges_left == 0)
269 return FAILED;
270 } else if (SCpnt->request_bufflen) {
271 SCpnt->SCp.dma_handle = pci_map_single(ioc->pcidev,
272 SCpnt->request_buffer,
273 SCpnt->request_bufflen,
274 SCpnt->sc_data_direction);
275 dsgprintk((MYIOC_s_INFO_FMT "SG: non-SG for %p, len=%d\n",
276 ioc->name, SCpnt, SCpnt->request_bufflen));
277 mptscsih_add_sge((char *) &pReq->SGL,
278 0xD1000000|MPT_SGE_FLAGS_ADDRESSING|sgdir|SCpnt->request_bufflen,
279 SCpnt->SCp.dma_handle);
280
281 return SUCCESS;
282 }
283 266
284 /* Handle the SG case. 267 /* Handle the SG case.
285 */ 268 */
286 sg = (struct scatterlist *) SCpnt->request_buffer; 269 sg = scsi_sglist(SCpnt);
287 sg_done = 0; 270 sg_done = 0;
288 sgeOffset = sizeof(SCSIIORequest_t) - sizeof(SGE_IO_UNION); 271 sgeOffset = sizeof(SCSIIORequest_t) - sizeof(SGE_IO_UNION);
289 chainSge = NULL; 272 chainSge = NULL;
@@ -662,7 +645,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
662 scsi_state = pScsiReply->SCSIState; 645 scsi_state = pScsiReply->SCSIState;
663 scsi_status = pScsiReply->SCSIStatus; 646 scsi_status = pScsiReply->SCSIStatus;
664 xfer_cnt = le32_to_cpu(pScsiReply->TransferCount); 647 xfer_cnt = le32_to_cpu(pScsiReply->TransferCount);
665 sc->resid = sc->request_bufflen - xfer_cnt; 648 scsi_set_resid(sc, scsi_bufflen(sc) - xfer_cnt);
666 log_info = le32_to_cpu(pScsiReply->IOCLogInfo); 649 log_info = le32_to_cpu(pScsiReply->IOCLogInfo);
667 650
668 /* 651 /*
@@ -767,7 +750,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
767 break; 750 break;
768 751
769 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ 752 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */
770 sc->resid = sc->request_bufflen - xfer_cnt; 753 scsi_set_resid(sc, scsi_bufflen(sc) - xfer_cnt);
771 if((xfer_cnt==0)||(sc->underflow > xfer_cnt)) 754 if((xfer_cnt==0)||(sc->underflow > xfer_cnt))
772 sc->result=DID_SOFT_ERROR << 16; 755 sc->result=DID_SOFT_ERROR << 16;
773 else /* Sufficient data transfer occurred */ 756 else /* Sufficient data transfer occurred */
@@ -816,7 +799,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
816 break; 799 break;
817 800
818 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN: /* 0x0044 */ 801 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN: /* 0x0044 */
819 sc->resid=0; 802 scsi_set_resid(sc, 0);
820 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */ 803 case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR: /* 0x0040 */
821 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */ 804 case MPI_IOCSTATUS_SUCCESS: /* 0x0000 */
822 sc->result = (DID_OK << 16) | scsi_status; 805 sc->result = (DID_OK << 16) | scsi_status;
@@ -899,23 +882,18 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
899 scsi_state, scsi_status, log_info)); 882 scsi_state, scsi_status, log_info));
900 883
901 dreplyprintk(("%s: [%d:%d:%d:%d] resid=%d " 884 dreplyprintk(("%s: [%d:%d:%d:%d] resid=%d "
902 "bufflen=%d xfer_cnt=%d\n", __FUNCTION__, 885 "bufflen=%d xfer_cnt=%d\n", __FUNCTION__,
903 sc->device->host->host_no, sc->device->channel, sc->device->id, 886 sc->device->host->host_no,
904 sc->device->lun, sc->resid, sc->request_bufflen, 887 sc->device->channel, sc->device->id,
905 xfer_cnt)); 888 sc->device->lun, scsi_get_resid(sc),
889 scsi_bufflen(sc), xfer_cnt));
906 } 890 }
907#endif 891#endif
908 892
909 } /* end of address reply case */ 893 } /* end of address reply case */
910 894
911 /* Unmap the DMA buffers, if any. */ 895 /* Unmap the DMA buffers, if any. */
912 if (sc->use_sg) { 896 scsi_dma_unmap(sc);
913 pci_unmap_sg(ioc->pcidev, (struct scatterlist *) sc->request_buffer,
914 sc->use_sg, sc->sc_data_direction);
915 } else if (sc->request_bufflen) {
916 pci_unmap_single(ioc->pcidev, sc->SCp.dma_handle,
917 sc->request_bufflen, sc->sc_data_direction);
918 }
919 897
920 sc->scsi_done(sc); /* Issue the command callback */ 898 sc->scsi_done(sc); /* Issue the command callback */
921 899
@@ -970,17 +948,8 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
970 /* Set status, free OS resources (SG DMA buffers) 948 /* Set status, free OS resources (SG DMA buffers)
971 * Do OS callback 949 * Do OS callback
972 */ 950 */
973 if (SCpnt->use_sg) { 951 scsi_dma_unmap(SCpnt);
974 pci_unmap_sg(ioc->pcidev, 952
975 (struct scatterlist *) SCpnt->request_buffer,
976 SCpnt->use_sg,
977 SCpnt->sc_data_direction);
978 } else if (SCpnt->request_bufflen) {
979 pci_unmap_single(ioc->pcidev,
980 SCpnt->SCp.dma_handle,
981 SCpnt->request_bufflen,
982 SCpnt->sc_data_direction);
983 }
984 SCpnt->result = DID_RESET << 16; 953 SCpnt->result = DID_RESET << 16;
985 SCpnt->host_scribble = NULL; 954 SCpnt->host_scribble = NULL;
986 955
@@ -1039,17 +1008,8 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1039 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf); 1008 mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf);
1040 if ((unsigned char *)mf != sc->host_scribble) 1009 if ((unsigned char *)mf != sc->host_scribble)
1041 continue; 1010 continue;
1042 if (sc->use_sg) { 1011 scsi_dma_unmap(sc);
1043 pci_unmap_sg(hd->ioc->pcidev, 1012
1044 (struct scatterlist *) sc->request_buffer,
1045 sc->use_sg,
1046 sc->sc_data_direction);
1047 } else if (sc->request_bufflen) {
1048 pci_unmap_single(hd->ioc->pcidev,
1049 sc->SCp.dma_handle,
1050 sc->request_bufflen,
1051 sc->sc_data_direction);
1052 }
1053 sc->host_scribble = NULL; 1013 sc->host_scribble = NULL;
1054 sc->result = DID_NO_CONNECT << 16; 1014 sc->result = DID_NO_CONNECT << 16;
1055 sc->scsi_done(sc); 1015 sc->scsi_done(sc);
@@ -1380,10 +1340,10 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1380 * will be no data transfer! GRRRRR... 1340 * will be no data transfer! GRRRRR...
1381 */ 1341 */
1382 if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) { 1342 if (SCpnt->sc_data_direction == DMA_FROM_DEVICE) {
1383 datalen = SCpnt->request_bufflen; 1343 datalen = scsi_bufflen(SCpnt);
1384 scsidir = MPI_SCSIIO_CONTROL_READ; /* DATA IN (host<--ioc<--dev) */ 1344 scsidir = MPI_SCSIIO_CONTROL_READ; /* DATA IN (host<--ioc<--dev) */
1385 } else if (SCpnt->sc_data_direction == DMA_TO_DEVICE) { 1345 } else if (SCpnt->sc_data_direction == DMA_TO_DEVICE) {
1386 datalen = SCpnt->request_bufflen; 1346 datalen = scsi_bufflen(SCpnt);
1387 scsidir = MPI_SCSIIO_CONTROL_WRITE; /* DATA OUT (host-->ioc-->dev) */ 1347 scsidir = MPI_SCSIIO_CONTROL_WRITE; /* DATA OUT (host-->ioc-->dev) */
1388 } else { 1348 } else {
1389 datalen = 0; 1349 datalen = 0;