Message ID | 1322630640-13708-6-git-send-email-tony@bakeyournoodle.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Josh Boyer |
Headers | show |
> +#define mfdcrx(rn) \ > + ({ \ > + unsigned long rval; \ > + asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \ > + rval; \ > + }) "g" is never correct on PowerPC, you want "r" here. You can write this as a static inline btw, you only need the #define stuff when there is an "i" constraint involved. Segher
> > +#define mfdcrx(rn) \ > > + ({ \ > > + unsigned long rval; \ > > + asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \ > > + rval; \ > > + }) > > "g" is never correct on PowerPC, you want "r" here. You can write > this as a static inline btw, you only need the #define stuff when > there is an "i" constraint involved. I think you can still use static inlines even when a constraint is one that requires a compile time constant. eg (not ppc, but the "n" become part of the instruction word): static __inline__ uint32_t custom_inic(const uint32_t op, uint32_t a, const uint32_t b) { uint32_t result; __asm__ ( "custom\t%1, %0, %2, c%3" : "=r" (result) : "n" (op), "r" (a), "n" (b)); return result; } David
On Wed, Nov 30, 2011 at 02:09:20PM +0100, Segher Boessenkool wrote: > >+#define mfdcrx(rn) \ > >+ ({ \ > >+ unsigned long rval; \ > >+ asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \ > >+ rval; \ > >+ }) > > "g" is never correct on PowerPC, you want "r" here. You can write > this as a static inline btw, you only need the #define stuff when > there is an "i" constraint involved. Okay I'll change it to "i", mostly I used a #define to match the style of m[tf]dcr. To be honnest I didn't know about the issue with "i" constraints and static inlines. Yours Tony
On Thu, Dec 01, 2011 at 10:30:27AM +1100, Tony Breeds wrote:
> Okay I'll change it to "i", mostly I used a #define to match the style
Of course I menat "r" here.
Yours Tony
>>> +#define mfdcrx(rn) \ >>> + ({ \ >>> + unsigned long rval; \ >>> + asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \ >>> + rval; \ >>> + }) >> >> "g" is never correct on PowerPC, you want "r" here. You can write >> this as a static inline btw, you only need the #define stuff when >> there is an "i" constraint involved. > > I think you can still use static inlines even when a > constraint is one that requires a compile time constant. Marking a function inline does not guarantee the compiler will perform inline substitution on it, which you need here. I don't think it's a problem with recent GCC in the context of the Linux kernel though, if you use __always_inline that is. Segher
diff --git a/arch/powerpc/boot/dcr.h b/arch/powerpc/boot/dcr.h index 645a7c9..51b5893 100644 --- a/arch/powerpc/boot/dcr.h +++ b/arch/powerpc/boot/dcr.h @@ -9,6 +9,12 @@ }) #define mtdcr(rn, val) \ asm volatile("mtdcr %0,%1" : : "i"(rn), "r"(val)) +#define mfdcrx(rn) \ + ({ \ + unsigned long rval; \ + asm volatile("mfdcrx %0,%1" : "=r"(rval) : "g"(rn)); \ + rval; \ + }) /* 440GP/440GX SDRAM controller DCRs */ #define DCRN_SDRAM0_CFGADDR 0x010
Signed-off-by: Tony Breeds <tony@bakeyournoodle.com> --- arch/powerpc/boot/dcr.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)