Index: README.tmscsim =================================================================== RCS file: /home/cvsroot/dc390/README.tmscsim,v retrieving revision 2.25.2.1 retrieving revision 2.25.2.3 diff -u -r2.25.2.1 -r2.25.2.3 --- README.tmscsim 2000/01/17 22:34:36 2.25.2.1 +++ README.tmscsim 2000/02/14 11:15:23 2.25.2.3 @@ -228,8 +228,8 @@ discussed above. The values used in this example will result in maximum performance. -(3) Special commands: You can force a SCSI bus reset, an INQUIRY command and - the removal or the addition of a device's DCB. +(3) Special commands: You can force a SCSI bus reset, an INQUIRY command, the + removal or the addition of a device's DCB and a SCSI register dump. This is only used for debugging when you meet problems. The parameter of 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 @@ -239,6 +239,7 @@ echo "inquiry 1" >/proc/scsi/tmscsim/0 echo "remove 2" >/proc/scsi/tmscsim/1 echo "add 2 3" >/proc/scsi/tmscsim/? + echo "dump" >/proc/scsi/tmscsim/0 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 @@ -297,7 +298,7 @@ *1 0x02 2 Synchronous Negotiation *2 0x04 4 Disconnection *3 0x08 8 Send Start command on startup. (Not used) - *4 0x10 16 Tagged Queueing + *4 0x10 16 Tagged Command Queueing As usual, the desired value is obtained by adding the wanted values. If you want to enable all values, e.g., you would use 31(0x1f). Default is 31. @@ -439,4 +440,4 @@ ------------------------------------------------------------------------- Written by Kurt Garloff 1998/06/11 Last updated 2000/01/17, driver revision 2.0d25 -$Id: README.tmscsim,v 2.25.2.1 2000/01/17 22:34:36 garloff Exp $ +$Id: README.tmscsim,v 2.25.2.3 2000/02/14 11:15:23 garloff Exp $ Index: dc390.h =================================================================== RCS file: /home/cvsroot/dc390/dc390.h,v retrieving revision 2.43.2.4 retrieving revision 2.43.2.11 diff -u -r2.43.2.4 -r2.43.2.11 --- dc390.h 2000/01/17 22:23:35 2.43.2.4 +++ dc390.h 2000/02/14 21:40:09 2.43.2.11 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390(T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: dc390.h,v 2.43.2.4 2000/01/17 22:23:35 garloff Exp $ */ +/* $Id: dc390.h,v 2.43.2.11 2000/02/14 21:40:09 garloff Exp $ */ /* * DC390/AMD 53C974 driver, header file @@ -19,8 +19,20 @@ #endif #define DC390_BANNER "Tekram DC390/AM53C974" -#define DC390_VERSION "2.0d25 2000/01/17" +#define DC390_VERSION "2.0d28 2000/02/14" +/* We don't have eh_abort_handler, eh_device_reset_handler, + * eh_bus_reset_handler, eh_host_reset_handler yet! + * So long: Use old exception handling :-( */ +#define OLD_EH + +#if LINUX_VERSION_CODE < KERNEL_VERSION (2,1,70) || defined (OLD_EH) +# define NEW_EH +#else +# define NEW_EH use_new_eh_code: 1, +# define USE_NEW_EH +#endif + #if defined(HOSTS_C) || defined(MODULE) extern int DC390_detect(Scsi_Host_Template *psht); @@ -40,12 +52,6 @@ #endif extern int DC390_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout); -#if LINUX_VERSION_CODE < KERNEL_VERSION (2,1,70) -# define NO_NEW_EH -#else -# define NO_NEW_EH use_new_eh_code: 0, -#endif - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,30) #define DC390_T { \ proc_name: "tmscsim", \ @@ -60,8 +66,8 @@ can_queue: 42, \ this_id: 7, \ sg_tablesize: SG_ALL, \ - cmd_per_lun: 8, \ - NO_NEW_EH \ + cmd_per_lun: 16, \ + NEW_EH \ unchecked_isa_dma: 0, \ use_clustering: DISABLE_CLUSTERING \ } @@ -79,8 +85,8 @@ can_queue: 42, \ this_id: 7, \ sg_tablesize: SG_ALL, \ - cmd_per_lun: 8, \ - NO_NEW_EH \ + cmd_per_lun: 16, \ + NEW_EH \ unchecked_isa_dma: 0, \ use_clustering: DISABLE_CLUSTERING \ } Index: scsiiom.c =================================================================== RCS file: /home/cvsroot/dc390/scsiiom.c,v retrieving revision 2.55.2.1 retrieving revision 2.55.2.9 diff -u -r2.55.2.1 -r2.55.2.9 --- scsiiom.c 2000/01/17 22:23:03 2.55.2.1 +++ scsiiom.c 2000/02/14 21:42:24 2.55.2.9 @@ -4,7 +4,7 @@ * Description: Device Driver for Tekram DC-390 (T) PCI SCSI * * Bus Master Host Adapter * ***********************************************************************/ -/* $Id: scsiiom.c,v 2.55.2.1 2000/01/17 22:23:03 garloff Exp $ */ +/* $Id: scsiiom.c,v 2.55.2.9 2000/02/14 21:42:24 garloff Exp $ */ static void __inline__ dc390_freetag (PDCB pDCB, PSRB pSRB) @@ -32,8 +32,12 @@ pACB->SelConn++; return 1; } - - DC390_write8 (Scsi_Dest_ID, pDCB->UnitSCSIID); + if (time_before (jiffies, pACB->pScsiHost->last_reset)) + { + DEBUG0(printk ("DC390: We were just reset and don't accept commands yet!\n");) + return 1; + } + DC390_write8 (Scsi_Dest_ID, pDCB->TargetID); DC390_write8 (Sync_Period, pDCB->SyncPeriod); DC390_write8 (Sync_Offset, pDCB->SyncOffset); DC390_write8 (CtrlReg1, pDCB->CtrlR1); @@ -52,21 +56,22 @@ * (pSRB->pcmd->cmnd[0] == TEST_UNIT_READY)) && pACB->scan_devices) ||*/ (pSRB->SRBFlag & AUTO_REQSENSE) ) disc_allowed = 0; - if ( (pDCB->SyncMode & SYNC_ENABLE) && (pDCB->UnitSCSILUN == 0) && + if ( (pDCB->SyncMode & SYNC_ENABLE) && (pDCB->TargetLUN == 0) && ( ( ( (pSRB->pcmd->cmnd[0] == REQUEST_SENSE) || (pSRB->SRBFlag & AUTO_REQSENSE) ) && !(pDCB->SyncMode & SYNC_NEGO_DONE) ) || (pSRB->pcmd->cmnd[0] == INQUIRY) ) ) try_sync_nego = 1; pSRB->MsgCnt = 0; cmd = SEL_W_ATN; - DC390_write8 (ScsiFifo, IDENTIFY(disc_allowed, pDCB->UnitSCSILUN)); + DC390_write8 (ScsiFifo, IDENTIFY(disc_allowed, pDCB->TargetLUN)); /* Change 99/05/31: Don't use tags when not disconnecting (BUSY) */ if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed) { UCHAR tag_no = 0; while ((1 << tag_no) & pDCB->TagMask) tag_no++; if (tag_no >= sizeof (pDCB->TagMask)*8 || tag_no >= pDCB->MaxCommand) { - printk (KERN_WARNING "DC390: Out of tags for Dev. %02x %02x\n", pDCB->UnitSCSIID, pDCB->UnitSCSILUN); - goto no_tag; + printk (KERN_WARNING "DC390: Out of tags for Dev. %02x %02x\n", pDCB->TargetID, pDCB->TargetLUN); + return 1; + //goto no_tag; }; DC390_write8 (ScsiFifo, SIMPLE_QUEUE_TAG); pDCB->TagMask |= (1 << tag_no); pSRB->TagNumber = tag_no; @@ -76,7 +81,7 @@ } else /* No TagQ */ { - no_tag: +// no_tag: DEBUG1(printk (KERN_DEBUG "DC390: Select w%s/DisCn for Cmd %li (SRB %p), No TagQ\n", (disc_allowed?"":"o"), pSRB->pcmd->pid, pSRB);) }; @@ -85,7 +90,7 @@ if (try_sync_nego) { UCHAR Sync_Off = pDCB->SyncOffset; - DEBUG0(printk (KERN_INFO "DC390: NEW Sync Nego code triggered (%i %i)\n", pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) + DEBUG0(printk (KERN_INFO "DC390: NEW Sync Nego code triggered (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN);) pSRB->MsgOutBuf[0] = EXTENDED_MESSAGE; pSRB->MsgOutBuf[1] = 3; pSRB->MsgOutBuf[2] = EXTENDED_SDTR; @@ -104,7 +109,7 @@ if( pSRB->SRBFlag & AUTO_REQSENSE ) { DC390_write8 (ScsiFifo, REQUEST_SENSE); - DC390_write8 (ScsiFifo, pDCB->UnitSCSILUN << 5); + DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5); DC390_write8 (ScsiFifo, 0); DC390_write8 (ScsiFifo, 0); DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer)); @@ -393,7 +398,11 @@ pSRB->SGToBeXferLen = ResidCnt; } } - DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ + if ((*psstatus & 7) != SCSI_DATA_OUT) + { + DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ + DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); + } } void @@ -503,6 +512,11 @@ } } + if ((*psstatus & 7) != SCSI_DATA_IN) + { + DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); + DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */ + } } static void @@ -621,7 +635,7 @@ { PDCB pDCB = pSRB->pSRBDCB; if (!(pSRB->SRBState & DO_SYNC_NEGO)) - printk (KERN_INFO "DC390: Target %i initiates Non-Sync?\n", pDCB->UnitSCSIID); + printk (KERN_INFO "DC390: Target %i initiates Non-Sync?\n", pDCB->TargetID); pSRB->SRBState &= ~DO_SYNC_NEGO; pDCB->SyncMode &= ~(SYNC_ENABLE+SYNC_NEGO_DONE); pDCB->SyncPeriod = 0; @@ -646,7 +660,7 @@ if (!(pSRB->SRBState & DO_SYNC_NEGO)) { printk (KERN_INFO "DC390: Target %i initiates Sync: %ins %i ... answer ...\n", - pDCB->UnitSCSIID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]); + pDCB->TargetID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]); /* reject */ //dc390_MsgIn_reject (pACB, pSRB); @@ -696,10 +710,10 @@ pDCB->CtrlR3 = bval; pDCB->SyncPeriod = (UCHAR)wval1; - if ((oldsyncperiod != wval1 || oldsyncoffset != pDCB->SyncOffset) && pDCB->UnitSCSILUN == 0) + if ((oldsyncperiod != wval1 || oldsyncoffset != pDCB->SyncOffset) && pDCB->TargetLUN == 0) { if (! (bval & FAST_SCSI)) wval1++; - printk (KERN_INFO "DC390: Target %i: Sync transfer %i.%1i MHz, Offset %i\n", pDCB->UnitSCSIID, + printk (KERN_INFO "DC390: Target %i: Sync transfer %i.%1i MHz, Offset %i\n", pDCB->TargetID, 40/wval1, ((40%wval1)*10+wval1/2)/wval1, pDCB->SyncOffset & 0x0f); } @@ -861,8 +875,17 @@ { PSGL psgl; ULONG lval; + PDCB pDCB = pACB->pActiveDCB; - if (pSRB == pACB->pTmpSRB) printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?)\n"); + if (pSRB == pACB->pTmpSRB) + { + if (pDCB) printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (%02i-%i)\n", + pDCB->TargetID, pDCB->TargetLUN); + else printk (KERN_ERR "DC390: pSRB == pTmpSRB! (TagQ Error?) (DCB 0!)\n"); + dc390_EnableMsgOut_Abort (pACB, pSRB); + if (pDCB) pDCB->DCBFlag |= ABORT_DEV; + return; + } if( pSRB->SGIndex < pSRB->SGcount ) { @@ -951,7 +974,7 @@ UCHAR bval = 0; DC390_write8 (ScsiFifo, REQUEST_SENSE); pDCB = pACB->pActiveDCB; - DC390_write8 (ScsiFifo, pDCB->UnitSCSILUN << 5); + DC390_write8 (ScsiFifo, pDCB->TargetLUN << 5); DC390_write8 (ScsiFifo, bval); DC390_write8 (ScsiFifo, bval); DC390_write8 (ScsiFifo, sizeof(pSRB->pcmd->sense_buffer)); @@ -1010,7 +1033,7 @@ else { mop1: - printk (KERN_ERR "DC390: OLD Sync Nego code triggered! (%i %i)\n", pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + printk (KERN_ERR "DC390: OLD Sync Nego code triggered! (%i %i)\n", pDCB->TargetID, pDCB->TargetLUN); DC390_write8 (ScsiFifo, EXTENDED_MESSAGE); DC390_write8 (ScsiFifo, 3); /* ;length of extended msg */ DC390_write8 (ScsiFifo, EXTENDED_SDTR); /* ; sync nego */ @@ -1054,16 +1077,16 @@ UCHAR bval, i, cnt; PDCB ptr; - if( !(pDCB->UnitSCSILUN) ) + if( !(pDCB->TargetLUN) ) { if( !pACB->scan_devices ) { ptr = pACB->pLinkDCB; cnt = pACB->DCBCnt; - bval = pDCB->UnitSCSIID; + bval = pDCB->TargetID; for(i=0; iUnitSCSIID == bval ) + if( ptr->TargetID == bval ) { ptr->SyncPeriod = pDCB->SyncPeriod; ptr->SyncOffset = pDCB->SyncOffset; @@ -1137,6 +1160,7 @@ pSRB->SRBState = SRB_READY; dc390_freetag (pDCB, pSRB); dc390_Going_to_Waiting (pDCB, pSRB); + dc390_waiting_timer (pACB, HZ/5); } else { @@ -1166,48 +1190,45 @@ { PDCB pDCB; PSRB pSRB; - USHORT wval; - UCHAR bval; + UCHAR id, lun; DEBUG0(printk(KERN_INFO "RSEL,");) pACB->Connected = 1; pDCB = pACB->pActiveDCB; if( pDCB ) { /* Arbitration lost but Reselection won */ - DEBUG0(printk ("(ActiveDCB != 0: Arb. lost but resel. won)");) + DEBUG0(printk ("DC390: (ActiveDCB != 0: Arb. lost but resel. won)!\n");) pSRB = pDCB->pActiveSRB; if( !( pACB->scan_devices ) ) { pSRB->SRBState = SRB_READY; dc390_freetag (pDCB, pSRB); dc390_Going_to_Waiting ( pDCB, pSRB); + dc390_waiting_timer (pACB, HZ/5); } } - bval = DC390_read8 (ScsiFifo); /* get ID */ - DEBUG0(printk ("Dev %02x,", bval);) - if (!(bval & 1 << pACB->pScsiHost->this_id)) - printk (KERN_ERR "Reselection must select host adapter: %02x!\n", bval); + /* Get ID */ + lun = DC390_read8 (ScsiFifo); + DEBUG0(printk ("Dev %02x,", lun);) + if (!(lun & (1 << pACB->pScsiHost->this_id))) + printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun); else - bval ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */ - wval = 0; - while (bval >>= 1) wval++; - bval = DC390_read8 (ScsiFifo); - if (!(bval & IDENTIFY_BASE)) printk (KERN_ERR "Expect identify message!\n"); - wval |= ( (USHORT) bval & 7) << 8; /* get LUN */ - DEBUG0(printk ("(ID %02x, LUN %02x),", wval & 0xff, (wval & 0xff00) >> 8);) - pDCB = pACB->pLinkDCB; - while( wval != *((PUSHORT) &pDCB->UnitSCSIID) ) + lun ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */ + id = 0; while (lun >>= 1) id++; + /* Get LUN */ + lun = DC390_read8 (ScsiFifo); + if (!(lun & IDENTIFY_BASE)) printk (KERN_ERR "DC390: Resel: Expect identify message!\n"); + lun &= 7; + DEBUG0(printk ("(%02i-%i),", id, lun);) + pDCB = dc390_findDCB (pACB, id, lun); + if (!pDCB) { - pDCB = pDCB->pNextDCB; - if( pDCB == pACB->pLinkDCB ) - { - printk (KERN_ERR "DC390: Reselect from non existing device (ID %02x, LUN %02x)\n", - wval & 0xff, (wval & 0xff00) >> 8); - return; - } + printk (KERN_ERR "DC390: Reselect from non existing device (%02i-%i)\n", + id, lun); + return; } pACB->pActiveDCB = pDCB; - /* TagQ: We expect a message soon, so never mind */ + /* TagQ: We expect a message soon, so never mind the exact SRB */ if( pDCB->SyncMode & EN_TAG_QUEUEING ) { pSRB = pACB->pTmpSRB; @@ -1220,8 +1241,8 @@ { pSRB= pACB->pTmpSRB; pSRB->SRBState = SRB_UNEXPECT_RESEL; - printk (KERN_ERR "DC390: Reselect without outstanding cmnd (ID %02x, LUN %02x)\n", - wval & 0xff, (wval & 0xff00) >> 8); + printk (KERN_ERR "DC390: Reselect without outstanding cmnd (%02i-%i)\n", + id, lun); pDCB->pActiveSRB = pSRB; dc390_EnableMsgOut_Abort ( pACB, pSRB ); } @@ -1230,8 +1251,8 @@ if( pDCB->DCBFlag & ABORT_DEV_ ) { pSRB->SRBState = SRB_ABORT_SENT; - printk (KERN_INFO "DC390: Reselect: Abort (ID %02x, LUN %02x)\n", - wval & 0xff, (wval & 0xff00) >> 8); + printk (KERN_INFO "DC390: Reselect: Abort (%02i-%i)\n", + id, lun); dc390_EnableMsgOut_Abort( pACB, pSRB ); } else @@ -1241,7 +1262,7 @@ DEBUG1(printk (KERN_DEBUG "Resel SRB(%p): TagNum (%02x)\n", pSRB, pSRB->TagNumber);) pSRB->ScsiPhase = SCSI_NOP0; - DC390_write8 (Scsi_Dest_ID, pDCB->UnitSCSIID); + DC390_write8 (Scsi_Dest_ID, pDCB->TargetID); DC390_write8 (Sync_Period, pDCB->SyncPeriod); DC390_write8 (Sync_Offset, pDCB->SyncOffset); DC390_write8 (CtrlReg1, pDCB->CtrlR1); @@ -1259,27 +1280,29 @@ if (pDCB->GoingSRBCnt > 1) { DCBDEBUG(printk (KERN_INFO "DC390: Driver won't free DCB (ID %i, LUN %i): 0x%08x because of SRBCnt %i\n",\ - pDCB->UnitSCSIID, pDCB->UnitSCSILUN, (int)pDCB, pDCB->GoingSRBCnt);) + pDCB->TargetID, pDCB->TargetLUN, (int)pDCB, pDCB->GoingSRBCnt);) return; }; - pACB->DCBmap[pDCB->UnitSCSIID] &= ~(1 << pDCB->UnitSCSILUN); + pACB->DCBmap[pDCB->TargetID] &= ~(1 << pDCB->TargetLUN); + // The first one if (pDCB == pACB->pLinkDCB) - { - if (pDCB->pNextDCB == pDCB) pDCB->pNextDCB = 0; + { + // The last one + if (pACB->pLastDCB == pDCB) { + pDCB->pNextDCB = 0; pACB->pLastDCB = 0; + } pACB->pLinkDCB = pDCB->pNextDCB; - if (pACB->pLastDCB == pDCB) pACB->pLastDCB = 0; - else if (pACB->pLastDCB) pACB->pLastDCB->pNextDCB = pDCB->pNextDCB; - } + } else - { + { while (pPrevDCB->pNextDCB != pDCB) pPrevDCB = pPrevDCB->pNextDCB; pPrevDCB->pNextDCB = pDCB->pNextDCB; if (pDCB == pACB->pLastDCB) pACB->pLastDCB = pPrevDCB; - } + } DCBDEBUG(printk (KERN_INFO "DC390: Driver about to free DCB (ID %i, LUN %i): %p\n",\ - pDCB->UnitSCSIID, pDCB->UnitSCSILUN, pDCB);) + pDCB->TargetID, pDCB->TargetLUN, pDCB);) if (pDCB == pACB->pActiveDCB) pACB->pActiveDCB = 0; if (pDCB == pACB->pLinkDCB) pACB->pLinkDCB = pDCB->pNextDCB; if (pDCB == pACB->pDCBRunRobin) pACB->pDCBRunRobin = pDCB->pNextDCB; @@ -1354,26 +1377,26 @@ switch (pcmd->sense_buffer[2] & 0x0f) { case NOT_READY: printk (KERN_INFO "DC390: ReqSense: NOT_READY (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i)\n", - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN, + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN, status, pACB->scan_devices); break; case UNIT_ATTENTION: printk (KERN_INFO "DC390: ReqSense: UNIT_ATTENTION (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i)\n", - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN, + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN, status, pACB->scan_devices); break; case ILLEGAL_REQUEST: printk (KERN_INFO "DC390: ReqSense: ILLEGAL_REQUEST (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i)\n", - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN, + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN, status, pACB->scan_devices); break; case MEDIUM_ERROR: printk (KERN_INFO "DC390: ReqSense: MEDIUM_ERROR (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i)\n", - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN, + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN, status, pACB->scan_devices); break; case HARDWARE_ERROR: printk (KERN_INFO "DC390: ReqSense: HARDWARE_ERROR (Cmnd = 0x%02x, Dev = %i-%i, Stat = %i, Scan = %i)\n", - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN, + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN, status, pACB->scan_devices); break; } #endif //pcmd->result = MK_RES(DRIVER_SENSE,DID_OK,0,status); if (status == (CHECK_CONDITION << 1)) { - pcmd->result = MK_RES_LNX(0,DID_BAD_TARGET,0,/*CHECK_CONDITION*/0); + pcmd->result = MK_RES_LNX(0,DID_BAD_TARGET,0,/*CHECK_CONDITION*/0); goto ckc_e; } if(pSRB->RetryCnt == 0) @@ -1385,8 +1408,8 @@ SET_RES_DID(pcmd->result,DID_OK) else pcmd->result = MK_RES_LNX(DRIVER_SENSE,DID_OK,0,CHECK_CONDITION); - REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x,Result=%08x,XferL=%08x\n",pSRB->pcmd->cmnd[0],\ - (UINT) pcmd->result, (UINT) pSRB->TotalXferredLen);) + REMOVABLEDEBUG(printk(KERN_INFO "Cmd=%02x,Result=%08x,XferL=%08x\n",pSRB->pcmd->cmnd[0],\ + (UINT) pcmd->result, (UINT) pSRB->TotalXferredLen);) goto ckc_e; } else /* Retry */ @@ -1419,8 +1442,10 @@ pSRB->Segmentx.address = (PUCHAR) pcmd->request_buffer; pSRB->Segmentx.length = pcmd->request_bufflen; } - if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) + if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) { dc390_Going_to_Waiting ( pDCB, pSRB ); + dc390_waiting_timer (pACB, HZ/5); + } return; } } @@ -1429,7 +1454,7 @@ if( status_byte(status) == CHECK_CONDITION ) { REMOVABLEDEBUG(printk (KERN_INFO "DC390: Check_Condition (Cmd %02x, Id %02x, LUN %02x)\n",\ - pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) + pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN);) if( (pSRB->SGIndex < pSRB->SGcount) && (pSRB->SGcount) && (pSRB->SGToBeXferLen) ) { bval = pSRB->SGcount; @@ -1453,6 +1478,7 @@ pDCB->MaxCommand = bval; dc390_freetag (pDCB, pSRB); dc390_Going_to_Waiting ( pDCB, pSRB ); + dc390_waiting_timer (pACB, HZ/5); pSRB->AdaptStatus = 0; pSRB->TargetStatus = 0; return; @@ -1490,9 +1516,11 @@ pSRB->Segmentx.address = (PUCHAR) pcmd->request_buffer; pSRB->Segmentx.length = pcmd->request_bufflen; } - if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) + if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) { dc390_Going_to_Waiting ( pDCB, pSRB ); - return; + dc390_waiting_timer (pACB, HZ/5); + } + return; } else { /* Report error */ @@ -1618,6 +1646,9 @@ { psrb2 = psrb->pNextSRB; pcmd = psrb->pcmd; + dc390_Free_insert (pACB, psrb); +#ifndef USE_NEW_EH + /* New EH will crash on being given timed out cmnds */ if (pcmd == cmd) pcmd->result = MK_RES(0,DID_ABORT,0,0); else @@ -1625,12 +1656,11 @@ /* ReleaseSRB( pDCB, pSRB ); */ - dc390_Free_insert (pACB, psrb); - DEBUG0(printk (KERN_DEBUG "DC390: DoingSRB_Done: done pid %li\n", pcmd->pid);) DC390_UNLOCK_ACB_NI; pcmd->scsi_done( pcmd ); DC390_LOCK_ACB_NI; +#endif psrb = psrb2; } pdcb->GoingSRBCnt = 0;; @@ -1663,12 +1693,14 @@ printk ("DC390: Rst_Detect: laststat = %08x\n", dc390_laststatus); //DEBUG0(printk(KERN_INFO "RST_DETECT,");) + if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer); DC390_write8 (DMA_Cmd, DMA_IDLE_CMD); - pACB->pScsiHost->last_reset = jiffies; /* Unlock before ? */ /* delay half a second */ - { unsigned int msec = 600; while (--msec) udelay(1000); } + udelay (1000); DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); + pACB->pScsiHost->last_reset = jiffies + 5*HZ/2 + + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]; pACB->Connected = 0; if( pACB->ACBFlag & RESET_DEV ) @@ -1679,7 +1711,7 @@ dc390_ResetDevParam( pACB ); dc390_DoingSRB_Done( pACB, 0 ); - dc390_RecoverSRB( pACB ); + //dc390_RecoverSRB( pACB ); pACB->pActiveDCB = NULL; pACB->ACBFlag = 0; dc390_Waiting_process( pACB ); @@ -1694,7 +1726,7 @@ PSCSICMD pcmd; REMOVABLEDEBUG(printk (KERN_INFO "DC390: RequestSense (Cmd %02x, Id %02x, LUN %02x)\n",\ - pSRB->pcmd->cmnd[0], pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) + pSRB->pcmd->cmnd[0], pDCB->TargetID, pDCB->TargetLUN);) pSRB->SRBFlag |= AUTO_REQSENSE; //pSRB->Segment0[0] = (UINT) pSRB->CmdBlock[0]; @@ -1715,15 +1747,17 @@ pSRB->SGIndex = 0; //pSRB->CmdBlock[0] = REQUEST_SENSE; - //pSRB->CmdBlock[1] = pDCB->UnitSCSILUN << 5; + //pSRB->CmdBlock[1] = pDCB->TargetLUN << 5; //(USHORT) pSRB->CmdBlock[2] = 0; //(USHORT) pSRB->CmdBlock[4] = sizeof(pcmd->sense_buffer); //pSRB->ScsiCmdLen = 6; pSRB->TotalXferredLen = 0; pSRB->SGToBeXferLen = 0; - if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) + if( dc390_StartSCSI( pACB, pDCB, pSRB ) ) { dc390_Going_to_Waiting ( pDCB, pSRB ); + dc390_waiting_timer (pACB, HZ/5); + } } Index: tmscsim.c =================================================================== RCS file: /home/cvsroot/dc390/tmscsim.c,v retrieving revision 2.60.2.7 diff -u -r2.60.2.7 tmscsim.c --- tmscsim.c 2000/01/17 22:23:03 2.60.2.7 +++ tmscsim.c 2000/02/14 21:41:34 @@ -7,7 +7,7 @@ ***********************************************************************/ /* (C) Copyright: put under GNU GPL in 10/96 (see README.tmscsim) * *************************************************************************/ -/* $Id: tmscsim.c,v 2.60.2.7 2000/01/17 22:23:03 garloff Exp $ */ +/* $Id: tmscsim.c,v 2.60.2.16 2000/02/14 11:15:23 garloff Exp $ */ /* Enhancements and bugfixes by * * Kurt Garloff * ***********************************************************************/ @@ -142,7 +142,16 @@ * done () w/ DID_BAD_TARGET in case of * * missing DCB. We are old EH!! * * 2.0d2500/01/15 KG 2.3.3x compat from Andreas Schultz * - * set dev_id. Disable RETRY message. * + * set unique_id. Disable RETRY message. * + * 2.0d2600/01/29 KG Go to new EH. * + * 2.0d2700/01/31 KG ... but maintain 2.0 compat. * + * and fix DCB freeing * + * 2.0d2800/02/14 KG Queue statistics fixed, dump special cmd* + * Waiting_Timer for failed StartSCSI * + * New EH: Don't return cmnds to ML on RST * + * Use old EH (don't have new EH fns yet) * + * Reset: Unlock, but refuse to queue * + * 2.3 __setup function * ***********************************************************************/ /* Uncomment SA_INTERRUPT, if the driver refuses to share its IRQ with other devices */ @@ -206,6 +215,7 @@ #include #include #include +#include #include "scsi.h" #include "hosts.h" @@ -621,6 +631,12 @@ }; #endif /* CONFIG_SCSI_DC390T_NOGENSUPP */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13) +#ifndef MODULE +__setup("tmscsim=", dc390_setup); +#endif +#endif + static void __init dc390_EEpromOutDI( PDEVDECL, PUCHAR regval, UCHAR Carry ) { @@ -710,7 +726,7 @@ static void __init dc390_interpret_delay (UCHAR index) { - char interpd [] = {1,2,5,10,15,30,60,120}; + char interpd [] = {1,3,5,10,16,30,60,120}; dc390_eepromBuf[index][EE_DELAY] = interpd [dc390_eepromBuf[index][EE_DELAY]]; }; @@ -741,7 +757,7 @@ static PDCB __inline__ dc390_findDCB ( PACB pACB, UCHAR id, UCHAR lun) { PDCB pDCB = pACB->pLinkDCB; if (!pDCB) return 0; - while (pDCB->UnitSCSIID != id || pDCB->UnitSCSILUN != lun) + while (pDCB->TargetID != id || pDCB->TargetLUN != lun) { pDCB = pDCB->pNextDCB; if (pDCB == pACB->pLinkDCB) @@ -752,13 +768,14 @@ } }; DCBDEBUG1( printk (KERN_DEBUG "DCB %p (%02x,%02x) found.\n", \ - pDCB, pDCB->UnitSCSIID, pDCB->UnitSCSILUN);) + pDCB, pDCB->TargetID, pDCB->TargetLUN);) return pDCB; }; /* Queueing philosphy: * There are a couple of lists: * - Query: Contains the Scsi Commands not yet turned into SRBs (per ACB) + * (Note: For new EH, it is unecessary!) * - Waiting: Contains a list of SRBs not yet sent (per DCB) * - Free: List of free SRB slots * @@ -851,6 +868,7 @@ if (!pDCB->pWaitingSRB) pDCB->pWaitLast = pSRB; pDCB->pWaitingSRB = pSRB; + pDCB->WaitSRBCnt++; } @@ -865,6 +883,7 @@ pDCB->pWaitLast = pSRB; pSRB->pNextSRB = NULL; + pDCB->WaitSRBCnt++; pDCB->pDCBACB->CmdInQ++; } @@ -920,9 +939,26 @@ DEBUG0(printk("DC390: Remove SRB %p from head of Waiting\n", pSRB);) pDCB->pWaitingSRB = pSRB->pNextSRB; if( !pDCB->pWaitingSRB ) pDCB->pWaitLast = NULL; + pDCB->WaitSRBCnt--; dc390_Going_append (pDCB, pSRB); } +void DC390_waiting_timed_out (unsigned long ptr); +/* Sets the timer to wake us up */ +static void dc390_waiting_timer (PACB pACB, unsigned long to) +{ + if (timer_pending (&pACB->Waiting_Timer)) return; + init_timer (&pACB->Waiting_Timer); + pACB->Waiting_Timer.function = DC390_waiting_timed_out; + pACB->Waiting_Timer.data = (unsigned long)pACB; + if (time_before (jiffies + to, pACB->pScsiHost->last_reset)) + pACB->Waiting_Timer.expires = pACB->pScsiHost->last_reset + 1; + else + pACB->Waiting_Timer.expires = jiffies + to + 1; + add_timer (&pACB->Waiting_Timer); +} + + /* Send the next command from the waiting list to the bus */ static void dc390_Waiting_process ( PACB pACB ) { @@ -931,6 +967,7 @@ if( (pACB->pActiveDCB) || (pACB->ACBFlag & (RESET_DETECT+RESET_DONE+RESET_DEV) ) ) return; + if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer); ptr = pACB->pDCBRunRobin; if( !ptr ) { @@ -950,12 +987,28 @@ /* Try to send to the bus */ if( !dc390_StartSCSI(pACB, ptr1, pSRB) ) dc390_Waiting_to_Going (ptr1, pSRB); + else + dc390_waiting_timer (pACB, HZ/5); break; } } while (ptr1 != ptr); return; } +/* Wake up waiting queue */ +void DC390_waiting_timed_out (unsigned long ptr) +{ + PACB pACB = (PACB)ptr; + DC390_IFLAGS + DC390_AFLAGS + printk ("DC390: Debug: Waiting queue woken up by timer!\n"); + DC390_LOCK_IO; + DC390_LOCK_ACB; + dc390_Waiting_process (pACB); + DC390_UNLOCK_ACB; + DC390_UNLOCK_IO; +} + /*********************************************************************** * Function: static void dc390_SendSRB (PACB pACB, PSRB pSRB) * @@ -991,9 +1044,10 @@ if (!dc390_StartSCSI(pACB, pDCB, pSRB)) dc390_Going_append (pDCB, pSRB); - else + else { dc390_Waiting_insert (pDCB, pSRB); - + dc390_waiting_timer (pACB, HZ/5); + }; } /*********************************************************************** @@ -1125,11 +1179,12 @@ if ( ( cmd->target >= pACB->pScsiHost->max_id ) || (cmd->lun >= pACB->pScsiHost->max_lun) ) { -/* printk("DC390: Ignore target %d lun %d\n", +/* printk ("DC390: Ignore target %d lun %d\n", cmd->target, cmd->lun); */ DC390_UNLOCK_ACB; - done(cmd); - return( 0 ); + //return (1); + done (cmd); + return (0); } if( (pACB->scan_devices || cmd->cmnd[0] == TEST_UNIT_READY) && !(pACB->DCBmap[cmd->target] & (1 << cmd->lun)) ) @@ -1143,8 +1198,12 @@ cmd->target, cmd->lun); DC390_UNLOCK_ACB; printk ("DC390: No DCB in queuecommand!\n"); - done(cmd); - return(0); +#ifdef USE_NEW_EH + return (1); +#else + done (cmd); + return (0); +#endif }; } @@ -1153,8 +1212,9 @@ printk(KERN_INFO "DC390: Ignore target %02x lun %02x\n", cmd->target, cmd->lun); DC390_UNLOCK_ACB; - done(cmd); - return(0); + //return (1); + done (cmd); + return (0); } else { @@ -1165,8 +1225,12 @@ cmd->target, cmd->lun); DC390_UNLOCK_ACB; printk ("DC390: No DCB in queuecommand (2)!\n"); - done(cmd); - return(0); +#ifdef USE_NEW_EH + return (1); +#else + done (cmd); + return (0); +#endif }; } @@ -1351,6 +1415,8 @@ void dc390_dumpinfo (PACB pACB, PDCB pDCB, PSRB pSRB) { USHORT pstat; PDEVDECL1; + if (!pDCB) pDCB = pACB->pActiveDCB; + if (!pSRB && pDCB) pSRB = pDCB->pActiveSRB; if (pSRB) { @@ -1450,12 +1516,13 @@ pDCB = dc390_findDCB (pACB, cmd->target, cmd->lun); if( !pDCB ) goto NOT_RUN; - if (pDCB) pSRB = pDCB->pActiveSRB; else pSRB = 0; /* Added 98/07/02 KG */ + /* pSRB = pDCB->pActiveSRB; if (pSRB && pSRB->pcmd == cmd ) goto ON_GOING; + */ pSRB = pDCB->pWaitingSRB; if( !pSRB ) @@ -1484,6 +1551,7 @@ pDCB->pWaitLast = psrb; IN_WAIT: dc390_Free_insert (pACB, pSRB); + pDCB->WaitSRBCnt--; cmd->next = NULL; status = SCSI_ABORT_SUCCESS; goto ABO_X; @@ -1560,7 +1628,9 @@ dc390_lastabortedpid = cmd->pid; DC390_UNLOCK_ACB; //do_DC390_Interrupt (pACB->IRQLevel, 0, 0); +#ifndef USE_NEW_EH if (status == SCSI_ABORT_SUCCESS) cmd->scsi_done(cmd); +#endif return( status ); } @@ -1587,8 +1657,9 @@ pACB->ACBFlag &= ~(RESET_DEV | RESET_DONE | RESET_DETECT); } - +#if 0 +/* Moves all SRBs from Going to Waiting for all DCBs */ static void dc390_RecoverSRB( PACB pACB ) { PDCB pDCB, pdcb; @@ -1625,7 +1696,7 @@ pdcb = pdcb->pNextDCB; } while( pdcb != pDCB ); } - +#endif /*********************************************************************** * Function : int DC390_reset (Scsi_Cmnd *cmd, ...) @@ -1641,26 +1712,25 @@ int DC390_reset (Scsi_Cmnd *cmd, unsigned int resetFlags) { UCHAR bval; - UINT i; DC390_AFLAGS PACB pACB = (PACB) cmd->host->hostdata; printk(KERN_INFO "DC390: RESET ... "); DC390_LOCK_ACB; + if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer); bval = DC390_read8 (CtrlReg1); bval |= DIS_INT_ON_SCSI_RST; DC390_write8 (CtrlReg1, bval); /* disable IRQ on bus reset */ pACB->ACBFlag |= RESET_DEV; dc390_ResetSCSIBus( pACB ); - pACB->pScsiHost->last_reset = jiffies; dc390_ResetDevParam( pACB ); - /* Unlock ? */ - for( i=0; i<(500 + 1000*dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]); i++ ) - udelay(1000); - + udelay (1000); + pACB->pScsiHost->last_reset = jiffies + 3*HZ/2 + + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]; + DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD); DC390_read8 (INT_Status); /* Reset Pending INT */ @@ -1719,11 +1789,12 @@ pACB->pLastDCB = pDCB; pDCB->pDCBACB = pACB; - pDCB->UnitSCSIID = id; - pDCB->UnitSCSILUN = lun; + pDCB->TargetID = id; + pDCB->TargetLUN = lun; pDCB->pWaitingSRB = NULL; pDCB->pGoingSRB = NULL; pDCB->GoingSRBCnt = 0; + pDCB->WaitSRBCnt = 0; pDCB->pActiveSRB = NULL; pDCB->TagMask = 0; pDCB->MaxCommand = 1; @@ -1807,7 +1878,7 @@ { int i; PDCB pDCB = pACB->pLinkDCB; - for (i = 0; i < pACB->DeviceCnt; i++) + for (i = 0; i < pACB->DCBCnt; i++) { dc390_updateDCB (pACB, pDCB); pDCB = pDCB->pNextDCB; @@ -1867,7 +1938,9 @@ psh->n_io_port = 0x80; psh->irq = Irq; psh->base = (char*)io_port; + psh->unique_id = io_port; psh->dma_channel = -1; + psh->last_reset = jiffies; pACB = (PACB) psh->hostdata; DC390_LOCKA_INIT; @@ -1915,6 +1988,7 @@ pACB->glitch_cfg = EATER_25NS; pACB->Cmds = pACB->CmdInQ = pACB->CmdOutOfSRB = 0; pACB->SelLost = pACB->SelConn = 0; + init_timer (&pACB->Waiting_Timer); } @@ -1974,10 +2048,13 @@ if (pACB->Gmode2 & RST_SCSI_BUS) { dc390_ResetSCSIBus( pACB ); - pACB->pScsiHost->last_reset = jiffies; - /* Unlock before ? */ + udelay (1000); + pACB->pScsiHost->last_reset = jiffies + HZ/2 + + HZ * dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]; + /* for( i=0; i<(500 + 1000*dc390_eepromBuf[pACB->AdapterIndex][EE_DELAY]); i++ ) udelay(1000); + */ }; pACB->ACBFlag = 0; DC390_read8 (INT_Status); /* Reset Pending INT */ @@ -2144,7 +2221,8 @@ PDEVDECL0; UCHAR irq; UINT io_port; - DC390_IFLAGS DC390_DFLAGS + //DC390_IFLAGS + DC390_DFLAGS DC390_LOCK_DRV; //dc390_pSHT_start = psht; @@ -2153,7 +2231,7 @@ if ( PCI_PRESENT ) while (PCI_FIND_DEVICE (PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD53C974)) { - DC390_LOCK_IO; /* Remove this when going to new eh */ + //DC390_LOCK_IO; /* Remove this when going to new eh */ PCI_GET_IO_AND_IRQ; DEBUG0(printk(KERN_INFO "DC390(%i): IO_PORT=%04x,IRQ=%x\n", dc390_adapterCnt, (UINT) io_port, irq);) @@ -2163,7 +2241,7 @@ dc390_set_pci_cfg (PDEV); dc390_adapterCnt++; }; - DC390_UNLOCK_IO; /* Remove when going to new eh */ + //DC390_UNLOCK_IO; /* Remove when going to new eh */ } else printk (KERN_ERR "DC390: No PCI BIOS found!\n"); @@ -2216,14 +2294,15 @@ memset (cmd, 0, sizeof(Scsi_Cmnd) + 256); cmd->cmnd[0] = INQUIRY; - cmd->cmnd[1] = (pDCB->UnitSCSILUN << 5) & 0xe0; + cmd->cmnd[1] = (pDCB->TargetLUN << 5) & 0xe0; cmd->cmnd[4] = 0xff; cmd->cmd_len = 6; cmd->old_cmd_len = 6; cmd->host = pACB->pScsiHost; - cmd->target = pDCB->UnitSCSIID; - cmd->lun = pDCB->UnitSCSILUN; + cmd->target = pDCB->TargetID; + cmd->lun = pDCB->TargetLUN; cmd->serial_number = 1; + cmd->pid = 390; cmd->bufflen = 128; cmd->buffer = buffer; cmd->request_bufflen = 128; @@ -2236,7 +2315,7 @@ pDCB->SyncMode &= ~SYNC_NEGO_DONE; printk (KERN_INFO "DC390: Queue INQUIRY command to dev ID %02x LUN %02x\n", - pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + pDCB->TargetID, pDCB->TargetLUN); DC390_queue_command (cmd, dc390_inquiry_done); }; @@ -2358,6 +2437,7 @@ else if (!memcmp (pos, "INQUIRY", 7)) goto inquiry; else if (!memcmp (pos, "REMOVE", 6)) goto remove; else if (!memcmp (pos, "ADD", 3)) goto add; + else if (!memcmp (pos, "DUMP", 4)) goto dump; if (isdigit (*pos)) { @@ -2374,7 +2454,7 @@ pDCB = pACB->pLinkDCB; for (dum = 0; dum < dev; dum++) pDCB = pDCB->pNextDCB; /* Sanity Check */ - if (pDCB->UnitSCSIID != id || pDCB->UnitSCSILUN != lun) + if (pDCB->TargetID != id || pDCB->TargetLUN != lun) { printk (KERN_ERR "DC390: no such device: Idx=%02i ID=%02i LUN=%02i\n", dev, id, lun); @@ -2384,7 +2464,7 @@ if (pDCB->pWaitingSRB || pDCB->pGoingSRB) { printk ("DC390: Cannot change dev (%i-%i) cfg: Pending requests\n", - pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + pDCB->TargetID, pDCB->TargetLUN); goto einv; }; @@ -2471,13 +2551,13 @@ } else { - char* p1 = pos; UCHAR dum; + char* p1 = pos; UCHAR dum, newadaptid; PARSEDEBUG(printk (KERN_INFO "DC390: chg adapt cfg \"%s\"\n", prstr (pos, &buffer[length]));) dum = GLITCH_TO_NS (pACB->glitch_cfg); /* Adapter setting */ SEARCH (pos, p0, pACB->pScsiHost->max_id, "MAXID", 8); SEARCH (pos, p0, pACB->pScsiHost->max_lun, "MAXLUN", 8); - SEARCH (pos, p0, pACB->pScsiHost->this_id, "ADAPTERID", 7); + SEARCH (pos, p0, newadaptid, "ADAPTERID", 7); SEARCH (pos, p0, pACB->TagMaxNum, "TAGMAXNUM", 32); SEARCH (pos, p0, pACB->ACBFlag, "ACBFLAG", 255); SEARCH3 (pos, p0, dum, "GLITCHEATER", 40, 1000, "NS"); @@ -2486,9 +2566,16 @@ ok2: pACB->glitch_cfg = NS_TO_GLITCH (dum); if (pACB->sel_timeout < 60) pACB->sel_timeout = 60; + DC390_write8 (Scsi_TimeOut, pACB->sel_timeout); + if (newadaptid != pACB->pScsiHost->this_id) + { + pACB->pScsiHost->this_id = newadaptid; + dc390_ResetDevParam (pACB); + } //dum = 0; while (1 << dum <= pACB->TagMaxNum) dum ++; //pACB->TagMaxNum &= (1 << --dum); dc390_updateDCBs (pACB); + // All devs should be INQUIRED now if (pos == p1) goto einv; } if (pos) goto next; @@ -2519,7 +2606,15 @@ DC390_UNLOCK_IO; }; return (length); - + + dump: + { + dc390_dumpinfo (pACB, 0, 0); + DC390_UNLOCK_ACB; + DC390_UNLOCK_IO; + } + return (length); + inquiry: { pos = strtok (0, " \t\n.:;="); if (!pos) goto einv; @@ -2527,7 +2622,7 @@ if (dev >= pACB->DCBCnt) goto einv_dev; for (dum = 0; dum < dev; dum++) pDCB = pDCB->pNextDCB; printk (KERN_NOTICE " DC390: Issue INQUIRY command to Dev(Idx) %i SCSI ID %i LUN %i\n", - dev, pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + dev, pDCB->TargetID, pDCB->TargetLUN); DC390_UNLOCK_ACB; dc390_inquiry (pACB, pDCB); DC390_UNLOCK_IO; @@ -2541,7 +2636,7 @@ if (dev >= pACB->DCBCnt) goto einv_dev; for (dum = 0; dum < dev; dum++) pDCB = pDCB->pNextDCB; printk (KERN_NOTICE " DC390: Remove DCB for Dev(Idx) %i SCSI ID %i LUN %i\n", - dev, pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + dev, pDCB->TargetID, pDCB->TargetLUN); /* TO DO: We should make sure no pending commands are left */ dc390_remove_dev (pACB, pDCB); DC390_UNLOCK_ACB; @@ -2613,6 +2708,7 @@ PSH shpnt; PACB pACB; PDCB pDCB; + PSCSICMD pcmd; DC390_AFLAGS pACB = dc390_pACB_start; @@ -2663,7 +2759,7 @@ pDCB = pACB->pLinkDCB; for (dev = 0; dev < pACB->DCBCnt; dev++) { - SPRINTF("%02i %02i %02i ", dev, pDCB->UnitSCSIID, pDCB->UnitSCSILUN); + SPRINTF("%02i %02i %02i ", dev, pDCB->TargetID, pDCB->TargetLUN); YESNO(pDCB->DevMode & PARITY_CHK_); YESNO(pDCB->SyncMode & SYNC_NEGO_DONE); YESNO(pDCB->DevMode & EN_DISCONNECT_); @@ -2682,6 +2778,43 @@ SPRINTF (" %02i\n", pDCB->MaxCommand); pDCB = pDCB->pNextDCB; } + SPRINTF ("Commands in Queues: Query: %li:", pACB->QueryCnt); + for (pcmd = pACB->pQueryHead; pcmd; pcmd = pcmd->next) + SPRINTF (" %li", pcmd->pid); + if (timer_pending(&pACB->Waiting_Timer)) SPRINTF ("Waiting queue timer running\n"); + else SPRINTF ("\n"); + pDCB = pACB->pLinkDCB; + + for (dev = 0; dev < pACB->DCBCnt; dev++) + { + PSRB pSRB; + if (pDCB->WaitSRBCnt) + SPRINTF ("DCB (%02i-%i): Waiting: %i:", pDCB->TargetID, pDCB->TargetLUN, + pDCB->WaitSRBCnt); + for (pSRB = pDCB->pWaitingSRB; pSRB; pSRB = pSRB->pNextSRB) + SPRINTF(" %li", pSRB->pcmd->pid); + if (pDCB->GoingSRBCnt) + SPRINTF ("\nDCB (%02i-%i): Going : %i:", pDCB->TargetID, pDCB->TargetLUN, + pDCB->GoingSRBCnt); + for (pSRB = pDCB->pGoingSRB; pSRB; pSRB = pSRB->pNextSRB) +#if 0 //def DC390_DEBUGTRACE + SPRINTF(" %s\n ", pSRB->debugtrace); +#else + SPRINTF(" %li", pSRB->pcmd->pid); +#endif + if (pDCB->WaitSRBCnt || pDCB->GoingSRBCnt) SPRINTF ("\n"); + pDCB = pDCB->pNextDCB; + } + +#ifdef DC390_DEBUGDCB + SPRINTF ("DCB list for ACB %p:\n", pACB); + pDCB = pACB->pLinkDCB; + SPRINTF ("%p", pDCB); + for (dev = 0; dev < pACB->DCBCnt; dev++, pDCB=pDCB->pNextDCB) + SPRINTF ("->%p", pDCB->pNextDCB); + SPRINTF("\n"); +#endif + DC390_UNLOCK_ACB; *start = buffer + offset; @@ -2723,6 +2856,7 @@ if (pACB->Gmode2 & RST_SCSI_BUS) dc390_ResetSCSIBus (pACB); + if (timer_pending (&pACB->Waiting_Timer)) del_timer (&pACB->Waiting_Timer); return( 0 ); } @@ -2737,15 +2871,15 @@ { nDCB = pDCB->pNextDCB; DCBDEBUG(printk (KERN_INFO "DC390: Free DCB (ID %i, LUN %i): %p\n",\ - pDCB->UnitSCSIID, pDCB->UnitSCSILUN, pDCB);) + pDCB->TargetID, pDCB->TargetLUN, pDCB);) //kfree (pDCB); dc390_remove_dev (pACB, pDCB); pDCB = nDCB; - } while (pDCB && pDCB != pACB->pLinkDCB && pACB->pLinkDCB); + } while (pDCB && pACB->pLinkDCB); }; -int DC390_release(struct Scsi_Host *host) +int DC390_release (struct Scsi_Host *host) { DC390_AFLAGS DC390_IFLAGS PACB pACB = (PACB)(host->hostdata); Index: tmscsim.h =================================================================== RCS file: /home/cvsroot/dc390/tmscsim.h,v retrieving revision 2.15 retrieving revision 2.15.2.1 diff -u -r2.15 -r2.15.2.1 --- tmscsim.h 1999/08/26 19:48:57 2.15 +++ tmscsim.h 2000/02/08 21:53:57 2.15.2.1 @@ -3,7 +3,7 @@ ;* TEKRAM DC-390(T) PCI SCSI Bus Master Host Adapter * ;* Device Driver * ;***********************************************************************/ -/* $Id: tmscsim.h,v 2.15 1999/08/26 19:48:57 garloff Exp $ */ +/* $Id: tmscsim.h,v 2.15.2.1 2000/02/08 21:53:57 garloff Exp $ */ #ifndef _TMSCSIM_H #define _TMSCSIM_H @@ -155,8 +155,8 @@ /* 0x20: */ UINT TagMask; -UCHAR UnitSCSIID; /*; SCSI Target ID (SCSI Only) */ -UCHAR UnitSCSILUN; /*; SCSI Log. Unit (SCSI Only) */ +UCHAR TargetID; /*; SCSI Target ID (SCSI Only) */ +UCHAR TargetLUN; /*; SCSI Log. Unit (SCSI Only) */ UCHAR DevMode; UCHAR DCBFlag; @@ -238,13 +238,14 @@ UINT SelConn; UINT CmdInQ; UINT CmdOutOfSRB; - -/* 0x60/0x5c: */ +/* 0x60/0x5c: */ +struct timer_list Waiting_Timer; +/* 0x74/0x70: */ DC390_SRB TmpSRB; -/* 0xc4/0xc0: */ +/* 0xd8/0xd4: */ DC390_SRB SRB_array[MAX_SRB_CNT]; /* 50 SRBs */ -/* 0xf9c/0xf98: */ +/* 0xfb0/0xfac: */ }; typedef struct _ACB DC390_ACB, *PACB;