RE: [PATCH] ACPICA: Export mutex functions

From: Zheng, Lv
Date: Mon Apr 17 2017 - 05:40:05 EST


Hi,

> From: Guenter Roeck [mailto:linux@xxxxxxxxxxxx]
> Subject: Re: [PATCH] ACPICA: Export mutex functions
>
> On Wed, Apr 12, 2017 at 03:29:55PM +0000, Moore, Robert wrote:
> > The ACPICA mutex functions are based on the host OS functions, so they don't really buy you anything.
> You should just use the native Linux functions.
> >
>
> You mean they don't really acquire the requested ACPI mutex,
> and the underlying DSDT which declares and uses the mutex
> just ignores if the mutex was acquired by acpi_acquire_mutex() ?
>
> To clarify: You are saying that code such as
>
> acpi_status status;
>
> status = acpi_acquire_mutex(NULL, "\\_SB.PCI0.SBRG.SIO1.MUT0", 0x10);
> if (ACPI_FAILURE(status)) {
> pr_err("Failed to acquire ACPI mutex\n");
> return -EBUSY;
> }

Why do you need to access \_SB.PCI0.SBRG.SIO1.MUT0?
OSPM should only invoke entry methods predefined by ACPI spec or whatever specs.
There shouldn't be any needs that a driver acquires an arbitrary AML mutex.
You do not seem to have justified the usage model, IMO.

Thanks
Lv

> ...
>
> when used in conjunction with
>
> ...
> Mutex (MUT0, 0x00)
> Method (ENFG, 1, NotSerialized)
> {
> Acquire (MUT0, 0x0FFF)
> ...
> }
>
> doesn't really provide exclusive access to the resource(s) protected
> by MUT0, even if acpi_acquire_mutex() returns ACPI_SUCCESS ?
>
> Outch. Really ?
>
> Thanks,
> Guenter
>
> >
> > > -----Original Message-----
> > > From: Guenter Roeck [mailto:linux@xxxxxxxxxxxx]
> > > Sent: Wednesday, April 12, 2017 8:13 AM
> > > To: Moore, Robert <robert.moore@xxxxxxxxx>; Zheng, Lv
> > > <lv.zheng@xxxxxxxxx>; Wysocki, Rafael J <rafael.j.wysocki@xxxxxxxxx>;
> > > Len Brown <lenb@xxxxxxxxxx>
> > > Cc: linux-acpi@xxxxxxxxxxxxxxx; devel@xxxxxxxxxx; linux-
> > > kernel@xxxxxxxxxxxxxxx; Guenter Roeck <linux@xxxxxxxxxxxx>
> > > Subject: [PATCH] ACPICA: Export mutex functions
> > >
> > > Mutex functions may be needed by drivers. Examples are accesses to
> > > Super-IO SIO registers (0x2e/0x2f or 0x4e/0x4f) or Super-IO
> > > environmental monitor registers, both which may also be accessed through
> > > DSDT.
> > >
> > > Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> > > ---
> > > drivers/acpi/acpica/utxfmutex.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/acpi/acpica/utxfmutex.c
> > > b/drivers/acpi/acpica/utxfmutex.c index c016211c35ae..5d20581f4b2f
> > > 100644
> > > --- a/drivers/acpi/acpica/utxfmutex.c
> > > +++ b/drivers/acpi/acpica/utxfmutex.c
> > > @@ -150,6 +150,7 @@ acpi_acquire_mutex(acpi_handle handle, acpi_string
> > > pathname, u16 timeout)
> > > status = acpi_os_acquire_mutex(mutex_obj->mutex.os_mutex, timeout);
> > > return (status);
> > > }
> > > +ACPI_EXPORT_SYMBOL(acpi_acquire_mutex)
> > >
> > >
> > > /***********************************************************************
> > > ********
> > > *
> > > @@ -185,3 +186,4 @@ acpi_status acpi_release_mutex(acpi_handle handle,
> > > acpi_string pathname)
> > > acpi_os_release_mutex(mutex_obj->mutex.os_mutex);
> > > return (AE_OK);
> > > }
> > > +ACPI_EXPORT_SYMBOL(acpi_release_mutex)
> > > --
> > > 2.7.4
> >