Merge "msm: pcie: add mutex for PCIe enumeration"
This commit is contained in:
commit
054b950dfd
1 changed files with 16 additions and 7 deletions
|
@ -589,6 +589,7 @@ struct msm_pcie_dev_t {
|
||||||
bool cfg_access;
|
bool cfg_access;
|
||||||
spinlock_t cfg_lock;
|
spinlock_t cfg_lock;
|
||||||
unsigned long irqsave_flags;
|
unsigned long irqsave_flags;
|
||||||
|
struct mutex enumerate_lock;
|
||||||
struct mutex setup_lock;
|
struct mutex setup_lock;
|
||||||
|
|
||||||
struct irq_domain *irq_domain;
|
struct irq_domain *irq_domain;
|
||||||
|
@ -4964,12 +4965,15 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
int ret = 0, bus_ret = 0, scan_ret = 0;
|
int ret = 0, bus_ret = 0, scan_ret = 0;
|
||||||
struct msm_pcie_dev_t *dev = &msm_pcie_dev[rc_idx];
|
struct msm_pcie_dev_t *dev = &msm_pcie_dev[rc_idx];
|
||||||
|
|
||||||
|
mutex_lock(&dev->enumerate_lock);
|
||||||
|
|
||||||
PCIE_DBG(dev, "Enumerate RC%d\n", rc_idx);
|
PCIE_DBG(dev, "Enumerate RC%d\n", rc_idx);
|
||||||
|
|
||||||
if (!dev->drv_ready) {
|
if (!dev->drv_ready) {
|
||||||
PCIE_DBG(dev, "RC%d has not been successfully probed yet\n",
|
PCIE_DBG(dev, "RC%d has not been successfully probed yet\n",
|
||||||
rc_idx);
|
rc_idx);
|
||||||
return -EPROBE_DEFER;
|
ret = -EPROBE_DEFER;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev->enumerated) {
|
if (!dev->enumerated) {
|
||||||
|
@ -4996,8 +5000,7 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
PCIE_ERR(dev,
|
PCIE_ERR(dev,
|
||||||
"PCIe: failed to get host bridge resources for RC%d: %d\n",
|
"PCIe: failed to get host bridge resources for RC%d: %d\n",
|
||||||
dev->rc_idx, ret);
|
dev->rc_idx, ret);
|
||||||
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bus = pci_create_root_bus(&dev->pdev->dev, 0,
|
bus = pci_create_root_bus(&dev->pdev->dev, 0,
|
||||||
|
@ -5008,8 +5011,8 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
PCIE_ERR(dev,
|
PCIE_ERR(dev,
|
||||||
"PCIe: failed to create root bus for RC%d\n",
|
"PCIe: failed to create root bus for RC%d\n",
|
||||||
dev->rc_idx);
|
dev->rc_idx);
|
||||||
|
ret = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_ret = pci_scan_child_bus(bus);
|
scan_ret = pci_scan_child_bus(bus);
|
||||||
|
@ -5057,7 +5060,8 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
PCIE_ERR(dev,
|
PCIE_ERR(dev,
|
||||||
"PCIe: Did not find PCI device for RC%d.\n",
|
"PCIe: Did not find PCI device for RC%d.\n",
|
||||||
dev->rc_idx);
|
dev->rc_idx);
|
||||||
return -ENODEV;
|
ret = -ENODEV;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bus_ret = bus_for_each_dev(&pci_bus_type, NULL, dev,
|
bus_ret = bus_for_each_dev(&pci_bus_type, NULL, dev,
|
||||||
|
@ -5067,7 +5071,8 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
PCIE_ERR(dev,
|
PCIE_ERR(dev,
|
||||||
"PCIe: Failed to set up device table for RC%d\n",
|
"PCIe: Failed to set up device table for RC%d\n",
|
||||||
dev->rc_idx);
|
dev->rc_idx);
|
||||||
return -ENODEV;
|
ret = -ENODEV;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PCIE_ERR(dev, "PCIe: failed to enable RC%d.\n",
|
PCIE_ERR(dev, "PCIe: failed to enable RC%d.\n",
|
||||||
|
@ -5078,6 +5083,9 @@ int msm_pcie_enumerate(u32 rc_idx)
|
||||||
dev->rc_idx);
|
dev->rc_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
mutex_unlock(&dev->enumerate_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(msm_pcie_enumerate);
|
EXPORT_SYMBOL(msm_pcie_enumerate);
|
||||||
|
@ -6436,6 +6444,7 @@ int __init pcie_init(void)
|
||||||
rc_name, i);
|
rc_name, i);
|
||||||
spin_lock_init(&msm_pcie_dev[i].cfg_lock);
|
spin_lock_init(&msm_pcie_dev[i].cfg_lock);
|
||||||
msm_pcie_dev[i].cfg_access = true;
|
msm_pcie_dev[i].cfg_access = true;
|
||||||
|
mutex_init(&msm_pcie_dev[i].enumerate_lock);
|
||||||
mutex_init(&msm_pcie_dev[i].setup_lock);
|
mutex_init(&msm_pcie_dev[i].setup_lock);
|
||||||
mutex_init(&msm_pcie_dev[i].recovery_lock);
|
mutex_init(&msm_pcie_dev[i].recovery_lock);
|
||||||
spin_lock_init(&msm_pcie_dev[i].linkdown_lock);
|
spin_lock_init(&msm_pcie_dev[i].linkdown_lock);
|
||||||
|
|
Loading…
Add table
Reference in a new issue