Re: pci_bus_for_each_resource, transparent bridges and rsrc_nonstatic.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxx>
CC: Bjorn Helgaas <bjorn.helgaas@xxxxxx>
Signed-off-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>

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;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux