Subject: Re: The esp bug
To: None <mjacob@feral.com>
From: Paul Kranenburg <pk@cs.few.eur.nl>
List: tech-kern
Date: 04/25/1997 23:50:03
> If a reselect has happened, your selection attempt was glotzed, and you can
> switch over to preemption code that handles a reselection. The ESP chip
> guarantees that it will latch up the FIFO count register for the things you
> wrote into it (for the selection attempt), and that when you read the FIFO
> count register that will unmask the *real* stuff in the FIFO which is the
> reselecting target's ID and an IDENTIFY message (which you should check
> by reading the fifo count register a second time as you attempt to
> handle the reselection and make sure it really is a value of 2).


There's currently one variant of the esp chip (ESP100) which exhibits
erratic behaviour (or exposes a driver bug, if you like); all other
chip revisions do the promised things if a target re-selects succesfully:

the FIFO is cleared and further access to it by the processor is blocked
as soon as a re-selection is started and this state persists until the
interrupt status register is read. The driver notices the re-selection
status bit and finds the expected two ID/IDENTIFY bytes in the FIFO.

The ESP100 on the other hand is said to only block FIFO access until the
reselection is complete, allowing a window in which the processor might
be finishing off an attempted selection of another target, piling up
command bytes into the FIFO. I attempted to work-around this by checking
the FIFO count and, when it's different from 2, discard anything but
the first two bytes in it on the assumption that those are the ID/IDENTIFY
pair we're looking for.

Apperently, this is not enough, since those first two bytes do not always
form a valid ID/IDENTIFY pair..  On top of that, the chip will report
an "Illegal Command" soon after that. I suspect this comes from the
"Select with ATN" we issued while we were still attempting to select,
while the chip thinks it had already dropped out of initiator mode (but
I'm not sure about this..)

If this is so, the spurious "Illegal Interrupt" status is something to
be dealt with even if DMAing the command out.

-pk