From 1c54ff3315bc168cc0464000cde568c46b2288a2 Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Wed, 13 Nov 2002 09:42:25 +0000 Subject: [PATCH] Convert kernel compile option PCI_ALLOW_UNSUPPORTED_IO_RANGE to a loader tunable hw.pci.allow_unsupported_io_range. Submitted by: Hiten Pandya Approved by: re (murray) --- sys/conf/options | 3 -- sys/dev/pci/pci_pci.c | 82 ++++++++++++++++++++++++++----------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/sys/conf/options b/sys/conf/options index 4433f1b04624..ae1642358353 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -480,9 +480,6 @@ SMP opt_global.h # Size of the kernel message buffer MSGBUF_SIZE opt_msgbuf.h -# PCI related options -PCI_ALLOW_UNSUPPORTED_IO_RANGE opt_pci.h - # NFS options NFS_MINATTRTIMO opt_nfs.h NFS_MAXATTRTIMO opt_nfs.h diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 3ffc3e454ebc..c28e998cd285 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -89,6 +90,18 @@ devclass_t pcib_devclass; DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0); +/* + * sysctl and tunable vars + */ +static int pci_allow_unsupported_io_range = 0; +TUNABLE_INT("hw.pci.allow_unsupported_io_range", + (int *)&pci_allow_unsupported_io_range); +SYSCTL_DECL(_hw_pci); +SYSCTL_INT(_hw_pci, OID_AUTO, allow_unsupported_io_range, CTLFLAG_RD, + &pci_allow_unsupported_io_range, 0, + "Allows the PCI Bridge to pass through an unsupported memory range " + "assigned by the BIOS."); + /* * Generic device interface */ @@ -288,21 +301,23 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, 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 +340,23 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, */ 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 +368,8 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, 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",