Subject: Re: kern/3067: NCR driver dies when "xmcd" accesses the CD-ROM drive
To: None <current-users@NetBSD.ORG>
From: Dave Huang <khym@bga.com>
List: current-users
Date: 01/01/1997 19:52:09
Well, it looks like the problem with the new ncr driver and "options
GENERIC" or "options CDROM_ASYNC" is that whenever the driver gets an
inquiry command, it saves a copy of the results somewhere and sets
some flags to renegotiate sync/wide transfers at the next command for
that target...

		/*
		**	On inquire cmd (0x12) save some data.
		*/
		if (xp->cmd->opcode == 0x12) {
			bcopy (	xp->data,
				&tp->inqdata,
				sizeof (tp->inqdata));

When it's time to do the negotiation, if CDROM_ASYNC or GENERIC are
defined, it checks the saved inquiry data and looks at the device type
field:

			if (SCSI_NCR_MAX_SYNC 
#if defined (CDROM_ASYNC) || defined (GENERIC)
			    && ((tp->inqdata[0] & 0x1f) != 5)
#endif
			    && (tp->inqdata[7] & INQ7_SYNC)) {
				nego = NS_SYNC;


Now the problem is that if the last inquiry command for a target was
for a nonexistant LUN (which is probably going to happen a lot when
probing the scsi bus), the device type field is set to 0x1f, which
messes up the above check.

I'm still not sure what the correct fix for the problem is, but I
figure if there's nothing at that LUN and the inquiry data is mostly
useless anyways, it shouldn't be saved. So here's a patch that does
that... it fixes the xmcd problem for me, at least :)

--- /usr/src/sys/dev/pci/ncr.c	Wed Dec 11 06:20:20 1996
+++ ncr.c	Wed Jan  1 18:05:33 1997
@@ -4395,7 +4395,9 @@
 		/*
 		**	On inquire cmd (0x12) save some data.
 		*/
-		if (xp->cmd->opcode == 0x12) {
+		if (xp->cmd->opcode == 0x12 &&
+		    ((xp->data[0] & SID_QUAL) == SID_QUAL_LU_OK ||
+		    (xp->data[0] & SID_QUAL) == SID_QUAL_LU_OFFLINE)) {
 			bcopy (	xp->data,
 				&tp->inqdata,
 				sizeof (tp->inqdata));

Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 21 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++