diff options
Diffstat (limited to 'drivers/scsi/nsp32.c')
-rw-r--r-- | drivers/scsi/nsp32.c | 85 |
1 files changed, 24 insertions, 61 deletions
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index e4dfdfb8af3a..8cc9e64bbdff 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c | |||
@@ -719,7 +719,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt) | |||
719 | command = 0; | 719 | command = 0; |
720 | command |= (TRANSFER_GO | ALL_COUNTER_CLR); | 720 | command |= (TRANSFER_GO | ALL_COUNTER_CLR); |
721 | if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { | 721 | if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { |
722 | if (SCpnt->request_bufflen > 0) { | 722 | if (scsi_bufflen(SCpnt) > 0) { |
723 | command |= BM_START; | 723 | command |= BM_START; |
724 | } | 724 | } |
725 | } else if (data->trans_method & NSP32_TRANSFER_MMIO) { | 725 | } else if (data->trans_method & NSP32_TRANSFER_MMIO) { |
@@ -868,31 +868,28 @@ static int nsp32_reselection(struct scsi_cmnd *SCpnt, unsigned char newlun) | |||
868 | static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) | 868 | static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) |
869 | { | 869 | { |
870 | nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; | 870 | nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; |
871 | struct scatterlist *sgl; | 871 | struct scatterlist *sg; |
872 | nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; | 872 | nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; |
873 | int num, i; | 873 | int num, i; |
874 | u32_le l; | 874 | u32_le l; |
875 | 875 | ||
876 | if (SCpnt->request_bufflen == 0) { | ||
877 | return TRUE; | ||
878 | } | ||
879 | |||
880 | if (sgt == NULL) { | 876 | if (sgt == NULL) { |
881 | nsp32_dbg(NSP32_DEBUG_SGLIST, "SGT == null"); | 877 | nsp32_dbg(NSP32_DEBUG_SGLIST, "SGT == null"); |
882 | return FALSE; | 878 | return FALSE; |
883 | } | 879 | } |
884 | 880 | ||
885 | if (SCpnt->use_sg) { | 881 | num = scsi_dma_map(SCpnt); |
886 | sgl = (struct scatterlist *)SCpnt->request_buffer; | 882 | if (!num) |
887 | num = pci_map_sg(data->Pci, sgl, SCpnt->use_sg, | 883 | return TRUE; |
888 | SCpnt->sc_data_direction); | 884 | else if (num < 0) |
889 | for (i = 0; i < num; i++) { | 885 | return FALSE; |
886 | else { | ||
887 | scsi_for_each_sg(SCpnt, sg, num, i) { | ||
890 | /* | 888 | /* |
891 | * Build nsp32_sglist, substitute sg dma addresses. | 889 | * Build nsp32_sglist, substitute sg dma addresses. |
892 | */ | 890 | */ |
893 | sgt[i].addr = cpu_to_le32(sg_dma_address(sgl)); | 891 | sgt[i].addr = cpu_to_le32(sg_dma_address(sg)); |
894 | sgt[i].len = cpu_to_le32(sg_dma_len(sgl)); | 892 | sgt[i].len = cpu_to_le32(sg_dma_len(sg)); |
895 | sgl++; | ||
896 | 893 | ||
897 | if (le32_to_cpu(sgt[i].len) > 0x10000) { | 894 | if (le32_to_cpu(sgt[i].len) > 0x10000) { |
898 | nsp32_msg(KERN_ERR, | 895 | nsp32_msg(KERN_ERR, |
@@ -909,23 +906,6 @@ static int nsp32_setup_sg_table(struct scsi_cmnd *SCpnt) | |||
909 | /* set end mark */ | 906 | /* set end mark */ |
910 | l = le32_to_cpu(sgt[num-1].len); | 907 | l = le32_to_cpu(sgt[num-1].len); |
911 | sgt[num-1].len = cpu_to_le32(l | SGTEND); | 908 | sgt[num-1].len = cpu_to_le32(l | SGTEND); |
912 | |||
913 | } else { | ||
914 | SCpnt->SCp.have_data_in = pci_map_single(data->Pci, | ||
915 | SCpnt->request_buffer, SCpnt->request_bufflen, | ||
916 | SCpnt->sc_data_direction); | ||
917 | |||
918 | sgt[0].addr = cpu_to_le32(SCpnt->SCp.have_data_in); | ||
919 | sgt[0].len = cpu_to_le32(SCpnt->request_bufflen | SGTEND); /* set end mark */ | ||
920 | |||
921 | if (SCpnt->request_bufflen > 0x10000) { | ||
922 | nsp32_msg(KERN_ERR, | ||
923 | "can't transfer over 64KB at a time, size=0x%lx", SCpnt->request_bufflen); | ||
924 | return FALSE; | ||
925 | } | ||
926 | nsp32_dbg(NSP32_DEBUG_SGLIST, "single : addr 0x%lx len=0x%lx", | ||
927 | le32_to_cpu(sgt[0].addr), | ||
928 | le32_to_cpu(sgt[0].len )); | ||
929 | } | 909 | } |
930 | 910 | ||
931 | return TRUE; | 911 | return TRUE; |
@@ -942,7 +922,7 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ | |||
942 | "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x " | 922 | "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x " |
943 | "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", | 923 | "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", |
944 | SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, | 924 | SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len, |
945 | SCpnt->use_sg, SCpnt->request_buffer, SCpnt->request_bufflen); | 925 | scsi_sg_count(SCpnt), scsi_sglist(SCpnt), scsi_bufflen(SCpnt)); |
946 | 926 | ||
947 | if (data->CurrentSC != NULL) { | 927 | if (data->CurrentSC != NULL) { |
948 | nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); | 928 | nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request"); |
@@ -974,10 +954,10 @@ static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_ | |||
974 | data->CurrentSC = SCpnt; | 954 | data->CurrentSC = SCpnt; |
975 | SCpnt->SCp.Status = CHECK_CONDITION; | 955 | SCpnt->SCp.Status = CHECK_CONDITION; |
976 | SCpnt->SCp.Message = 0; | 956 | SCpnt->SCp.Message = 0; |
977 | SCpnt->resid = SCpnt->request_bufflen; | 957 | scsi_set_resid(SCpnt, scsi_bufflen(SCpnt)); |
978 | 958 | ||
979 | SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; | 959 | SCpnt->SCp.ptr = (char *)scsi_sglist(SCpnt); |
980 | SCpnt->SCp.this_residual = SCpnt->request_bufflen; | 960 | SCpnt->SCp.this_residual = scsi_bufflen(SCpnt); |
981 | SCpnt->SCp.buffer = NULL; | 961 | SCpnt->SCp.buffer = NULL; |
982 | SCpnt->SCp.buffers_residual = 0; | 962 | SCpnt->SCp.buffers_residual = 0; |
983 | 963 | ||
@@ -1288,7 +1268,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) | |||
1288 | } | 1268 | } |
1289 | 1269 | ||
1290 | if ((auto_stat & DATA_IN_PHASE) && | 1270 | if ((auto_stat & DATA_IN_PHASE) && |
1291 | (SCpnt->resid > 0) && | 1271 | (scsi_get_resid(SCpnt) > 0) && |
1292 | ((nsp32_read2(base, FIFO_REST_CNT) & FIFO_REST_MASK) != 0)) { | 1272 | ((nsp32_read2(base, FIFO_REST_CNT) & FIFO_REST_MASK) != 0)) { |
1293 | printk( "auto+fifo\n"); | 1273 | printk( "auto+fifo\n"); |
1294 | //nsp32_pio_read(SCpnt); | 1274 | //nsp32_pio_read(SCpnt); |
@@ -1309,7 +1289,7 @@ static irqreturn_t do_nsp32_isr(int irq, void *dev_id) | |||
1309 | nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", | 1289 | nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", |
1310 | nsp32_read4(base, SAVED_SACK_CNT)); | 1290 | nsp32_read4(base, SAVED_SACK_CNT)); |
1311 | 1291 | ||
1312 | SCpnt->resid = 0; /* all data transfered! */ | 1292 | scsi_set_resid(SCpnt, 0); /* all data transfered! */ |
1313 | } | 1293 | } |
1314 | 1294 | ||
1315 | /* | 1295 | /* |
@@ -1577,25 +1557,8 @@ static void nsp32_scsi_done(struct scsi_cmnd *SCpnt) | |||
1577 | nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; | 1557 | nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; |
1578 | unsigned int base = SCpnt->device->host->io_port; | 1558 | unsigned int base = SCpnt->device->host->io_port; |
1579 | 1559 | ||
1580 | /* | 1560 | scsi_dma_unmap(SCpnt); |
1581 | * unmap pci | ||
1582 | */ | ||
1583 | if (SCpnt->request_bufflen == 0) { | ||
1584 | goto skip; | ||
1585 | } | ||
1586 | |||
1587 | if (SCpnt->use_sg) { | ||
1588 | pci_unmap_sg(data->Pci, | ||
1589 | (struct scatterlist *)SCpnt->request_buffer, | ||
1590 | SCpnt->use_sg, SCpnt->sc_data_direction); | ||
1591 | } else { | ||
1592 | pci_unmap_single(data->Pci, | ||
1593 | (u32)SCpnt->SCp.have_data_in, | ||
1594 | SCpnt->request_bufflen, | ||
1595 | SCpnt->sc_data_direction); | ||
1596 | } | ||
1597 | 1561 | ||
1598 | skip: | ||
1599 | /* | 1562 | /* |
1600 | * clear TRANSFERCONTROL_BM_START | 1563 | * clear TRANSFERCONTROL_BM_START |
1601 | */ | 1564 | */ |
@@ -1751,7 +1714,7 @@ static int nsp32_busfree_occur(struct scsi_cmnd *SCpnt, unsigned short execph) | |||
1751 | SCpnt->SCp.Message = 0; | 1714 | SCpnt->SCp.Message = 0; |
1752 | nsp32_dbg(NSP32_DEBUG_BUSFREE, | 1715 | nsp32_dbg(NSP32_DEBUG_BUSFREE, |
1753 | "normal end stat=0x%x resid=0x%x\n", | 1716 | "normal end stat=0x%x resid=0x%x\n", |
1754 | SCpnt->SCp.Status, SCpnt->resid); | 1717 | SCpnt->SCp.Status, scsi_get_resid(SCpnt)); |
1755 | SCpnt->result = (DID_OK << 16) | | 1718 | SCpnt->result = (DID_OK << 16) | |
1756 | (SCpnt->SCp.Message << 8) | | 1719 | (SCpnt->SCp.Message << 8) | |
1757 | (SCpnt->SCp.Status << 0); | 1720 | (SCpnt->SCp.Status << 0); |
@@ -1795,7 +1758,7 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen | |||
1795 | unsigned int restlen, sentlen; | 1758 | unsigned int restlen, sentlen; |
1796 | u32_le len, addr; | 1759 | u32_le len, addr; |
1797 | 1760 | ||
1798 | nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", SCpnt->resid); | 1761 | nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", scsi_get_resid(SCpnt)); |
1799 | 1762 | ||
1800 | /* adjust saved SACK count with 4 byte start address boundary */ | 1763 | /* adjust saved SACK count with 4 byte start address boundary */ |
1801 | s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; | 1764 | s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; |
@@ -1839,12 +1802,12 @@ static void nsp32_adjust_busfree(struct scsi_cmnd *SCpnt, unsigned int s_sacklen | |||
1839 | return; | 1802 | return; |
1840 | 1803 | ||
1841 | last: | 1804 | last: |
1842 | if (SCpnt->resid < sentlen) { | 1805 | if (scsi_get_resid(SCpnt) < sentlen) { |
1843 | nsp32_msg(KERN_ERR, "resid underflow"); | 1806 | nsp32_msg(KERN_ERR, "resid underflow"); |
1844 | } | 1807 | } |
1845 | 1808 | ||
1846 | SCpnt->resid -= sentlen; | 1809 | scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) - sentlen); |
1847 | nsp32_dbg(NSP32_DEBUG_SGLIST, "new resid=0x%x", SCpnt->resid); | 1810 | nsp32_dbg(NSP32_DEBUG_SGLIST, "new resid=0x%x", scsi_get_resid(SCpnt)); |
1848 | 1811 | ||
1849 | /* update hostdata and lun */ | 1812 | /* update hostdata and lun */ |
1850 | 1813 | ||
@@ -1973,7 +1936,7 @@ static void nsp32_restart_autoscsi(struct scsi_cmnd *SCpnt, unsigned short comma | |||
1973 | transfer = 0; | 1936 | transfer = 0; |
1974 | transfer |= (TRANSFER_GO | ALL_COUNTER_CLR); | 1937 | transfer |= (TRANSFER_GO | ALL_COUNTER_CLR); |
1975 | if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { | 1938 | if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { |
1976 | if (SCpnt->request_bufflen > 0) { | 1939 | if (scsi_bufflen(SCpnt) > 0) { |
1977 | transfer |= BM_START; | 1940 | transfer |= BM_START; |
1978 | } | 1941 | } |
1979 | } else if (data->trans_method & NSP32_TRANSFER_MMIO) { | 1942 | } else if (data->trans_method & NSP32_TRANSFER_MMIO) { |