Subject: Re: on-board ahc(4) initialization on O2
To: None <port-sgimips@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sgimips
Date: 10/21/2005 00:59:34
In article <051018230829.M0115986@mirage.ceres.dti.ne.jp> on port-sgimips
I wrote:

> In article <051018225659.M0128372@mirage.ceres.dti.ne.jp>
> I wrote:
> 
> > > -ahc1: aic7880: Wide Channel A, SCSI Id=0, 16/253 SCBs
> > > +ahc1: Host Adapter Bios disabled.  Using default SCSI device parameters
> > > +ahc1: aic7880: Wide Channel A, SCSI Id=7, 16/253 SCBs
> > 
> > Umm, ARCS set host adapter's ID to zero? IRIX uses the same value?
> > Then we should think some MD hooks or options to override it?
> 
> ...or it's better to have options to ignore only xfer configurations
> (sync, wide and tagqueue etc.) if the adapter doesn't have SEEPROM?
> (i.e. preserve SCSI ID set by BIOS in that case)

How about the attached patch to fix kern/23276?
The problem is ARCS BIOS on O2 uses conservative xfer settings (async)
on boot. This patch provides an option to ignore them but preserve
host adapter settings (host ID, termination) by BIOS.
---
Izumi Tsutsui

Index: sys/dev/ic/aic7xxx.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/aic7xxx.c,v
retrieving revision 1.116
diff -u -r1.116 aic7xxx.c
--- sys/dev/ic/aic7xxx.c	10 Sep 2005 19:15:44 -0000	1.116
+++ sys/dev/ic/aic7xxx.c	20 Oct 2005 15:46:24 -0000
@@ -4634,12 +4634,19 @@
 	/* Grab the disconnection disable table and invert it for our needs */
 	if ((ahc->flags & AHC_USEDEFAULTS) != 0) {
 		printf("%s: Host Adapter Bios disabled.  Using default SCSI "
-			"device parameters\n", ahc_name(ahc));
+			"host/target device parameters\n", ahc_name(ahc));
 		ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B|
 			      AHC_TERM_ENB_A|AHC_TERM_ENB_B;
 		discenable = ALL_TARGETS_MASK;
 		if ((ahc->features & AHC_ULTRA) != 0)
 			ultraenb = ALL_TARGETS_MASK;
+	} else if ((ahc->flags & AHC_DEFAULTTARGETCONF) != 0) {
+		printf("%s: Host Adapter has no SEEPROM. Using default SCSI"
+		    " target device parameters\n", ahc_name(ahc));
+		ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B;
+		discenable = ALL_TARGETS_MASK;
+		if ((ahc->features & AHC_ULTRA) != 0)
+			ultraenb = ALL_TARGETS_MASK;
 	} else {
 		discenable = ~((ahc_inb(ahc, DISC_DSB + 1) << 8)
 			   | ahc_inb(ahc, DISC_DSB));
@@ -4670,7 +4677,7 @@
 					    target_id, &tstate);
 		/* Default to async narrow across the board */
 		memset(tinfo, 0, sizeof(*tinfo));
-		if (ahc->flags & AHC_USEDEFAULTS) {
+		if (ahc->flags & (AHC_USEDEFAULTS | AHC_DEFAULTTARGETCONF)) {
 			if ((ahc->features & AHC_WIDE) != 0)
 				tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
 
Index: sys/dev/ic/aic7xxxvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/aic7xxxvar.h,v
retrieving revision 1.49
diff -u -r1.49 aic7xxxvar.h
--- sys/dev/ic/aic7xxxvar.h	28 Jun 2005 00:32:28 -0000	1.49
+++ sys/dev/ic/aic7xxxvar.h	20 Oct 2005 15:46:24 -0000
@@ -415,8 +415,7 @@
 	AHC_USEDEFAULTS	      = 0x004,  /*
 					 * For cards without an seeprom
 					 * or a BIOS to initialize the chip's
-					 * SRAM, we use the default target
-					 * settings.
+					 * SRAM, we use the default settings.
 					 */
 	AHC_SEQUENCER_DEBUG   = 0x008,
 	AHC_SHARED_SRAM	      = 0x010,
@@ -455,7 +454,8 @@
 	AHC_LSCBS_ENABLED     = 0x2000000, /* 64Byte SCBs enabled */
 	AHC_SCB_CONFIG_USED   = 0x4000000, /* No SEEPROM but SCB2 had info. */
 	AHC_NO_BIOS_INIT      = 0x8000000, /* No BIOS left over settings. */
-	AHC_DISABLE_PCI_PERR  = 0x10000000
+	AHC_DISABLE_PCI_PERR  = 0x10000000,
+	AHC_DEFAULTTARGETCONF = 0x20000000
 } ahc_flag;
 
 /************************* Hardware  SCB Definition ***************************/
Index: sys/dev/pci/ahc_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/ahc_pci.c,v
retrieving revision 1.51
diff -u -r1.51 ahc_pci.c
--- sys/dev/pci/ahc_pci.c	28 Jun 2005 00:28:41 -0000	1.51
+++ sys/dev/pci/ahc_pci.c	20 Oct 2005 15:46:25 -0000
@@ -1042,6 +1042,9 @@
 			printf("%s: Using left over BIOS settings\n",
 				ahc_name(ahc));
 			ahc->flags &= ~AHC_USEDEFAULTS;
+#ifdef AHC_IGNORE_BIOSTARGETSETTINGS
+			ahc->flags |= AHC_DEFAULTTARGETCONF;
+#endif
 			ahc->flags |= AHC_BIOS_ENABLED;
 		} else {
 			/*