From patchwork Tue Mar 30 06:51:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Brodowski X-Patchwork-Id: 89207 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2U6pPKR013292 for ; Tue, 30 Mar 2010 06:51:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713Ab0C3GvY (ORCPT ); Tue, 30 Mar 2010 02:51:24 -0400 Received: from isilmar.linta.de ([213.133.102.198]:36017 "EHLO linta.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752022Ab0C3GvX (ORCPT ); Tue, 30 Mar 2010 02:51:23 -0400 Received: (qmail 17199 invoked from network); 30 Mar 2010 06:51:21 -0000 Received: from p54a07e0f.dip.t-dialin.net (HELO comet.dominikbrodowski.net) (brodo@84.160.126.15) by isilmar.linta.de with (DHE-RSA-AES256-SHA encrypted) SMTP; 30 Mar 2010 06:51:21 -0000 Received: by comet.dominikbrodowski.net (Postfix, from userid 1000) id EF9895807C; Tue, 30 Mar 2010 08:51:11 +0200 (CEST) Date: Tue, 30 Mar 2010 08:51:11 +0200 From: Dominik Brodowski To: Bjorn Helgaas Cc: Jesse Barnes , linux-pci@vger.kernel.org, linux-pcmcia@lists.infradead.org Subject: Re: pci_bus_for_each_resource, transparent bridges and rsrc_nonstatic.c Message-ID: <20100330065111.GB4498@comet.dominikbrodowski.net> Mail-Followup-To: Bjorn Helgaas , Jesse Barnes , linux-pci@vger.kernel.org, linux-pcmcia@lists.infradead.org References: <20091111203303.GA7939@comet.dominikbrodowski.net> <201003221628.56232.bjorn.helgaas@hp.com> <20100322225235.GA29522@isilmar.linta.de> <201003221711.34997.bjorn.helgaas@hp.com> <20100322232800.GA532@isilmar.linta.de> <20100327190340.27310.qmail@stuge.se> <20100328114559.GA2504@comet.dominikbrodowski.net> <20100329094137.25a0e695@jbarnes-piketon> <20100329194703.GC8450@comet.dominikbrodowski.net> <1269905593.10752.73.camel@dc7800.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1269905593.10752.73.camel@dc7800.home> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 30 Mar 2010 06:51:26 +0000 (UTC) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 39c89e1..bfb2774 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -930,23 +930,42 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) return -ENODEV; #if defined(CONFIG_X86) - /* If this is the root bus, the risk of hitting - * some strange system devices which aren't protected - * by either ACPI resource tables or properly requested - * resources is too big. Therefore, don't do auto-adding - * of resources at the moment. + /* If this is the root bus, the risk of hitting some strange + * system devices is too high: If a driver isn't loaded, the + * resources are not claimed; even if a driver is loaded, it + * may not request all resources or even the wrong one. We + * can neither trust the rest of the kernel nor ACPI/PNP and + * CRS parsing to get it right. Therefore, use several + * safeguards: + * + * - Do not auto-add resources if the CardBus bridge is on + * the PCI root bus + * + * - Avoid any I/O ports < 0x100. + * + * - On PCI-PCI bridges, only use resources which are set up + * exclusively for the secondary PCI bus: the risk of hitting + * system devices is quite low, as they usually aren't + * connected to the secondary PCI bus. */ if (s->cb_dev->bus->number == 0) return -EINVAL; -#endif + for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) { + res = s->cb_dev->bus->resource[i]; +#else pci_bus_for_each_resource(s->cb_dev->bus, res, i) { +#endif if (!res) continue; if (res->flags & IORESOURCE_IO) { + /* safeguard against the root resource, where the + * risk of hitting any other device would be too + * high */ if (res == &ioport_resource) continue; + dev_printk(KERN_INFO, &s->cb_dev->dev, "pcmcia: parent PCI bridge window: %pR\n", res); @@ -956,8 +975,12 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) } if (res->flags & IORESOURCE_MEM) { + /* safeguard against the root resource, where the + * risk of hitting any other device would be too + * high */ if (res == &iomem_resource) continue; + dev_printk(KERN_INFO, &s->cb_dev->dev, "pcmcia: parent PCI bridge window: %pR\n", res);