Skip to content

Commit 962f197

Browse files
yghannambp3tk0v
authored andcommitted
x86/amd_nb: Simplify function 4 search
Use the newly added helper function to look up a CPU/Node function to find "function 4" devices. Thus, avoid the need to regularly add new PCI IDs for basic discovery. The unique PCI IDs are still useful in case of quirks or functional changes. And they should be used only in such a manner. Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e6e6e5e commit 962f197

File tree

2 files changed

+4
-64
lines changed

2 files changed

+4
-64
lines changed

arch/x86/include/asm/amd_nb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <linux/ioport.h>
66
#include <linux/pci.h>
7-
#include <linux/refcount.h>
7+
#include <asm/amd_node.h>
88

99
struct amd_nb_bus_dev_range {
1010
u8 bus;

arch/x86/kernel/amd_nb.c

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,6 @@
3030
#define PCI_DEVICE_ID_AMD_MI200_ROOT 0x14bb
3131
#define PCI_DEVICE_ID_AMD_MI300_ROOT 0x14f8
3232

33-
#define PCI_DEVICE_ID_AMD_17H_DF_F4 0x1464
34-
#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F4 0x15ec
35-
#define PCI_DEVICE_ID_AMD_17H_M30H_DF_F4 0x1494
36-
#define PCI_DEVICE_ID_AMD_17H_M60H_DF_F4 0x144c
37-
#define PCI_DEVICE_ID_AMD_17H_M70H_DF_F4 0x1444
38-
#define PCI_DEVICE_ID_AMD_17H_MA0H_DF_F4 0x1728
39-
#define PCI_DEVICE_ID_AMD_19H_DF_F4 0x1654
40-
#define PCI_DEVICE_ID_AMD_19H_M10H_DF_F4 0x14b1
41-
#define PCI_DEVICE_ID_AMD_19H_M40H_DF_F4 0x167d
42-
#define PCI_DEVICE_ID_AMD_19H_M50H_DF_F4 0x166e
43-
#define PCI_DEVICE_ID_AMD_19H_M60H_DF_F4 0x14e4
44-
#define PCI_DEVICE_ID_AMD_19H_M70H_DF_F4 0x14f4
45-
#define PCI_DEVICE_ID_AMD_19H_M78H_DF_F4 0x12fc
46-
#define PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4 0x12c4
47-
#define PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4 0x16fc
48-
#define PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4 0x124c
49-
#define PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4 0x12bc
50-
#define PCI_DEVICE_ID_AMD_MI200_DF_F4 0x14d4
51-
#define PCI_DEVICE_ID_AMD_MI300_DF_F4 0x152c
52-
5333
/* Protect the PCI config register pairs used for SMN. */
5434
static DEFINE_MUTEX(smn_mutex);
5535

@@ -73,8 +53,6 @@ static const struct pci_device_id amd_root_ids[] = {
7353
{}
7454
};
7555

76-
#define PCI_DEVICE_ID_AMD_CNB17H_F4 0x1704
77-
7856
static const struct pci_device_id amd_nb_misc_ids[] = {
7957
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
8058
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
@@ -107,35 +85,6 @@ static const struct pci_device_id amd_nb_misc_ids[] = {
10785
{}
10886
};
10987

110-
static const struct pci_device_id amd_nb_link_ids[] = {
111-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
112-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) },
113-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F4) },
114-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
115-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
116-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F4) },
117-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F4) },
118-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) },
119-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F4) },
120-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F4) },
121-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_MA0H_DF_F4) },
122-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F4) },
123-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M10H_DF_F4) },
124-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M40H_DF_F4) },
125-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F4) },
126-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M60H_DF_F4) },
127-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M70H_DF_F4) },
128-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M78H_DF_F4) },
129-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F4) },
130-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_DF_F4) },
131-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_DF_F4) },
132-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F4) },
133-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F4) },
134-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_DF_F4) },
135-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI300_DF_F4) },
136-
{}
137-
};
138-
13988
static const struct pci_device_id hygon_root_ids[] = {
14089
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_ROOT) },
14190
{}
@@ -146,11 +95,6 @@ static const struct pci_device_id hygon_nb_misc_ids[] = {
14695
{}
14796
};
14897

149-
static const struct pci_device_id hygon_nb_link_ids[] = {
150-
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F4) },
151-
{}
152-
};
153-
15498
const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[] __initconst = {
15599
{ 0x00, 0x18, 0x20 },
156100
{ 0xff, 0x00, 0x20 },
@@ -275,13 +219,11 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value)
275219
}
276220
EXPORT_SYMBOL_GPL(amd_smn_write);
277221

278-
279222
static int amd_cache_northbridges(void)
280223
{
281224
const struct pci_device_id *misc_ids = amd_nb_misc_ids;
282-
const struct pci_device_id *link_ids = amd_nb_link_ids;
283225
const struct pci_device_id *root_ids = amd_root_ids;
284-
struct pci_dev *root, *misc, *link;
226+
struct pci_dev *root, *misc;
285227
struct amd_northbridge *nb;
286228
u16 roots_per_misc = 0;
287229
u16 misc_count = 0;
@@ -294,7 +236,6 @@ static int amd_cache_northbridges(void)
294236
if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
295237
root_ids = hygon_root_ids;
296238
misc_ids = hygon_nb_misc_ids;
297-
link_ids = hygon_nb_link_ids;
298239
}
299240

300241
misc = NULL;
@@ -328,14 +269,13 @@ static int amd_cache_northbridges(void)
328269
amd_northbridges.nb = nb;
329270
amd_northbridges.num = misc_count;
330271

331-
link = misc = root = NULL;
272+
misc = root = NULL;
332273
for (i = 0; i < amd_northbridges.num; i++) {
333274
node_to_amd_nb(i)->root = root =
334275
next_northbridge(root, root_ids);
335276
node_to_amd_nb(i)->misc = misc =
336277
next_northbridge(misc, misc_ids);
337-
node_to_amd_nb(i)->link = link =
338-
next_northbridge(link, link_ids);
278+
node_to_amd_nb(i)->link = amd_node_get_func(i, 4);
339279

340280
/*
341281
* If there are more PCI root devices than data fabric/

0 commit comments

Comments
 (0)