Skip to content

Commit c1979ba

Browse files
jimsnow-intelsuryasaimadhu
authored andcommitted
EDAC, sb_edac: Add support for duplicate device IDs
Add options to sbridge_get_all_devices() to allow for duplicate device IDs and devices that are scattered across mulitple PCI buses. Signed-off-by: Jim Snow <[email protected]> Acked-by: Tony Luck <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: linux-edac <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] [ Rebase to 4.4-rc3. ] Signed-off-by: Hubert Chrzaniuk <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent c59f9c0 commit c1979ba

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

drivers/edac/sb_edac.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,19 @@ static inline int numcol(u32 mtr)
637637
return 1 << cols;
638638
}
639639

640-
static struct sbridge_dev *get_sbridge_dev(u8 bus)
640+
static struct sbridge_dev *get_sbridge_dev(u8 bus, int multi_bus)
641641
{
642642
struct sbridge_dev *sbridge_dev;
643643

644+
/*
645+
* If we have devices scattered across several busses that pertain
646+
* to the same memory controller, we'll lump them all together.
647+
*/
648+
if (multi_bus) {
649+
return list_first_entry_or_null(&sbridge_edac_list,
650+
struct sbridge_dev, list);
651+
}
652+
644653
list_for_each_entry(sbridge_dev, &sbridge_edac_list, list) {
645654
if (sbridge_dev->bus == bus)
646655
return sbridge_dev;
@@ -1588,7 +1597,8 @@ static void sbridge_put_all_devices(void)
15881597
static int sbridge_get_onedevice(struct pci_dev **prev,
15891598
u8 *num_mc,
15901599
const struct pci_id_table *table,
1591-
const unsigned devno)
1600+
const unsigned devno,
1601+
const int multi_bus)
15921602
{
15931603
struct sbridge_dev *sbridge_dev;
15941604
const struct pci_id_descr *dev_descr = &table->descr[devno];
@@ -1624,7 +1634,7 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
16241634
}
16251635
bus = pdev->bus->number;
16261636

1627-
sbridge_dev = get_sbridge_dev(bus);
1637+
sbridge_dev = get_sbridge_dev(bus, multi_bus);
16281638
if (!sbridge_dev) {
16291639
sbridge_dev = alloc_sbridge_dev(bus, table);
16301640
if (!sbridge_dev) {
@@ -1673,21 +1683,32 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
16731683
* @num_mc: pointer to the memory controllers count, to be incremented in case
16741684
* of success.
16751685
* @table: model specific table
1686+
* @allow_dups: allow for multiple devices to exist with the same device id
1687+
* (as implemented, this isn't expected to work correctly in the
1688+
* multi-socket case).
1689+
* @multi_bus: don't assume devices on different buses belong to different
1690+
* memory controllers.
16761691
*
16771692
* returns 0 in case of success or error code
16781693
*/
1679-
static int sbridge_get_all_devices(u8 *num_mc,
1680-
const struct pci_id_table *table)
1694+
static int sbridge_get_all_devices_full(u8 *num_mc,
1695+
const struct pci_id_table *table,
1696+
int allow_dups,
1697+
int multi_bus)
16811698
{
16821699
int i, rc;
16831700
struct pci_dev *pdev = NULL;
16841701

16851702
while (table && table->descr) {
16861703
for (i = 0; i < table->n_devs; i++) {
1687-
pdev = NULL;
1704+
if (!allow_dups || i == 0 ||
1705+
table->descr[i].dev_id !=
1706+
table->descr[i-1].dev_id) {
1707+
pdev = NULL;
1708+
}
16881709
do {
16891710
rc = sbridge_get_onedevice(&pdev, num_mc,
1690-
table, i);
1711+
table, i, multi_bus);
16911712
if (rc < 0) {
16921713
if (i == 0) {
16931714
i = table->n_devs;
@@ -1696,14 +1717,17 @@ static int sbridge_get_all_devices(u8 *num_mc,
16961717
sbridge_put_all_devices();
16971718
return -ENODEV;
16981719
}
1699-
} while (pdev);
1720+
} while (pdev && !allow_dups);
17001721
}
17011722
table++;
17021723
}
17031724

17041725
return 0;
17051726
}
17061727

1728+
#define sbridge_get_all_devices(num_mc, table) \
1729+
sbridge_get_all_devices_full(num_mc, table, 0, 0)
1730+
17071731
static int sbridge_mci_bind_devs(struct mem_ctl_info *mci,
17081732
struct sbridge_dev *sbridge_dev)
17091733
{

0 commit comments

Comments
 (0)