Skip to content

Commit e1907d3

Browse files
muralimk-amdsuryasaimadhu
authored andcommitted
x86/amd_nb: Unexport amd_cache_northbridges()
amd_cache_northbridges() is exported by amd_nb.c and is called by amd64-agp.c and amd64_edac.c modules at module_init() time so that NB descriptors are properly cached before those drivers can use them. However, the init_amd_nbs() initcall already does call amd_cache_northbridges() unconditionally and thus makes sure the NB descriptors are enumerated. That initcall is a fs_initcall type which is on the 5th group (starting from 0) of initcalls that gets run in increasing numerical order by the init code. The module_init() call is turned into an __initcall() in the MODULE=n case and those are device-level initcalls, i.e., group 6. Therefore, the northbridges caching is already finished by the time module initialization starts and thus the correct initialization order is retained. Unexport amd_cache_northbridges(), update dependent modules to call amd_nb_num() instead. While at it, simplify the checks in amd_cache_northbridges(). [ bp: Heavily massage and *actually* explain why the change is ok. ] Signed-off-by: Muralidhara M K <[email protected]> Signed-off-by: Naveen Krishna Chatradhi <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3123109 commit e1907d3

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

arch/x86/include/asm/amd_nb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ extern const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[];
1616

1717
extern bool early_is_amd_nb(u32 value);
1818
extern struct resource *amd_get_mmconfig_range(struct resource *res);
19-
extern int amd_cache_northbridges(void);
2019
extern void amd_flush_garts(void);
2120
extern int amd_numa_init(void);
2221
extern int amd_get_subcaches(int);

arch/x86/kernel/amd_nb.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int amd_smn_write(u16 node, u32 address, u32 value)
188188
EXPORT_SYMBOL_GPL(amd_smn_write);
189189

190190

191-
int amd_cache_northbridges(void)
191+
static int amd_cache_northbridges(void)
192192
{
193193
const struct pci_device_id *misc_ids = amd_nb_misc_ids;
194194
const struct pci_device_id *link_ids = amd_nb_link_ids;
@@ -210,14 +210,14 @@ int amd_cache_northbridges(void)
210210
}
211211

212212
misc = NULL;
213-
while ((misc = next_northbridge(misc, misc_ids)) != NULL)
213+
while ((misc = next_northbridge(misc, misc_ids)))
214214
misc_count++;
215215

216216
if (!misc_count)
217217
return -ENODEV;
218218

219219
root = NULL;
220-
while ((root = next_northbridge(root, root_ids)) != NULL)
220+
while ((root = next_northbridge(root, root_ids)))
221221
root_count++;
222222

223223
if (root_count) {
@@ -290,7 +290,6 @@ int amd_cache_northbridges(void)
290290

291291
return 0;
292292
}
293-
EXPORT_SYMBOL_GPL(amd_cache_northbridges);
294293

295294
/*
296295
* Ignores subdevice/subvendor but as far as I can figure out

drivers/char/agp/amd64-agp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int cache_nbs(struct pci_dev *pdev, u32 cap_ptr)
327327
{
328328
int i;
329329

330-
if (amd_cache_northbridges() < 0)
330+
if (!amd_nb_num())
331331
return -ENODEV;
332332

333333
if (!amd_nb_has_feature(AMD_NB_GART))

drivers/edac/amd64_edac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4336,7 +4336,7 @@ static int __init amd64_edac_init(void)
43364336
if (!x86_match_cpu(amd64_cpuids))
43374337
return -ENODEV;
43384338

4339-
if (amd_cache_northbridges() < 0)
4339+
if (!amd_nb_num())
43404340
return -ENODEV;
43414341

43424342
opstate_init();

0 commit comments

Comments
 (0)