Subject: kern/4318: ncr53c9x driver handles sequence step 0 after select with ATN
To: None <>
From: None <mhitch@NetBSD.ORG>
List: netbsd-bugs
Date: 10/22/1997 11:39:17
>Number:         4318
>Category:       kern
>Synopsis:       Sequence step 0 after select with atn is not always a timeout
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 22 10:50:04 1997
>Originator:     Michael L. Hitch
	Montana State Univerisity
>Release:        1997-10-19
System: NetBSD 1.2G NetBSD 1.2G (ZEUS) #971019-0: Sun Oct 19 13:47:21 MDT 1997 amiga

	A sequence step of 0 after a select with ATN can be a selection
	timeout, or it can also indicate the target did not respond with
	a message out phase.  The latter will occur on very old SCSI
	devices which do not respond to the ATN signal and go directly to
	the command phase [guess what my CDROM does].

	The driver correctly detects a select timeout condition because the
	disconnect bit in the interrupt register is set.  If the disconnect
	bit is not set, the driver incorrectly processes it as a select
	timout and tries to error the operation.  The target is still
	connected and the operation won't terminate until the driver
	timeout processing occurs.

	The driver should reset ATN and continue normal sequencing as
	specified by the target device.
	Attach an old SCSI device to a machine using the ncr53c9x driver.
	Watch it "select timeout", and then get timeouts from the driver
	and finally give up.
	The following patch replaces the incorrect check for a select timeout
by deasserting ATN and continuing the operation.  This patch assumes that
the target is in an appropriate phase (i.e. command phase) and will continue

--- /usr/src/sys/dev/ic/ncr53c9x.c	Sat Oct  4 06:14:42 1997
+++ ./ncr53c9x.c	Wed Oct 22 11:23:59 1997
@@ -1680,11 +1680,17 @@
 				switch (sc->sc_espstep) {
 				case 0:
-					printf("%s: select timeout/no "
-					    "disconnect\n",
-					    sc->sc_dev.dv_xname);
-					ecb->xs->error = XS_SELTIMEOUT;
-					goto finish;
+					/*
+					 * The target did not respond with a
+					 * message out phase - probably an old
+					 * device that doesn't recognize ATN.
+					 * Clear ATN and just continue, the
+					 * target should be in the command
+					 * phase.
+					 * XXXX check for command phase?
+					 */
+					break;
 				case 1:
 					if ((ti->flags & T_NEGOTIATE) == 0) {
 						printf("%s: step 1 & !NEG\n",