From ecc227ac5e865b599819376f1e3b14dbccbd2abe Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Thu, 21 May 2015 11:23:45 +1000 Subject: Fix race in firenze_get_slot_info() leading to assert() with many PCI cards With many PCI cards, we'd hit a race where calls to firenze_add_pcidev_to_fsp_inventory would step on each other leading to memory corruption and finally an assert() in the allocator being hit during boot. Observed with 33+ devices. Signed-off-by: Stewart Smith --- platforms/ibm-fsp/firenze.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'platforms/ibm-fsp/firenze.c') diff --git a/platforms/ibm-fsp/firenze.c b/platforms/ibm-fsp/firenze.c index c0a13c0..300b4ff 100644 --- a/platforms/ibm-fsp/firenze.c +++ b/platforms/ibm-fsp/firenze.c @@ -51,6 +51,8 @@ static struct fsp_pcie_inventory *fsp_pcie_inv; static unsigned int fsp_pcie_inv_alloc_count; #define FSP_PCIE_INV_ALLOC_CHUNK 4 +struct lock fsp_pcie_inv_lock = LOCK_UNLOCKED; + static bool firenze_probe(void) { return dt_node_is_compatible(dt_root, "ibm,firenze"); @@ -218,7 +220,9 @@ static void firenze_get_slot_info(struct phb *phb, struct pci_device * pd) return; if (!pd->parent->slot_info->pluggable) return; + lock(&fsp_pcie_inv_lock); firenze_add_pcidev_to_fsp_inventory(phb, pd); + unlock(&fsp_pcie_inv_lock); } static void firenze_setup_phb(struct phb *phb, unsigned int index) -- cgit v1.1