On Fri, Nov 08, 2002 at 05:45:00PM -0500, Matthew N. Dodd wrote the words in effect of:
> On Fri, 8 Nov 2002, Terry Lambert wrote:
> > "Matthew N. Dodd" wrote:
> > > Recompile your kernel with
> > >
> > > options PCI_ALLOW_UNSUPPORTED_IO_RANGE
> >
> > Given the number of times that this comes up, can we change that to
> > "PCI_ALLOW_ACTUALLY_SUPPORTED_IO_RANGE_WHICH_IS_NON_DEFAULT_TO_BE_ANNOYING"
> > ?
> 
> I think the plan is to make this option a loader tunable and make the
> conditional in the pci code "bitchy" and then fix the larger problem with
> IO ranges.

Hi there.

I have made a basic patch, which took me about 10 minutes to do so.
Basically, it removes the option PCI_ALLOW_UNSUPPORTED_IO_RANGE, and
replaces it with a loader tunable.  This is no different from imp's
change to make PCI_ENABLE_IO_MODES a l-tunable.  But this time, I do not
have a sysctl to show the _readonly_ value, this is because the hw.pci
node leaves in pci.c and I am unsure of how to tackle that.  I have not
tested this patch, so consider it experimental.

Also.  If this patch works, then we will have to remove the
PCI_ALLOW_UNSUPPORTED_I0_RANGE from ``options'' files and add entries
for hw.pci.enable_io_modes and this loader tunable to the loader(8)
manual page or some such.

Patch also available at:
http://www.unixdaemons.com/~hiten/work/diffs/pci_pci.patch

Cheers.

P.S.  hw.pci should moved somewhere global, but donno how this can be
done or even if it is possible to do.

-- 
Hiten Pandya
[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]
--- /home/hiten/pci_pci.c       Fri Nov  8 17:25:52 2002
+++ /sys/dev/pci/pci_pci.c      Fri Nov  8 19:11:03 2002
@@ -38,6 +38,9 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/bus.h>
+#if 0
+#include <sys/sysctl.h>
+#endif
 
 #include <machine/resource.h>
 
@@ -90,6 +93,18 @@
 DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0);
 
 /*
+ * sysctl and tunable vars
+ */
+int pci_allow_unsupported_io_range = 1;
+TUNABLE_INT("hw.pci.allow_unsupported_io_range",
+       (int *)&pci_allow_unsupported_io_range);
+#if 0
+SYSCTL_INT(_hw_pci, OID_AUTO, allow_unsupported_io_range, CTLFLAG_RD,
+       &pci_allow_unsupported_io_range, 1,
+       "Allows the PCI Bridge to pass through an unsupported memory range"
+       "assigned by the BIOS.");
+#endif
+/*
  * Generic device interface
  */
 static int
@@ -288,21 +303,23 @@
        switch (type) {
        case SYS_RES_IOPORT:
            if (!pcib_is_isa_io(start)) {
-#ifndef PCI_ALLOW_UNSUPPORTED_IO_RANGE
-               if (start < sc->iobase)
-                   start = sc->iobase;
-               if (end > sc->iolimit)
-                   end = sc->iolimit;
-               if (end < start)
-                   start = 0;
-#else
-               if (start < sc->iobase)
-                   printf("start (%lx) < sc->iobase (%x)\n", start, sc->iobase);
-               if (end > sc->iolimit)
-                   printf("end (%lx) > sc->iolimit (%x)\n", end, sc->iolimit);
-               if (end < start)
-                   printf("end (%lx) < start (%lx)\n", end, start);
-#endif
+               if (!pci_allow_unsupported_io_range) {
+                   if (start < sc->iobase)
+                       start = sc->iobase;
+                   if (end > sc->iolimit)
+                       end = sc->iolimit;
+                   if (end < start)
+                       start = 0;
+               } else {
+                   if (start < sc->iobase)
+                       printf("start (%lx) < sc->iobase (%x)\n", start,
+                               sc->iobase);
+                   if (end > sc->iolimit)
+                       printf("end (%lx) > sc->iolimit (%x)\n",
+                               end, sc->iolimit);
+                   if (end < start)
+                       printf("end (%lx) < start (%lx)\n", end, start);
+               }
            }
            if (!pcib_is_isa_io(start) &&
              ((start < sc->iobase) || (end > sc->iolimit))) {
@@ -325,21 +342,23 @@
             */
        case SYS_RES_MEMORY:
            if (!pcib_is_isa_mem(start)) {
-#ifndef PCI_ALLOW_UNSUPPORTED_IO_RANGE
-               if (start < sc->membase && end >= sc->membase)
-                   start = sc->membase;
-               if (end > sc->memlimit)
-                   end = sc->memlimit;
-               if (end < start)
-                   start = 0;
-#else
-               if (start < sc->membase && end > sc->membase)
-                   printf("start (%lx) < sc->membase (%x)\n", start, sc->membase);
-               if (end > sc->memlimit)
-                   printf("end (%lx) > sc->memlimit (%x)\n", end, sc->memlimit);
-               if (end < start) 
-                   printf("end (%lx) < start (%lx)\n", end, start);
-#endif
+               if (!pci_allow_unsupported_io_range) {
+                   if (start < sc->membase && end >= sc->membase)
+                       start = sc->membase;
+                   if (end > sc->memlimit)
+                       end = sc->memlimit;
+                   if (end < start)
+                       start = 0;
+               } else {
+                   if (start < sc->membase && end > sc->membase)
+                       printf("start (%lx) < sc->membase (%x)\n",
+                               start, sc->membase);
+                   if (end > sc->memlimit)
+                       printf("end (%lx) > sc->memlimit (%x)\n",
+                               end, sc->memlimit);
+                   if (end < start)
+                       printf("end (%lx) < start (%lx)\n", end, start);
+               }
            }
            if (!pcib_is_isa_mem(start) &&
                (((start < sc->membase) || (end > sc->memlimit)) &&
@@ -351,9 +370,8 @@
                        device_get_name(child), device_get_unit(child), start,
                        end, sc->membase, sc->memlimit, sc->pmembase,
                        sc->pmemlimit);
-#ifndef PCI_ALLOW_UNSUPPORTED_IO_RANGE
-               return(NULL);
-#endif
+               if (!pci_allow_unsupported_io_range)
+                   return (NULL);
            }
            if (bootverbose)
                device_printf(sc->dev, "device %s%d requested decoded memory range 
0x%lx-0x%lx\n",

Reply via email to