Index: dc390/README.tmscsim =================================================================== RCS file: /usr/local/cvsroot/dc390/README.tmscsim,v retrieving revision 2.13 retrieving revision 2.18 diff -u -r2.13 -r2.18 --- dc390/README.tmscsim 1999/06/01 00:39:52 2.13 +++ dc390/README.tmscsim 1999/06/01 22:39:13 2.18 @@ -222,21 +222,24 @@ performance. (3) Special commands: You can force a SCSI bus reset, an INQUIRY command and - the removal of a device's DCB. + the removal or the addition of a device's DCB. This is only used for debugging when you meet problems. The parameter of - the INQUIRY and remove command is the device index as shown by the + the INQUIRY and REMOVE commands is the device index as shown by the output of /proc/scsi/tmscsim/? in the device listing in the first column - (Idx). + (Idx). ADD takes the SCSI ID and LUN. Examples: echo "reset" >/proc/scsi/tmscsim/0 echo "inquiry 1" >/proc/scsi/tmscsim/0 echo "remove 2" >/proc/scsi/tmscsim/1 + echo "add 2 3" >/proc/scsi/tmscsim/? - Note that you will meet problems when you remove a device's DCB with the + Note that you will meet problems when you REMOVE a device's DCB with the remove command if it contains partitions which are mounted. Only use it after unmounting its partitions, telling the SCSI mid-level code to remove it (scsi remove-single-device) and you really need a few bytes of memory. + The ADD command allows you to configure a device before you tell the + mid-level code to try detection. I'd suggest reviewing the output of /proc/scsi/tmscsim/? after changing @@ -335,6 +338,7 @@ Most of the intended work on the driver has been done. Here are a few ideas to further improve its usability: +* Cleanly separate per-Target and per-LUN properties (DCB) * 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 @@ -426,5 +430,5 @@ ------------------------------------------------------------------------- Written by Kurt Garloff 1998/06/11 -Last updated 1999/05/30, driver revision 2.0d3 -$Id: README.tmscsim,v 2.13 1999/06/01 00:39:52 garloff Exp $ +Last updated 1999/06/02, driver revision 2.0d6 +$Id: README.tmscsim,v 2.18 1999/06/01 22:39:13 garloff Exp $ Index: dc390/dc390-120-kernel.diff =================================================================== RCS file: /usr/local/cvsroot/dc390/dc390-120-kernel.diff,v retrieving revision 2.3 retrieving revision 2.5 diff -u -r2.3 -r2.5 --- dc390/dc390-120-kernel.diff 1998/12/25 18:04:20 2.3 +++ dc390/dc390-120-kernel.diff 1999/06/01 22:20:02 2.5 @@ -1,6 +1,6 @@ # dc390-kernel.diff # patches against 2.1.125 kernel for DC390/AM53C974 driver integration -# $Id: dc390-120-kernel.diff,v 2.3 1998/12/25 18:04:20 garloff Exp $ # +# $Id: dc390-120-kernel.diff,v 2.5 1999/06/01 22:20:02 garloff Exp $ # 8<---------------------------------------------------------------------- Patch for allowing omission of the non DC390 parts of the driver: Index: dc390/dc390.h =================================================================== RCS file: /usr/local/cvsroot/dc390/dc390.h,v retrieving revision 2.16 retrieving revision 2.22 diff -u -r2.16 -r2.22 --- dc390/dc390.h 1999/06/01 00:37:43 2.16 +++ dc390/dc390.h 1999/06/01 22:39:13 2.22 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390(T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: dc390.h,v 2.16 1999/06/01 00:37:43 garloff Exp $ */ +/* $Id: dc390.h,v 2.22 1999/06/01 22:39:13 garloff Exp $ */ #include @@ -16,7 +16,7 @@ #define DC390_H #define DC390_BANNER "Tekram DC390/AM53C974" -#define DC390_VERSION "2.0d4 1999/06/01" +#define DC390_VERSION "2.0d6 1999/06/02" #if defined(HOSTS_C) || defined(MODULE) Index: dc390/scsiiom.c =================================================================== RCS file: /usr/local/cvsroot/dc390/scsiiom.c,v retrieving revision 2.25 retrieving revision 2.28 diff -u -r2.25 -r2.28 --- dc390/scsiiom.c 1999/06/01 09:23:31 2.25 +++ dc390/scsiiom.c 1999/06/02 06:13:20 2.28 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: scsiiom.c,v 2.25 1999/06/01 09:23:31 garloff Exp $ */ +/* $Id: scsiiom.c,v 2.28 1999/06/02 06:13:20 garloff Exp $ */ UCHAR dc390_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) @@ -1645,8 +1645,6 @@ static void dc390_ResetSCSIBus( PACB pACB ) { - pACB->ACBFlag |= RESET_DEV; - DC390_write8 (ScsiCmd, RST_DEVICE_CMD); udelay (250); DC390_write8 (ScsiCmd, NOP_CMD); Index: dc390/tmscsim.c =================================================================== RCS file: /usr/local/cvsroot/dc390/tmscsim.c,v retrieving revision 2.26 retrieving revision 2.35 diff -u -r2.26 -r2.35 --- dc390/tmscsim.c 1999/06/01 09:43:35 2.26 +++ dc390/tmscsim.c 1999/06/02 06:13:20 2.35 @@ -7,7 +7,7 @@ ***********************************************************************/ /* (C) Copyright: put under GNU GPL in 10/96 (see README.tmscsim) * *************************************************************************/ -/* $Id: tmscsim.c,v 2.26 1999/06/01 09:43:35 garloff Exp $ */ +/* $Id: tmscsim.c,v 2.35 1999/06/02 06:13:20 garloff Exp $ */ /* Enhancements and bugfixes by * * Kurt Garloff * ***********************************************************************/ @@ -108,6 +108,10 @@ * 24. SDTR cleanup. Cleaner multi-LUN * * handling. Don't modify ControlRegs/FIFO * * when connected. * + * 2.0d5 99/06/01 KG Clear DevID, Fix INQUIRY after cfg chg. * + * 2.0d6 99/06/02 KG Added ADD special command to allow cfg. * + * before detection. Reset SYNC_NEGO_DONE * + * after a bus reset. * ***********************************************************************/ /* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */ @@ -390,7 +394,7 @@ void do_DC390_Interrupt( int, void *, struct pt_regs *); int dc390_initAdapter( PSH psh, ULONG io_port, UCHAR Irq, UCHAR index ); -void dc390_initDCB( PACB pACB, PDCB *ppDCB, PSCSICMD cmd ); +void dc390_initDCB( PACB pACB, PDCB *ppDCB, UCHAR id, UCHAR lun); void dc390_updateDCB (PACB pACB, PDCB pDCB); #ifdef MODULE @@ -697,21 +701,21 @@ * (DCBs, SRBs, Queueing) * **********************************************************************/ -static PDCB __inline__ dc390_findDCB ( PACB pACB, Scsi_Cmnd *cmd) +static PDCB __inline__ dc390_findDCB ( PACB pACB, UCHAR id, UCHAR lun) { PDCB pDCB = pACB->pLinkDCB; if (!pDCB) return 0; - while (pDCB->UnitSCSIID != cmd->target || pDCB->UnitSCSILUN != cmd->lun) + while (pDCB->UnitSCSIID != id || pDCB->UnitSCSILUN != lun) { pDCB = pDCB->pNextDCB; if (pDCB == pACB->pLinkDCB) { DCBDEBUG(printk (KERN_WARNING "DC390: DCB not found (DCB=%p, DCBmap[%2x]=%2x)\n", - pDCB, cmd->target, pACB->DCBmap[cmd->target]);) + pDCB, id, pACB->DCBmap[id]);) return 0; } }; - DCBDEBUG1( printk (KERN_DEBUG "DCB %08x (%02x,%02x) found.\n", \ - (int)pDCB, pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) + DCBDEBUG1( printk (KERN_DEBUG "DCB %p (%02x,%02x) found.\n", \ + pDCB, pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) return pDCB; }; @@ -1049,7 +1053,7 @@ pACB->DCBmap[cmd->target] |= (1 << cmd->lun); pACB->scan_devices = 1; - dc390_initDCB( pACB, &pDCB, cmd ); + dc390_initDCB( pACB, &pDCB, cmd->target, cmd->lun ); if (!pDCB) { printk (KERN_ERR "DC390: kmalloc for DCB failed, ID=%2x\n", cmd->target); @@ -1069,7 +1073,7 @@ } else { - pDCB = dc390_findDCB (pACB, cmd); + pDCB = dc390_findDCB (pACB, cmd->target, cmd->lun); if (!pDCB) { /* should never happen */ DC390_UNLOCK_ACB; @@ -1327,7 +1331,7 @@ DC390_LOCK_ACB; - pDCB = dc390_findDCB (pACB, cmd); + pDCB = dc390_findDCB (pACB, cmd->target, cmd->lun); /* 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; @@ -1438,7 +1442,7 @@ /* Let's do something to help the bus getting clean again */ DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); DC390_write8 (ScsiCmd, DMA_COMMAND); - //DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); + //DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); //DC390_write8 (ScsiCmd, RESET_ATN_CMD); DC390_write8 (ScsiCmd, NOP_CMD); //udelay (10000); @@ -1489,6 +1493,8 @@ pDCB = pDCB->pNextDCB; } while( pdcb != pDCB ); + pACB->ACBFlag &= ~(RESET_DEV | RESET_DONE | RESET_DETECT); + } @@ -1554,6 +1560,7 @@ bval |= DIS_INT_ON_SCSI_RST; DC390_write8 (CtrlReg1, bval); /* disable interrupt */ + pACB->ACBFlag |= RESET_DEV; dc390_ResetSCSIBus( pACB ); pACB->pScsiHost->last_reset = jiffies; /* Unlock ? */ @@ -1586,20 +1593,20 @@ /*********************************************************************** * Function : static void dc390_initDCB() * - * Purpose : initialize the internal structures for a given DCB + * Purpose : initialize the internal structures for a DCB (to be malloced) * - * Inputs : cmd - pointer to this scsi cmd request block structure + * Inputs : SCSI id and lun ***********************************************************************/ -void dc390_initDCB( PACB pACB, PDCB *ppDCB, PSCSICMD cmd ) +void dc390_initDCB( PACB pACB, PDCB *ppDCB, UCHAR id, UCHAR lun ) { PEEprom prom; UCHAR index; PDCB pDCB, pDCB2; pDCB = kmalloc (sizeof(DC390_DCB), GFP_ATOMIC); - DCBDEBUG(printk (KERN_INFO "DC390: alloc mem for DCB (ID %i, LUN %i): 0x%08x\n", \ - cmd->target, cmd->lun, (int)pDCB);) + DCBDEBUG(printk (KERN_INFO "DC390: alloc mem for DCB (ID %i, LUN %i): %p\n", \ + id, lun, pDCB);) *ppDCB = pDCB; pDCB2 = 0; if (!pDCB) return; @@ -1620,8 +1627,8 @@ pDCB->pDCBACB = pACB; pDCB->QIORBCnt = 0; - pDCB->UnitSCSIID = cmd->target; - pDCB->UnitSCSILUN = cmd->lun; + pDCB->UnitSCSIID = id; + pDCB->UnitSCSILUN = lun; pDCB->pWaitingSRB = NULL; pDCB->pGoingSRB = NULL; pDCB->GoingSRBCnt = 0; @@ -1632,13 +1639,9 @@ pDCB->DCBFlag = 0; /* Is there a corresp. LUN==0 device ? */ - if (cmd->lun != 0) - { - cmd->lun = 0; - pDCB2 = dc390_findDCB (pACB, cmd); - cmd->lun = pDCB->UnitSCSILUN; - } - prom = (PEEprom) &dc390_eepromBuf[index][cmd->target << 2]; + if (lun != 0) + pDCB2 = dc390_findDCB (pACB, id, 0); + prom = (PEEprom) &dc390_eepromBuf[index][id << 2]; /* Some values are for all LUNs: Copy them */ /* In a clean way: We would have an own structure for a SCSI-ID */ if (pDCB2) @@ -1897,6 +1900,7 @@ DC390_write8 (CtrlReg3, FAST_CLK); /* fast clock */ DC390_write8 (CtrlReg4, pACB->glitch_cfg | /* glitch eater */ (dc390_eepromBuf[index][EE_MODE2] & ACTIVE_NEGATION) ? NEGATE_REQACKDATA : 0); /* Negation */ + DC390_write8 (CtcReg_High, 0); /* Clear Transfer Count High: ID */ DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT); @@ -2099,7 +2103,7 @@ if (cmd->result) { PACB pACB = (PACB)cmd->host->hostdata; - PDCB pDCB = dc390_findDCB (pACB, cmd); + PDCB pDCB = dc390_findDCB (pACB, cmd->target, cmd->lun); printk ("DC390: Unsetting DsCn, Sync and TagQ!\n"); if (pDCB) { @@ -2141,6 +2145,7 @@ cmd->request.rq_status = RQ_SCSI_BUSY; + pDCB->SyncMode &= ~SYNC_NEGO_DONE; printk (KERN_INFO "DC390: Queue INQUIRY command to dev ID %02x LUN %02x\n", pDCB->UnitSCSIID, pDCB->UnitSCSILUN); DC390_queue_command (cmd, dc390_inquiry_done); @@ -2263,6 +2268,7 @@ if (!memcmp (pos, "RESET", 5)) goto reset; else if (!memcmp (pos, "INQUIRY", 7)) goto inquiry; else if (!memcmp (pos, "REMOVE", 6)) goto remove; + else if (!memcmp (pos, "ADD", 3)) goto add; if (isdigit (*pos)) { @@ -2433,6 +2439,21 @@ }; return (length); + add: + { + int id, lun; + pos = strtok (0, " \t\n.:;="); + if (pos) { SCANF (pos, p0, id, 0, 7); } else goto einv; + if (pos) { SCANF (pos, p0, lun, 0, 7); } else goto einv; + pDCB = dc390_findDCB (pACB, id, lun); + if (pDCB) { printk ("DC390: ADD: Device already existing\n"); goto einv; }; + dc390_initDCB (pACB, &pDCB, id, lun); + DC390_UNLOCK_ACB; + dc390_inquiry (pACB, pDCB); + DC390_UNLOCK_IO; + }; + return (length); + einv_dev: printk (KERN_WARNING "DC390: Ignore cmnd to illegal Dev(Idx) %i. Valid range: 0 - %i.\n", dev, pACB->DCBCnt - 1); @@ -2580,7 +2601,7 @@ printk(KERN_INFO "DC390: shutdown\n"); - pACB->ACBFlag = RESET_DONE; + pACB->ACBFlag = RESET_DEV; bval = DC390_read8 (CtrlReg1); bval |= DIS_INT_ON_SCSI_RST; DC390_write8 (CtrlReg1, bval); /* disable interrupt */ Index: dc390/tmscsim.h =================================================================== RCS file: /usr/local/cvsroot/dc390/tmscsim.h,v retrieving revision 2.7 retrieving revision 2.9 diff -u -r2.7 -r2.9 --- dc390/tmscsim.h 1999/06/01 00:37:44 2.7 +++ dc390/tmscsim.h 1999/06/01 22:20:02 2.9 @@ -3,7 +3,7 @@ ;* TEKRAM DC-390(T) PCI SCSI Bus Master Host Adapter * ;* Device Driver * ;***********************************************************************/ -/* $Id: tmscsim.h,v 2.7 1999/06/01 00:37:44 garloff Exp $ */ +/* $Id: tmscsim.h,v 2.9 1999/06/01 22:20:02 garloff Exp $ */ #ifndef _TMSCSIM_H #define _TMSCSIM_H