Commit f2557779 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pci-v4.10-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI fix from Bjorn Helgaas:
 "Configure ASPM on the link from a PCI-to-PCIe bridge (avoids a NULL
  pointer dereference on topologies including these bridges)"

* tag 'pci-v4.10-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI/ASPM: Handle PCI-to-PCIe bridges as roots of PCIe hierarchies
parents 6d04dfc8 030305d6
...@@ -532,25 +532,32 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev) ...@@ -532,25 +532,32 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
link = kzalloc(sizeof(*link), GFP_KERNEL); link = kzalloc(sizeof(*link), GFP_KERNEL);
if (!link) if (!link)
return NULL; return NULL;
INIT_LIST_HEAD(&link->sibling); INIT_LIST_HEAD(&link->sibling);
INIT_LIST_HEAD(&link->children); INIT_LIST_HEAD(&link->children);
INIT_LIST_HEAD(&link->link); INIT_LIST_HEAD(&link->link);
link->pdev = pdev; link->pdev = pdev;
if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) {
/*
* Root Ports and PCI/PCI-X to PCIe Bridges are roots of PCIe
* hierarchies.
*/
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT ||
pci_pcie_type(pdev) == PCI_EXP_TYPE_PCIE_BRIDGE) {
link->root = link;
} else {
struct pcie_link_state *parent; struct pcie_link_state *parent;
parent = pdev->bus->parent->self->link_state; parent = pdev->bus->parent->self->link_state;
if (!parent) { if (!parent) {
kfree(link); kfree(link);
return NULL; return NULL;
} }
link->parent = parent; link->parent = parent;
link->root = link->parent->root;
list_add(&link->link, &parent->children); list_add(&link->link, &parent->children);
} }
/* Setup a pointer to the root port link */
if (!link->parent)
link->root = link;
else
link->root = link->parent->root;
list_add(&link->sibling, &link_list); list_add(&link->sibling, &link_list);
pdev->link_state = link; pdev->link_state = link;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment