Skip to content

Commit a97d9a1

Browse files
mpesmb49
authored andcommitted
powerpc/4xx: Fix build errors from mfdcr()
BugLink: https://bugs.launchpad.net/bugs/1923220 [ Upstream commit eead089 ] lkp reported a build error in fsp2.o: CC arch/powerpc/platforms/44x/fsp2.o {standard input}:577: Error: unsupported relocation against base Which comes from: pr_err("GESR0: 0x%08x\n", mfdcr(base + PLB4OPB_GESR0)); Where our mfdcr() macro is stringifying "base + PLB4OPB_GESR0", and passing that to the assembler, which obviously doesn't work. The mfdcr() macro already checks that the argument is constant using __builtin_constant_p(), and if not calls the out-of-line version of mfdcr(). But in this case GCC is smart enough to notice that "base + PLB4OPB_GESR0" will be constant, even though it's not something we can immediately stringify into a register number. Segher pointed out that passing the register number to the inline asm as a constant would be better, and in fact it fixes the build error, presumably because it gives GCC a chance to resolve the value. While we're at it, change mtdcr() similarly. Reported-by: kernel test robot <[email protected]> Suggested-by: Segher Boessenkool <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Acked-by: Feng Tang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent b774ab5 commit a97d9a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/powerpc/include/asm/dcr-native.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val)
5353
#define mfdcr(rn) \
5454
({unsigned int rval; \
5555
if (__builtin_constant_p(rn) && rn < 1024) \
56-
asm volatile("mfdcr %0," __stringify(rn) \
57-
: "=r" (rval)); \
56+
asm volatile("mfdcr %0, %1" : "=r" (rval) \
57+
: "n" (rn)); \
5858
else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR))) \
5959
rval = mfdcrx(rn); \
6060
else \
@@ -64,8 +64,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val)
6464
#define mtdcr(rn, v) \
6565
do { \
6666
if (__builtin_constant_p(rn) && rn < 1024) \
67-
asm volatile("mtdcr " __stringify(rn) ",%0" \
68-
: : "r" (v)); \
67+
asm volatile("mtdcr %0, %1" \
68+
: : "n" (rn), "r" (v)); \
6969
else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR))) \
7070
mtdcrx(rn, v); \
7171
else \

0 commit comments

Comments
 (0)