From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934066AbeAXOYy (ORCPT ); Wed, 24 Jan 2018 09:24:54 -0500 Received: from mga02.intel.com ([134.134.136.20]:63970 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933651AbeAXOYx (ORCPT ); Wed, 24 Jan 2018 09:24:53 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,408,1511856000"; d="scan'208";a="29122803" Date: Wed, 24 Jan 2018 16:24:48 +0200 From: Mika Westerberg To: Sinan Kaya Cc: Wolfram Sang , Eric Auger , eric.auger.pro@gmail.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, "linux-acpi@vger.kernel.org" , "Rafael J. Wysocki" , Lan Tianyu Subject: Re: [PATCH v2] i2c: Allow ACPI_I2C_OPREGION if I2C is built as a module Message-ID: <20180124142448.GS27654@lahna.fi.intel.com> References: <1514988151-12248-1-git-send-email-eric.auger@redhat.com> <20180124055615.c3qwhwnj7spmcr3w@ninjato> <20180124062725.GK27654@lahna.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 24, 2018 at 08:29:44AM -0500, Sinan Kaya wrote: > +linux-acpi > > On 1/24/2018 1:27 AM, Mika Westerberg wrote: > > On Wed, Jan 24, 2018 at 06:56:16AM +0100, Wolfram Sang wrote: > >> On Wed, Jan 03, 2018 at 03:02:31PM +0100, Eric Auger wrote: > >>> If I2C is built as a module, ACPI_I2C_OPREGION cannot be set > >>> and any ACPI opregion calls targeting I2C fail with no opregion found. > >>> > >>> This patch allows ACPI_I2C_OPREGION to be enabled both if I2C is > >>> built into the kernel or built as a module. > >>> > >>> Signed-off-by: Eric Auger > >> > >> I recall that we had some discussion until ending up with the current > >> solution. And I finally found it again: > >> > >> http://www.serverphorums.com/read.php?12,1001402 > >> > >> In any case, I surely want Mika's ack on any change to ACPI related > >> Kconfig symbols. Adding him to CC... > > > > So the problem is/was that what happens if you are in a middle of BIOS > > AML code touching the opregion and someone unloads the opregion handler? > > If you can quarantee nothing bad happens, then I'm fine with the patch :) > > > > Rafael to correct me if I got this right. > > The behavior of the operating system is well defined in the ACPI specification. > > Here is what I tested recently: > > ACPI defines _REG method to inform firmware of presence/removal of an operating > region. > > When driver gets loaded, ACPI calls the _REG method with 1 argument. When driver > gets unloaded, ACPI call the _REG method with 0 argument. > > Firmware can use this notification to its advantage to determine when an I2C > related functionality should be accessed or not. > > If firmware doesn't use the _REG method, ACPI defines that AML statements > accessing the operating region are ignored. > > You'll also see a warning from ACPICA saying the OperatingRegion 9 is no longer > accessible and AML code execution failed. > > Also note that someone can always unbind an I2C driver from ACPI even with built-in > module. Yes, that's right. However, the I2C core parts are not removed when you unbind a driver and the imporant piece is i2c_acpi_space_handler() which then stays in the memory even if any of the drivers get removed. After this patch you can also remove the i2c_acpi_space_handler() which might cause issues if there is AML code running at the same time using the opregion. Commit da3c6647ee08 ("I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config") says following: Current there is a race between removing I2C ACPI operation region and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI is set. But I don't remember all the details unfortunately so adding Rafael and Tianyu if they can shed some more light into this ;-)