Subject: Re: NCR 53c810 promble with Quantum XP34301 FAST SCSI-2 drive
To: Andrew Gillham <gillham@andrews.edu>
From: Christoph Kukulies <kuku@gilberto.physik.rwth-aachen.de>
List: port-i386
Date: 08/07/1995 10:41:19
It looks like netbsd is using Stefan Essers (et al.) ncr driver.
I had this problem under FreeBSD with a Quantum 4GB (Grand Prix)
and the patches below fixed the problem.

I'm not sure whether the patch to pcibus.c is necessaey - I extracted it
from my saved mail anyway.


> 
> > sd0(ncr0:0:0): COMMAND FAILED (4 a8) @f86bd200
> > [2 assert failures from lines 5172 and 5173 in sys/dev/pci/ncr.c]
> > ncr0 targ 0?: ERROR(80:100:29) (8/13) @3870cc:e0000000
> > ncr0: restart (fatal error)
> > sd0(ncr0:0:0): COMMAND FAILED (9 ff) @f86bd200

> I know it is a quantum.. :-)  I also know it has worked fine!
> 
> > Has anyone seen something like this? Any workarounds?
> 
> Unfortunately, "Yes, and Not that I know of"
> 
> -Andrew
> -- 
> ============================ Real 32bit multi-tasking UN*X System
> Andrew Gillham             | TCP/IP,NFS,PPP,4.4BSD-lite,multi-user
> gillham@andrews.edu        | i386,sparc,alpha,mac68k,amiga,others
> LAN/WAN/NW/UN*X specialist |   ---> http://www.NetBSD.org <---
> 

--Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
FreeBSD blues.physik.rwth-aachen.de 2.2-CURRENT FreeBSD 2.2-CURRENT #0:
Tue Jul 18 14:49:19 MET DST 1995     kuku@blues.physik.rwth-aachen.de:
/usr/src/sys/compile/BLUESGUS  i386
Index: /sys/i386/isa/pcibus.c
===================================================================
RCS file: /usr/cvs/src/sys/i386/isa/pcibus.c,v
retrieving revision 1.8
diff -C2 -r1.8 pcibus.c
*** 1.8	1995/03/22 21:35:39
--- pcibus.c	1995/06/12 19:04:50
***************
*** 140,143 ****
--- 140,144 ----
  
  #define CONF1_ENABLE       0x80000000ul
+ #define CONF1_ENABLE_CHK   0xF0000000ul
  #define CONF1_ADDR_PORT    0x0cf8
  #define CONF1_DATA_PORT    0x0cfc
***************
*** 154,170 ****
  
  	/*---------------------------------------
- 	**      Configuration mode 2 ?
- 	**---------------------------------------
- 	*/
- 
- 	outb (CONF2_ENABLE_PORT,  0);
- 	outb (CONF2_FORWARD_PORT, 0);
- 	if (!inb (CONF2_ENABLE_PORT) && !inb (CONF2_FORWARD_PORT)) {
- 		pci_mechanism = 2;
- 		pci_maxdevice = 16;
- 		return;
- 	};
- 
- 	/*---------------------------------------
  	**      Configuration mode 1 ?
  	**---------------------------------------
--- 155,158 ----
***************
*** 172,176 ****
  
  	oldval = inl (CONF1_ADDR_PORT);
! 	outl (CONF1_ADDR_PORT, CONF1_ENABLE);
  	result = inl (CONF1_ADDR_PORT);
  	outl (CONF1_ADDR_PORT, oldval);
--- 160,165 ----
  
  	oldval = inl (CONF1_ADDR_PORT);
! 	outl (CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
! 	outb (CONF1_ADDR_PORT +3, 0);
  	result = inl (CONF1_ADDR_PORT);
  	outl (CONF1_ADDR_PORT, oldval);
***************
*** 179,182 ****
--- 168,184 ----
  		pci_mechanism = 1;
  		pci_maxdevice = 32;
+ 		return;
+ 	};
+ 
+ 	/*---------------------------------------
+ 	**      Configuration mode 2 ?
+ 	**---------------------------------------
+ 	*/
+ 
+ 	outb (CONF2_ENABLE_PORT,  0);
+ 	outb (CONF2_FORWARD_PORT, 0);
+ 	if (!inb (CONF2_ENABLE_PORT) && !inb (CONF2_FORWARD_PORT)) {
+ 		pci_mechanism = 2;
+ 		pci_maxdevice = 16;
  		return;
  	};
Index: /sys/pci/ncr.c
===================================================================
RCS file: /usr/cvs/src/sys/pci/ncr.c,v
retrieving revision 1.37
diff -C2 -r1.37 ncr.c
*** 1.37	1995/05/30 08:13:07
--- ncr.c	1995/06/06 17:04:31
***************
*** 357,360 ****
--- 357,362 ----
  #define	QUIRK_AUTOSAVE	(0x01)
  #define	QUIRK_NOMSG	(0x02)
+ #define QUIRK_NOSYNC	(0x10)
+ #define QUIRK_NOWIDE16	(0x20)
  #define	QUIRK_UPDATE	(0x80)
  
***************
*** 1042,1047 ****
  	**	COPY script command.
  	*/
! 	u_char	  msgout[8];
! 	u_char	  msgin [8];
  	u_long		lastmsg;
  
--- 1044,1049 ----
  	**	COPY script command.
  	*/
! 	u_char		msgout[8];
! 	u_char		msgin [8];
  	u_long		lastmsg;
  
***************
*** 1125,1129 ****
  	ncrcmd	cleanup0	[ 11];
  	ncrcmd	signal		[ 10];
! 	ncrcmd  save_dp	 [  5];
  	ncrcmd  restore_dp	[  5];
  	ncrcmd  disconnect	[ 12];
--- 1127,1131 ----
  	ncrcmd	cleanup0	[ 11];
  	ncrcmd	signal		[ 10];
! 	ncrcmd  save_dp		[  5];
  	ncrcmd  restore_dp	[  5];
  	ncrcmd  disconnect	[ 12];
***************
*** 3595,3599 ****
  
  		if (!tp->period) {
! 			if (tp->inqdata[7] & INQ7_SYNC) {
  				nego = NS_SYNC;
  			} else {
--- 3597,3603 ----
  
  		if (!tp->period) {
! 			if (SCSI_NCR_MAX_SYNC 
! 			    && ((tp->inqdata[0] & 0x1f) != 5)
! 			    && (tp->inqdata[7] & INQ7_SYNC)) {
  				nego = NS_SYNC;
  			} else {
***************
*** 3786,3790 ****
  	/*----------------------------------------------------
  	**
! 	**	fill ccb
  	**
  	**----------------------------------------------------
--- 3790,3794 ----
  	/*----------------------------------------------------
  	**
! 	**	fill in ccb
  	**
  	**----------------------------------------------------
***************
*** 3850,3854 ****
  	/*----------------------------------------------------
  	**
! 	**	Critical region: starting this job.
  	**
  	**----------------------------------------------------
--- 3854,3858 ----
  	/*----------------------------------------------------
  	**
! 	**	Critical region: start this job.
  	**
  	**----------------------------------------------------
***************
*** 3861,3868 ****
  	cp->jump_ccb.l_cmd	= (SCR_JUMP ^ IFFALSE (DATA (cp->tag)));
  	cp->tlimit		= time.tv_sec + xp->timeout / 1000 + 2;
! 	cp->magic	       = CCB_MAGIC;
  
  	/*
! 	**	insert into startqueue.
  	*/
  
--- 3865,3872 ----
  	cp->jump_ccb.l_cmd	= (SCR_JUMP ^ IFFALSE (DATA (cp->tag)));
  	cp->tlimit		= time.tv_sec + xp->timeout / 1000 + 2;
! 	cp->magic		= CCB_MAGIC;
  
  	/*
! 	**	insert into start queue.
  	*/
  
***************
*** 3880,3884 ****
  
  	/*
! 	**	Script processor may be waiting for reconnect.
  	**	Wake it up.
  	*/
--- 3884,3888 ----
  
  	/*
! 	**	Script processor may be waiting for reselect.
  	**	Wake it up.
  	*/
***************
*** 3996,4003 ****
  			cp->host_status,cp->scsi_status);
  
! 	xp  = cp->xfer;
  	cp->xfer = NULL;
  	tp = &np->target[xp->sc_link->target];
! 	lp  = tp->lp[xp->sc_link->lun];
  
  	/*
--- 4000,4007 ----
  			cp->host_status,cp->scsi_status);
  
! 	xp = cp->xfer;
  	cp->xfer = NULL;
  	tp = &np->target[xp->sc_link->target];
! 	lp = tp->lp[xp->sc_link->lun];
  
  	/*
***************
*** 5233,5244 ****
  		cp = cp->link_ccb;
  
- 	assert (cp == np->header.cp);
  	assert (cp);
  	if (!cp)
  		return;
  
  	/*
  	**	find the interrupted script command,
! 	**	and the address at where to continue.
  	*/
  
--- 5237,5252 ----
  		cp = cp->link_ccb;
  
  	assert (cp);
  	if (!cp)
+ /* @@@ --> Is it OK to simply return here ??? */
+ 		return;
+ 	assert (cp == np->header.cp);
+ 	if (cp != np->header.cp)
  		return;
+ /* @@@ --> Is it OK to continue if above assertion failed ??? */
  
  	/*
  	**	find the interrupted script command,
! 	**	and the address at which to continue.
  	*/
  
***************
*** 5477,5485 ****
  **
  **	We try to negotiate sync and wide transfer only after
! **	a successfull inquire command. We look to byte 7 of the
  **	inquire data to determine the capabilities if the target.
  **
  **	When we try to negotiate, we append the negotiation message
! **	to the identify and (maybe) simpletag message.
  **	The host status field is set to HS_NEGOTIATE to mark this
  **	situation.
--- 5485,5493 ----
  **
  **	We try to negotiate sync and wide transfer only after
! **	a successfull inquire command. We look at byte 7 of the
  **	inquire data to determine the capabilities if the target.
  **
  **	When we try to negotiate, we append the negotiation message
! **	to the identify and (maybe) simple tag message.
  **	The host status field is set to HS_NEGOTIATE to mark this
  **	situation.
***************
*** 5495,5512 ****
  **
  **	If we receive a Reject message immediately, we assume the
! **	negotiation has failed, and set to the standard values.
  **
  **	If we receive a negotiation message while not in HS_NEGOTIATE
  **	state, it's a target initiated negotiation. We prepare a
! **	(hopefully) valid answer, set the values, and send this
! **	answer back to the target.
  **
  **	If the target doesn't fetch the answer (no message out phase),
! **	we assume the negotiation has failed, and set the values to
! **	the default.
  **
! **	When we set the values, we set in all ccbs belonging to this
! **	target, in the controllers register, and in the "phys"
! **	field of the controllers struct ncb.
  **
  **	Possible cases:	    hs  sir   msg_in value  send   goto
--- 5503,5520 ----
  **
  **	If we receive a Reject message immediately, we assume the
! **	negotiation has failed, and fall back to standard values.
  **
  **	If we receive a negotiation message while not in HS_NEGOTIATE
  **	state, it's a target initiated negotiation. We prepare a
! **	(hopefully) valid answer, set our parameters, and send back 
! **	this answer to the target.
  **
  **	If the target doesn't fetch the answer (no message out phase),
! **	we assume the negotiation has failed, and fall back to default
! **	settings.
  **
! **	When we set the values, we adjust them in all ccbs belonging 
! **	to this target, in the controller's register, and in the "phys"
! **	field of the controller's struct ncb.
  **
  **	Possible cases:	    hs  sir   msg_in value  send   goto
***************
*** 5675,5680 ****
  		np->msgout[4] = ofs;
  
- 		np->msgin [0] = M_NOOP;
- 
  		cp->nego_status = NS_SYNC;
  
--- 5683,5686 ----
***************
*** 5685,5688 ****
--- 5691,5701 ----
  			printf (".\n");
  		}
+ 
+ 		if (!ofs) {
+ 			OUTL (nc_dsp,vtophys (&np->script->msg_bad));
+ 			return;
+ 		}
+ 		np->msgin [0] = M_NOOP;
+ 
  		break;
  
***************
*** 6522,6525 ****
--- 6535,6539 ----
  static struct table_entry device_tab[] =
  {
+ 	{"", "", "", QUIRK_NOMSG},
  	{"SONY", "SDT-5000", "3.17", QUIRK_NOMSG},
  	{"WangDAT", "Model 2600", "01.7", QUIRK_NOMSG},


 -Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
FreeBSD blues.physik.rwth-aachen.de 2.0-BUILT-19950606 FreeBSD 2.0-BUILT-1995
0606 #0: Tue Jun  6 19:13:32 MET DST 1995    kuku@blues.physik.rwth-aachen.de
:/usr/src/sys/compile/BLUESGUS  i386