* Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors @ 2003-12-17 9:05 James Daniel 2003-12-17 14:24 ` James Bottomley 0 siblings, 1 reply; 10+ messages in thread From: James Daniel @ 2003-12-17 9:05 UTC (permalink / raw) To: SCSI Mailing List; +Cc: Mike Christie, James Bottomley First off.. Mike, thank you for your work on this driver. James, thank you for pointing out the patch. I finally had time to take the server down and recompile with vga mode selection support.. so, with 80x60, the entire scsi setup stays on the screen at the time of panic.. here we go: i91u: PCI Base=0xEC00, IRQ=12, BIOS=0xC8000, SCSI ID=7 i91u: Reset SCSI Bus ... ERROR: SCSI host `INI9100U' has no error handling ERROR: This is not a safe way to run your SCSI host ERROR: The error handling must be added to this driver Call Trace: [<c029cfd1>] scsi_host_alloc+0x291/0x2a0 [<c029cff1>] scsi_register+0x11/0x60 [<c02a4ed1>] i91u_detect+0x1d1/0x3c0 [<c0290e28>] ide_register_driver+0xe8/0x120 [<c03628b3>] init_this_scsi_driver+0x53/0x100 [<c035276c>] do_initcalls+0x2c/0xa0 [<c01050ed>] init+0x2d/0x140 [<c01050c0>] init+0x0/0x140 [<c0107329>] kernel_thread_helper+0x5/0x1c It then goes on to ID the drive correctly, and loads the sd driver, which again IDs the drive correctly.. and we get: SCSI device sda: 17783240 512-byte hdwr sectors (9105 MB) SCSI device sda: drive cache: write back /dev/scsi/host0/bus0/target1/lun0: unknown partition table Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 which results in the end: VFS: Cannot open root device "801" or sda1 Please append a correct "root=" boot option kernel panic: VFS: Unable to mount root fs on sda1 Hope this helps in the debugging.. as you may guess, the whole box works absolutely fine under 2.4.23... - James Daniel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-17 9:05 Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Daniel @ 2003-12-17 14:24 ` James Bottomley 2003-12-18 7:00 ` Mike Christie 0 siblings, 1 reply; 10+ messages in thread From: James Bottomley @ 2003-12-17 14:24 UTC (permalink / raw) To: James Daniel; +Cc: SCSI Mailing List, Mike Christie On Wed, 2003-12-17 at 04:05, James Daniel wrote: > i91u: PCI Base=0xEC00, IRQ=12, BIOS=0xC8000, SCSI ID=7 > i91u: Reset SCSI Bus ... > ERROR: SCSI host `INI9100U' has no error handling > ERROR: This is not a safe way to run your SCSI host > ERROR: The error handling must be added to this driver > Call Trace: > [<c029cfd1>] scsi_host_alloc+0x291/0x2a0 > [<c029cff1>] scsi_register+0x11/0x60 > [<c02a4ed1>] i91u_detect+0x1d1/0x3c0 > [<c0290e28>] ide_register_driver+0xe8/0x120 > [<c03628b3>] init_this_scsi_driver+0x53/0x100 > [<c035276c>] do_initcalls+0x2c/0xa0 > [<c01050ed>] init+0x2d/0x140 > [<c01050c0>] init+0x0/0x140 > [<c0107329>] kernel_thread_helper+0x5/0x1c This one's expected: although the driver was made compilable and converted to the new dma API, it still needs a new error handler, which is what the complaint is about. > It then goes on to ID the drive correctly, and loads the sd driver, which > again IDs the drive correctly.. and we get: > > SCSI device sda: 17783240 512-byte hdwr sectors (9105 MB) > SCSI device sda: drive cache: write back > /dev/scsi/host0/bus0/target1/lun0: unknown partition table > Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 This one's really strange, because clearly the INQUIRY and the READ_CAPACITY both succeeded and returned apparently good values. The READ10 to the DOS parition sector has failed (with no errors). The only difference is that the READ10 is generated in the partition code (via read_dev_sector), so it will be a sg read (probably with scsi_device->use_sg set to 1)...I'm travelling today, so if Mike hasn't found the problem by the tomorrow, I'll take a look. James ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-17 14:24 ` James Bottomley @ 2003-12-18 7:00 ` Mike Christie 2003-12-18 9:45 ` Mike Christie 0 siblings, 1 reply; 10+ messages in thread From: Mike Christie @ 2003-12-18 7:00 UTC (permalink / raw) To: James Bottomley; +Cc: James Daniel, SCSI Mailing List >>It then goes on to ID the drive correctly, and loads the sd driver, which >>again IDs the drive correctly.. and we get: >> >>SCSI device sda: 17783240 512-byte hdwr sectors (9105 MB) >>SCSI device sda: drive cache: write back >>/dev/scsi/host0/bus0/target1/lun0: unknown partition table >>Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 > > > This one's really strange, because clearly the INQUIRY and the > READ_CAPACITY both succeeded and returned apparently good values. The > READ10 to the DOS parition sector has failed (with no errors). > > The only difference is that the READ10 is generated in the partition > code (via read_dev_sector), so it will be a sg read (probably with > scsi_device->use_sg set to 1)...I'm travelling today, so if Mike hasn't > found the problem by the tomorrow, I'll take a look. > For use_sg == 1 the driver was doing this: - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */ - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address); - TotalLen = pSrbSG->length; - pSCB->SCB_SGLen = 0; but I had changed it to do sg io instead not knowing why it needed to treat it is as regular I/O. I will send a new patch in the next mail. mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-18 7:00 ` Mike Christie @ 2003-12-18 9:45 ` Mike Christie 2003-12-19 2:14 ` James Daniel 0 siblings, 1 reply; 10+ messages in thread From: Mike Christie @ 2003-12-18 9:45 UTC (permalink / raw) To: James Bottomley; +Cc: James Daniel, SCSI Mailing List, mikenc [-- Attachment #1: Type: TEXT/PLAIN, Size: 1563 bytes --] On Wed, 17 Dec 2003, Mike Christie wrote: > > >>It then goes on to ID the drive correctly, and loads the sd driver, which > >>again IDs the drive correctly.. and we get: > >> > >>SCSI device sda: 17783240 512-byte hdwr sectors (9105 MB) > >>SCSI device sda: drive cache: write back > >>/dev/scsi/host0/bus0/target1/lun0: unknown partition table > >>Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 > > > > > > This one's really strange, because clearly the INQUIRY and the > > READ_CAPACITY both succeeded and returned apparently good values. The > > READ10 to the DOS parition sector has failed (with no errors). > > > > The only difference is that the READ10 is generated in the partition > > code (via read_dev_sector), so it will be a sg read (probably with > > scsi_device->use_sg set to 1)...I'm travelling today, so if Mike hasn't > > found the problem by the tomorrow, I'll take a look. > > > > For use_sg == 1 the driver was doing this: > > - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* > treat it as regular I/O */ > - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address); > - TotalLen = pSrbSG->length; > - pSCB->SCB_SGLen = 0; > > but I had changed it to do sg io instead not knowing why it needed to > treat it is as regular I/O. I will send a new patch in the next mail. > Ignore my comment above. Try the attached patch. It was built against 2.6.0-test11. I do not have the HW and the other testers I know about are only using their card for scsi cd writers, so I only know it compiles. mike [-- Attachment #2: Type: TEXT/PLAIN, Size: 9152 bytes --] diff -aurp linux-2.6.0-test11-orig/drivers/scsi/i91uscsi.c linux-2.6.0-test11-scsi/drivers/scsi/i91uscsi.c --- linux-2.6.0-test11-orig/drivers/scsi/i91uscsi.c 2003-11-26 12:43:24.000000000 -0800 +++ linux-2.6.0-test11-scsi/drivers/scsi/i91uscsi.c 2003-12-18 01:14:42.392963503 -0800 @@ -1747,9 +1747,9 @@ int tul_state_5(HCS * pCurHcb) xcnt += (long) sgp->SG_Len; /* xcnt == bytes xferred in this sgp */ sgp->SG_Ptr += (U32) xcnt; /* new ptr to be xfer */ sgp->SG_Len -= (U32) xcnt; /* new len to be xfer */ - pCurScb->SCB_BufPtr += ((U32) (i - pCurScb->SCB_SGIdx) << 3); + pCurScb->SCB_BufPtr = sgp->SG_Ptr; /* new SG table ptr */ - pCurScb->SCB_SGLen = (BYTE) (pCurScb->SCB_SGMax - i); + pCurScb->SCB_SGLen = sgp->SG_Len; /* new SG table len */ pCurScb->SCB_SGIdx = (WORD) i; /* for next disc and come in this loop */ diff -aurp linux-2.6.0-test11-orig/drivers/scsi/ini9100u.c linux-2.6.0-test11-scsi/drivers/scsi/ini9100u.c --- linux-2.6.0-test11-orig/drivers/scsi/ini9100u.c 2003-11-26 12:43:26.000000000 -0800 +++ linux-2.6.0-test11-scsi/drivers/scsi/ini9100u.c 2003-12-18 01:14:35.776797751 -0800 @@ -104,12 +104,12 @@ * Now fixed. * 05/07/99 bv - v1.03g * - Changed the assumption that HZ = 100 + * 10/17/03 mc - v1.04 + * - added new DMA API support **************************************************************************/ #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) -#error Please convert me to Documentation/DMA-mapping.txt - #ifndef LINUX_VERSION_CODE #include <linux/version.h> #endif @@ -143,13 +143,12 @@ unsigned int i91u_debug = DEBUG_DEFAULT; static Scsi_Host_Template driver_template = { .proc_name = "INI9100U", - .proc_info = "INI9100U", .name = i91u_REVID, .detect = i91u_detect, .release = i91u_release, .queuecommand = i91u_queue, - .abort = i91u_abort, - .reset = i91u_reset, +// .abort = i91u_abort, +// .reset = i91u_reset, .bios_param = i91u_biosparam, .can_queue = 1, .this_id = 1, @@ -162,7 +161,7 @@ static Scsi_Host_Template driver_templat char *i91uCopyright = "Copyright (C) 1996-98"; char *i91uInitioName = "by Initio Corporation"; char *i91uProductName = "INI-9X00U/UW"; -char *i91uVersion = "v1.03g"; +char *i91uVersion = "v1.04"; #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0])) #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) )) @@ -238,12 +237,12 @@ static void i91uAppendSRBToQueue(HCS * p ULONG flags; spin_lock_irqsave(&(pHCB->pSRB_lock), flags); - pSRB->next = NULL; /* Pointer to next */ + pSRB->host_scribble = NULL; /* Pointer to next */ if (pHCB->pSRB_head == NULL) pHCB->pSRB_head = pSRB; else - pHCB->pSRB_tail->next = pSRB; /* Pointer to next */ + pHCB->pSRB_tail->host_scribble = (char *)pSRB; /* Pointer to next */ pHCB->pSRB_tail = pSRB; spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); @@ -265,8 +264,8 @@ static Scsi_Cmnd *i91uPopSRBFromQueue(HC spin_lock_irqsave(&(pHCB->pSRB_lock), flags); if ((pSRB = pHCB->pSRB_head) != NULL) { - pHCB->pSRB_head = pHCB->pSRB_head->next; - pSRB->next = NULL; + pHCB->pSRB_head = (struct scsi_cmnd *)pHCB->pSRB_head->host_scribble; + pSRB->host_scribble = NULL; } spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); @@ -308,6 +307,12 @@ int tul_NewReturnNumberOfAdapters(void) if (((dRegValue & 0xFF00) >> 8) == 0xFF) dRegValue = 0; wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (pci_set_dma_mask(pDev, 0xffffffff)) { + printk(KERN_WARNING + "i91u: Could not set 32 bit DMA mask\n"); + continue; + } + if (Addi91u_into_Adapter_table(wBIOS, (pDev->resource[0].start), pDev->irq, @@ -346,12 +351,7 @@ int i91u_detect(Scsi_Host_Template * tpn #endif } /* Get total number of adapters in the motherboard */ -#ifdef CONFIG_PCI iAdapters = tul_NewReturnNumberOfAdapters(); -#else - iAdapters = tul_ReturnNumberOfAdapters(); -#endif - if (iAdapters == 0) /* If no tulip founded, return */ return (0); @@ -370,7 +370,7 @@ int i91u_detect(Scsi_Host_Template * tpn for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { i = tul_num_ch * tul_num_scb * sizeof(SCB); - if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) + if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC)) != NULL) break; } if (tul_scb == NULL) { @@ -381,7 +381,7 @@ int i91u_detect(Scsi_Host_Template * tpn pSCB = tul_scb; for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) { - pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]); + pSCB->SCB_SGPAddr = (u32)&pSCB->SCB_SGList[0]; } for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */ @@ -476,6 +476,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB SG *pSG; /* Pointer to SG list */ int i; long TotalLen; + dma_addr_t dma_addr; pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */ pSCB->SCB_Srb = SCpnt; @@ -484,11 +485,13 @@ static void i91uBuildSCB(HCS * pHCB, SCB pSCB->SCB_Target = SCpnt->device->id; pSCB->SCB_Lun = SCpnt->device->lun; pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW; - pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ - - pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer); + pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer, + SENSE_SIZE, DMA_FROM_DEVICE); + pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr); pSCB->SCB_SenseLen = SENSE_SIZE; + SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr; pSCB->SCB_CDBLen = SCpnt->cmd_len; pSCB->SCB_HaStat = 0; @@ -503,30 +506,32 @@ static void i91uBuildSCB(HCS * pHCB, SCB if (SCpnt->use_sg) { pSrbSG = (struct scatterlist *) SCpnt->request_buffer; - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */ - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address); - TotalLen = pSrbSG->length; - pSCB->SCB_SGLen = 0; - } else { /* Assign SG physical address */ - pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr; - pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ - for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ - i < SCpnt->use_sg; - i++, pSG++, pSrbSG++) { - pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address); - TotalLen += pSG->SG_Len = pSrbSG->length; - } - pSCB->SCB_SGLen = i; + + pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG, + SCpnt->use_sg, SCpnt->sc_data_direction); + /* todo handle map_sg error */ + pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ + for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ + i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) { + pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG)); + TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG)); } + + pSCB->SCB_BufPtr = pSCB->SCB_SGList[0].SG_Ptr; pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ? TotalLen : SCpnt->request_bufflen; - } else { /* Non SG */ - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer); - pSCB->SCB_BufLen = SCpnt->request_bufflen; + } else if (SCpnt->request_bufflen) { /* Non SG */ + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer, + SCpnt->request_bufflen, + SCpnt->sc_data_direction); + SCpnt->SCp.dma_handle = dma_addr; + pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr); + pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen); + pSCB->SCB_SGLen = 0; + } else { + pSCB->SCB_BufLen = 0; pSCB->SCB_SGLen = 0; } - - return; } /* @@ -623,6 +628,28 @@ int i91u_biosparam(struct scsi_device *s return 0; } +static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) +{ + /* auto sense buffer */ + if (cmnd->SCp.ptr) { + dma_unmap_single(&pci_dev->dev, + (dma_addr_t)((unsigned long)cmnd->SCp.ptr), + SENSE_SIZE, SCSI_DATA_READ); + cmnd->SCp.ptr = NULL; + } + + /* request buffer */ + if (cmnd->use_sg) { + dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer, + cmnd->use_sg, + cmnd->sc_data_direction); + } else if (cmnd->request_bufflen) { + dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, + cmnd->request_bufflen, + cmnd->sc_data_direction); + } +} + /***************************************************************************** Function name : i91uSCBPost Description : This is callback routine be called when tulip finish one @@ -686,6 +713,8 @@ static void i91uSCBPost(BYTE * pHcb, BYT if (pSRB == NULL) { printk("pSRB is NULL\n"); } + + i91u_unmap_cmnd(pHCB->pci_dev, pSRB); pSRB->scsi_done(pSRB); /* Notify system DONE */ if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL) /* Find the next pending SRB */ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-18 9:45 ` Mike Christie @ 2003-12-19 2:14 ` James Daniel 2003-12-19 9:26 ` Mike Christie 0 siblings, 1 reply; 10+ messages in thread From: James Daniel @ 2003-12-19 2:14 UTC (permalink / raw) To: SCSI Mailing List; +Cc: James Bottomley, Mike Christie > Try the attached patch. It was built against 2.6.0-test11. I do not have > the HW and the other testers I know about are only using their card for > scsi cd writers, so I only know it compiles. > > > mike // all prior lines same as previous, including the error handler messages.. SCSI device sda: drive cache: write back sda:/*~25 second pause*/scsi: Device offlined - not ready after error recover: host 0 channel 0 id 1 lun 0 SCSI error : <0 0 1 0> return code - 0x6000000 end_request: I/O error, dev sda, sector 0 Buffer I/O error on device sda, logical block 0 scsi0 (1:0): rejection I/O to offline device Buffer I/O error on device sda, logical block 0 unable to read partition table Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 still no root fs. The errors have changed.. and I consider that a degree of progress. Thank you Mike :) -- James Daniel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-19 2:14 ` James Daniel @ 2003-12-19 9:26 ` Mike Christie 2003-12-19 11:15 ` Mike Christie 0 siblings, 1 reply; 10+ messages in thread From: Mike Christie @ 2003-12-19 9:26 UTC (permalink / raw) To: James Daniel; +Cc: SCSI Mailing List, James Bottomley > // all prior lines same as previous, including the error handler messages.. > SCSI device sda: drive cache: write back > sda:/*~25 second pause*/scsi: Device offlined - not ready after error > recover: host 0 channel 0 id 1 lun 0 > SCSI error : <0 0 1 0> return code - 0x6000000 > end_request: I/O error, dev sda, sector 0 > Buffer I/O error on device sda, logical block 0 > scsi0 (1:0): rejection I/O to offline device > Buffer I/O error on device sda, logical block 0 > unable to read partition table > Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 > Ok, in the orginal patch I forgot to replace the shared buffer with a DMA-API equiv. This will take some time. mike ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-19 9:26 ` Mike Christie @ 2003-12-19 11:15 ` Mike Christie 2003-12-21 11:09 ` [FIXED] Initio 9100u -- It lives James Daniel 2003-12-21 15:46 ` Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Bottomley 0 siblings, 2 replies; 10+ messages in thread From: Mike Christie @ 2003-12-19 11:15 UTC (permalink / raw) To: James Daniel; +Cc: SCSI Mailing List, James Bottomley [-- Attachment #1: Type: TEXT/PLAIN, Size: 867 bytes --] On Fri, 19 Dec 2003, Mike Christie wrote: > > > // all prior lines same as previous, including the error handler messages.. > > SCSI device sda: drive cache: write back > > sda:/*~25 second pause*/scsi: Device offlined - not ready after error > > recover: host 0 channel 0 id 1 lun 0 > > SCSI error : <0 0 1 0> return code - 0x6000000 > > end_request: I/O error, dev sda, sector 0 > > Buffer I/O error on device sda, logical block 0 > > scsi0 (1:0): rejection I/O to offline device > > Buffer I/O error on device sda, logical block 0 > > unable to read partition table > > Attached scsi disk sda at scsi0, channel 0, id 1, lun 0 > > > > Ok, in the orginal patch I forgot to replace the shared buffer with a > DMA-API equiv. This will take some time. > Here is another try. It should compile against 2.6.0-test11/2.6.0. mike Mike Christie mikenc@us.ibm.com [-- Attachment #2: Type: TEXT/PLAIN, Size: 8424 bytes --] --- linux-2.6.0-test11-orig/drivers/scsi/ini9100u.c 2003-12-19 02:51:01.468388841 -0800 +++ linux-2.6.0-test11-work/drivers/scsi/ini9100u.c 2003-12-19 03:03:29.599819709 -0800 @@ -104,12 +104,12 @@ * Now fixed. * 05/07/99 bv - v1.03g * - Changed the assumption that HZ = 100 + * 10/17/03 mc - v1.04 + * - added new DMA API support **************************************************************************/ #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S) -#error Please convert me to Documentation/DMA-mapping.txt - #ifndef LINUX_VERSION_CODE #include <linux/version.h> #endif @@ -143,13 +143,12 @@ unsigned int i91u_debug = DEBUG_DEFAULT; static Scsi_Host_Template driver_template = { .proc_name = "INI9100U", - .proc_info = "INI9100U", .name = i91u_REVID, .detect = i91u_detect, .release = i91u_release, .queuecommand = i91u_queue, - .abort = i91u_abort, - .reset = i91u_reset, +// .abort = i91u_abort, +// .reset = i91u_reset, .bios_param = i91u_biosparam, .can_queue = 1, .this_id = 1, @@ -162,7 +161,7 @@ static Scsi_Host_Template driver_templat char *i91uCopyright = "Copyright (C) 1996-98"; char *i91uInitioName = "by Initio Corporation"; char *i91uProductName = "INI-9X00U/UW"; -char *i91uVersion = "v1.03g"; +char *i91uVersion = "v1.04"; #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0])) #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) )) @@ -238,12 +237,12 @@ static void i91uAppendSRBToQueue(HCS * p ULONG flags; spin_lock_irqsave(&(pHCB->pSRB_lock), flags); - pSRB->next = NULL; /* Pointer to next */ + pSRB->host_scribble = NULL; /* Pointer to next */ if (pHCB->pSRB_head == NULL) pHCB->pSRB_head = pSRB; else - pHCB->pSRB_tail->next = pSRB; /* Pointer to next */ + pHCB->pSRB_tail->host_scribble = (char *)pSRB; /* Pointer to next */ pHCB->pSRB_tail = pSRB; spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); @@ -265,8 +264,8 @@ static Scsi_Cmnd *i91uPopSRBFromQueue(HC spin_lock_irqsave(&(pHCB->pSRB_lock), flags); if ((pSRB = pHCB->pSRB_head) != NULL) { - pHCB->pSRB_head = pHCB->pSRB_head->next; - pSRB->next = NULL; + pHCB->pSRB_head = (struct scsi_cmnd *)pHCB->pSRB_head->host_scribble; + pSRB->host_scribble = NULL; } spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags); @@ -308,6 +307,12 @@ int tul_NewReturnNumberOfAdapters(void) if (((dRegValue & 0xFF00) >> 8) == 0xFF) dRegValue = 0; wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8)); + if (pci_set_dma_mask(pDev, 0xffffffff)) { + printk(KERN_WARNING + "i91u: Could not set 32 bit DMA mask\n"); + continue; + } + if (Addi91u_into_Adapter_table(wBIOS, (pDev->resource[0].start), pDev->irq, @@ -323,7 +328,6 @@ int tul_NewReturnNumberOfAdapters(void) int i91u_detect(Scsi_Host_Template * tpnt) { - SCB *pSCB; HCS *pHCB; struct Scsi_Host *hreg; unsigned long i; /* 01/14/98 */ @@ -346,12 +350,7 @@ int i91u_detect(Scsi_Host_Template * tpn #endif } /* Get total number of adapters in the motherboard */ -#ifdef CONFIG_PCI iAdapters = tul_NewReturnNumberOfAdapters(); -#else - iAdapters = tul_ReturnNumberOfAdapters(); -#endif - if (iAdapters == 0) /* If no tulip founded, return */ return (0); @@ -379,11 +378,6 @@ int i91u_detect(Scsi_Host_Template * tpn } memset((unsigned char *) tul_scb, 0, i); - pSCB = tul_scb; - for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) { - pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]); - } - for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */ i < tul_num_ch; i++, pHCB++) { @@ -476,6 +470,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB SG *pSG; /* Pointer to SG list */ int i; long TotalLen; + dma_addr_t dma_addr; pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */ pSCB->SCB_Srb = SCpnt; @@ -484,11 +479,13 @@ static void i91uBuildSCB(HCS * pHCB, SCB pSCB->SCB_Target = SCpnt->device->id; pSCB->SCB_Lun = SCpnt->device->lun; pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW; - pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ - - pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer); + pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */ + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer, + SENSE_SIZE, DMA_FROM_DEVICE); + pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr); pSCB->SCB_SenseLen = SENSE_SIZE; + SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr; pSCB->SCB_CDBLen = SCpnt->cmd_len; pSCB->SCB_HaStat = 0; @@ -500,33 +497,39 @@ static void i91uBuildSCB(HCS * pHCB, SCB } else { pSCB->SCB_TagMsg = 0; /* No tag support */ } - + /* todo handle map_sg error */ if (SCpnt->use_sg) { + dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0], + sizeof(struct SG_Struc) * TOTAL_SG_ENTRY, + DMA_BIDIRECTIONAL); + pSCB->SCB_BufPtr = dma_addr; + SCpnt->SCp.dma_handle = dma_addr; + pSrbSG = (struct scatterlist *) SCpnt->request_buffer; - if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */ - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address); - TotalLen = pSrbSG->length; - pSCB->SCB_SGLen = 0; - } else { /* Assign SG physical address */ - pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr; - pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ - for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ - i < SCpnt->use_sg; - i++, pSG++, pSrbSG++) { - pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address); - TotalLen += pSG->SG_Len = pSrbSG->length; - } - pSCB->SCB_SGLen = i; + pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG, + SCpnt->use_sg, SCpnt->sc_data_direction); + + pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ + for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ + i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) { + pSG->SG_Ptr = (u32)sg_dma_address(pSrbSG); + TotalLen += pSG->SG_Len = (u32)sg_dma_len(pSrbSG); } + pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ? TotalLen : SCpnt->request_bufflen; - } else { /* Non SG */ - pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer); - pSCB->SCB_BufLen = SCpnt->request_bufflen; + } else if (SCpnt->request_bufflen) { /* Non SG */ + dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer, + SCpnt->request_bufflen, + SCpnt->sc_data_direction); + SCpnt->SCp.dma_handle = dma_addr; + pSCB->SCB_BufPtr = (u32)dma_addr; + pSCB->SCB_BufLen = (u32)SCpnt->request_bufflen; + pSCB->SCB_SGLen = 0; + } else { + pSCB->SCB_BufLen = 0; pSCB->SCB_SGLen = 0; } - - return; } /* @@ -623,6 +626,32 @@ int i91u_biosparam(struct scsi_device *s return 0; } +static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd) +{ + /* auto sense buffer */ + if (cmnd->SCp.ptr) { + dma_unmap_single(&pci_dev->dev, + (dma_addr_t)((unsigned long)cmnd->SCp.ptr), + SENSE_SIZE, SCSI_DATA_READ); + cmnd->SCp.ptr = NULL; + } + + /* request buffer */ + if (cmnd->use_sg) { + dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, + sizeof(struct SG_Struc) * TOTAL_SG_ENTRY, + DMA_BIDIRECTIONAL); + + dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer, + cmnd->use_sg, + cmnd->sc_data_direction); + } else if (cmnd->request_bufflen) { + dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle, + cmnd->request_bufflen, + cmnd->sc_data_direction); + } +} + /***************************************************************************** Function name : i91uSCBPost Description : This is callback routine be called when tulip finish one @@ -686,6 +715,8 @@ static void i91uSCBPost(BYTE * pHcb, BYT if (pSRB == NULL) { printk("pSRB is NULL\n"); } + + i91u_unmap_cmnd(pHCB->pci_dev, pSRB); pSRB->scsi_done(pSRB); /* Notify system DONE */ if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL) /* Find the next pending SRB */ ^ permalink raw reply [flat|nested] 10+ messages in thread
* [FIXED] Initio 9100u -- It lives 2003-12-19 11:15 ` Mike Christie @ 2003-12-21 11:09 ` James Daniel 2003-12-21 15:46 ` Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Bottomley 1 sibling, 0 replies; 10+ messages in thread From: James Daniel @ 2003-12-21 11:09 UTC (permalink / raw) To: Mike Christie; +Cc: SCSI Mailing List, James Bottomley > On Fri, 19 Dec 2003, Mike Christie wrote: > > > Ok, in the orginal patch I forgot to replace the shared buffer with a > > DMA-API equiv. This will take some time. > > > > Here is another try. It should compile against 2.6.0-test11/2.6.0. It appears to be working again. Mad props. The card has left my server, however. I dug up a 2940u2w. The ini9100u now resides in a test box which is still actively using the card and actually has a monitor permanently attached, so I'll be able to do much better diagnostics on it now. Currently it's loaded as a module, not being used for root fs, and is reading the drive attached to the card quite nicely. As soon as I have a distro running 2.6 running a root partition via scsi, I'll be sure to let the list know how it goes. Thanks Mike =) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-19 11:15 ` Mike Christie 2003-12-21 11:09 ` [FIXED] Initio 9100u -- It lives James Daniel @ 2003-12-21 15:46 ` James Bottomley 2003-12-22 23:42 ` Mike Christie 1 sibling, 1 reply; 10+ messages in thread From: James Bottomley @ 2003-12-21 15:46 UTC (permalink / raw) To: Mike Christie; +Cc: James Daniel, SCSI Mailing List On Fri, 2003-12-19 at 05:15, Mike Christie wrote: > Here is another try. It should compile against 2.6.0-test11/2.6.0. That's great thanks. I've put it in the scsi tree. I did notice in the diffs between this one and the previous patch things like: - pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG)); - TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG)); + pSG->SG_Ptr = (u32)sg_dma_address(pSrbSG); + TotalLen += pSG->SG_Len = (u32)sg_dma_len(pSrbSG); Which is obviously incorrect, since sg_dma_address() does return the address in CPU endianness (and the device SG list needs to be in PCI endiannes), but I think, since it was hard enough to find anyone with one of these things, that the chances of finding one on a non-x86 box are zero. James ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors 2003-12-21 15:46 ` Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Bottomley @ 2003-12-22 23:42 ` Mike Christie 0 siblings, 0 replies; 10+ messages in thread From: Mike Christie @ 2003-12-22 23:42 UTC (permalink / raw) To: James Bottomley; +Cc: James Daniel, SCSI Mailing List [-- Attachment #1: Type: TEXT/PLAIN, Size: 1193 bytes --] On 21 Dec 2003, James Bottomley wrote: > On Fri, 2003-12-19 at 05:15, Mike Christie wrote: > > Here is another try. It should compile against 2.6.0-test11/2.6.0. > > That's great thanks. I've put it in the scsi tree. > > I did notice in the diffs between this one and the previous patch things > like: > > > - pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG)); > - TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG)); > + pSG->SG_Ptr = (u32)sg_dma_address(pSrbSG); > + TotalLen += pSG->SG_Len = (u32)sg_dma_len(pSrbSG); > > Which is obviously incorrect, since sg_dma_address() does return the > address in CPU endianness (and the device SG list needs to be in PCI > endiannes), I read the docs and added the cpu_to_le32 calls, but when the patch failed for JamesD I looked at the Initio driver that was already converted and noticed it was not managing the endiannes so I put 2 and 2 together and got 3. but I think, since it was hard enough to find anyone with > one of these things, that the chances of finding one on a non-x86 box > are zero. > The attached patch adds the cpu_to_le32 calls just in case. It was built against my previous patch. mike [-- Attachment #2: Type: TEXT/PLAIN, Size: 1971 bytes --] --- linux-2.6.0-test11-orig/drivers/scsi/ini9100u.c 2003-12-22 15:30:15.927861943 -0800 +++ linux-2.6.0-test11-work/drivers/scsi/ini9100u.c 2003-12-22 15:28:28.393293412 -0800 @@ -484,7 +484,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer, SENSE_SIZE, DMA_FROM_DEVICE); pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr); - pSCB->SCB_SenseLen = SENSE_SIZE; + pSCB->SCB_SenseLen = cpu_to_le32(SENSE_SIZE); SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr; pSCB->SCB_CDBLen = SCpnt->cmd_len; @@ -502,7 +502,7 @@ static void i91uBuildSCB(HCS * pHCB, SCB dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0], sizeof(struct SG_Struc) * TOTAL_SG_ENTRY, DMA_BIDIRECTIONAL); - pSCB->SCB_BufPtr = dma_addr; + pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr); SCpnt->SCp.dma_handle = dma_addr; pSrbSG = (struct scatterlist *) SCpnt->request_buffer; @@ -512,8 +512,8 @@ static void i91uBuildSCB(HCS * pHCB, SCB pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */ for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */ i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) { - pSG->SG_Ptr = (u32)sg_dma_address(pSrbSG); - TotalLen += pSG->SG_Len = (u32)sg_dma_len(pSrbSG); + pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG)); + TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG)); } pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ? @@ -523,8 +523,8 @@ static void i91uBuildSCB(HCS * pHCB, SCB SCpnt->request_bufflen, SCpnt->sc_data_direction); SCpnt->SCp.dma_handle = dma_addr; - pSCB->SCB_BufPtr = (u32)dma_addr; - pSCB->SCB_BufLen = (u32)SCpnt->request_bufflen; + pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr); + pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen); pSCB->SCB_SGLen = 0; } else { pSCB->SCB_BufLen = 0; ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-12-22 23:46 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-12-17 9:05 Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Daniel 2003-12-17 14:24 ` James Bottomley 2003-12-18 7:00 ` Mike Christie 2003-12-18 9:45 ` Mike Christie 2003-12-19 2:14 ` James Daniel 2003-12-19 9:26 ` Mike Christie 2003-12-19 11:15 ` Mike Christie 2003-12-21 11:09 ` [FIXED] Initio 9100u -- It lives James Daniel 2003-12-21 15:46 ` Initio 9100u -- Mike Christie's 2.6.0-test11 Patch -- Kernel Errors James Bottomley 2003-12-22 23:42 ` Mike Christie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox