Skip to contentSkip to conversation

EDAC, skx_edac: Fix for PCI multi-segment system

PATCH Masayoshi Mizuma 1 participant 1 message Oct 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Currently, skx_edac is not handled correctly the PCI segment except segment #0 because get_sky_dev() is only check the bus number of the uncore devices. If the system has milti-segment and each bus number of the devices are the same number, skx_edac driver initializes the devices only segment #0.

So, if skx_edac module is loaded to PCI multi-segment system, kernel panic occurs because of reference of the uninitialized segment #1 or more.

This patch introduces to check the segment to get_sky_dev() and fix the panic.

---
 drivers/edac/skx_edac.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/edac/skx_edac.c +6 -3
index 16dea97..7f56044 100644
@@ -68,6 +68,7 @@ struct skx_dev {
 	struct pci_dev	*sad_all;
 	struct pci_dev	*util_all;
 	u32	mcroute;
+	int	domain;
 	struct skx_imc {
 		struct mem_ctl_info *mci;
 		u8	mc;	/* system wide mc# */
@@ -110,12 +111,12 @@ struct decoded_addr {
 	int	bank_group;
 };
 
-static struct skx_dev *get_skx_dev(u8 bus, u8 idx)
+static struct skx_dev *get_skx_dev(int domain, u8 bus, u8 idx)
 {
 	struct skx_dev *d;
 
 	list_for_each_entry(d, &skx_edac_list, list) {
-		if (d->bus[idx] == bus)
+		if ((d->bus[idx] == bus) && (d->domain == domain))
 			return d;
 	}
 
@@ -179,6 +180,7 @@ static int get_all_bus_mappings(void)
 		d->bus[3] =  GET_BITFIELD(reg, 24, 31);
 		edac_dbg(2, "busses: %x, %x, %x, %x\n",
 			 d->bus[0], d->bus[1], d->bus[2], d->bus[3]);
+		d->domain =  pci_domain_nr(pdev->bus);
 		list_add_tail(&d->list, &skx_edac_list);
 		skx_num_sockets++;
 		prev = pdev;
@@ -207,7 +209,8 @@ static int get_all_munits(const struct munit *m)
 			if (i == NUM_IMC)
 				goto fail;
 		}
-		d = get_skx_dev(pdev->bus->number, m->busidx);
+		d = get_skx_dev(pci_domain_nr(pdev->bus), pdev->bus->number,
+				m->busidx);
 		if (!d)
 			goto fail;