pci_bus_for_each_resource, transparent bridges and rsrc_nonstatic.c
Dominik Brodowski
linux at dominikbrodowski.net
Mon Mar 29 15:47:03 EDT 2010
On Mon, Mar 29, 2010 at 09:41:37AM -0700, Jesse Barnes wrote:
> On Sun, 28 Mar 2010 13:45:59 +0200
> Dominik Brodowski <linux at dominikbrodowski.net> wrote:
>
> >
> > On Sat, Mar 27, 2010 at 08:03:40PM +0100, Peter Stuge wrote:
> > > Dominik Brodowski wrote:
> > > > can we safely trust BIOS authors to get it right?
> > >
> > > As a long time member of the coreboot project I can assure you that
> > > the answer to that is "No!!"
> >
> > Thanks. Jesse, Bjorn: recalling my mesage of 22 March 2010, what's your
> > opinion on the two options spelled out there:
> >
> > | (1) The best way seems to be to skip all resources of type
> > | PCI_SUBTRACTIVE_DECODE, but this flag is only stored in
> > | struct pci_bus_resource, which is hard to access, and nonexistent for the
> > | first four resources. Actually, the "flag" field is unused otherwise. Could
> > | we set res->flags |= PCI_SUBTRACTIVE_DECODE instead? (it probably needs to
> > | be != 0x1 then, but anyways). Then it's trivial in rsrc_nonstatic.c
> > |
> > | (2) An alternative would be to
> > |
> > | diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
> > | index ba3a53e..b0e60a1 100644
> > | --- a/drivers/pcmcia/rsrc_nonstatic.c
> > | +++ b/drivers/pcmcia/rsrc_nonstatic.c
> > | @@ -933,7 +933,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
> > | return -EINVAL;
> > | #endif
> > |
> > | - pci_bus_for_each_resource(s->cb_dev->bus, res, i) {
> > | + for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
> > | + res = s->cb_dev->bus->resource[i];
> > | if (!res)
> > | continue;
>
> It would be nice to avoid pushing subtractive decode into the generic
> resource code, since it's pretty PCI specific
Well, isn't that what
#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
are for; and at least PCI ROM control bits are already defined in
include/linux/ioport.h . Still, I'm perfectly fine with the second approach:
From: Dominik Brodowski <linux at dominikbrodowski.net>
Date: Mon, 29 Mar 2010 21:40:35 +0200
Subject: [PATCH] pcmcia: do not autoadd root PCI bus resources
On the PCI root bus on the x86 architecture, the risk of hitting
some strange system devices which aren't protected by either ACPI
resource tables or properly requested resources is too big. In
the past, we were protected by the PCI root bridge being set to
&iomem_resource or &ioport_resource. However, on systems where CRS
is enabled, this no longer is true. Therefore, only loop over the
first (non-subtractive) resources of the upstream PCI bus brdige.
CC: Jesse Barnes <jbarnes at virtuousgeek.org>
CC: Bjorn Helgaas <bjorn.helgaas at hp.com>
Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 39c89e1..ad68e53 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -940,7 +940,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
return -EINVAL;
#endif
- pci_bus_for_each_resource(s->cb_dev->bus, res, i) {
+ for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
+ res = s->cb_dev->bus->resource[i];
if (!res)
continue;
More information about the linux-pcmcia
mailing list