diff options
Diffstat (limited to 'drivers/scsi/53c700.c')
-rw-r--r-- | drivers/scsi/53c700.c | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 562432d017b0..68103e508db7 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c | |||
@@ -313,7 +313,7 @@ NCR_700_detect(struct scsi_host_template *tpnt, | |||
313 | hostdata->status = memory + STATUS_OFFSET; | 313 | hostdata->status = memory + STATUS_OFFSET; |
314 | /* all of these offsets are L1_CACHE_BYTES separated. It is fatal | 314 | /* all of these offsets are L1_CACHE_BYTES separated. It is fatal |
315 | * if this isn't sufficient separation to avoid dma flushing issues */ | 315 | * if this isn't sufficient separation to avoid dma flushing issues */ |
316 | BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); | 316 | BUG_ON(!dma_is_consistent(hostdata->dev, pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); |
317 | hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); | 317 | hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); |
318 | hostdata->dev = dev; | 318 | hostdata->dev = dev; |
319 | 319 | ||
@@ -362,11 +362,11 @@ NCR_700_detect(struct scsi_host_template *tpnt, | |||
362 | for (j = 0; j < PATCHES; j++) | 362 | for (j = 0; j < PATCHES; j++) |
363 | script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); | 363 | script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); |
364 | /* now patch up fixed addresses. */ | 364 | /* now patch up fixed addresses. */ |
365 | script_patch_32(script, MessageLocation, | 365 | script_patch_32(hostdata->dev, script, MessageLocation, |
366 | pScript + MSGOUT_OFFSET); | 366 | pScript + MSGOUT_OFFSET); |
367 | script_patch_32(script, StatusAddress, | 367 | script_patch_32(hostdata->dev, script, StatusAddress, |
368 | pScript + STATUS_OFFSET); | 368 | pScript + STATUS_OFFSET); |
369 | script_patch_32(script, ReceiveMsgAddress, | 369 | script_patch_32(hostdata->dev, script, ReceiveMsgAddress, |
370 | pScript + MSGIN_OFFSET); | 370 | pScript + MSGIN_OFFSET); |
371 | 371 | ||
372 | hostdata->script = script; | 372 | hostdata->script = script; |
@@ -622,8 +622,10 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata, | |||
622 | dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); | 622 | dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); |
623 | /* restore the old result if the request sense was | 623 | /* restore the old result if the request sense was |
624 | * successful */ | 624 | * successful */ |
625 | if(result == 0) | 625 | if (result == 0) |
626 | result = cmnd[7]; | 626 | result = cmnd[7]; |
627 | /* restore the original length */ | ||
628 | SCp->cmd_len = cmnd[8]; | ||
627 | } else | 629 | } else |
628 | NCR_700_unmap(hostdata, SCp, slot); | 630 | NCR_700_unmap(hostdata, SCp, slot); |
629 | 631 | ||
@@ -819,8 +821,9 @@ process_extended_message(struct Scsi_Host *host, | |||
819 | shost_printk(KERN_WARNING, host, | 821 | shost_printk(KERN_WARNING, host, |
820 | "Unexpected SDTR msg\n"); | 822 | "Unexpected SDTR msg\n"); |
821 | hostdata->msgout[0] = A_REJECT_MSG; | 823 | hostdata->msgout[0] = A_REJECT_MSG; |
822 | dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); | 824 | dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE); |
823 | script_patch_16(hostdata->script, MessageCount, 1); | 825 | script_patch_16(hostdata->dev, hostdata->script, |
826 | MessageCount, 1); | ||
824 | /* SendMsgOut returns, so set up the return | 827 | /* SendMsgOut returns, so set up the return |
825 | * address */ | 828 | * address */ |
826 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; | 829 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; |
@@ -831,8 +834,9 @@ process_extended_message(struct Scsi_Host *host, | |||
831 | printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", | 834 | printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", |
832 | host->host_no, pun, lun); | 835 | host->host_no, pun, lun); |
833 | hostdata->msgout[0] = A_REJECT_MSG; | 836 | hostdata->msgout[0] = A_REJECT_MSG; |
834 | dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); | 837 | dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE); |
835 | script_patch_16(hostdata->script, MessageCount, 1); | 838 | script_patch_16(hostdata->dev, hostdata->script, MessageCount, |
839 | 1); | ||
836 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; | 840 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; |
837 | 841 | ||
838 | break; | 842 | break; |
@@ -845,8 +849,9 @@ process_extended_message(struct Scsi_Host *host, | |||
845 | printk("\n"); | 849 | printk("\n"); |
846 | /* just reject it */ | 850 | /* just reject it */ |
847 | hostdata->msgout[0] = A_REJECT_MSG; | 851 | hostdata->msgout[0] = A_REJECT_MSG; |
848 | dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); | 852 | dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE); |
849 | script_patch_16(hostdata->script, MessageCount, 1); | 853 | script_patch_16(hostdata->dev, hostdata->script, MessageCount, |
854 | 1); | ||
850 | /* SendMsgOut returns, so set up the return | 855 | /* SendMsgOut returns, so set up the return |
851 | * address */ | 856 | * address */ |
852 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; | 857 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; |
@@ -927,8 +932,9 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata | |||
927 | printk("\n"); | 932 | printk("\n"); |
928 | /* just reject it */ | 933 | /* just reject it */ |
929 | hostdata->msgout[0] = A_REJECT_MSG; | 934 | hostdata->msgout[0] = A_REJECT_MSG; |
930 | dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); | 935 | dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE); |
931 | script_patch_16(hostdata->script, MessageCount, 1); | 936 | script_patch_16(hostdata->dev, hostdata->script, MessageCount, |
937 | 1); | ||
932 | /* SendMsgOut returns, so set up the return | 938 | /* SendMsgOut returns, so set up the return |
933 | * address */ | 939 | * address */ |
934 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; | 940 | resume_offset = hostdata->pScript + Ent_SendMessageWithATN; |
@@ -937,7 +943,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata | |||
937 | } | 943 | } |
938 | NCR_700_writel(temp, host, TEMP_REG); | 944 | NCR_700_writel(temp, host, TEMP_REG); |
939 | /* set us up to receive another message */ | 945 | /* set us up to receive another message */ |
940 | dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE); | 946 | dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE); |
941 | return resume_offset; | 947 | return resume_offset; |
942 | } | 948 | } |
943 | 949 | ||
@@ -1007,6 +1013,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1007 | * of the command */ | 1013 | * of the command */ |
1008 | cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; | 1014 | cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; |
1009 | cmnd[7] = hostdata->status[0]; | 1015 | cmnd[7] = hostdata->status[0]; |
1016 | cmnd[8] = SCp->cmd_len; | ||
1017 | SCp->cmd_len = 6; /* command length for | ||
1018 | * REQUEST_SENSE */ | ||
1010 | slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); | 1019 | slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); |
1011 | slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); | 1020 | slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); |
1012 | slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); | 1021 | slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); |
@@ -1014,9 +1023,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1014 | slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); | 1023 | slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); |
1015 | slot->SG[1].pAddr = 0; | 1024 | slot->SG[1].pAddr = 0; |
1016 | slot->resume_offset = hostdata->pScript; | 1025 | slot->resume_offset = hostdata->pScript; |
1017 | dma_cache_sync(slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); | 1026 | dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); |
1018 | dma_cache_sync(SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); | 1027 | dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); |
1019 | 1028 | ||
1020 | /* queue the command for reissue */ | 1029 | /* queue the command for reissue */ |
1021 | slot->state = NCR_700_SLOT_QUEUED; | 1030 | slot->state = NCR_700_SLOT_QUEUED; |
1022 | slot->flags = NCR_700_FLAG_AUTOSENSE; | 1031 | slot->flags = NCR_700_FLAG_AUTOSENSE; |
@@ -1131,11 +1140,12 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1131 | hostdata->cmd = slot->cmnd; | 1140 | hostdata->cmd = slot->cmnd; |
1132 | 1141 | ||
1133 | /* re-patch for this command */ | 1142 | /* re-patch for this command */ |
1134 | script_patch_32_abs(hostdata->script, CommandAddress, | 1143 | script_patch_32_abs(hostdata->dev, hostdata->script, |
1135 | slot->pCmd); | 1144 | CommandAddress, slot->pCmd); |
1136 | script_patch_16(hostdata->script, | 1145 | script_patch_16(hostdata->dev, hostdata->script, |
1137 | CommandCount, slot->cmnd->cmd_len); | 1146 | CommandCount, slot->cmnd->cmd_len); |
1138 | script_patch_32_abs(hostdata->script, SGScriptStartAddress, | 1147 | script_patch_32_abs(hostdata->dev, hostdata->script, |
1148 | SGScriptStartAddress, | ||
1139 | to32bit(&slot->pSG[0].ins)); | 1149 | to32bit(&slot->pSG[0].ins)); |
1140 | 1150 | ||
1141 | /* Note: setting SXFER only works if we're | 1151 | /* Note: setting SXFER only works if we're |
@@ -1145,13 +1155,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1145 | * should therefore always clear ACK */ | 1155 | * should therefore always clear ACK */ |
1146 | NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), | 1156 | NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), |
1147 | host, SXFER_REG); | 1157 | host, SXFER_REG); |
1148 | dma_cache_sync(hostdata->msgin, | 1158 | dma_cache_sync(hostdata->dev, hostdata->msgin, |
1149 | MSG_ARRAY_SIZE, DMA_FROM_DEVICE); | 1159 | MSG_ARRAY_SIZE, DMA_FROM_DEVICE); |
1150 | dma_cache_sync(hostdata->msgout, | 1160 | dma_cache_sync(hostdata->dev, hostdata->msgout, |
1151 | MSG_ARRAY_SIZE, DMA_TO_DEVICE); | 1161 | MSG_ARRAY_SIZE, DMA_TO_DEVICE); |
1152 | /* I'm just being paranoid here, the command should | 1162 | /* I'm just being paranoid here, the command should |
1153 | * already have been flushed from the cache */ | 1163 | * already have been flushed from the cache */ |
1154 | dma_cache_sync(slot->cmnd->cmnd, | 1164 | dma_cache_sync(hostdata->dev, slot->cmnd->cmnd, |
1155 | slot->cmnd->cmd_len, DMA_TO_DEVICE); | 1165 | slot->cmnd->cmd_len, DMA_TO_DEVICE); |
1156 | 1166 | ||
1157 | 1167 | ||
@@ -1215,7 +1225,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, | |||
1215 | hostdata->reselection_id = reselection_id; | 1225 | hostdata->reselection_id = reselection_id; |
1216 | /* just in case we have a stale simple tag message, clear it */ | 1226 | /* just in case we have a stale simple tag message, clear it */ |
1217 | hostdata->msgin[1] = 0; | 1227 | hostdata->msgin[1] = 0; |
1218 | dma_cache_sync(hostdata->msgin, | 1228 | dma_cache_sync(hostdata->dev, hostdata->msgin, |
1219 | MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL); | 1229 | MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL); |
1220 | if(hostdata->tag_negotiated & (1<<reselection_id)) { | 1230 | if(hostdata->tag_negotiated & (1<<reselection_id)) { |
1221 | resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; | 1231 | resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; |
@@ -1331,7 +1341,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp) | |||
1331 | hostdata->cmd = NULL; | 1341 | hostdata->cmd = NULL; |
1332 | /* clear any stale simple tag message */ | 1342 | /* clear any stale simple tag message */ |
1333 | hostdata->msgin[1] = 0; | 1343 | hostdata->msgin[1] = 0; |
1334 | dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, | 1344 | dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, |
1335 | DMA_BIDIRECTIONAL); | 1345 | DMA_BIDIRECTIONAL); |
1336 | 1346 | ||
1337 | if(id == 0xff) { | 1347 | if(id == 0xff) { |
@@ -1428,29 +1438,30 @@ NCR_700_start_command(struct scsi_cmnd *SCp) | |||
1428 | NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); | 1438 | NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); |
1429 | } | 1439 | } |
1430 | 1440 | ||
1431 | script_patch_16(hostdata->script, MessageCount, count); | 1441 | script_patch_16(hostdata->dev, hostdata->script, MessageCount, count); |
1432 | 1442 | ||
1433 | 1443 | ||
1434 | script_patch_ID(hostdata->script, | 1444 | script_patch_ID(hostdata->dev, hostdata->script, |
1435 | Device_ID, 1<<scmd_id(SCp)); | 1445 | Device_ID, 1<<scmd_id(SCp)); |
1436 | 1446 | ||
1437 | script_patch_32_abs(hostdata->script, CommandAddress, | 1447 | script_patch_32_abs(hostdata->dev, hostdata->script, CommandAddress, |
1438 | slot->pCmd); | 1448 | slot->pCmd); |
1439 | script_patch_16(hostdata->script, CommandCount, SCp->cmd_len); | 1449 | script_patch_16(hostdata->dev, hostdata->script, CommandCount, |
1450 | SCp->cmd_len); | ||
1440 | /* finally plumb the beginning of the SG list into the script | 1451 | /* finally plumb the beginning of the SG list into the script |
1441 | * */ | 1452 | * */ |
1442 | script_patch_32_abs(hostdata->script, SGScriptStartAddress, | 1453 | script_patch_32_abs(hostdata->dev, hostdata->script, |
1443 | to32bit(&slot->pSG[0].ins)); | 1454 | SGScriptStartAddress, to32bit(&slot->pSG[0].ins)); |
1444 | NCR_700_clear_fifo(SCp->device->host); | 1455 | NCR_700_clear_fifo(SCp->device->host); |
1445 | 1456 | ||
1446 | if(slot->resume_offset == 0) | 1457 | if(slot->resume_offset == 0) |
1447 | slot->resume_offset = hostdata->pScript; | 1458 | slot->resume_offset = hostdata->pScript; |
1448 | /* now perform all the writebacks and invalidates */ | 1459 | /* now perform all the writebacks and invalidates */ |
1449 | dma_cache_sync(hostdata->msgout, count, DMA_TO_DEVICE); | 1460 | dma_cache_sync(hostdata->dev, hostdata->msgout, count, DMA_TO_DEVICE); |
1450 | dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, | 1461 | dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, |
1451 | DMA_FROM_DEVICE); | 1462 | DMA_FROM_DEVICE); |
1452 | dma_cache_sync(SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE); | 1463 | dma_cache_sync(hostdata->dev, SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE); |
1453 | dma_cache_sync(hostdata->status, 1, DMA_FROM_DEVICE); | 1464 | dma_cache_sync(hostdata->dev, hostdata->status, 1, DMA_FROM_DEVICE); |
1454 | 1465 | ||
1455 | /* set the synchronous period/offset */ | 1466 | /* set the synchronous period/offset */ |
1456 | NCR_700_writeb(NCR_700_get_SXFER(SCp->device), | 1467 | NCR_700_writeb(NCR_700_get_SXFER(SCp->device), |
@@ -1626,7 +1637,7 @@ NCR_700_intr(int irq, void *dev_id) | |||
1626 | slot->SG[i].ins = bS_to_host(SCRIPT_NOP); | 1637 | slot->SG[i].ins = bS_to_host(SCRIPT_NOP); |
1627 | slot->SG[i].pAddr = 0; | 1638 | slot->SG[i].pAddr = 0; |
1628 | } | 1639 | } |
1629 | dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); | 1640 | dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); |
1630 | /* and pretend we disconnected after | 1641 | /* and pretend we disconnected after |
1631 | * the command phase */ | 1642 | * the command phase */ |
1632 | resume_offset = hostdata->pScript + Ent_MsgInDuringData; | 1643 | resume_offset = hostdata->pScript + Ent_MsgInDuringData; |
@@ -1892,9 +1903,9 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)) | |||
1892 | } | 1903 | } |
1893 | slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); | 1904 | slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); |
1894 | slot->SG[i].pAddr = 0; | 1905 | slot->SG[i].pAddr = 0; |
1895 | dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); | 1906 | dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); |
1896 | DEBUG((" SETTING %08lx to %x\n", | 1907 | DEBUG((" SETTING %08lx to %x\n", |
1897 | (&slot->pSG[i].ins), | 1908 | (&slot->pSG[i].ins), |
1898 | slot->SG[i].ins)); | 1909 | slot->SG[i].ins)); |
1899 | } | 1910 | } |
1900 | slot->resume_offset = 0; | 1911 | slot->resume_offset = 0; |