Subject: Re: kern/23276
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 03/14/2006 15:50:02
The following reply was made to PR kern/23276; it has been noted by GNATS.
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: thorpej@shagadelic.org
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
gnats-admin@NetBSD.org, gibbs@scsiguy.com, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/23276
Date: Wed, 15 Mar 2006 00:45:55 +0900
In article <9F3D3A1E-D976-4952-90AC-4BB98DB2FBC8@shagadelic.org>
thorpej@shagadelic.org wrote:
> Wouldn't it be better to use a device property here rather than an
> #ifdef?
Now I see how properties(9) could be used. How about this patch?
---
Index: sys/arch/sgimips/sgimips/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/sgimips/autoconf.c,v
retrieving revision 1.27
diff -u -r1.27 autoconf.c
--- sys/arch/sgimips/sgimips/autoconf.c 26 Feb 2006 05:31:54 -0000 1.27
+++ sys/arch/sgimips/sgimips/autoconf.c 14 Mar 2006 15:35:30 -0000
@@ -48,6 +48,8 @@
#include <machine/machtype.h>
#include <machine/autoconf.h>
+#include <dev/pci/pcivar.h>
+
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
@@ -166,14 +168,37 @@
}
/*
- * Try to determine the boot device.
+ * Try to determine the boot device and set up some device properties
+ * to handle machine depedent quirks.
*/
+
+#define BUILTIN_AHC_P(pa) \
+ (((pa)->pa_bus == 0 && (pa)->pa_device == 1 && (pa)->pa_function == 0) || \
+ ((pa)->pa_bus == 0 && (pa)->pa_device == 2 && (pa)->pa_function == 0))
+
void
device_register(struct device *dev, void *aux)
{
static int found, initted, scsiboot, netboot;
struct device *parent = device_parent(dev);
+ if (mach_type == MACH_SGI_IP32 &&
+ parent != NULL && device_is_a(parent, "pci")) {
+ struct pci_attach_args *pa = aux;
+
+ if (BUILTIN_AHC_P(pa)) {
+ boolean_t usetd;
+
+ usetd = TRUE;
+ if (devprop_set(dev, "use-target-defaults",
+ &usetd, sizeof(usetd), 0, 0) != 0) {
+ printf("WARNING: unable to set"
+ "use-target-defaults property for %s\n",
+ dev->dv_xname);
+ }
+ }
+ }
+
if (found)
return;
Index: sys/dev/ic/aic7xxx.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/aic7xxx.c,v
retrieving revision 1.119
diff -u -r1.119 aic7xxx.c
--- sys/dev/ic/aic7xxx.c 14 Mar 2006 15:24:30 -0000 1.119
+++ sys/dev/ic/aic7xxx.c 14 Mar 2006 15:35:32 -0000
@@ -4634,13 +4634,20 @@
/* 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));
+ printf("%s: Host Adapter BIOS disabled. Using default SCSI "
+ "host and 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_USETARGETDEFAULTS) != 0) {
+ printf("%s: Host Adapter has no SEEPROM. Using default SCSI"
+ " target 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));
@@ -4671,7 +4678,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_USETARGETDEFAULTS)) {
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.51
diff -u -r1.51 aic7xxxvar.h
--- sys/dev/ic/aic7xxxvar.h 14 Mar 2006 15:30:03 -0000 1.51
+++ sys/dev/ic/aic7xxxvar.h 14 Mar 2006 15:35:33 -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,14 @@
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_USETARGETDEFAULTS = 0x20000000 /*
+ * For cards without an seeprom but
+ * with BIOS which initializes chip's
+ * SRAM with some conservative target
+ * settings, we use the default
+ * SCSI target settings.
+ */
} 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.53
diff -u -r1.53 ahc_pci.c
--- sys/dev/pci/ahc_pci.c 24 Dec 2005 20:27:42 -0000 1.53
+++ sys/dev/pci/ahc_pci.c 14 Mar 2006 15:35:33 -0000
@@ -1039,9 +1039,22 @@
/* See if someone else set us up already */
if ((ahc->flags & AHC_NO_BIOS_INIT) == 0
&& scsiseq != 0) {
+ boolean_t usetd;
+
printf("%s: Using left over BIOS settings\n",
ahc_name(ahc));
ahc->flags &= ~AHC_USEDEFAULTS;
+ /*
+ * Ignore target device settings and use default
+ * if BIOS initializes chip's SRAM with some
+ * conservative settings (async, no tagged
+ * queuing etc.) and machine dependent device
+ * property is set.
+ */
+ if (devprop_get(&ahc->sc_dev, "use-target-defaults",
+ &usetd, sizeof(usetd), NULL) == sizeof(usetd) &&
+ usetd == TRUE)
+ ahc->flags |= AHC_USETARGETDEFAULTS;
ahc->flags |= AHC_BIOS_ENABLED;
} else {
/*