Index: dc390/2035-scsi-singlelun.diff =================================================================== RCS file: 2035-scsi-singlelun.diff diff -N 2035-scsi-singlelun.diff --- /dev/null Mon Dec 22 21:49:24 1997 +++ /tmp/01192aaa Thu Aug 20 12:18:37 1998 @@ -0,0 +1,45 @@ +From: Edgar Toernig +Subject: [PATCH] 2.0.35 scsi.c single_lun flag + +Hi, + +as I (or better Derrick) noticed, the fix for the single_lun flag never +made it to the 2.0 kernels. It's already present in the 2.1 kernels +since 2.1.75 and in my 2.0 kernel for over a year now. + +This patch is required by some CD-changers. Without it, you may get +spurious scsi lockups when accessing multiple LUNs at the same time. + +Ciao, ET. + +--- /usr/src/linux-2.0.35/drivers/scsi/scsi.c.orig Fri Aug 7 02:21:37 1998 ++++ /usr/src/linux-2.0.35/drivers/scsi/scsi.c Fri Aug 7 02:24:12 1998 +@@ -750,6 +750,13 @@ + SDpnt->borken = 0; + ++ /* ++ * If we want to only allow I/O to one of the luns attached to this device ++ * at a time, then we set this flag. ++ */ ++ if (bflags & BLIST_SINGLELUN) ++ SDpnt->single_lun = 1; ++ + /* + * These devices need this "key" to unlock the devices so we can use it + */ + if ((bflags & BLIST_KEY) != 0) { +@@ -790,13 +797,6 @@ + */ + if (bflags & BLIST_NOLUN) + return 0; /* break; */ + +- /* +- * If we want to only allow I/O to one of the luns attached to this device +- * at a time, then we set this flag. +- */ +- if (bflags & BLIST_SINGLELUN) +- SDpnt->single_lun = 1; +- + /* + * If this device is known to support sparse multiple units, override the + Index: dc390/21115-sr_ioctl.diff =================================================================== RCS file: 21115-sr_ioctl.diff diff -N 21115-sr_ioctl.diff --- /dev/null Mon Dec 22 21:49:24 1997 +++ /tmp/01192baa Thu Aug 20 12:18:37 1998 @@ -0,0 +1,14 @@ +--- linux/drivers/scsi/sr_ioctl.c.21115 Tue Aug 4 20:50:51 1998 ++++ linux/drivers/scsi/sr_ioctl.c Mon Aug 17 21:22:46 1998 +@@ -56,7 +56,10 @@ + unsigned long flags; + + SDev = scsi_CDs[target].device; +- SCpnt = scsi_allocate_device(NULL, scsi_CDs[target].device, 1); ++ ++ spin_lock_irqsave(&io_request_lock, flags); ++ SCpnt = scsi_allocate_device(NULL, SDev, 1); ++ spin_unlock_irqrestore(&io_request_lock, flags); + + retry: + if( !scsi_block_when_processing_errors(SDev) ) Index: dc390/README.tmscsim =================================================================== RCS file: /usr/local/cvsroot/dc390/README.tmscsim,v retrieving revision 1.18 retrieving revision 1.20 diff -u -r1.18 -r1.20 --- README.tmscsim 1998/07/13 22:29:00 1.18 +++ README.tmscsim 1998/08/20 09:28:41 1.20 @@ -77,6 +77,10 @@ * have copies of your SCSI disk's partition tables on some safe location: dd if=/dev/sda of=/mnt/floppy/sda bs=512 count=1 +If you want to share the IRQ with another device and the driver refuses to +do, you might succeed with changing the DC390_IRQ type in tmscsim.c to +SA_SHIRQ | SA_INTERRUPT. + 3.Features ---------- @@ -88,11 +92,11 @@ - General * Support for up to 4 adapters. - * DC390 EEPROM usage or Boot/module params + * DC390 EEPROM usage or boot/module params * Information via cat /proc/scsi/tmscsim/? * Dynamically configurable by writing to /proc/scsi/tmscsim/? * Dynamic allocation of resources - * SMP support: Adapter specific locks (Linux 2.1.xx) + * SMP support: Adapter specific locks (Linux 2.1.x) * Uniform source code for Linux-2.x.y * Support for dyn. addition/removal of devices via add/remove-single-device (Try: echo "scsi add-single-device H C I L" >/proc/scsi/scsi @@ -298,12 +302,12 @@ Most of the intended work on the driver has been done. Here are a few ideas to further improve its usability: +* More intelligent abort() routine * Implement new_eh code (Linux-2.1+) * Have the mid-level code (and not the driver) handle more of the various conditions. * More user friendly boot/module param syntax * Profiling and possibly performance enhancements -* More intelligent abort routine Further investigation on these problems: @@ -317,6 +321,10 @@ * In some situations, the driver will get stuck in an abort loop. Please disable DsCn, if you meet this problem. Please contact me for further debugging. +* 2.0.35: CD changers (e.g. NAKAMICHI MBR-7.{0,2}) have problems because + the mid-level code doesn't handle BLIST_SINGLELUN correctly. Apply + the patch 2035-scsi-singlelun.diff. +* 2.1.115: Linux misses a lock in sr_ioctl.c: Apply 21115-sr_ioctl.diff 7. Bug reports, debugging and updates @@ -351,4 +359,4 @@ ------------------------------------------------------------------------- Written by Kurt Garloff 1998/06/11 Last updated 1998/06/18, driver revision 1.20p -$Id: README.tmscsim,v 1.18 1998/07/13 22:29:00 garloff Exp $ +$Id: README.tmscsim,v 1.20 1998/08/20 09:28:41 garloff Exp $ Index: dc390/dc390-120-kernel.diff =================================================================== RCS file: /usr/local/cvsroot/dc390/dc390-120-kernel.diff,v retrieving revision 1.4 retrieving revision 1.6 diff -u -r1.4 -r1.6 --- dc390-120-kernel.diff 1998/08/07 21:08:03 1.4 +++ dc390-120-kernel.diff 1998/08/20 10:17:46 1.6 @@ -1,4 +1,4 @@ -# dc390-120-kernel.diff # $Id: dc390-120-kernel.diff,v 1.4 1998/08/07 21:08:03 garloff Exp $ # +# dc390-120-kernel.diff # $Id: dc390-120-kernel.diff,v 1.6 1998/08/20 10:17:46 garloff Exp $ # 8<---------------------------------------------------------------------- Patch for allowing omission of the non DC390 parts of the driver: 8<---------------------------------------------------------------------- @@ -44,9 +44,9 @@ 8<---------------------------------------------------------------------- Patch to update Documentation: 8<---------------------------------------------------------------------- ---- linux/Documentation/Configure.help.NoDC390NoGen Wed Jun 17 09:32:33 1998 -+++ linux/Documentation/Configure.help Wed Jun 17 09:36:55 1998 -@@ -3603,10 +3603,10 @@ +--- linux/Documentation/Configure.help.21114 Tue Aug 11 09:03:33 1998 ++++ linux/Documentation/Configure.help Tue Aug 11 09:07:34 1998 +@@ -3988,10 +3988,10 @@ say M here and read Documentation/modules.txt. The module will be called NCR53c406.o. @@ -56,13 +56,14 @@ This driver supports the Tekram DC390(T) PCI SCSI host adapter with - the Am53C974A chip, and perhaps other cards using the same chip. + the Am53C974A chip and other cards using the same chip. - This driver does _not_ support the DC390W/U/F adaptor with the + This driver does _not_ support the DC390W/U/F adapter with the NCR/Symbios chips; use "NCR53C8XX SCSI support" for that one. - -@@ -3615,6 +3615,15 @@ + +@@ -3999,6 +3999,15 @@ + inserted in and removed from the running kernel whenever you want), say M here and read Documentation/modules.txt. The module will be called tmscsim.o. - ++ +Skip support for other AM53C974 based SCSI adapters +CONFIG_SCSI_DC390T_NOGENSUPP + Normally the DC390(T) SCSI driver relies on the DC390 EEPROM to get @@ -71,11 +72,9 @@ + module parameters it gets. See linux/drivers/scsi/README.tmscsim for + details on driver configuration. + With this option set, if no EEPROM is found, the driver gives up. -+ + AM53/79C974 PCI SCSI support CONFIG_SCSI_AM53C974 - This is support for the AM53/79C974 SCSI host adapters. Please read - 8<---------------------------------------------------------------------- --- linux/MAINTAINERS.21114 Fri Jul 31 05:06:52 1998 +++ linux/MAINTAINERS Fri Aug 7 23:04:25 1998 Index: dc390/dc390.h =================================================================== RCS file: /usr/local/cvsroot/dc390/dc390.h,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- dc390.h 1998/08/07 21:08:04 1.40 +++ dc390.h 1998/08/20 09:28:41 1.41 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390(T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: dc390.h,v 1.40 1998/08/07 21:08:04 garloff Exp $ */ +/* $Id: dc390.h,v 1.41 1998/08/20 09:28:41 garloff Exp $ */ #include @@ -37,7 +37,7 @@ #define DC390_T { \ proc_dir: &DC390_proc_scsi_tmscsim, \ proc_info: DC390_proc_info, \ - name: "Tekram DC390/AM53C974 V1.20r5 Aug-7-1998", \ + name: "Tekram DC390/AM53C974 V1.20s Aug-20-1998", \ detect: DC390_detect, \ release: DC390_release, \ queuecommand: DC390_queue_command, \ Index: dc390/scsiiom.c =================================================================== RCS file: /usr/local/cvsroot/dc390/scsiiom.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- scsiiom.c 1998/08/07 21:08:04 1.57 +++ scsiiom.c 1998/08/20 09:28:41 1.58 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: scsiiom.c,v 1.57 1998/08/07 21:08:04 garloff Exp $ */ +/* $Id: scsiiom.c,v 1.58 1998/08/20 09:28:41 garloff Exp $ */ UCHAR dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) @@ -150,7 +150,7 @@ { pSRB->SRBState = SRB_READY; pDCB->TagMask &= ~( 1 << pSRB->TagNumber ); - DEBUG0(printk ("DC390: Interrupt StartSCSI!\n");) + DEBUG0(printk ("DC390: Interrupt during StartSCSI!\n");) return 1; } else Index: dc390/tmscsim.c =================================================================== RCS file: /usr/local/cvsroot/dc390/tmscsim.c,v retrieving revision 1.71 retrieving revision 1.75 diff -u -r1.71 -r1.75 --- tmscsim.c 1998/08/07 21:08:04 1.71 +++ tmscsim.c 1998/08/20 10:11:32 1.75 @@ -5,7 +5,7 @@ * Bus Master Host Adapter * * (C)Copyright 1995-1996 Tekram Technology Co., Ltd. * ***********************************************************************/ -/* $Id: tmscsim.c,v 1.71 1998/08/07 21:08:04 garloff Exp $ */ +/* $Id: tmscsim.c,v 1.75 1998/08/20 10:11:32 garloff Exp $ */ /* Enhancements and bugfixes by * * Kurt Garloff * ***********************************************************************/ @@ -74,21 +74,24 @@ * 1.20r 98/06/30 KG Debug macros, allow disabling DsCn, set * * BIT4 in CtrlR4, EN_PAGE_INT, 2.0 module * * param -1 fixed. * - * 1.20r198/07/13 KG Added Register dump on abort. IRQ on PCI* - * abort. PCI checks. * - * 1.20r298/07/23 KG Fixed sel. process & EN_ATN_STOP, phys * - * changed to bus * - * 1.20r598/08/07 KG Fixed locking. Updated MAINTAINERS. * + * 1.20s 98/08/20 KG Debug info on abort(), try to check PCI,* + * phys_to_bus instead of phys_to_virt, * + * fixed sel. process, fixed locking, * + * added MODULE_XXX infos, changed IRQ * + * request flags, disable DMA_INT * ***********************************************************************/ +/* Uncomment SA_INTERRUPT, if the driver refuses to share IRQs with another device */ +#define DC390_IRQ SA_SHIRQ /* | SA_INTERRUPT */ -//#define DEBUG_SPINLOCKS 2 /* Set to 0, 1 or 2 in include/asm/spinlock.h */ -#define DC390_DEBUG0 +/* DEBUG options */ +//#define DC390_DEBUG0 //#define DC390_DEBUG1 //#define DC390_DCBDEBUG //#define DC390_PARSEDEBUG //#define DC390_REMOVABLEDEBUG +/* Debug definitions */ #ifdef DC390_DEBUG0 # define DEBUG0(x) x; #else @@ -116,6 +119,7 @@ #endif #define DCBDEBUG1(x) +/* Includes */ #ifdef MODULE # include #endif @@ -148,6 +152,8 @@ #define PCI_DEVICE_ID_AMD53C974 PCI_DEVICE_ID_AMD_SCSI +/* Locking */ + /* Note: Starting from 2.1.9x, the mid-level scsi code issues a * spinlock_irqsave (&io_request_lock) before calling the driver's * routines, so we don't need to lock. @@ -164,6 +170,8 @@ * undef : traditional save_flags; cli; restore_flags; */ +//#define DEBUG_SPINLOCKS 2 /* Set to 0, 1 or 2 in include/asm/spinlock.h */ + #define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s)) #if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30) @@ -275,7 +283,9 @@ # define DC390_LOCK_INIT #endif /* def */ + /* These macros are used for uniform access to 2.0.x and 2.1.x PCI config space*/ + #ifdef NEW_PCI # define PDEV pdev # define PDEVDECL struct pci_dev *pdev @@ -320,11 +330,6 @@ # define __initfunc(x) x #endif -struct proc_dir_entry DC390_proc_scsi_tmscsim ={ - PROC_SCSI_DC390T, 7 ,"tmscsim", - S_IFDIR | S_IRUGO | S_IXUGO, 2 - }; - UCHAR dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ); void dc390_DataOut_0( PACB pACB, PSRB pSRB, PUCHAR psstatus); void dc390_DataIn_0( PACB pACB, PSRB pSRB, PUCHAR psstatus); @@ -385,11 +390,19 @@ | LUN_CHECK # endif , 3 /* 16 Tags per LUN */}; + # if defined(MODULE) && LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30) MODULE_PARM(tmscsim, "1-5i"); +MODULE_PARM_DESC(tmscsim, "Host SCSI ID, Speed (0=10MHz), Device Flags, Adapter Flags, Max Tags (log2(tags)-1)"); # endif + #endif /* CONFIG_SCSI_DC390T_NOGENSUPP */ +#if defined(MODULE) && LINUX_VERSION_CODE >= LinuxVersionCode(2,1,30) +MODULE_AUTHOR("C.L. Huang / Kurt Garloff"); +MODULE_DESCRIPTION("SCSI host adapter driver for Tekram DC390 and other AMD53C974A based PCI SCSI adapters"); +MODULE_SUPPORTED_DEVICE("sd,sr,sg,st"); +#endif static PVOID dc390_phase0[]={ dc390_DataOut_0, @@ -441,19 +454,21 @@ }; #endif -UCHAR dc390_eepromBuf[MAX_ADAPTER_NUM][EE_LEN]; - -static char* dc390_adapname = "DC390"; - -UCHAR dc390_clock_period1[] = {4, 5, 6, 7, 8, 10, 13, 20}; - /* Devices erroneously pretending to be able to do TagQ */ UCHAR dc390_baddevname1[2][28] ={ "SEAGATE ST3390N 9546", "HP C3323-300 4269"}; - #define BADDEVCNT 2 +static char* dc390_adapname = "DC390"; +UCHAR dc390_eepromBuf[MAX_ADAPTER_NUM][EE_LEN]; +UCHAR dc390_clock_period1[] = {4, 5, 6, 7, 8, 10, 13, 20}; + +struct proc_dir_entry DC390_proc_scsi_tmscsim ={ + PROC_SCSI_DC390T, 7 ,"tmscsim", + S_IFDIR | S_IRUGO | S_IXUGO, 2 + }; + /*********************************************************************** * * @@ -944,32 +959,34 @@ int status; DC390_AFLAGS PACB pACB = (PACB) cmd->host->hostdata; - DEBUG0(PDEVDECL1;USHORT pstat;) + PDEVDECL1; USHORT pstat; DC390_LOCK_ACB; pDCB = dc390_findDCB (pACB, cmd); - DEBUG0(if(pDCB) pSRB = pDCB->pActiveSRB; else pSRB = 0;) - DEBUG0(printk ("DC390: Abort command (pid %li, DCB %p, SRB %p)\n", - cmd->pid, pDCB, pSRB);) - DEBUG0(if (pSRB) printk ("DC390: SRB: Xferred %08lx, Remain %08lx, State %08lx, Phase %02x\n", - pSRB->TotalXferredLen, pSRB->SGToBeXferLen, pSRB->SRBState, - pSRB->ScsiPhase);) - DEBUG0(printk ("DC390: Register dump: SCSI block:\n");) - DEBUG0(printk ("DC390: XferCnt Cmd Stat IRQS IntS FFIS Ctl1 Ctl2 Ctl3 Ctl4\n");) - DEBUG0(printk ("DC390: %06x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - DC390_read8(CtcReg_Low) + (DC390_read8(CtcReg_Mid) << 8) + (DC390_read8(CtcReg_High) << 24), - DC390_read8(ScsiCmd), DC390_read8(Scsi_Status), DC390_read8(INT_Status), - DC390_read8(Intern_State), DC390_read8(Current_Fifo), DC390_read8(CtrlReg1), - DC390_read8(CtrlReg2), DC390_read8(CtrlReg3), DC390_read8(CtrlReg4));) - DEBUG0(printk ("DC390: Register dump: DMA engine:\n");) - DEBUG0(printk ("DC390: Cmd STrCnt SBusA WrkBC WrkAC Stat SBusCtrl\n");) - DEBUG0(printk ("DC390: %02x %08x %08x %08x %08x %02x %08x\n", - DC390_read8(DMA_Cmd), DC390_read32(DMA_XferCnt), DC390_read32(DMA_XferAddr), - DC390_read32(DMA_Wk_ByteCntr), DC390_read32(DMA_Wk_AddrCntr), - DC390_read8(DMA_Status), DC390_read32(DMA_ScsiBusCtrl));) - DEBUG0(PDEVSET1; PCI_READ_CONFIG_WORD(PDEV, PCI_STATUS, &pstat);) - DEBUG0(printk ("DC390: Register dump: PCI Status: %04x\n", pstat);) + /* abort() is too buggy at the moment. If it's called we are in trouble anyway. + * so let's dump some info into the syslog at least. (KG, 98/08/20) */ + if (pDCB) pSRB = pDCB->pActiveSRB; else pSRB = 0; + printk ("DC390: Abort command (pid %li, DCB %p, SRB %p)\n", + cmd->pid, pDCB, pSRB); + if (pSRB) printk ("DC390: SRB: Xferred %08lx, Remain %08lx, State %08lx, Phase %02x\n", + pSRB->TotalXferredLen, pSRB->SGToBeXferLen, pSRB->SRBState, + pSRB->ScsiPhase); + printk ("DC390: Register dump: SCSI block:\n"); + printk ("DC390: XferCnt Cmd Stat IRQS IntS FFIS Ctl1 Ctl2 Ctl3 Ctl4\n"); + printk ("DC390: %06x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", + DC390_read8(CtcReg_Low) + (DC390_read8(CtcReg_Mid) << 8) + (DC390_read8(CtcReg_High) << 24), + DC390_read8(ScsiCmd), DC390_read8(Scsi_Status), DC390_read8(INT_Status), + DC390_read8(Intern_State), DC390_read8(Current_Fifo), DC390_read8(CtrlReg1), + DC390_read8(CtrlReg2), DC390_read8(CtrlReg3), DC390_read8(CtrlReg4)); + printk ("DC390: Register dump: DMA engine:\n"); + printk ("DC390: Cmd STrCnt SBusA WrkBC WrkAC Stat SBusCtrl\n"); + printk ("DC390: %02x %08x %08x %08x %08x %02x %08x\n", + DC390_read8(DMA_Cmd), DC390_read32(DMA_XferCnt), DC390_read32(DMA_XferAddr), + DC390_read32(DMA_Wk_ByteCntr), DC390_read32(DMA_Wk_AddrCntr), + DC390_read8(DMA_Status), DC390_read32(DMA_ScsiBusCtrl)); + PDEVSET1; PCI_READ_CONFIG_WORD(PDEV, PCI_STATUS, &pstat); + printk ("DC390: Register dump: PCI Status: %04x\n", pstat); if( !pDCB ) goto NOT_RUN; @@ -1051,8 +1068,8 @@ if( (pACB->pActiveDCB == pDCB) && (pDCB->pActiveSRB == pSRB) ) { status = SCSI_ABORT_BUSY; - DEBUG0(printk ("DC390: Abort current command (pid %li, SRB %p)\n",\ - cmd->pid, pSRB);) + printk ("DC390: Abort current command (pid %li, SRB %p)\n", + cmd->pid, pSRB); if (cmd->pid == dc390_lastabortedpid) /* repeated failure ? */ { /* Let's do something to help the bus getting clean again */ @@ -1081,7 +1098,7 @@ ABO_X: cmd->result = DID_ABORT << 16; - DEBUG0(printk(KERN_INFO "DC390: Aborted pid %li with status %i\n", cmd->pid, status);) + printk(KERN_INFO "DC390: Aborted pid %li with status %i\n", cmd->pid, status); dc390_lastabortedpid = cmd->pid; DC390_UNLOCK_ACB; //do_DC390_Interrupt (pACB->IRQLevel, 0, 0); @@ -1443,15 +1460,11 @@ if( !used_irq ) { - if( (i = request_irq(Irq, do_DC390_Interrupt, SA_INTERRUPT | SA_SHIRQ, "tmscsim", NULL) )) - { - - if ((i = request_irq (Irq, do_DC390_Interrupt, SA_SHIRQ, "tmscsim", NULL))) + if( (i = request_irq(Irq, do_DC390_Interrupt, DC390_IRQ, "tmscsim", NULL) )) { printk(KERN_ERR "DC390: register IRQ error!\n"); return( -1 ); } - } } if (check_region (io_port, psh->n_io_port)) @@ -1698,7 +1711,7 @@ if (dc390_CheckEEpromCheckSum (PDEV, index)) { int period; - printk (KERN_WARNING "DC390_init: EEPROM reading error!\n"); + printk (KERN_WARNING "DC390_init: No EEPROM found!\n"); #ifdef CONFIG_SCSI_DC390T_NOGENSUPP return( -1 ); #else @@ -2269,7 +2282,7 @@ return dc390_set_info(buffer, length, pACB); SPRINTF("Tekram DC390/AM53C974 PCI SCSI Host Adapter, "); - SPRINTF("Driver Version 1.20r5, 1998/08/07\n"); + SPRINTF("Driver Version 1.20s, 1998/08/20\n"); DC390_LOCK_ACB;