Subject: Re: ahc lossage on SOYO motherboard
To: Matt <spore@psibercom.org>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: port-i386
Date: 02/26/1999 11:12:07
> ahc1: aic7880 Wide Channel, SCSI Id=7, 1 SCBs

Only 1 SCB? that seems odd; i'm not really familiar with the hardware,
but aic7xxxvar.h mentions the SCB counts of a number of different
aic7* chips and none of the listed ones have SCB counts that low.

> scsibus0 at ahc1 channel 0: 16 targets, 8 luns per target
> kernel: page fault trap, code=0
> stopped in  at  _ahc_handle_seqint+0x1e70:	movl	0x24(%edi),%eax

I'm not familiar with the ahc driver, but I happened to have a kernel
compiled -g lying around, and the instruction at
_ahc_handle_seqint+0x1e70 was the same in my copy, so...

The fault appears to be occuring in the evaluation of scb->flags at
the "DIES HERE" comment in the code quoted below
(/usr/src/sys/dev/ic/aic7xxx.c, around line 1868).  

You can get a bit more information out of ddb at this point..  for
instance, try "print %edi" to print the value of the %edi register,
which I believe contains `scb'.

I'm willing to believe the device is giving us a bogus scb_index
value, which is causing us to fetch scb from part of ahc->scbarray[]
which hasn't been initialized.

	case AWAITING_MSG:
	{
		int   scb_index;
		scb_index = AHC_INB(ahc, SCB_TAG);
		scb = ahc->scbarray[scb_index];
		/*
		 * This SCB had a zero length command, informing
		 * the sequencer that we wanted to send a special
		 * message to this target.  We only do this for
		 * BUS_DEVICE_RESET messages currently.
		 */
		if (scb->flags & SCB_DEVICE_RESET) {	/* DIES HERE */
			AHC_OUTB(ahc, MSG0,
				 MSG_BUS_DEV_RESET);
			AHC_OUTB(ahc, MSG_LEN, 1);
			printf("Bus Device Reset Message Sent\n");
		} else if (scb->flags & SCB_MSGOUT_WDTR) {
		  ....
		}
	}


Random speculation, done in absence of facts...
 - Maybe it lied when it said it only has one SCB .. 

 - Maybe it really only has one SCB and, as a result, the scb_index it
gives you is garbage because, umm, "there can be only one..." ..