Skip to contentSkip to conversation

avr32: fix asm operand constraint in cmpxchg()

PATCH In review Mans Rullgard 4 participants 4 messages Mar 10, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avr32: fix asm operand constraint in cmpxchg()

If the 'old' operand to cmpxchg() is a constant wider than 21 bits, linking fails with a "relocation truncated to fit: R_AVR32_21S" error.

Fix this by replacing the "i" constraint with "Ks21" which makes the compiler use a temporary register for out of range constants.

---
This fixes link errors in linux-next with CONFIG_AIO_THREAD enabled.

---
 arch/avr32/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/avr32/include/asm/cmpxchg.h +1 -1
index 366bbeaeb405..572739b4c4b4 100644
@@ -57,7 +57,7 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
 		"	brne	1b\n"
 		"2:\n"
 		: [ret] "=&r"(ret), [m] "=m"(*m)
-		: "m"(m), [old] "ir"(old), [new] "r"(new)
+		: "m"(m), [old] "Ks21r"(old), [new] "r"(new)
 		: "memory", "cc");
 	return ret;
 }
Signature · 1 line
2.7.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mans Rullgard

If the 'old' operand to cmpxchg() is a constant wider than 21 bits, linking fails with a "relocation truncated to fit: R_AVR32_21S" error.

Fix this by replacing the "i" constraint with "Ks21" which makes the compiler use a temporary register for out of range constants.

---
This fixes link errors in linux-next with CONFIG_AIO_THREAD enabled.

Good find, thank you for fixing.

I'll push this for next merge window.

Quoted 17 lines
---
 arch/avr32/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/avr32/include/asm/cmpxchg.h +1 -1
index 366bbeaeb405..572739b4c4b4 100644
@@ -57,7 +57,7 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
 		"	brne	1b\n"
 		"2:\n"
 		: [ret] "=&r"(ret), [m] "=m"(*m)
-		: "m"(m), [old] "ir"(old), [new] "r"(new)
+		: "m"(m), [old] "Ks21r"(old), [new] "r"(new)
 		: "memory", "cc");
 	return ret;
 }
Signature · 2 lines
mvh
Hans-Christian Egtvedt
Tested-by on v1 1/1
#2 lore raw
In reply to Mans Rullgard
Quoted 7 lines · Mans Rullgard

If the 'old' operand to cmpxchg() is a constant wider than 21 bits, linking fails with a "relocation truncated to fit: R_AVR32_21S" error.

Fix this by replacing the "i" constraint with "Ks21" which makes the compiler use a temporary register for out of range constants.

Quoted 22 lines

---
This fixes link errors in linux-next with CONFIG_AIO_THREAD enabled.

---
 arch/avr32/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/avr32/include/asm/cmpxchg.h +1 -2
index 366bbeaeb405..572739b4c4b4 100644
@@ -57,7 +57,7 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
                "       brne    1b\n"
                "2:\n"
                : [ret] "=&r"(ret), [m] "=m"(*m)
-               : "m"(m), [old] "ir"(old), [new] "r"(new)
+               : "m"(m), [old] "Ks21r"(old), [new] "r"(new)
                : "memory", "cc");
        return ret;
 }
--

2.7.2

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Tested-by on v1 1/1
#3 lore raw
In reply to Mans Rullgard
Quoted 7 lines · Mans Rullgard

If the 'old' operand to cmpxchg() is a constant wider than 21 bits, linking fails with a "relocation truncated to fit: R_AVR32_21S" error.

Fix this by replacing the "i" constraint with "Ks21" which makes the compiler use a temporary register for out of range constants.

build log at: https://gitlab.com/sudipm/linux-next/builds/839572

regards
sudip