Memory region check in drivers/pcmcia/rsrc_mgr.c

Paul Mackerras (paulus@samba.org)
Sat, 7 Jul 2001 21:42:24 +1000 (EST)


In drivers/pcmcia/rsrc_mgr.c, there is code that check whether a given
range of PCI memory addresses are available for the pcmcia code to
use. This code uses a macro, check_mem_resource(), to check whether a
particular region is available, defined like this:

#define check_mem_resource(b,n) check_resource(&iomem_resource, (b), (n))

This code is now causing me problems on my powerbook because we now
register the regions mapped by each PCI host bridge in the
iomem_resource structure. The basic problem is that check_resource
only checks at the top level of the iomem_resource tree. I think that
we should be using check_mem_region instead, which will descend the
tree until it finds out whether the region is actually in use or not.

The patch below does this (and makes a similar correction for I/O
space). With this patch applied, the pcmcia stuff works fine on my
powerbook, and I end up with something like this in /proc/iomem:

80000000-afffffff : /pci@f2000000
80000000-8007ffff : Apple Computer Inc. KeyLargo Mac I/O
90000000-9fffffff : PCI CardBus #02
a0000000-a0000fff : Texas Instruments PCI1211
a0001000-a0001fff : Apple Computer Inc. KeyLargo USB (#2)
a0001000-a0001fff : usb-ohci
a0002000-a0002fff : Apple Computer Inc. KeyLargo USB
a0002000-a0002fff : usb-ohci
a7000000-a7000fff : card services
b0000000-bfffffff : /pci@f0000000
b0000000-b0003fff : ATI Technologies Inc Mobility M3 AGP 2x
b0000000-b0003fff : aty128fb MMIO
b4000000-b7ffffff : ATI Technologies Inc Mobility M3 AGP 2x
b4000000-b7ffffff : aty128fb FB
f1000000-f1ffffff : /pci@f0000000
f3000000-f3ffffff : /pci@f2000000
f3000000-f33fffff : PCI CardBus #02
f5000000-f5ffffff : /pci@f4000000
f5000000-f5000fff : Apple Computer Inc. UniNorth FireWire
f5200000-f53fffff : Apple Computer Inc. UniNorth GMAC

Linus, would you apply this patch to your tree?

Paul.

diff -urN linux/drivers/pcmcia/rsrc_mgr.c pmac/drivers/pcmcia/rsrc_mgr.c
--- linux/drivers/pcmcia/rsrc_mgr.c Sat Mar 31 03:06:19 2001
+++ pmac/drivers/pcmcia/rsrc_mgr.c Wed Jun 20 14:25:25 2001
@@ -104,8 +104,8 @@

======================================================================*/

-#define check_io_resource(b,n) check_resource(&ioport_resource, (b), (n))
-#define check_mem_resource(b,n) check_resource(&iomem_resource, (b), (n))
+#define check_io_resource(b,n) check_region((b), (n))
+#define check_mem_resource(b,n) check_mem_region((b), (n))

/*======================================================================

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/