linux-mips
[Top] [All Lists]

[PATCH] MIPS: avoid possible resource conflict in register_pci_controlle

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH] MIPS: avoid possible resource conflict in register_pci_controller
From: Gabor Juhos <juhosg@openwrt.org>
Date: Sat, 2 Feb 2013 15:18:54 +0100
Cc: linux-mips <linux-mips@linux-mips.org>, John Crispin <blogic@openwrt.org>, Gabor Juhos <juhosg@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Sender: linux-mips-bounce@linux-mips.org
The IO and memory resources of a PCI controller
might already have a parent resource set when
they are passed to 'register_pci_controller'.

If the parent resource is set, the request_resource
call will fail due to resource conflict and the
current code will not be able to register the
PCI controller.

Use the parent resource if it is available in the
request_resource call to avoid the isssue.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/pci/pci.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index a184344..eb65399 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -175,9 +175,20 @@ static DEFINE_MUTEX(pci_scan_mutex);
 
 void register_pci_controller(struct pci_controller *hose)
 {
-       if (request_resource(&iomem_resource, hose->mem_resource) < 0)
+       struct resource *parent;
+
+       parent = hose->mem_resource->parent;
+       if (!parent)
+               parent = &iomem_resource;
+
+       if (request_resource(parent, hose->mem_resource) < 0)
                goto out;
-       if (request_resource(&ioport_resource, hose->io_resource) < 0) {
+
+       parent = hose->io_resource->parent;
+       if (!parent)
+               parent = &ioport_resource;
+
+       if (request_resource(parent, hose->io_resource) < 0) {
                release_resource(hose->mem_resource);
                goto out;
        }
-- 
1.7.10


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] MIPS: avoid possible resource conflict in register_pci_controller, Gabor Juhos <=