Skip to content

Commit

Permalink
MIPS: avoid possible resource conflict in register_pci_controller
Browse files Browse the repository at this point in the history
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>
Patchwork: http://patchwork.linux-mips.org/patch/4910/
Signed-off-by: John Crispin <blogic@openwrt.org>
  • Loading branch information
Gabor Juhos authored and John Crispin committed Feb 17, 2013
1 parent 6e78386 commit 2228317
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions arch/mips/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2228317

Please sign in to comment.