From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nate Lawson Subject: RE: ACPI global lock macros Date: Thu, 11 Dec 2003 09:46:30 -0800 (PST) Sender: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Message-ID: <20031211094510.J50052@root.org> References: <3ACA40606221794F80A5670F0AF15F8401720C22@PDSMSX403.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: <3ACA40606221794F80A5670F0AF15F8401720C22-SRlDPOYGfgogGBtAFL8yw7fspsVTdybXVpNB7YpNyf8@public.gmane.org> Errors-To: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: "Yu, Luming" Cc: Paul Menage , agrover-qb8aLOKklSjp4P8CbLYnNQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-acpi@vger.kernel.org On Thu, 11 Dec 2003, Yu, Luming wrote: > -----Original Message----- > From: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org [mailto:acpi-devel-admin@lists.sourceforge.net]On Behalf Of Yu, Luming > Sent: 2003?12?11? 15:06 > To: Paul Menage; agrover-qb8aLOKklSjp4P8CbLYnNQ@public.gmane.org > Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/