Skip to content

Commit 49b96fc

Browse files
yghannambp3tk0v
authored andcommitted
x86/amd_nb: Simplify function 3 search
Use the newly introduced helper function to look up "function 3". Drop unused PCI IDs and code. 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 bc7b2e6 commit 49b96fc

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

arch/x86/kernel/amd_nb.c

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,6 @@ static const struct pci_device_id amd_nb_misc_ids[] = {
2929
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) },
3030
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) },
3131
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) },
32-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_DF_F3) },
33-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M10H_DF_F3) },
34-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) },
35-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F3) },
36-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_MA0H_DF_F3) },
37-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CNB17H_F3) },
38-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) },
39-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) },
40-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M10H_DF_F3) },
41-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M40H_DF_F3) },
42-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F3) },
43-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M60H_DF_F3) },
44-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M70H_DF_F3) },
45-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_19H_M78H_DF_F3) },
46-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M00H_DF_F3) },
47-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_DF_F3) },
48-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_DF_F3) },
49-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M70H_DF_F3) },
50-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI200_DF_F3) },
51-
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_MI300_DF_F3) },
52-
{}
53-
};
54-
55-
static const struct pci_device_id hygon_nb_misc_ids[] = {
56-
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) },
5732
{}
5833
};
5934

@@ -84,17 +59,6 @@ struct amd_northbridge *node_to_amd_nb(int node)
8459
}
8560
EXPORT_SYMBOL_GPL(node_to_amd_nb);
8661

87-
static struct pci_dev *next_northbridge(struct pci_dev *dev,
88-
const struct pci_device_id *ids)
89-
{
90-
do {
91-
dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
92-
if (!dev)
93-
break;
94-
} while (!pci_match_id(ids, dev));
95-
return dev;
96-
}
97-
9862
/*
9963
* SMN accesses may fail in ways that are difficult to detect here in the called
10064
* functions amd_smn_read() and amd_smn_write(). Therefore, callers must do
@@ -183,18 +147,12 @@ EXPORT_SYMBOL_GPL(amd_smn_write);
183147

184148
static int amd_cache_northbridges(void)
185149
{
186-
const struct pci_device_id *misc_ids = amd_nb_misc_ids;
187-
struct pci_dev *misc;
188150
struct amd_northbridge *nb;
189151
u16 i;
190152

191153
if (amd_northbridges.num)
192154
return 0;
193155

194-
if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
195-
misc_ids = hygon_nb_misc_ids;
196-
}
197-
198156
amd_northbridges.num = amd_num_nodes();
199157

200158
nb = kcalloc(amd_northbridges.num, sizeof(struct amd_northbridge), GFP_KERNEL);
@@ -203,11 +161,9 @@ static int amd_cache_northbridges(void)
203161

204162
amd_northbridges.nb = nb;
205163

206-
misc = NULL;
207164
for (i = 0; i < amd_northbridges.num; i++) {
208165
node_to_amd_nb(i)->root = amd_node_get_root(i);
209-
node_to_amd_nb(i)->misc = misc =
210-
next_northbridge(misc, misc_ids);
166+
node_to_amd_nb(i)->misc = amd_node_get_func(i, 3);
211167

212168
/*
213169
* Each Northbridge must have a 'misc' device.

0 commit comments

Comments
 (0)