From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdDQOFS (ORCPT ); Mon, 17 Apr 2017 10:05:18 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:33481 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752373AbdDQOFO (ORCPT ); Mon, 17 Apr 2017 10:05:14 -0400 Subject: Re: [PATCH] ACPICA: Export mutex functions To: "Zheng, Lv" , "Moore, Robert" References: <1492009990-3539-1-git-send-email-linux@roeck-us.net> <94F2FBAB4432B54E8AACC7DFDE6C92E37E5924DB@ORSMSX110.amr.corp.intel.com> <20170412212241.GA12384@roeck-us.net> <1AE640813FDE7649BE1B193DEA596E886CE92A85@SHSMSX101.ccr.corp.intel.com> <1AE640813FDE7649BE1B193DEA596E886CE92ACC@SHSMSX101.ccr.corp.intel.com> Cc: "linux-acpi@vger.kernel.org" , "devel@acpica.org" , "Wysocki, Rafael J" , "linux-kernel@vger.kernel.org" From: Guenter Roeck Message-ID: <146dd98c-b9b6-70c9-ef9e-be11e6e2e323@roeck-us.net> Date: Mon, 17 Apr 2017 07:05:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1AE640813FDE7649BE1B193DEA596E886CE92ACC@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/17/2017 02:48 AM, Zheng, Lv wrote: > Hi, > >> From: Devel [mailto:devel-bounces@acpica.org] On Behalf Of Zheng, Lv >> Sent: Monday, April 17, 2017 5:40 PM >> To: Guenter Roeck ; Moore, Robert >> Cc: linux-acpi@vger.kernel.org; devel@acpica.org; Wysocki, Rafael J ; >> linux-kernel@vger.kernel.org >> Subject: Re: [Devel] [PATCH] ACPICA: Export mutex functions >> >> Hi, >> >>> From: Guenter Roeck [mailto:linux@roeck-us.net] >>> 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 ? > > IMO, the use case you are talking about is commonly seen in an operation region access code. > Most likely, we'll prepare a driver own lock, and use it for both driver initiated accesses and AML initiated accesses. > > Finally, how can the driver writer know which mutex he should acquire? > AML mutexes should be invisible to the OS (except the global lock). > In my experimental code I am using DMI to determine the platform and provide the mutex name to the kernel driver needing it. > So I'm really confused by your argument. > Please explain in details - what the resource is. > Super-IO ports 0x2e, 0x2f. If you look through the Linux kernel, and search for superio_enter(), you'll see where that address space is used (for the most part in watchdog, hwmon, and gpio drivers). You are correct, the resource is in operation region access code. Are you saying that the mutex (and other mutexes) may not be accessed from the OS, ie that the respective ACPI mutex functions are not really supposed to be available for the OS ? Thanks, Guenter > Thanks > Lv > > >>> >>> Outch. Really ? >>> >>> Thanks, >>> Guenter >>> >>>> >>>>> -----Original Message----- >>>>> From: Guenter Roeck [mailto:linux@roeck-us.net] >>>>> Sent: Wednesday, April 12, 2017 8:13 AM >>>>> To: Moore, Robert ; Zheng, Lv >>>>> ; Wysocki, Rafael J ; >>>>> Len Brown >>>>> Cc: linux-acpi@vger.kernel.org; devel@acpica.org; linux- >>>>> kernel@vger.kernel.org; Guenter Roeck >>>>> 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 >>>>> --- >>>>> 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 >>>> >> _______________________________________________ >> Devel mailing list >> Devel@acpica.org >> https://lists.acpica.org/mailman/listinfo/devel >