linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nate Lawson <nate@root.org>
To: "Yu, Luming" <luming.yu@intel.com>
Cc: Paul Menage <menage@google.com>,
	agrover@groveronline.com, linux-kernel@vger.kernel.org,
	acpi-devel@lists.sourceforge.net
Subject: RE: [ACPI] ACPI global lock macros
Date: Thu, 11 Dec 2003 09:46:30 -0800 (PST)	[thread overview]
Message-ID: <20031211094510.J50052@root.org> (raw)
In-Reply-To: <3ACA40606221794F80A5670F0AF15F8401720C22@PDSMSX403.ccr.corp.intel.com>

On Thu, 11 Dec 2003, Yu, Luming wrote:
> -----Original Message-----
> From: acpi-devel-admin@lists.sourceforge.net [mailto:acpi-devel-admin@lists.sourceforge.net]On Behalf Of Yu, Luming
> Sent: 2003?12?11? 15:06
> To: Paul Menage; agrover@groveronline.com
> Cc: linux-kernel@vger.kernel.org; acpi-devel@lists.sourceforge.net
> Subject: RE: [ACPI] ACPI global lock macros
>
>
> >>#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
> >>     do { \
> >>        asm volatile("1:movl   (%1),%%eax;" \
> >>             "movl   %%eax,%%edx;" \
> >>             "andl   %2,%%edx;" \
> >>             "btsl   $0x1,%%edx;" \
> >>             "adcl   $0x0,%%edx;" \
> >>             "lock;  cmpxchgl %%edx,(%1);" \
> >>             "jnz    1b;" \
> >>             "cmpb   $0x3,%%dl;" \
> >>             "sbbl   %0,%0" \
> >>             :"=r"(Acq):"r"(GLptr),"i"(~1L):"dx", "ax"); \
> >>     } while(0)
>
> Above code have a bug! Considering below code:
>
> u8	acquired = FALSE;
>
> ACPI_ACQUIRE_GLOBAL_LOC(acpi_gbl_common_fACS.global_lock, acquired);
> if(acquired) {
> ....
> }
>
> Gcc will complain " ERROR: '%cl' not allowed with sbbl ". And I think any other compiler will
> complain that  too !
>
> How about  below changes to your proposal code.
>
> <             "sbbl   %0,%0" \
> <             :"=r"(Acq):"r"(GLptr),"i"(~1L):"dx","ax"); \
> ---
> >             "sbbl   %%eax,%%eax" \
> >             :"=a"(Acq):"r"(GLptr),"i"(~1L):"dx"); \

FYI, that's what we do in FreeBSD also.  The only difference after your
patch is that we use +m for GLptr.

#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
    do { \
        asm("1:     movl %1,%%eax;" \
            "movl   %%eax,%%edx;" \
            "andl   %2,%%edx;" \
            "btsl   $0x1,%%edx;" \
            "adcl   $0x0,%%edx;" \
            "lock;  cmpxchgl %%edx,%1;" \
            "jnz    1b;" \
            "cmpb   $0x3,%%dl;" \
            "sbbl   %%eax,%%eax" \
            : "=a" (Acq), "+m" (GLptr) : "i" (~1L) : "edx"); \
    } while(0)

-Nate

  reply	other threads:[~2003-12-11 17:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-11  7:27 [ACPI] ACPI global lock macros Yu, Luming
2003-12-11 17:46 ` Nate Lawson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-11  7:06 Yu, Luming
2003-12-11  8:07 ` Andi Kleen
2003-12-11  8:27   ` Paul Menage
2003-12-11  8:20 ` Paul Menage
2003-12-09 18:20 Grover, Andrew
2003-12-09 19:04 ` Paul Menage
2003-12-09 19:03   ` David Mosberger
2003-12-09  9:22 Paul Menage
2003-12-10  7:45 ` [ACPI] " Andi Kleen

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=20031211094510.J50052@root.org \
    --to=nate@root.org \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=agrover@groveronline.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luming.yu@intel.com \
    --cc=menage@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).