Subject: Re: port-alpha/36628: cdhdtape image panics with memory management
To: None <tsutsui@NetBSD.org, gnats-admin@netbsd.org,>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 07/23/2007 16:05:04
The following reply was made to PR port-alpha/36628; it has been noted by GNATS.

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: ChristophFranzen@gmx.net
Cc: gnats-bugs@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-alpha/36628: cdhdtape image panics with memory management
	 trap on Jensen
Date: Tue, 24 Jul 2007 01:01:22 +0900

 ChristophFranzen@gmx.net wrote:
 
 > > Hmm. According to src/sys/dev/eisa/ahb.c, the irq setting
 > > is stored in AHA-1742 INTDEF register so the ECU should
 > > set up the card properly but somehow it doesn't.
 > 
 > This is weird. My logs from the July 19th and previous versions of 
 > cdhdtape show the correct IRQ 11. The next version (the one with max. 
 > 8 instead of 16 slots), however, shows IRQ 12.
 
 "IRQ 11 level" is a value read from the EISA configuration space
 in sys/arch/alpha/eisa/eisa_machdep.c:eisa_parse_irq() called from
 eisa_init().
 
 "ahb0: interrupting at eisa irq 12" is a value read from
 the INTDEF register on AHA-1742 in sys/dev/eisa/ahb.c:ahb_find()
 called from ahbattach().
 
 Then I thought the ECU didn't set ahb's register, but
 maybe other OSes always prefer the ECU's value, I guess.
 (though I'm not sure if it could be a problem if there is no IRQ conflict)
 
 I've written a quick patch which makes ahb use the ECU irq value
 if it's different from card setting. Could you try this one?
 http://www.ceres.dti.ne.jp/~tsutsui/netbsd/cdhdtape-GENERIC-20070723.gz
 
 ---
 Index: sys/dev/eisa/ahb.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/eisa/ahb.c,v
 retrieving revision 1.47
 diff -u -r1.47 ahb.c
 --- sys/dev/eisa/ahb.c	16 Nov 2006 01:32:50 -0000	1.47
 +++ sys/dev/eisa/ahb.c	23 Jul 2007 15:37:03 -0000
 @@ -201,6 +201,8 @@
  	struct ahb_probe_data apd;
  	struct scsipi_adapter *adapt = &sc->sc_adapter;
  	struct scsipi_channel *chan = &sc->sc_channel;
 +	struct eisa_cfg_irq eci;
 +	uint8_t intdef;
  
  	if (!strcmp(ea->ea_idstring, "ADP0000"))
  		model = EISA_PRODUCT_ADP0000;
 @@ -254,6 +256,46 @@
  		return;
  	}
  
 +	/*
 +	 * On some alpha machines (Jensen), ECU doesn't set
 +	 * INTDEF register properly, so check the ECU irq value
 +	 * if it's available and override the card setting with it.
 +	 */
 +	if (eisa_conf_read_irq(ea->ea_ec, ea->ea_slot, 0, 0, &eci) == 0) {
 +		if (apd.sc_irq != eci.eci_irq) {
 +			printf("%s: INTDEF configured to use irq %d, "
 +			    "but ECU configured to use irq %d\n",
 +			     sc->sc_dev.dv_xname, apd.sc_irq, eci.eci_irq);
 +			apd.sc_irq = eci.eci_irq;
 +			intdef = bus_space_read_1(iot, ioh, INTDEF);
 +			intdef &= ~(INTMASK | INTHIGH);
 +			switch (apd.sc_irq) {
 +			case  9:
 +				intdef |= INT9;
 +				break;
 +			case 10:
 +				intdef |= INT10;
 +				break;
 +			case 11:
 +				intdef |= INT11;
 +				break;
 +			case 12:
 +				intdef |= INT12;
 +				break;
 +			case 14:
 +				intdef |= INT14;
 +				break;
 +			case 15:
 +				intdef |= INT15;
 +				break;
 +			}
 +			if (eci.eci_ist == IST_LEVEL)
 +				intdef |= INTHIGH;
 +
 +			bus_space_write_1(iot, ioh, INTDEF, (intdef | INTEN));
 +		}
 +	}
 +
  	if (eisa_intr_map(ec, apd.sc_irq, &ih)) {
  		printf("%s: couldn't map interrupt (%d)\n",
  		    sc->sc_dev.dv_xname, apd.sc_irq);
 Index: sys/dev/eisa/ahbreg.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/eisa/ahbreg.h,v
 retrieving revision 1.15
 diff -u -r1.15 ahbreg.h
 --- sys/dev/eisa/ahbreg.h	11 Dec 2005 12:21:20 -0000	1.15
 +++ sys/dev/eisa/ahbreg.h	23 Jul 2007 15:37:03 -0000
 @@ -77,6 +77,7 @@
  #define	INT12	0x03
  #define	INT14	0x05
  #define	INT15	0x06
 +#define	INTMASK	0x07
  #define INTHIGH 0x08		/* int high=ACTIVE (else edge) */
  #define	INTEN	0x10
  /**** bit definitions for SCSIDEF ****/
 
 ---
 Izumi Tsutsui