diff options
author | marius <marius@FreeBSD.org> | 2009-07-21 19:06:39 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2009-07-21 19:06:39 +0000 |
commit | 109d6f3c87933f2d5603d091a6f77e034c23d09f (patch) | |
tree | d20fd6b04b77509b7c65aa31778fa749fdabac73 | |
parent | 0d00f45642b88a95b53e69a9c2beb4d34619bd7a (diff) | |
download | FreeBSD-src-109d6f3c87933f2d5603d091a6f77e034c23d09f.zip FreeBSD-src-109d6f3c87933f2d5603d091a6f77e034c23d09f.tar.gz |
Add a MD __PCI_BAR_ZERO_VALID which denotes that BARs containing 0
actually specify valid bases that should be treated just as normal.
The PCI specifications have no indication that 0 would be a magic value
indicating a disabled BAR as commonly used on at least amd64 and i386
but not sparc64. It's unclear what to do in pci_delete_resource()
instead of writing 0 to a BAR though as there's no (other) way do
disable individual BARs so its decoding is left enabled in case of
__PCI_BAR_ZERO_VALID for now.
Approved by: re (kib), jhb
MFC after: 1 week
-rw-r--r-- | sys/dev/pci/pci.c | 23 | ||||
-rw-r--r-- | sys/sparc64/include/param.h | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index a473ad2..0b7b267 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -2352,7 +2352,7 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, { pci_addr_t base, map, testval; pci_addr_t start, end, count; - int barlen, maprange, mapsize, type; + int barlen, basezero, maprange, mapsize, type; uint16_t cmd; struct resource *res; @@ -2365,6 +2365,11 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, type = SYS_RES_IOPORT; mapsize = pci_mapsize(testval); base = pci_mapbase(map); +#ifdef __PCI_BAR_ZERO_VALID + basezero = 0; +#else + basezero = base == 0; +#endif maprange = pci_maprange(map); barlen = maprange == 64 ? 2 : 1; @@ -2393,17 +2398,17 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, } /* - * If base is 0, then we have problems. It is best to ignore - * such entries for the moment. These will be allocated later if - * the driver specifically requests them. However, some - * removable busses look better when all resources are allocated, - * so allow '0' to be overriden. + * If base is 0, then we have problems if this architecture does + * not allow that. It is best to ignore such entries for the + * moment. These will be allocated later if the driver specifically + * requests them. However, some removable busses look better when + * all resources are allocated, so allow '0' to be overriden. * * Similarly treat maps whose values is the same as the test value * read back. These maps have had all f's written to them by the * BIOS in an attempt to disable the resources. */ - if (!force && (base == 0 || map == testval)) + if (!force && (basezero || map == testval)) return (barlen); if ((u_long)base != base) { device_printf(bus, @@ -2440,7 +2445,7 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, } count = 1 << mapsize; - if (base == 0 || base == pci_mapbase(testval)) { + if (basezero || base == pci_mapbase(testval)) { start = 0; /* Let the parent decide. */ end = ~0ULL; } else { @@ -3683,6 +3688,7 @@ pci_delete_resource(device_t dev, device_t child, int type, int rid) return; } +#ifndef __PCI_BAR_ZERO_VALID /* * If this is a BAR, clear the BAR so it stops * decoding before releasing the resource. @@ -3693,6 +3699,7 @@ pci_delete_resource(device_t dev, device_t child, int type, int rid) pci_write_bar(child, rid, 0); break; } +#endif bus_release_resource(dev, type, rid, rle->res); } resource_list_delete(rl, type, rid); diff --git a/sys/sparc64/include/param.h b/sys/sparc64/include/param.h index ebd7f0d..2642a8a 100644 --- a/sys/sparc64/include/param.h +++ b/sys/sparc64/include/param.h @@ -48,6 +48,8 @@ #ifndef _NO_NAMESPACE_POLLUTION +#define __PCI_BAR_ZERO_VALID + #ifndef _MACHINE_PARAM_H_ #define _MACHINE_PARAM_H_ |