Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: John David Anglin <dave.anglin@bell.net>,
	linux-parisc@vger.kernel.org,
	James Bottomley <James.Bottomley@HansenPartnership.com>
Subject: Re: [PATCH] parisc: fix out-of-register compiler error in ldcw inline assembler function
Date: Thu, 11 Dec 2014 00:08:04 +0100	[thread overview]
Message-ID: <5488D254.7010401@gmx.de> (raw)
In-Reply-To: <BLU436-SMTP234E0B9D24642C60497B1EB97940@phx.gbl>

[-- Attachment #1: Type: text/plain, Size: 978 bytes --]

On 10/21/2014 10:01 PM, John David Anglin wrote:
> On 10/21/2014 3:46 PM, Helge Deller wrote:
>>   /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*.  */
>> -#define __ldcw(a) ({                        \
>> -    unsigned __ret;                        \
>> -    __asm__ __volatile__(__LDCW " 0(%2),%0"            \
>> -        : "=r" (__ret), "+m" (*(a)) : "r" (a));        \
>> -    __ret;                            \
>> -})
>> +static inline unsigned int __ldcw(volatile unsigned int *address)
>> +{
>> +    unsigned int ret;
>> +    register volatile unsigned int *a = address;
>> +    __asm__ __volatile__(__LDCW " 0(%2),%0"
>> +        : "=r" (ret), "+m" (*(a)) : "r" (a));
>> +    return ret;
>> +}
> You could keep the old macro version for 32-bit builds as the problem shouldn't occur there.

Attached is an updated patch/work-around which just reuses the existing register.
I don't like this patch much, but it's better than nothing for now.

Helge
  


[-- Attachment #2: ldcw2.patch --]
[-- Type: text/x-patch, Size: 1317 bytes --]

diff --git a/arch/parisc/include/asm/ldcw.h b/arch/parisc/include/asm/ldcw.h
index d2d11b7..989595d 100644
--- a/arch/parisc/include/asm/ldcw.h
+++ b/arch/parisc/include/asm/ldcw.h
@@ -1,6 +1,8 @@
 #ifndef __PARISC_LDCW_H
 #define __PARISC_LDCW_H
 
+#include <linux/compiler.h>
+
 #ifndef CONFIG_PA20
 /* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
    and GCC only guarantees 8-byte alignment for stack locals, we can't
@@ -34,12 +36,22 @@
 #endif /*!CONFIG_PA20*/
 
 /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*.  */
-#define __ldcw(a) ({						\
-	unsigned __ret;						\
-	__asm__ __volatile__(__LDCW " 0(%2),%0"			\
-		: "=r" (__ret), "+m" (*(a)) : "r" (a));		\
-	__ret;							\
-})
+static inline unsigned int __ldcw(volatile unsigned int *address)
+{
+#if GCC_VERSION >= 40900
+	/* work around gcc-4.9 bug:
+	 * error: can't find a register in class 'R1_REGS' while reloading 'asm'
+	 */
+	__asm__ __volatile__(__LDCW " 0(%0),%0"
+		: "=r" (address), "+m" (*(address)) : "0" (address));
+	return (unsigned long) address;
+#else
+	unsigned int val;
+	__asm__ __volatile__(__LDCW " 0(%2),%0"
+		: "=r" (val), "+m" (*(address)) : "r" (address));
+	return val;
+#endif
+}
 
 #ifdef CONFIG_SMP
 # define __lock_aligned __attribute__((__section__(".data..lock_aligned")))

  reply	other threads:[~2014-12-10 23:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 19:46 [PATCH] parisc: fix out-of-register compiler error in ldcw inline assembler function Helge Deller
2014-10-21 20:01 ` John David Anglin
2014-12-10 23:08   ` Helge Deller [this message]
2014-12-14 15:49 ` John David Anglin
2014-12-15 20:58   ` Helge Deller
     [not found]     ` <BLU436-SMTP141439F4C676F97CF7D44EB976F0@phx.gbl>
     [not found]       ` <548F5251.4070708@gmx.de>
2014-12-15 21:45         ` John David Anglin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5488D254.7010401@gmx.de \
    --to=deller@gmx.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dave.anglin@bell.net \
    --cc=linux-parisc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox