mips: fix r3k_cache_init build regression
PATCH 1/1 mips: fix r3k_cache_init build regression
From: Arnd Bergmann <[email protected]>
My earlier patch removed __weak function declarations that used to be turned into wild branches by the linker, instead causing a link failure when the called functions are unavailable:
mips-linux-ld: arch/mips/mm/cache.o: in function `cpu_cache_init':
cache.c:(.text+0x670): undefined reference to `r3k_cache_init'
The __weak method seems suboptimal, so rather than putting that back, make the function calls conditional on the Kconfig symbol that controls the compilation.
---
My broken patch is currently in linux-mm, so the fix should be applied on top.
--- arch/mips/mm/cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/mm/cache.c +3 -3
@@ -205,14 +205,14 @@ static inline void setup_protection_map(void)void cpu_cache_init (void ) { -if (cpu_has_3k_cache) { +if (IS_ENABLED (CONFIG_CPU_R3000 ) && cpu_has_3k_cache) {r3k_cache_init (); } -if (cpu_has_4k_cache) { +if (IS_ENABLED (CONFIG_CPU_R4K_CACHE_TLB ) && cpu_has_4k_cache) {r4k_cache_init (); } -if (cpu_has_octeon_cache) { +if (IS_ENABLED (CONFIG_CPU_CAVIUM_OCTEON ) && cpu_has_octeon_cache) {octeon_cache_init (); }
Signature · 1 line
2.39.2
Quoted 6 lines · On Thu, 14 Dec 2023 20:54:47 +0000 Arnd Bergmann <[email protected]> wrote:
From: Arnd Bergmann <[email protected]>
My earlier patch removed
__weakfunction declarations that used to be turned into wild branches by the linker, instead causing a link failure when the called functions are unavailable:
Quoted 6 lines
mips-linux-ld:
arch/mips/mm/cache.o: in function `cpu_cache_init':
cache.c:(.text+0x670): undefined reference to `r3k_cache_init'The
__weakmethod seems suboptimal, so rather than putting that back, make the function calls conditional on theKconfigsymbol that controls the compilation.
Cool, thanks.
Quoted 1 line
Reported-by kernelci.org bot <[email protected]>
Please don't forget the Closes: - they're sometimes handy.
Quoted 5 lines
Fixes 66445677f01e ("mips: move cache declarations into header")Signed-off-by Arnd Bergmann <[email protected]>---
My broken patch is currently in linux-mm, so the fix should be applied on top.
The mm-nonmm-stable branch of mm.git. So I'll queue this separately and we'll have a minor bisection hole. <git rant elided>
Quoted 9 lines
arch/mips/mm/cache.c +1
-1@@ -205,14 +205,14 @@ static inline void setup_protection_map(void)void cpu_cache_init (void ) { -if (cpu_has_3k_cache) { +if (IS_ENABLED (CONFIG_CPU_R3000 ) && cpu_has_3k_cache) {r3k_cache_init ();
arch/mips/mm/cache.c static inline void setup_protection_map(void) · line 217
Quoted 10 lines
arch/mips/mm/cache.c +2
-2} -if (cpu_has_4k_cache) { +if (IS_ENABLED (CONFIG_CPU_R4K_CACHE_TLB ) && cpu_has_4k_cache) {r4k_cache_init (); } -if (cpu_has_octeon_cache) { +if (IS_ENABLED (CONFIG_CPU_CAVIUM_OCTEON ) && cpu_has_octeon_cache) {octeon_cache_init (); }
I just can't help myself.
arch/mips/mm/cache.c renamed from arch/mips/mm/cache.c~mips-fix-r3k_cache_init-build-regression-fix +3 -6
@@ -205,16 +205,13 @@ static inline void setup_protection_map(void cpu_cache_init (void ) { -if (IS_ENABLED (CONFIG_CPU_R3000 ) && cpu_has_3k_cache) { +if (IS_ENABLED (CONFIG_CPU_R3000 ) && cpu_has_3k_cache)r3k_cache_init (); - } -if (IS_ENABLED (CONFIG_CPU_R4K_CACHE_TLB ) && cpu_has_4k_cache) { +if (IS_ENABLED (CONFIG_CPU_R4K_CACHE_TLB ) && cpu_has_4k_cache)r4k_cache_init (); - } -if (IS_ENABLED (CONFIG_CPU_CAVIUM_OCTEON ) && cpu_has_octeon_cache) { +if (IS_ENABLED (CONFIG_CPU_CAVIUM_OCTEON ) && cpu_has_octeon_cache)octeon_cache_init (); - }setup_protection_map (); }
The rest of the file doesn't do the over-bracing, so there.
Hi Arnd,
Quoted 28 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
My earlier patch removed
__weakfunction declarations that used to be turned into wild branches by the linker, instead causing a link failure when the called functions are unavailable:mips-linux-ld:
arch/mips/mm/cache.o: in function `cpu_cache_init':
cache.c:(.text+0x670): undefined reference to `r3k_cache_init'The
__weakmethod seems suboptimal, so rather than putting that back, make the function calls conditional on theKconfigsymbol that controls the compilation.Reported-by kernelci.org bot <[email protected]>Fixes 66445677f01e ("mips: move cache declarations into header")Signed-off-by Arnd Bergmann <[email protected]>---
My broken patch is currently in linux-mm, so the fix should be applied on top.--- arch/mips/mm/cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/mips/mm/cache.c +0
-0
arch/mips/mm/cache.c static inline void setup_protection_map(void) · line 211
Quoted 9 lines
arch/mips/mm/cache.c +2
-2@@ -205,14 +205,14 @@ static inline void setup_protection_map(void)void cpu_cache_init (void ) { -if (cpu_has_3k_cache) { +if (IS_ENABLED (CONFIG_CPU_R3000 ) && cpu_has_3k_cache) {r3k_cache_init (); } -if (cpu_has_4k_cache) { +if (IS_ENABLED (CONFIG_CPU_R4K_CACHE_TLB ) && cpu_has_4k_cache) {
Shouldn't we also check for CONFIG_CPU_SB1 enabled? (See commit 641e97f31887 "Replace SB1 cachecode with standard R4000 class cache code.")
With that:
Quoted 8 lines
arch/mips/mm/cache.c +1
-1r4k_cache_init (); } -if (cpu_has_octeon_cache) { +if (IS_ENABLED (CONFIG_CPU_CAVIUM_OCTEON ) && cpu_has_octeon_cache) {octeon_cache_init (); }