[PATCH] tmscsim: INQUIRY always only untagged

Guennadi Liakhovetski
2004-09-03T22:48:42Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 302 bytes --]

Hello

The attached patch makes sure, all INQUIRY commands are only sent
untagged. This way drives, affected by bug 2139, also survive further
INQUIRYs, sent after the initial scan, e.g., by scsiinfo.

Hopefully, will be superseeded, when switching to tcq.

Thanks
Guennadi
---
Guennadi Liakhovetski

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2969 bytes --]

INQUIRY always send only untagged.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

diff -ur --exclude=CVS a/drivers/scsi/scsiiom.c b/drivers/scsi/scsiiom.c
--- a/drivers/scsi/scsiiom.c Tue Aug 17 23:16:53 2004
+++ b/drivers/scsi/scsiiom.c Sat Aug 21 23:42:11 2004
@@ -8,9 +8,9 @@
static void __inline__
dc390_freetag (struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
{
- if (pSRB->TagNumber < 255) {
+ if (pSRB->TagNumber != (u8)SCSI_NO_TAG) {
pDCB->TagMask &= ~(1 << pSRB->TagNumber); /* free tag mask */
- pSRB->TagNumber = 255;
+ pSRB->TagNumber = (u8)SCSI_NO_TAG;
}
}

@@ -67,7 +67,7 @@
pSRB->MsgCnt = 0; cmd = SEL_W_ATN;
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)
+ if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed && pSRB->pcmd->cmnd[0] != INQUIRY)
{
u8 tag_no = 0;
while ((1 << tag_no) & pDCB->TagMask) tag_no++;
@@ -903,18 +903,11 @@
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");
-
- /* Try to recover - some broken disks react badly to tagged INQUIRY */
- if (pDCB && pACB->scan_devices && pDCB->GoingSRBCnt == 1) {
- pSRB = pDCB->pGoingSRB;
- pDCB->pActiveSRB = pSRB;
- } else {
- pSRB->pSRBDCB = pDCB;
- dc390_EnableMsgOut_Abort(pACB, pSRB);
- if (pDCB)
- pDCB->DCBFlag |= ABORT_DEV;
- return;
- }
+ pSRB->pSRBDCB = pDCB;
+ dc390_EnableMsgOut_Abort(pACB, pSRB);
+ if (pDCB)
+ pDCB->DCBFlag |= ABORT_DEV;
+ return;
}

if( pSRB->SGIndex < pSRB->SGcount )
@@ -1257,7 +1250,7 @@
}
pACB->pActiveDCB = pDCB;
/* TagQ: We expect a message soon, so never mind the exact SRB */
- if( pDCB->SyncMode & EN_TAG_QUEUEING )
+ if ((pDCB->SyncMode & EN_TAG_QUEUEING) && (!pDCB->pActiveSRB || pDCB->pActiveSRB->TagNumber != (u8)SCSI_NO_TAG))
{
pSRB = pACB->pTmpSRB;
pDCB->pActiveSRB = pSRB;
diff -ur --exclude=CVS a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
--- a/drivers/scsi/tmscsim.c Sat Aug 21 23:07:42 2004
+++ b/drivers/scsi/tmscsim.c Sat Aug 21 23:37:42 2004
@@ -245,6 +245,7 @@
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsicam.h>
+#include <scsi/scsi_tcq.h>

#define DC390_BANNER "Tekram DC390/AM53C974"
@@ -861,6 +862,10 @@
goto host_busy;
if (acb->ACBFlag & (RESET_DETECT|RESET_DONE|RESET_DEV))
goto host_busy;
+ /* INQUIRY only untagged, do not accept more commands if the going one is untagged, e.g., INQUIRY */
+ if (unlikely((cmd->cmnd[0] == INQUIRY && dcb->pGoingSRB) ||
+ (dcb->pGoingSRB && dcb->pGoingSRB->TagNumber == (u8)SCSI_NO_TAG)))
+ goto device_busy;

srb = acb->pFreeSRB;
if (unlikely(srb == NULL))