Re: [PATCH] tmscsim: INQUIRY always only untagged

Guennadi Liakhovetski
2004-10-02T18:04:02Z

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

On Fri, 1 Oct 2004, Christoph Hellwig wrote:

>> + if (pcmd->cmnd[0] == INQUIRY &&
>> + (pcmd->result == (DID_OK << 16) || status_byte(pcmd->result) & CHECK_CONDITION) &&
>> + (ptr->DevType & SCSI_DEVTYPE) != TYPE_NODEV)
>> + /* device found: add */
>> + pDCB->DevType = ptr->DevType & SCSI_DEVTYPE;
>
> instead of ptr->DevType you can use the 'device' field in struct scsi_device.
> In fact the dcb DevType field should go away aswell in favour of that one.

Ok, as I just realised, this can be "naturally" addressed by the next
patch, removing internal queues. So, for now I am just re-sending
yesterday's patch as attachments, if there are no further comments.

Thanks
Guennadi
---
Guennadi Liakhovetski

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

Use mid-layer's decision wrt tag-support.

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

diff -u a/drivers/scsi/scsiiom.c b/drivers/scsi/scsiiom.c
--- a/drivers/scsi/scsiiom.c 17 Aug 2004 21:16:53
+++ b/drivers/scsi/scsiiom.c 6 Sep 2004 09:32:53
@@ -8,9 +8,9 @@
static void __inline__
dc390_freetag (struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
{
- if (pSRB->TagNumber < 255) {
+ if (pSRB->TagNumber != SCSI_NO_TAG) {
pDCB->TagMask &= ~(1 << pSRB->TagNumber); /* free tag mask */
- pSRB->TagNumber = 255;
+ pSRB->TagNumber = SCSI_NO_TAG;
}
}

@@ -69,7 +69,7 @@
/* Change 99/05/31: Don't use tags when not disconnecting (BUSY) */
if ((pDCB->SyncMode & EN_TAG_QUEUEING) && disc_allowed)
{
- u8 tag_no = 0;
+ s8 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->TargetID, pDCB->TargetLUN);
@@ -604,7 +604,7 @@
}

static struct dc390_srb*
-dc390_MsgIn_QTag (struct dc390_acb* pACB, struct dc390_dcb* pDCB, u8 tag)
+dc390_MsgIn_QTag (struct dc390_acb* pACB, struct dc390_dcb* pDCB, s8 tag)
{
struct dc390_srb* lastSRB = pDCB->pGoingLast;
struct dc390_srb* pSRB = pDCB->pGoingSRB;
@@ -1291,49 +1291,6 @@
DC390_write8 (ScsiCmd, MSG_ACCEPTED_CMD); /* ;to release the /ACK signal */
}

-static u8 __inline__
-dc390_tagq_blacklist (char* name)
-{
- u8 i;
- for(i=0; i<BADDEVCNT; i++)
- if (memcmp (name, dc390_baddevname1[i], 28) == 0)
- return 1;
- return 0;
-}
-
-
-static void
-dc390_disc_tagq_set (struct dc390_dcb* pDCB, PSCSI_INQDATA ptr)
-{
- /* Check for SCSI format (ANSI and Response data format) */
- if ( (ptr->Vers & 0x07) >= 2 || (ptr->RDF & 0x0F) == 2 )
- {
- if ( (ptr->Flags & SCSI_INQ_CMDQUEUE) &&
- (pDCB->DevMode & TAG_QUEUEING_) &&
- /* ((pDCB->DevType == TYPE_DISK)
- || (pDCB->DevType == TYPE_MOD)) &&*/
- !dc390_tagq_blacklist (((char*)ptr)+8) )
- {
- if (pDCB->MaxCommand ==1) pDCB->MaxCommand = pDCB->pDCBACB->TagMaxNum;
- pDCB->SyncMode |= EN_TAG_QUEUEING /* | EN_ATN_STOP */;
- //pDCB->TagMask = 0;
- }
- else
- pDCB->MaxCommand = 1;
- }
-}
-
-
-static void
-dc390_add_dev (struct dc390_acb* pACB, struct dc390_dcb* pDCB, PSCSI_INQDATA ptr)
-{
- u8 bval1 = ptr->DevType & SCSI_DEVTYPE;
- pDCB->DevType = bval1;
- /* if (bval1 == TYPE_DISK || bval1 == TYPE_MOD) */
- dc390_disc_tagq_set (pDCB, ptr);
-}
-
-
static void __inline__
dc390_RequestSense(struct dc390_acb* pACB, struct dc390_dcb* pDCB, struct dc390_srb* pSRB)
{
@@ -1544,15 +1501,11 @@
pDCB->Inquiry7 = ptr->Flags;

ckc_e:
- if( pcmd->cmnd[0] == INQUIRY &&
- (pcmd->result == (DID_OK << 16) || status_byte(pcmd->result) & CHECK_CONDITION) )
- {
- if ((ptr->DevType & SCSI_DEVTYPE) != TYPE_NODEV)
- {
- /* device found: add */
- dc390_add_dev (pACB, pDCB, ptr);
- }
- }
+ if (pcmd->cmnd[0] == INQUIRY &&
+ (pcmd->result == (DID_OK << 16) || status_byte(pcmd->result) & CHECK_CONDITION) &&
+ (ptr->DevType & SCSI_DEVTYPE) != TYPE_NODEV)
+ /* device found: add */
+ pDCB->DevType = ptr->DevType & SCSI_DEVTYPE;

pcmd->resid = pcmd->request_bufflen - pSRB->TotalXferredLen;

diff -u a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
--- a/drivers/scsi/tmscsim.h 17 Aug 2004 21:16:53
+++ b/drivers/scsi/tmscsim.h 6 Sep 2004 09:33:08
@@ -62,7 +62,7 @@
u8 TargetStatus;

u8 ScsiPhase;
-u8 TagNumber;
+s8 TagNumber;
u8 SGIndex;
u8 SGcount;

diff -u a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
--- a/drivers/scsi/tmscsim.c 3 Sep 2004 22:10:14
+++ b/drivers/scsi/tmscsim.c 6 Sep 2004 09:33:59
@@ -242,6 +242,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"
@@ -277,8 +278,6 @@
static void dc390_EnableMsgOut_Abort(struct dc390_acb*, struct dc390_srb*);
static irqreturn_t do_DC390_Interrupt( int, void *, struct pt_regs *);

-static void dc390_updateDCB (struct dc390_acb* pACB, struct dc390_dcb* pDCB);
-
static u32 dc390_laststatus = 0;
static u8 dc390_adapterCnt = 0;

@@ -343,12 +342,6 @@
};
#endif

-/* Devices erroneously pretending to be able to do TagQ */
-static u8 dc390_baddevname1[2][28] ={
- "SEAGATE ST3390N 9546",
- "HP C3323-300 4269"};
-#define BADDEVCNT 2
-
static u8 dc390_eepromBuf[MAX_ADAPTER_NUM][EE_LEN];
static u8 dc390_clock_period1[] = {4, 5, 6, 7, 8, 10, 13, 20};
static u8 dc390_clock_speed[] = {100,80,67,57,50, 40, 31, 20};
@@ -648,7 +641,7 @@
srb->SGToBeXferLen = 0;
srb->ScsiPhase = 0;
srb->EndMessage = 0;
- srb->TagNumber = 255;
+ srb->TagNumber = SCSI_NO_TAG;

if (dc390_StartSCSI(acb, dcb, srb)) {
dc390_Waiting_insert(dcb, srb);
@@ -825,35 +818,6 @@

#include "scsiiom.c"

-/***********************************************************************
- * Function : static void dc390_updateDCB()
- *
- * Purpose : Set the configuration dependent DCB parameters
- ***********************************************************************/
-
-static void dc390_updateDCB (struct dc390_acb* pACB, struct dc390_dcb* pDCB)
-{
- pDCB->SyncMode &= EN_TAG_QUEUEING | SYNC_NEGO_DONE /*| EN_ATN_STOP*/;
- if (pDCB->DevMode & TAG_QUEUEING_) {
- //if (pDCB->SyncMode & EN_TAG_QUEUEING) pDCB->MaxCommand = pACB->TagMaxNum;
- } else {
- pDCB->SyncMode &= ~EN_TAG_QUEUEING;
- pDCB->MaxCommand = 1;
- }
-
- if( pDCB->DevMode & SYNC_NEGO_ )
- pDCB->SyncMode |= SYNC_ENABLE;
- else {
- pDCB->SyncMode &= ~(SYNC_NEGO_DONE | SYNC_ENABLE);
- pDCB->SyncOffset &= ~0x0f;
- }
-
- //if (! (pDCB->DevMode & EN_DISCONNECT_)) pDCB->SyncMode &= ~EN_ATN_STOP;
-
- pDCB->CtrlR1 = pACB->pScsiHost->this_id;
- if( pDCB->DevMode & PARITY_CHK_ )
- pDCB->CtrlR1 |= PARITY_ERR_REPO;
-}

/**
* dc390_slave_alloc - Called by the scsi mid layer to tell us about a new
@@ -894,7 +858,7 @@
*/
if (lun && (pDCB2 = dc390_findDCB(pACB, id, 0))) {
pDCB->DevMode = pDCB2->DevMode;
- pDCB->SyncMode = pDCB2->SyncMode;
+ pDCB->SyncMode = pDCB2->SyncMode & SYNC_NEGO_DONE;
pDCB->SyncPeriod = pDCB2->SyncPeriod;
pDCB->SyncOffset = pDCB2->SyncOffset;
pDCB->NegoPeriod = pDCB2->NegoPeriod;
@@ -915,7 +879,16 @@
pDCB->CtrlR4 |= NEGATE_REQACKDATA | NEGATE_REQACK;
}

- dc390_updateDCB(pACB, pDCB);
+ if (pDCB->DevMode & SYNC_NEGO_)
+ pDCB->SyncMode |= SYNC_ENABLE;
+ else {
+ pDCB->SyncMode = 0;
+ pDCB->SyncOffset &= ~0x0f;
+ }
+
+ pDCB->CtrlR1 = pACB->pScsiHost->this_id;
+ if (pDCB->DevMode & PARITY_CHK_)
+ pDCB->CtrlR1 |= PARITY_ERR_REPO;

pACB->scan_devices = 1;
scsi_device->hostdata = pDCB;
@@ -963,10 +936,16 @@
pACB->DCBCnt--;
}

-static int dc390_slave_configure(struct scsi_device *scsi_device)
+static int dc390_slave_configure(struct scsi_device *sdev)
{
- struct dc390_acb* pACB = (struct dc390_acb*) scsi_device->host->hostdata;
- pACB->scan_devices = 0;
+ struct dc390_acb *acb = (struct dc390_acb *)sdev->host->hostdata;
+ struct dc390_dcb *dcb = (struct dc390_dcb *)sdev->hostdata;
+
+ acb->scan_devices = 0;
+ if (sdev->tagged_supported && (dcb->DevMode & TAG_QUEUEING_)) {
+ dcb->SyncMode |= EN_TAG_QUEUEING;
+ dcb->MaxCommand = dcb->pDCBACB->TagMaxNum;
+ }
return 0;
}