Index: dc395x_trm.c =================================================================== RCS file: /usr/local/cvsroot/dc395/dc395x_trm.c,v retrieving revision 1.6 retrieving revision 1.12 diff -u -r1.6 -r1.12 --- dc395x_trm.c 1999/07/12 15:27:24 1.6 +++ dc395x_trm.c 1999/07/14 23:42:04 1.12 @@ -20,6 +20,8 @@ //* 1.06 99/06/30 Erich Chen Modify for linux SMP kernel 2.2.5 //* include spinlock.h //* 1.07 99/07/12 Kurt Garloff Merge of 1.01 and 1.06 +//* 1.08 99/07/15 Kurt Garloff Fix Oopses, Message Handling, +//* Copy SyncMode to LUNs //*********************************************************************** /* ************************************************************************* @@ -50,8 +52,8 @@ ************************************************************************* */ -#define DC395x_trm_DEBUG0 -#define DC395x_trm_DEBUG1 +//#define DC395x_trm_DEBUG0 +//#define DC395x_trm_DEBUG1 #include @@ -87,7 +89,6 @@ # include # include # define USE_SPINLOCKS 1 -# define NEW_PCI 1 #else # define __initfunc(A) A # define __initdata @@ -95,6 +96,9 @@ # include #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70) +# define NEW_PCI 1 +#endif # if defined(MODULE) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,30) //MODULE_PARM(dc395x_trm, "1-6i"); @@ -287,7 +291,7 @@ BYTE AdpMode; BYTE SyncMode; /* 0:async mode */ - BYTE MaxNegoPeriod; /* for nego. */ + BYTE MinNegoPeriod; /* for nego. */ BYTE SyncPeriod; /* for reg. */ BYTE SyncOffset; /* for reg. and nego.(low nibble) */ @@ -503,7 +507,7 @@ #define EN_TAG_QUEUEING BIT4 #define EN_ATN_STOP BIT5 -#define SYNC_NEGO_OFFSET 16 +#define SYNC_NEGO_OFFSET 15 /*----SCSI MSG BYTE*/ #define MSG_COMPLETE 0x00 @@ -1088,20 +1092,20 @@ static void DC395x_trm_DataIO_transfer( PACB pACB, PSRB pSRB, WORD ioDir); static void DC395x_trm_Disconnect( PACB pACB ); static void DC395x_trm_Reselect( PACB pACB ); -static inline WORD DC395x_trm_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ); -static inline void DC395x_trm_BuildSRB(Scsi_Cmnd* pcmd, PDCB pDCB, PSRB pSRB); -static inline void DC395x_trm_DoingSRB_Done( PACB pACB ); -static inline void DC395x_trm_ScsiRstDetect( PACB pACB ); + WORD DC395x_trm_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ); +static void DC395x_trm_BuildSRB(Scsi_Cmnd* pcmd, PDCB pDCB, PSRB pSRB); +static void DC395x_trm_DoingSRB_Done( PACB pACB ); +static void DC395x_trm_ScsiRstDetect( PACB pACB ); static inline void DC395x_trm_EnableMsgOutAbort1( PACB pACB, PSRB pSRB ); static inline void DC395x_trm_EnableMsgOutAbort2( PACB pACB, PSRB pSRB ); -static inline void DC395x_trm_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ); -static inline void DC395x_trm_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ); +static void DC395x_trm_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ); +static void DC395x_trm_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ); static inline void DC395x_trm_SetXferRate( PACB pACB, PDCB pDCB ); - inline void DC395x_trm_initDCB( PACB pACB, PDCB pDCB, PSCSICMD cmd ); + void DC395x_trm_initDCB( PACB pACB, PDCB pDCB, PSCSICMD cmd ); #ifdef MODULE -static int DC395x_trm_release(struct Scsi_Host *host); -static int DC395x_trm_shutdown (struct Scsi_Host *host); +int DC395x_trm_release(struct Scsi_Host *host); +int DC395x_trm_shutdown (struct Scsi_Host *host); #endif static PACB DC395x_TRM_pACB_start = NULL; @@ -1294,7 +1298,7 @@ ** ********************************************************************* */ -static inline void DC395x_trm_RewaitSRB( PDCB pDCB, PSRB pSRB ) +static void DC395x_trm_RewaitSRB( PDCB pDCB, PSRB pSRB ) { PACB pACB; PSRB pSRBTemp; @@ -1302,7 +1306,7 @@ //DC395x_TRM_DRV_LOCK(drv_flags); #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_RewaitSRB..............\n "); + printk(KERN_INFO "DC395x_RewaitSRB..............\n "); #endif pACB = pDCB->pDCBACB; @@ -1367,7 +1371,7 @@ ** ********************************************************************* */ -static inline void DC395x_trm_DoWaitingSRB( PACB pACB ) +static void DC395x_trm_DoWaitingSRB( PACB pACB ) { PDCB pDCBTemp, pDCBTemp1; PSRB pSRB; @@ -1375,7 +1379,7 @@ //DC395x_TRM_DRV_LOCK(drv_flags); #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DoWaitingSRB..............\n "); + printk(KERN_INFO "DC395x_DoWaitingSRB..............\n "); #endif if( !(pACB->pActiveDCB) && !(pACB->ACBFlag & (RESET_DETECT+RESET_DONE+RESET_DEV) ) ) @@ -1471,14 +1475,14 @@ ** ********************************************************************* */ -static inline void DC395x_trm_SendSRB( PSCSICMD pcmd, PACB pACB, PSRB pSRB ) +static void DC395x_trm_SendSRB( PSCSICMD pcmd, PACB pACB, PSRB pSRB ) { PDCB pDCB; //DWORD drv_flags=0; //DC395x_TRM_DRV_LOCK(drv_flags); #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_SendSRB..............\n "); + printk(KERN_INFO "DC395x_SendSRB..............\n "); #endif pDCB = pSRB->pSRBDCB; @@ -1566,7 +1570,7 @@ pACB = (PACB) cmd->host->hostdata; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_queue_command..............\n "); + printk(KERN_INFO "DC395x_queue_command..............\n "); printk(KERN_INFO "pACB = %8x,Cmd=%2x,ID=%d,LUN=%d\n",(UINT)pACB,cmd->cmnd[0],cmd->target,cmd->lun); #endif @@ -1669,14 +1673,14 @@ ** ********************************************************************** */ -static inline void DC395x_trm_BuildSRB(Scsi_Cmnd* pcmd, PDCB pDCB, PSRB pSRB) +static void DC395x_trm_BuildSRB(Scsi_Cmnd* pcmd, PDCB pDCB, PSRB pSRB) { int i,max; PSGE0 sgp; struct scatterlist *sl; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_BuildSRB..............\n "); + printk(KERN_INFO "DC395x_BuildSRB..............\n "); #endif pSRB->pSRBDCB = pDCB; pSRB->pcmd = pcmd; @@ -1697,7 +1701,7 @@ max = pcmd->use_sg; if(max > DC395x_trm_MAX_SG_LISTENTRY) { - printk(KERN_INFO "cmd->use_sg=%4d bigger then dc395x: DC395x_trm_MAX_SG_LISTENTRY=%4d\n",pcmd->use_sg,DC395x_trm_MAX_SG_LISTENTRY); + printk(KERN_INFO "cmd->use_sg=%4d bigger then dc395x: DC395x_MAX_SG_LISTENTRY=%4d\n",pcmd->use_sg,DC395x_trm_MAX_SG_LISTENTRY); } for (i = 0; i < max; i++,sgp++) @@ -1746,7 +1750,7 @@ //DWORD drv_flags=0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DoNextCmd..............\n "); + printk(KERN_INFO "DC395x_DoNextCmd..............\n "); #endif if( pACB->ACBFlag & (RESET_DETECT+RESET_DONE+RESET_DEV) ) return; @@ -1781,7 +1785,7 @@ PACB pACB; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_bios_param..............\n "); + printk(KERN_INFO "DC395x_bios_param..............\n "); #endif pACB = (PACB) disk->device->host->hostdata; heads = 64; @@ -1822,7 +1826,7 @@ pACB = (PACB) cmd->host->hostdata; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_abort..............\n "); + printk(KERN_INFO "DC395x_abort..............\n "); #endif pACB = (PACB) cmd->host->hostdata; @@ -1940,7 +1944,7 @@ ** ********************************************************************* */ -static inline void DC395x_trm_ResetDevParam( PACB pACB ) +static void DC395x_trm_ResetDevParam( PACB pACB ) { PDCB pDCB, pDCBTemp; PNVRAMTYPE pEEpromBuf; @@ -1948,7 +1952,7 @@ WORD index; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_ResetDevParam..............\n "); + printk(KERN_INFO "DC395x_ResetDevParam..............\n "); #endif pDCB = pACB->pLinkDCB; if( pDCB == NULL ) @@ -1966,13 +1970,13 @@ pDCB->DevMode = pEEpromBuf->NvramTarget[pDCB->TargetID].NvmTarCfg0; pDCB->AdpMode = pEEpromBuf->NvramChannelCfg; PeriodIndex = pEEpromBuf->NvramTarget[pDCB->TargetID].NvmTarPeriod & 0x07; - pDCB->MaxNegoPeriod = dc395x_trm_clock_period[ PeriodIndex ] ; + pDCB->MinNegoPeriod = dc395x_trm_clock_period[ PeriodIndex ] ; if ((pDCB->DevMode & NTC_DO_WIDE_NEGO) && (pACB->Config & HCC_WIDE_CARD)) pDCB->SyncMode |= WIDE_NEGO_ENABLE; pDCB = pDCB->pNextDCB; } - while( pDCBTemp != pDCB ); + while( pDCBTemp != pDCB && pDCB != NULL ); } /* @@ -1982,14 +1986,14 @@ ** ********************************************************************* */ -static inline void DC395x_trm_RecoverSRB( PACB pACB ) +static void DC395x_trm_RecoverSRB( PACB pACB ) { PDCB pDCB, pDCBTemp; PSRB pSRBTemp, pSRBTemp2; WORD cnt, i; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_RecoverSRB.............\n "); + printk(KERN_INFO "DC395x_RecoverSRB.............\n "); #endif pDCB = pACB->pLinkDCB; if( pDCB == NULL ) @@ -2043,7 +2047,7 @@ pACB = (PACB ) cmd->host->hostdata; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_reset..............\n "); + printk(KERN_INFO "DC395x_reset..............\n "); #endif pACB = (PACB) cmd->host->hostdata; @@ -2092,7 +2096,7 @@ ** ********************************************************************* */ -static inline WORD DC395x_trm_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) +WORD DC395x_trm_StartSCSI( PACB pACB, PDCB pDCB, PSRB pSRB ) { WORD ioport, return_code; BYTE tag_number, scsicommand, i,command,identify_message; @@ -2100,7 +2104,7 @@ DWORD tag_mask; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_StartSCSI..............\n "); + printk(KERN_INFO "DC395x_StartSCSI..............\n "); #endif pSRB->TagNumber = 31;/* pACB->TagMaxNum: had error read in eeprom*/ ioport = pACB->IOPortBase; @@ -2117,7 +2121,8 @@ if( (pSRB->CmdBlock[0] == INQUIRY) || (pSRB->CmdBlock[0] == REQUEST_SENSE) || (pSRB->SRBFlag & AUTO_REQSENSE) ) { - if( (pDCB->SyncMode & WIDE_NEGO_ENABLE) || (pDCB->SyncMode & SYNC_NEGO_ENABLE) ) + if ( ((pDCB->SyncMode & WIDE_NEGO_ENABLE) && !(pDCB->SyncMode & WIDE_NEGO_DONE)) + || ((pDCB->SyncMode & SYNC_NEGO_ENABLE) && !(pDCB->SyncMode & SYNC_NEGO_DONE)) ) { if( !(pDCB->IdentifyMsg & 7) || (pSRB->CmdBlock[0] != INQUIRY) ) { @@ -2246,13 +2251,13 @@ DC395x_LOCK_IO; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_Interrupt..............\n "); + printk(KERN_INFO "DC395x_Interrupt..............\n "); #endif pACB = DC395x_TRM_pACB_start; if( pACB == NULL ) { - printk(KERN_WARNING "DC395x_TRM: Interrupt on uninitialized pACB!\n"); + printk(KERN_WARNING "DC395x: Interrupt on uninitialized pACB!\n"); return; } @@ -2304,9 +2309,9 @@ } //DC395x_TRM_DRV_UNLOCK(drv_flags); - if( pACB == (PACB )-1 ) + if( pACB == (PACB)-1 ) { - printk("DC395x_trm_Interrupt: Spurious interrupt detected!\n"); + //printk("DC395x_Interrupt: Spurious interrupt detected!\n"); goto out_unlock; } scsi_intstatus = inb( ioport+TRM_S1040_SCSI_INTSTATUS ); @@ -2435,7 +2440,7 @@ WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_MsgOutPhase0..... "); + printk(KERN_INFO "DC395x_MsgOutPhase0..... "); #endif ioport = pACB->IOPortBase; if( pSRB->SRBState & (SRB_UNEXPECT_RESEL+SRB_ABORT_SENT) ) @@ -2460,7 +2465,7 @@ PDCB pDCB; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_MsgOutPhase1..............\n "); + printk(KERN_INFO "DC395x_MsgOutPhase1..............\n "); #endif ioport = pACB->IOPortBase; outw(DO_CLRFIFO, ioport+TRM_S1040_SCSI_CONTROL); @@ -2470,12 +2475,15 @@ if( pSRB->MsgCnt ) { ptr = (PBYTE) pSRB->MsgOutBuf; + //printk ("DC395x: MsgOut: "); for(i=0; i < pSRB->MsgCnt ; i++) { outb(*ptr, ioport+TRM_S1040_SCSI_FIFO); + //printk ("%02x ", *ptr); ptr++; } pSRB->MsgCnt = 0; + //printk ("\n"); if( (pDCB->DCBFlag & ABORT_DEV_) && (pSRB->MsgOutBuf[0] == MSG_ABORT) ) pSRB->SRBState = SRB_ABORT_SENT; @@ -2502,11 +2510,14 @@ */ pDCB->SyncMode &= ~(SYNC_NEGO_DONE | EN_ATN_STOP ); outb( (pDCB->IdentifyMsg & 0xBF) ,ioport+TRM_S1040_SCSI_FIFO); - outb( MSG_EXTENDED,ioport+TRM_S1040_SCSI_FIFO); /* (01h) */ - outb( 2,ioport+TRM_S1040_SCSI_FIFO); /* Message length (02h) */ - outb( 3,ioport+TRM_S1040_SCSI_FIFO); /* wide data xfer (03h) */ - outb( 1,ioport+TRM_S1040_SCSI_FIFO); /* width:0(8bit),1(16bit),2(32bit) */ - pSRB->SRBState |= SRB_DO_WIDE_NEGO; + outb( MSG_EXTENDED,ioport+TRM_S1040_SCSI_FIFO); /* (01h) */ + outb( 2,ioport+TRM_S1040_SCSI_FIFO); /* Message length (01h) */ + outb( EXTENDED_WDTR,ioport+TRM_S1040_SCSI_FIFO); /* wide data xfer (03h) */ + outb( 1,ioport+TRM_S1040_SCSI_FIFO); /* width:0(8bit),1(16bit),2(32bit) */ +#ifdef DC395x_trm_DEBUG0 + printk ("DC395x: Send WDTR to target %02i\n", pDCB->TargetID); +#endif + pSRB->SRBState |= SRB_DO_WIDE_NEGO; } else if( !(pSRB->SRBState & SRB_DO_SYNC_NEGO) && (pDCB->SyncMode & SYNC_NEGO_ENABLE) ) { @@ -2516,12 +2527,15 @@ if(!(pDCB->SyncMode & WIDE_NEGO_DONE) ) outb( (pDCB->IdentifyMsg & 0xBF) ,ioport+TRM_S1040_SCSI_FIFO); - outb( MSG_EXTENDED,ioport+TRM_S1040_SCSI_FIFO); /* (01h) */ - outb( 3,ioport+TRM_S1040_SCSI_FIFO); /* Message length (03h) */ - outb( 1,ioport+TRM_S1040_SCSI_FIFO); /* SYNCHRONOUS DATA TRANSFER REQUEST code (01h) */ - outb( pDCB->MaxNegoPeriod,ioport+TRM_S1040_SCSI_FIFO);/* Transfer period factor */ - outb( SYNC_NEGO_OFFSET,ioport+TRM_S1040_SCSI_FIFO); /* REQ/ACK offset */ + outb( MSG_EXTENDED,ioport+TRM_S1040_SCSI_FIFO); /* (01h) */ + outb( 3,ioport+TRM_S1040_SCSI_FIFO); /* Message length (03h) */ + outb( EXTENDED_SDTR,ioport+TRM_S1040_SCSI_FIFO); /* SYNCHRONOUS DATA TRANSFER REQUEST code (01h) */ + outb( pDCB->MinNegoPeriod,ioport+TRM_S1040_SCSI_FIFO); /* Transfer period factor */ + outb( SYNC_NEGO_OFFSET,ioport+TRM_S1040_SCSI_FIFO); /* REQ/ACK offset */ pSRB->SRBState |= SRB_DO_SYNC_NEGO; +#ifdef DC395x_trm_DEBUG0 + printk ("DC395x: Send SDTR to target %02i\n", pDCB->TargetID); +#endif } } outw(DO_DATALATCH, ioport+TRM_S1040_SCSI_CONTROL);/* it's important for atn stop*/ @@ -2560,7 +2574,7 @@ WORD ioport, i; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_CommandPhase1..............\n "); + printk(KERN_INFO "DC395x_CommandPhase1..............\n "); #endif ioport = pACB->IOPortBase; outw( DO_CLRATN | DO_CLRFIFO , ioport+TRM_S1040_SCSI_CONTROL); @@ -2611,7 +2625,7 @@ DWORD TempSRBXferredLength,dLeftCounter=0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DataOutPhase0..... "); + printk(KERN_INFO "DC395x_DataOutPhase0..... "); #endif pDCB = pSRB->pSRBDCB; ioport = pACB->IOPortBase; @@ -2721,7 +2735,7 @@ WORD ioDir; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DataOutPhase1..... "); + printk(KERN_INFO "DC395x_DataOutPhase1..... "); #endif /* ** do prepare befor transfer when data out phase @@ -2749,7 +2763,7 @@ DWORD TempSRBXferredLength,dLeftCounter=0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DataInPhase0..............\n "); + printk(KERN_INFO "DC395x_DataInPhase0..............\n "); #endif ioport = pACB->IOPortBase; scsi_status = *pscsi_status; @@ -2834,7 +2848,7 @@ WORD ioDir; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DataInPhase1..... "); + printk(KERN_INFO "DC395x_DataInPhase1..... "); #endif /* ** do prepare befor transfer when data in phase @@ -2859,7 +2873,7 @@ PDCB pDCB; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DataIO_transfer..............\n "); + printk(KERN_INFO "DC395x_DataIO_transfer..............\n "); #endif ioport = pACB->IOPortBase; pDCB = pSRB->pSRBDCB; @@ -2932,7 +2946,7 @@ WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_StatusPhase0..... "); + printk(KERN_INFO "DC395x_StatusPhase0..... "); #endif ioport = pACB->IOPortBase; @@ -2961,7 +2975,7 @@ WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_StatusPhase1..............\n "); + printk(KERN_INFO "DC395x_StatusPhase1..............\n "); #endif ioport = pACB->IOPortBase; if (inw(ioport+TRM_S1040_DMA_COMMAND) & 0x0001) @@ -3016,7 +3030,7 @@ PSRB pSRBTemp; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_MsgInPhase0..............\n "); + printk(KERN_INFO "DC395x_MsgInPhase0..............\n "); #endif ioport = pACB->IOPortBase; pDCB = pACB->pActiveDCB; @@ -3095,17 +3109,15 @@ else /* when extend message in:pSRB->SRBState = SRB_EXTEND_MSGIN */ { /* - ** Parsing incomming extented messages + ** Parsing incoming extented messages */ *pSRB->pMsgPtr = message_in_code; pSRB->MsgCnt++; pSRB->pMsgPtr++; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "pSRB->MsgInBuf[0]=%2x \n ",pSRB->MsgInBuf[0]); - printk(KERN_INFO "pSRB->MsgInBuf[1]=%2x \n ",pSRB->MsgInBuf[1]); - printk(KERN_INFO "pSRB->MsgInBuf[2]=%2x \n ",pSRB->MsgInBuf[2]); - printk(KERN_INFO "pSRB->MsgInBuf[3]=%2x \n ",pSRB->MsgInBuf[3]); - printk(KERN_INFO "pSRB->MsgInBuf[4]=%2x \n ",pSRB->MsgInBuf[4]); + printk(KERN_INFO "pSRB->MsgInBuf: %02x %02x %02x %02x %02x %02x\n ", + pSRB->MsgInBuf[0], pSRB->MsgInBuf[1], pSRB->MsgInBuf[2], + pSRB->MsgInBuf[3], pSRB->MsgInBuf[4], pSRB->MsgInBuf[5]); #endif if( (pSRB->MsgInBuf[0] >= MSG_SIMPLE_QTAG) && (pSRB->MsgInBuf[0] <= MSG_ORDER_QTAG) ) { @@ -3119,7 +3131,7 @@ ** byte 1: ** Queue tag (00h - FFh) */ - if( pSRB->MsgCnt == 2) + if (pSRB->MsgCnt == 2) { pSRB->SRBState = 0; message_in_tag_id = pSRB->MsgInBuf[1]; @@ -3162,7 +3174,7 @@ } } } - else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgInBuf[2] == 3) && (pSRB->MsgCnt == 4) ) + else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgInBuf[2] == EXTENDED_WDTR) && (pSRB->MsgCnt == 2+pSRB->MsgInBuf[1])) { /* ** is Wide data xfer Extended message : @@ -3206,7 +3218,10 @@ pSRB->SRBState &= ~(SRB_DO_WIDE_NEGO+SRB_MSGIN); pDCB->SyncMode |= WIDE_NEGO_DONE; pDCB->SyncMode &= ~(SYNC_NEGO_DONE | EN_ATN_STOP | WIDE_NEGO_ENABLE ); - if (pSRB->MsgInBuf[3] != 0) + printk ("DC395x: Target %02i: Wide %i transfer negotiated\n", + pDCB->TargetID, 8<MsgInBuf[3]); + + if (pSRB->MsgInBuf[3] != 0) { /* is Wide data xfer */ pDCB->SyncPeriod |= WIDE_SYNC; @@ -3221,7 +3236,7 @@ outw( DO_SETATN,ioport+TRM_S1040_SCSI_CONTROL ); goto min6; } - else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgInBuf[2] == 1) && (pSRB->MsgCnt == 5) ) + else if( (pSRB->MsgInBuf[0] == MSG_EXTENDED) && (pSRB->MsgInBuf[2] == EXTENDED_SDTR) && (pSRB->MsgCnt == 2+pSRB->MsgInBuf[1]) ) { /* ** is 8bit transfer Extended message : @@ -3255,7 +3270,7 @@ /* set_sync */ pDCB = pSRB->pSRBDCB; pDCB->SyncMode |= SYNC_NEGO_ENABLE+SYNC_NEGO_DONE; - pDCB->MaxNegoPeriod = pSRB->MsgInBuf[3];/* Transfer period factor */ + pDCB->MinNegoPeriod = pSRB->MsgInBuf[3];/* Transfer period factor */ pDCB->SyncOffset = pSRB->MsgInBuf[4]; /* REQ/ACK offset */ for (bIndex = 0; bIndex < 7; bIndex++) { @@ -3269,6 +3284,8 @@ */ outb(pDCB->SyncPeriod, ioport+TRM_S1040_SCSI_SYNC); outb(pDCB->SyncOffset, ioport+TRM_S1040_SCSI_OFFSET); + printk ("DC395x: Target %02i: Sync transfer %i ns, Offset %i\n", + pDCB->TargetID, pSRB->MsgInBuf[3]<<2, pSRB->MsgInBuf[4]); DC395x_trm_SetXferRate( pACB, pDCB); } } @@ -3297,7 +3314,7 @@ WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_MsgInPhase1..............\n "); + printk(KERN_INFO "DC395x_MsgInPhase1..............\n "); #endif ioport = pACB->IOPortBase; outw(DO_CLRFIFO, ioport+TRM_S1040_SCSI_CONTROL); @@ -3374,7 +3391,8 @@ { pDCBTemp->SyncPeriod = pDCB->SyncPeriod; pDCBTemp->SyncOffset = pDCB->SyncOffset; - pDCBTemp->SyncMode = pDCB->SyncMode; + pDCBTemp->SyncMode = pDCB->SyncMode; + pDCBTemp->MinNegoPeriod = pDCB->MinNegoPeriod; } pDCBTemp = pDCBTemp->pNextDCB; } @@ -3397,7 +3415,7 @@ WORD ioport,i,j,count; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_Disconnected..............\n "); + printk(KERN_INFO "DC395x_Disconnected..............\n "); #endif ioport = pACB->IOPortBase; pDCB = pACB->pActiveDCB; @@ -3506,7 +3524,7 @@ WORD ioport,RselTarLunId; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_Reselect..............\n "); + printk(KERN_INFO "DC395x_Reselect..............\n "); #endif ioport = pACB->IOPortBase; @@ -3592,7 +3610,7 @@ ** ********************************************************************* */ -static inline void DC395x_trm_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) +static void DC395x_trm_SRBdone( PACB pACB, PDCB pDCB, PSRB pSRB ) { PSRB pSRBTemp; BYTE tempcnt,status; @@ -3601,7 +3619,7 @@ //DWORD drv_flags=0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_SRBdone..............\n "); + printk(KERN_INFO "DC395x_SRBdone..............\n "); #endif pcmd = pSRB->pcmd; status = pSRB->TargetStatus; @@ -3643,7 +3661,7 @@ /* ** target status.......................... */ - if( status == SCSI_STAT_CHECKCOND) + if (status == SCSI_STAT_CHECKCOND) { DC395x_trm_RequestSense( pACB, pDCB, pSRB ); return; @@ -3807,7 +3825,7 @@ ** ********************************************************************* */ -static inline void DC395x_trm_DoingSRB_Done( PACB pACB ) +static void DC395x_trm_DoingSRB_Done( PACB pACB ) { PDCB pDCB, pDCBTemp; PSRB pSRBTemp, pSRBTemp2; @@ -3815,7 +3833,7 @@ PSCSICMD pcmd; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_DoingSRB_Done..............\n "); + printk(KERN_INFO "DC395x_DoingSRB_Done..............\n "); #endif pDCB = pACB->pLinkDCB; pDCBTemp = pDCB; @@ -3859,7 +3877,7 @@ //DWORD drv_flags=0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_ResetSCSIBus..............\n "); + printk(KERN_INFO "DC395x_ResetSCSIBus..............\n "); #endif //DC395x_TRM_DRV_LOCK(drv_flags); @@ -3880,13 +3898,13 @@ ** ********************************************************************* */ -static inline void DC395x_trm_ScsiRstDetect( PACB pACB ) +static void DC395x_trm_ScsiRstDetect( PACB pACB ) { DWORD msec; WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_ScsiRstDetect..............\n "); + printk(KERN_INFO "DC395x_ScsiRstDetect..............\n "); #endif /* delay half a second */ { msec = 600; while (--msec) udelay(1000); } @@ -3922,12 +3940,12 @@ ** ********************************************************************* */ -static inline void DC395x_trm_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ) +static void DC395x_trm_RequestSense( PACB pACB, PDCB pDCB, PSRB pSRB ) { PSCSICMD pcmd; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_RequestSense..............\n "); + printk(KERN_INFO "DC395x_RequestSense..............\n "); #endif pSRB->SRBFlag |= AUTO_REQSENSE; pSRB->Segment0[0] = *((PDWORD) &(pSRB->CmdBlock[0])); @@ -3976,7 +3994,7 @@ WORD ioport; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_EnableMsgOutAbort2..............\n "); + printk(KERN_INFO "DC395x_EnableMsgOutAbort2..............\n "); #endif ioport = pACB->IOPortBase; pSRB->MsgCnt = 1; @@ -3993,7 +4011,7 @@ static inline void DC395x_trm_EnableMsgOutAbort1( PACB pACB, PSRB pSRB ) { #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_EnableMsgOutAbort1..............\n "); + printk(KERN_INFO "DC395x_EnableMsgOutAbort1..............\n "); #endif pSRB->MsgOutBuf[0] = MSG_ABORT; DC395x_trm_EnableMsgOutAbort2( pACB, pSRB ); @@ -4003,20 +4021,20 @@ ********************************************************************** ** DC395x_trm_queue_command ** -** Function : static void DC395x_trm_initDCB +** Function : void DC395x_trm_initDCB ** Purpose : initialize the internal structures for a given DCB ** Inputs : cmd - pointer to this scsi cmd request block structure ** ********************************************************************** */ -__initfunc(inline void DC395x_trm_initDCB( PACB pACB, PDCB pDCB, PSCSICMD cmd )) +void DC395x_trm_initDCB( PACB pACB, PDCB pDCB, PSCSICMD cmd ) { PNVRAMTYPE pEEpromBuf; - BYTE bval,PeriodIndex; + BYTE PeriodIndex; WORD index; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_trm_initDCB..............\n "); + printk(KERN_INFO "DC395x_initDCB..............\n "); #endif if( pACB->DeviceCnt == 0 ) { @@ -4058,7 +4076,7 @@ pDCB->SyncPeriod = 0; pDCB->SyncOffset = 0; PeriodIndex = pEEpromBuf->NvramTarget[cmd->target].NvmTarPeriod & 0x07; - pDCB->MaxNegoPeriod = dc395x_trm_clock_period[ PeriodIndex ] ; + pDCB->MinNegoPeriod = dc395x_trm_clock_period[ PeriodIndex ] ; if ((pDCB->DevMode & NTC_DO_WIDE_NEGO) && (pACB->Config & HCC_WIDE_CARD)) pDCB->SyncMode |= WIDE_NEGO_ENABLE; @@ -4066,13 +4084,22 @@ if( !(cmd->lun) || DC395x_TRM_CurrSyncOffset ) pDCB->SyncMode |= SYNC_NEGO_ENABLE; /* $$$$$$$ */ - if( pDCB->DevMode & NTC_DO_DISCONNECT ) - bval = 0xC0; - else - bval = 0x80; - bval |= cmd->lun; - pDCB->IdentifyMsg = bval; + pDCB->IdentifyMsg = IDENTIFY(pDCB->DevMode & NTC_DO_DISCONNECT, cmd->lun); /* $$$$$$$ */ + if (pDCB->TargetLUN != 0) + { + /* Copy settings */ + PDCB prevDCB = pACB->pLinkDCB; + while (prevDCB->TargetID != pDCB->TargetID) + prevDCB = prevDCB->pNextDCB; + printk ("DC395x: Copy settings from %02i-%02i to %02i-%02i\n", + prevDCB->TargetID, prevDCB->TargetLUN, + pDCB->TargetID, pDCB->TargetLUN); + pDCB->SyncMode = prevDCB->SyncMode; + pDCB->SyncPeriod = prevDCB->SyncPeriod; + pDCB->MinNegoPeriod = prevDCB->MinNegoPeriod; + pDCB->SyncOffset = prevDCB->SyncOffset; + }; } @@ -4216,8 +4243,8 @@ for(i=0; i < DC395x_trm_MAX_SCSI_ID; i++) pACB->DCBmap[i] = 0; #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_TRM: pACB = %8x, pDCBmap = %8x, pSRB_array = %8x\n",(UINT) pACB, (UINT) pACB->DCBmap, (UINT) pACB->SRB_array); - printk(KERN_INFO "DC395x_TRM: ACB size= %4x, DCB size= %4x, SRB size= %4x\n",sizeof(DC395X_TRM_ACB), sizeof(DC395X_TRM_DCB), sizeof(DC395X_TRM_SRB) ); + printk(KERN_INFO "DC395x: pACB = %8x, pDCBmap = %8x, pSRB_array = %8x\n",(UINT) pACB, (UINT) pACB->DCBmap, (UINT) pACB->SRB_array); + printk(KERN_INFO "DC395x: ACB size= %4x, DCB size= %4x, SRB size= %4x\n",sizeof(DC395X_TRM_ACB), sizeof(DC395X_TRM_DCB), sizeof(DC395X_TRM_SRB) ); #endif } @@ -4258,7 +4285,7 @@ } if (check_region (io_port, psh->n_io_port)) { - printk(KERN_ERR "DC395x_TRM: register IO ports error!\n"); + printk(KERN_ERR "DC395x: register IO ports error!\n"); return( -1 ); } else @@ -4647,9 +4674,12 @@ psh = scsi_register( psht, sizeof(DC395X_TRM_ACB) ); if( !psh ) { - printk(KERN_INFO "DC395x_trm_init : pSH scsi_register ERROR\n"); + printk(KERN_INFO "DC395x_init : pSH scsi_register ERROR\n"); return( -1 ); } + printk (KERN_INFO "DC395x: Used settings: AdaptID=%i\n", + dc395x_trm_eepromBuf[index].NvramScsiId); + pACB = (PACB) psh->hostdata; //DC395x_TRM_ACB_INITLOCK(pACB); //DC395x_TRM_ACB_LOCK(pACB,acb_flags); @@ -4668,14 +4698,14 @@ { DC395x_TRM_pACB_current->pNextACB = pACB; DC395x_TRM_pACB_current = pACB; - pACB->pNextACB = (PACB) -1; + pACB->pNextACB = (PACB) -1; } //DC395x_TRM_ACB_UNLOCK(pACB,acb_flags); return( 0 ); } else { - printk(KERN_INFO "DC395x_trm_initAdapter initial ERROR\n"); + printk(KERN_INFO "DC395x_initAdapter initial ERROR\n"); scsi_unregister( psh ); //DC395x_TRM_ACB_UNLOCK(pACB,acb_flags); return( -1 ); @@ -4693,7 +4723,7 @@ ** ********************************************************************** */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,93) +#ifndef NEW_PCI __initfunc(static void DC395x_trm_set_master(BYTE pci_bus,BYTE pci_device_fn)) { WORD cmd; @@ -4725,7 +4755,7 @@ ** ********************************************************************** */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93) +#ifdef NEW_PCI __initfunc(static void DC395x_trm_set_pci_cfg( struct pci_dev *pPCI_DEVICE )) { WORD cmd; @@ -4815,7 +4845,7 @@ */ __initfunc(int DC395x_trm_detect(Scsi_Host_Template *psht)) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93) +#ifdef NEW_PCI struct pci_dev *pPCI_DEVICE = NULL; #else BYTE pci_bus, pci_device_fn; @@ -4832,19 +4862,21 @@ DC395x_TRM_pACB_start = NULL; /* search DC395x SCSI adapter in each slot */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93) +#ifdef NEW_PCI if(pci_present()) { + printk (KERN_INFO "DC395x (TRM-S1040) SCSI driver %s\n", DC395x_VERSION); while( (pPCI_DEVICE = pci_find_device( PCI_VendorID_TEKRAM,PCI_DeviceID_TRMS1040, pPCI_DEVICE) ) ) #else if(pcibios_present()) { + printk (KERN_INFO "DC395x_TRM (TRM-S1040) driver %s\n", DC395x_VERSION); while( !pcibios_find_device( PCI_VendorID_TEKRAM, PCI_DeviceID_TRMS1040, pci_index++, &pci_bus, &pci_device_fn) ) #endif { - /* get adapter io_port ,irq */ + /* get adapter io_port ,irq */ //DC395x_TRM_DRV_LOCK(drv_flags); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,93) +#ifdef NEW_PCI io_port = pPCI_DEVICE->base_address[0] & PCI_BASE_ADDRESS_IO_MASK; irq = pPCI_DEVICE->irq; #else @@ -4858,7 +4890,7 @@ (WORD) io_port = (WORD) io_port & PCI_BASE_ADDRESS_IO_MASK; #endif #ifdef DC395x_trm_DEBUG0 - printk(KERN_INFO "DC395x_TRM: IO_PORT=%04x,IRQ=%x\n",(UINT) io_port, irq); + printk(KERN_INFO "DC395x: IO_PORT=%04x,IRQ=%x\n",(UINT) io_port, irq); #endif if( !DC395x_trm_init(psht, io_port, irq, DC395x_TRM_adapterCnt) ) { @@ -4883,7 +4915,7 @@ psht->proc_dir = &DC395x_trm_proc_scsi; #endif - printk(KERN_INFO "DC395x(TRM-S1040): %i adapters found\n", DC395x_TRM_adapterCnt); + printk(KERN_INFO "DC395x (TRM-S1040): %i adapters found\n", DC395x_TRM_adapterCnt); //DC395x_TRM_SMP_IO_UNLOCK(irq_flags); DC395x_UNLOCK_IO; @@ -4979,7 +5011,7 @@ SPRINTF("Nr of attached devices: %i\n", acbpnt->DeviceCnt); - SPRINTF("Un ID LUN Prty Sync Wide DsCn SndS TagQ MaxNegoPeriod SyncSpeed SyncOffs\n"); + SPRINTF("Un ID LUN Prty Sync Wide DsCn SndS TagQ NegoPeriod SyncSpeed SyncOffs\n"); dcbpnt = acbpnt->pLinkDCB; for (dev = 0; dev < acbpnt->DeviceCnt; dev++) @@ -4991,12 +5023,16 @@ YESNO(dcbpnt->DevMode & NTC_DO_DISCONNECT); YESNO(dcbpnt->DevMode & NTC_DO_SEND_START); YESNO(dcbpnt->SyncMode & EN_TAG_QUEUEING); - SPRINTF(" %03i ns ", (dcbpnt->MaxNegoPeriod) << 2); + if (dcbpnt->SyncMode & SYNC_NEGO_DONE) + SPRINTF(" %03i ns ", (dcbpnt->MinNegoPeriod) << 2); + else + SPRINTF(" (%03i ns)", (dcbpnt->MinNegoPeriod) << 2); + if (dcbpnt->SyncOffset & 0x0f) { - spd = 1000/(dcbpnt->MaxNegoPeriod <<2); - spd1 = 1000%(dcbpnt->MaxNegoPeriod <<2); - spd1 = (spd1 * 10)/(dcbpnt->MaxNegoPeriod <<2); + spd = 1000/(dcbpnt->MinNegoPeriod <<2); + spd1 = 1000%(dcbpnt->MinNegoPeriod <<2); + spd1 = (spd1 * 10)/(dcbpnt->MinNegoPeriod <<2); SPRINTF(" %2i.%1i M %02i\n", spd, spd1, (dcbpnt->SyncOffset & 0x0f)); } else @@ -5021,13 +5057,13 @@ /* ********************************************************************** -** Function : static int DC395x_trm_shutdown (struct Scsi_Host *host) +** Function : int DC395x_trm_shutdown (struct Scsi_Host *host) ** Purpose : does a clean (we hope) shutdown of the SCSI chip. ** Use prior to dumping core, unloading the driver, etc. ** Returns : 0 on success ********************************************************************** */ -static int DC395x_trm_shutdown (struct Scsi_Host *host) +int DC395x_trm_shutdown (struct Scsi_Host *host) { BYTE bval; WORD ioport; @@ -5070,7 +5106,7 @@ if (host->irq != IRQ_NONE) { for (irq_count = 0, pACB = DC395x_TRM_pACB_start; - pACB; pACB = pACB->pNextACB) + pACB != (PACB)-1; pACB = pACB->pNextACB) { if ( pACB->IRQLevel == host->irq ) ++irq_count; Index: dc395x_trm.h =================================================================== RCS file: /usr/local/cvsroot/dc395/dc395x_trm.h,v retrieving revision 1.4 retrieving revision 1.6 diff -u -r1.4 -r1.6 --- dc395x_trm.h 1999/07/12 14:54:58 1.4 +++ dc395x_trm.h 1999/07/14 20:58:06 1.6 @@ -18,7 +18,7 @@ #define DC395x_trm_H #define DC395x_BANNER "Tekram DC395U/UW/F DC315/U" -#define DC395x_VERSION "1.07, 1999/07/11" +#define DC395x_VERSION "1.08, 1999/07/15" /* Kernel version autodetection */ #include @@ -70,7 +70,7 @@ # endif //-------------- -#if LINUX_VERSION_CODE < KERNEL_VERSION (2,2,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION (2,1,70) # define NO_NEW_EH #else # define NO_NEW_EH use_new_eh_code: 0,