Skip to content

Commit

Permalink
powerpc/eeh: Remove reference to PCI device
Browse files Browse the repository at this point in the history
We will rely on pcibios_release_device() to remove the EEH cache
and unbind EEH device for the specific PCI device. So we shouldn't
hold the reference to the PCI device from EEH cache and EEH device.
Otherwise, pcibios_release_device() won't be called as we expected.
The patch removes the reference to the PCI device in EEH core.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Gavin Shan authored and Benjamin Herrenschmidt committed Jul 24, 2013
1 parent ee1dd1e commit 0ba1788
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
4 changes: 0 additions & 4 deletions arch/powerpc/kernel/eeh.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,6 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
}

eeh_dev_check_failure(edev);

pci_dev_put(eeh_dev_to_pci_dev(edev));
return val;
}

Expand Down Expand Up @@ -904,7 +902,6 @@ static void eeh_add_device_late(struct pci_dev *dev)
}
WARN_ON(edev->pdev);

pci_dev_get(dev);
edev->pdev = dev;
dev->dev.archdata.edev = edev;

Expand Down Expand Up @@ -992,7 +989,6 @@ static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
}
edev->pdev = NULL;
dev->dev.archdata.edev = NULL;
pci_dev_put(dev);

eeh_rmv_from_parent_pe(edev, purge_pe);
eeh_addr_cache_rmv_dev(dev);
Expand Down
18 changes: 5 additions & 13 deletions arch/powerpc/kernel/eeh_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr)
struct pci_io_addr_range *piar;
piar = rb_entry(n, struct pci_io_addr_range, rb_node);

if (addr < piar->addr_lo) {
if (addr < piar->addr_lo)
n = n->rb_left;
} else {
if (addr > piar->addr_hi) {
n = n->rb_right;
} else {
pci_dev_get(piar->pcidev);
return piar->edev;
}
}
else if (addr > piar->addr_hi)
n = n->rb_right;
else
return piar->edev;
}

return NULL;
Expand Down Expand Up @@ -156,7 +152,6 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
if (!piar)
return NULL;

pci_dev_get(dev);
piar->addr_lo = alo;
piar->addr_hi = ahi;
piar->edev = pci_dev_to_eeh_dev(dev);
Expand Down Expand Up @@ -250,7 +245,6 @@ static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev)

if (piar->pcidev == dev) {
rb_erase(n, &pci_io_addr_cache_root.rb_root);
pci_dev_put(piar->pcidev);
kfree(piar);
goto restart;
}
Expand Down Expand Up @@ -302,12 +296,10 @@ void eeh_addr_cache_build(void)
if (!edev)
continue;

pci_dev_get(dev); /* matching put is in eeh_remove_device() */
dev->dev.archdata.edev = edev;
edev->pdev = dev;

eeh_addr_cache_insert_dev(dev);

eeh_sysfs_add_device(dev);
}

Expand Down

0 comments on commit 0ba1788

Please sign in to comment.