Subject: Re: kern/2105: ncr5380sbc stumbles over reselect during selection
To: Matthias Pfaller <ra!leo@marco.de>
From: Gordon W. Ross <gwr@mc.com>
List: netbsd-bugs
Date: 02/21/1996 14:09:23
Matthias,

First, thanks VERY much for identifying that problem with reselection.
I too noticed that targets would somehow end up marked as "busy" when
they in fact were idle, but had not managed to track it down.

I've attached a slightly different, but equivalent fix that I'd
like to use instead of what you sent.  (I avoid marking the target
busy until its is really busy, rather than unmarking it later.)

Thanks again,
Gordon

[ My fix at the end. ]

> Date: Mon, 19 Feb 96 9:08:17 GMT
> From: ra!leo@marco.de
> 
> >Number:         2105
> >Category:       kern
> >Synopsis:       ncr5380sbc stumbles over reselect during selection

> >Arrival-Date:   Wed Feb 21 04:50:06 1996
> >Originator:     Matthias Pfaller
> >Organization:
> leo@dachau.marco.de			in real life: Matthias Pfaller
> marco GmbH, 85221 Dachau, Germany	tel: +49 8131 516142
> >Release:        960209
> >Environment:
> 	<machine, os, target, libraries (multiple lines)>
> System: NetBSD klondike 1.1A NetBSD 1.1A (KLONDIKE) #48: Sun Feb 18 13:12:42 MET 1996 leo@klondike:/usr/src/sys/arch/pc532/compile/KLONDIKE pc532

> >Description:
> 	When a reselection occours while a selection is in progress, the
> 	selection is aborted and the reconnecting request is handled.
> 	In this case sc_matrix[target][lun] should get reset to NULL, but
> 	it doesn't.
> >How-To-Repeat:
> 	Try something like:
> 	# dd if=/dev/rsd0a of=/dev/null bs=32k &
> 	# dd if=/dev/rsd0b of=/dev/null bs=32k &
> 	# dd if=/dev/rsd1a of=/dev/null bs=32k &
> 	After a short period of time you won't be able to access one of the
> 	two disks (if you had reselect enabled).
> >Fix:

*** ncr5380sbc.c.~1~	Sat Feb 10 23:44:09 1996
--- ncr5380sbc.c	Wed Feb 21 13:50:53 1996
***************
*** 838,847 ****
  			target = sc->sc_ring[i].sr_target;
  			lun = sc->sc_ring[i].sr_lun;
  			if (sc->sc_matrix[target][lun] == NULL) {
! 			    sc->sc_matrix[target][lun] =
! 					sr = &sc->sc_ring[i];
! 			    sc->sc_rr = i;
! 			    break;
  			}
  		}
  		i++;
--- 838,846 ----
  			target = sc->sc_ring[i].sr_target;
  			lun = sc->sc_ring[i].sr_lun;
  			if (sc->sc_matrix[target][lun] == NULL) {
! 				sc->sc_rr = i;
! 				sr = &sc->sc_ring[i];
! 				break;
  			}
  		}
  		i++;
***************
*** 883,889 ****
  		goto have_nexus;
  	}
  
! 	/* Normal selection result */
  	sc->sc_current = sr;	/* connected */
  	xs = sr->sr_xs;
  
--- 882,889 ----
  		goto have_nexus;
  	}
  
! 	/* Normal selection result.  Target/LUN is now busy. */
! 	sc->sc_matrix[target][lun] = sr;
  	sc->sc_current = sr;	/* connected */
  	xs = sr->sr_xs;