Commit 65ccf7f1 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by James Bottomley

[PATCH] tmscsim: 64-bit cleanup

Ok, here comes the first one. I chose this one because it fixes an actual
bug in the driver. This bug was (partially) introduced by myself when
porting to 2.6. Partly the reason was that I disliked using
function-like macros as lvalues:

sg_dma_address(x) = ...
sg_dma_len(x) = ...

[OT] wouldn't it be better to introduce some macros like
set_sg_dma_{address|len}(x, y)?

A part of the original patch has already been merged (s/UINT/ULONG/), so,
the actual version is re-diffed against 2.6.6-bk6 and re-tested (on a
plain Pentium).

Also updates the driver-version, printed on startup.
parent 7d2370c1
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#endif #endif
#define DC390_BANNER "Tekram DC390/AM53C974" #define DC390_BANNER "Tekram DC390/AM53C974"
#define DC390_VERSION "2.0f 2000-12-20" #define DC390_VERSION "2.1b 2004-04-13"
/* We don't have eh_abort_handler, eh_device_reset_handler, /* We don't have eh_abort_handler, eh_device_reset_handler,
* eh_bus_reset_handler, eh_host_reset_handler yet! * eh_bus_reset_handler, eh_host_reset_handler yet!
......
...@@ -521,7 +521,7 @@ dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus) ...@@ -521,7 +521,7 @@ dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus)
{ {
DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
} }
} }
static void static void
...@@ -740,9 +740,9 @@ dc390_restore_ptr (PACB pACB, PSRB pSRB) ...@@ -740,9 +740,9 @@ dc390_restore_ptr (PACB pACB, PSRB pSRB)
psgl = pSRB->pSegmentList; psgl = pSRB->pSegmentList;
//dc390_pci_sync(pSRB); //dc390_pci_sync(pSRB);
while (pSRB->TotalXferredLen + (ULONG) psgl->length < pSRB->Saved_Ptr) while (pSRB->TotalXferredLen + (ULONG) sg_dma_len(psgl) < pSRB->Saved_Ptr)
{ {
pSRB->TotalXferredLen += (ULONG) psgl->length; pSRB->TotalXferredLen += (ULONG) sg_dma_len(psgl);
pSRB->SGIndex++; pSRB->SGIndex++;
if( pSRB->SGIndex < pSRB->SGcount ) if( pSRB->SGIndex < pSRB->SGcount )
{ {
...@@ -762,7 +762,7 @@ dc390_restore_ptr (PACB pACB, PSRB pSRB) ...@@ -762,7 +762,7 @@ dc390_restore_ptr (PACB pACB, PSRB pSRB)
} else if(pcmd->request_buffer) { } else if(pcmd->request_buffer) {
//dc390_pci_sync(pSRB); //dc390_pci_sync(pSRB);
pSRB->Segmentx.length = pcmd->request_bufflen - pSRB->Saved_Ptr; sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen - pSRB->Saved_Ptr;
pSRB->SGcount = 1; pSRB->SGcount = 1;
pSRB->pSegmentList = (PSGL) &pSRB->Segmentx; pSRB->pSegmentList = (PSGL) &pSRB->Segmentx;
} else { } else {
...@@ -885,6 +885,8 @@ dc390_DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir) ...@@ -885,6 +885,8 @@ dc390_DataIO_Comm( PACB pACB, PSRB pSRB, UCHAR ioDir)
if (pDCB) printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (%02i-%i)\n", if (pDCB) printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (%02i-%i)\n",
pDCB->TargetID, pDCB->TargetLUN); pDCB->TargetID, pDCB->TargetLUN);
else printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (DCB 0!)\n"); else printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (DCB 0!)\n");
pSRB->pSRBDCB = pDCB;
dc390_EnableMsgOut_Abort (pACB, pSRB); dc390_EnableMsgOut_Abort (pACB, pSRB);
if (pDCB) pDCB->DCBFlag |= ABORT_DEV; if (pDCB) pDCB->DCBFlag |= ABORT_DEV;
return; return;
...@@ -1466,7 +1468,7 @@ dc390_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) ...@@ -1466,7 +1468,7 @@ dc390_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB )
ptr2 = pSRB->pSegmentList; ptr2 = pSRB->pSegmentList;
for( i=pSRB->SGIndex; i < bval; i++) for( i=pSRB->SGIndex; i < bval; i++)
{ {
swlval += ptr2->length; swlval += sg_dma_len(ptr2);
ptr2++; ptr2++;
} }
REMOVABLEDEBUG(printk(KERN_INFO "XferredLen=%08x,NotXferLen=%08x\n",\ REMOVABLEDEBUG(printk(KERN_INFO "XferredLen=%08x,NotXferLen=%08x\n",\
......
...@@ -168,6 +168,7 @@ ...@@ -168,6 +168,7 @@
* 2.1a 03/11/29 GL, KG Initial fixing for 2.6. Convert to * * 2.1a 03/11/29 GL, KG Initial fixing for 2.6. Convert to *
* use the current PCI-mapping API, update * * use the current PCI-mapping API, update *
* command-queuing. * * command-queuing. *
* 2.1b 04/04/13 GL Fix for 64-bit platforms *
***********************************************************************/ ***********************************************************************/
/* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */ /* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */
...@@ -1022,7 +1023,7 @@ static int dc390_pci_map (PSRB pSRB) ...@@ -1022,7 +1023,7 @@ static int dc390_pci_map (PSRB pSRB)
pci_map_page(pdev, virt_to_page(pcmd->sense_buffer), pci_map_page(pdev, virt_to_page(pcmd->sense_buffer),
(unsigned long)pcmd->sense_buffer & ~PAGE_MASK, sizeof(pcmd->sense_buffer), (unsigned long)pcmd->sense_buffer & ~PAGE_MASK, sizeof(pcmd->sense_buffer),
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
pSRB->Segmentx.length = sizeof(pcmd->sense_buffer); sg_dma_len(&pSRB->Segmentx) = sizeof(pcmd->sense_buffer);
pSRB->SGcount = 1; pSRB->SGcount = 1;
pSRB->pSegmentList = (PSGL) &pSRB->Segmentx; pSRB->pSegmentList = (PSGL) &pSRB->Segmentx;
DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle)); DEBUG1(printk("%s(): Mapped sense buffer %p at %x\n", __FUNCTION__, pcmd->sense_buffer, cmdp->saved_dma_handle));
...@@ -1043,7 +1044,7 @@ static int dc390_pci_map (PSRB pSRB) ...@@ -1043,7 +1044,7 @@ static int dc390_pci_map (PSRB pSRB)
(unsigned long)pcmd->request_buffer & ~PAGE_MASK, (unsigned long)pcmd->request_buffer & ~PAGE_MASK,
pcmd->request_bufflen, scsi_to_pci_dma_dir(pcmd->sc_data_direction)); pcmd->request_bufflen, scsi_to_pci_dma_dir(pcmd->sc_data_direction));
/* TODO: error handling */ /* TODO: error handling */
pSRB->Segmentx.length = pcmd->request_bufflen; sg_dma_len(&pSRB->Segmentx) = pcmd->request_bufflen;
pSRB->SGcount = 1; pSRB->SGcount = 1;
pSRB->pSegmentList = (PSGL) &pSRB->Segmentx; pSRB->pSegmentList = (PSGL) &pSRB->Segmentx;
DEBUG1(printk("%s(): Mapped request buffer %p at %x\n", __FUNCTION__, pcmd->request_buffer, cmdp->saved_dma_handle)); DEBUG1(printk("%s(): Mapped request buffer %p at %x\n", __FUNCTION__, pcmd->request_buffer, cmdp->saved_dma_handle));
...@@ -1131,7 +1132,7 @@ static void dc390_Query_to_Waiting (PACB pACB) ...@@ -1131,7 +1132,7 @@ static void dc390_Query_to_Waiting (PACB pACB)
if (!pcmd) { dc390_Free_insert (pACB, pSRB); return; } /* should not happen */ if (!pcmd) { dc390_Free_insert (pACB, pSRB); return; } /* should not happen */
pDCB = dc390_findDCB (pACB, pcmd->device->id, pcmd->device->lun); pDCB = dc390_findDCB (pACB, pcmd->device->id, pcmd->device->lun);
if (!pDCB) if (!pDCB)
{ {
dc390_Free_insert (pACB, pSRB); dc390_Free_insert (pACB, pSRB);
printk (KERN_ERR "DC390: Command in queue to non-existing device!\n"); printk (KERN_ERR "DC390: Command in queue to non-existing device!\n");
pcmd->result = MK_RES(DRIVER_ERROR,DID_ERROR,0,0); pcmd->result = MK_RES(DRIVER_ERROR,DID_ERROR,0,0);
...@@ -1180,7 +1181,7 @@ int DC390_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) ...@@ -1180,7 +1181,7 @@ int DC390_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *))
/* Assume BAD_TARGET; will be cleared later */ /* Assume BAD_TARGET; will be cleared later */
cmd->result = DID_BAD_TARGET << 16; cmd->result = DID_BAD_TARGET << 16;
/* TODO: Change the policy: Alway accept TEST_UNIT_READY or INQUIRY /* TODO: Change the policy: Always accept TEST_UNIT_READY or INQUIRY
* commands and alloc a DCB for the device if not yet there. DCB will * commands and alloc a DCB for the device if not yet there. DCB will
* be removed in dc390_SRBdone if SEL_TIMEOUT */ * be removed in dc390_SRBdone if SEL_TIMEOUT */
...@@ -1767,7 +1768,7 @@ void dc390_initDCB( PACB pACB, PDCB *ppDCB, UCHAR id, UCHAR lun ) ...@@ -1767,7 +1768,7 @@ void dc390_initDCB( PACB pACB, PDCB *ppDCB, UCHAR id, UCHAR lun )
PDCB pDCB, pDCB2; PDCB pDCB, pDCB2;
pDCB = kmalloc (sizeof(DC390_DCB), GFP_ATOMIC); pDCB = kmalloc (sizeof(DC390_DCB), GFP_ATOMIC);
DCBDEBUG(printk (KERN_INFO "DC390: alloc mem for DCB (ID %i, LUN %i): %p\n" \ DCBDEBUG(printk (KERN_INFO "DC390: alloc mem for DCB (ID %i, LUN %i): %p\n", \
id, lun, pDCB)); id, lun, pDCB));
*ppDCB = pDCB; *ppDCB = pDCB;
...@@ -2229,10 +2230,13 @@ int __init DC390_detect (Scsi_Host_Template *psht) ...@@ -2229,10 +2230,13 @@ int __init DC390_detect (Scsi_Host_Template *psht)
if ( PCI_PRESENT ) if ( PCI_PRESENT )
while (PCI_FIND_DEVICE (PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD53C974)) while (PCI_FIND_DEVICE (PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD53C974))
{ {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,30)
if (pci_enable_device (pdev)) if (pci_enable_device (pdev))
continue; continue;
#endif
if (pci_set_dma_mask(pdev, 0xffffffff)) {
printk(KERN_ERR "DC390(%i): No suitable DMA available.\n", dc390_adapterCnt);
continue;
}
PCI_GET_IO_AND_IRQ; PCI_GET_IO_AND_IRQ;
DEBUG0(printk(KERN_INFO "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq)); DEBUG0(printk(KERN_INFO "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment