Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250107222847.3300430-8-yazen.ghannam@amd.com

authored by

Yazen Ghannam and committed by
Borislav Petkov (AMD)
49b96fc0 bc7b2e62

+1 -45
+1 -45
arch/x86/kernel/amd_nb.c
··· 29 29 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_M60H_NB_F3) }, 30 30 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3) }, 31 31 { 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) }, 57 32 {} 58 33 }; 59 34 ··· 58 83 return (node < amd_northbridges.num) ? &amd_northbridges.nb[node] : NULL; 59 84 } 60 85 EXPORT_SYMBOL_GPL(node_to_amd_nb); 61 - 62 - static struct pci_dev *next_northbridge(struct pci_dev *dev, 63 - const struct pci_device_id *ids) 64 - { 65 - do { 66 - dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); 67 - if (!dev) 68 - break; 69 - } while (!pci_match_id(ids, dev)); 70 - return dev; 71 - } 72 86 73 87 /* 74 88 * SMN accesses may fail in ways that are difficult to detect here in the called ··· 147 183 148 184 static int amd_cache_northbridges(void) 149 185 { 150 - const struct pci_device_id *misc_ids = amd_nb_misc_ids; 151 - struct pci_dev *misc; 152 186 struct amd_northbridge *nb; 153 187 u16 i; 154 188 155 189 if (amd_northbridges.num) 156 190 return 0; 157 - 158 - if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { 159 - misc_ids = hygon_nb_misc_ids; 160 - } 161 191 162 192 amd_northbridges.num = amd_num_nodes(); 163 193 ··· 161 203 162 204 amd_northbridges.nb = nb; 163 205 164 - misc = NULL; 165 206 for (i = 0; i < amd_northbridges.num; i++) { 166 207 node_to_amd_nb(i)->root = amd_node_get_root(i); 167 - node_to_amd_nb(i)->misc = misc = 168 - next_northbridge(misc, misc_ids); 208 + node_to_amd_nb(i)->misc = amd_node_get_func(i, 3); 169 209 170 210 /* 171 211 * Each Northbridge must have a 'misc' device.