Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbdHKGNN convert rfc822-to-8bit (ORCPT ); Fri, 11 Aug 2017 02:13:13 -0400 Received: from mga11.intel.com ([192.55.52.93]:58211 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbdHKGNL (ORCPT ); Fri, 11 Aug 2017 02:13:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,356,1498546800"; d="scan'208";a="1161571979" From: "Zheng, Lv" To: "Rafael J. Wysocki" CC: Linux ACPI , Mika Westerberg , Srinivas Pandruvada , Linux PCI , LKML , "Moore, Robert" Subject: RE: [PATCH 2/3] ACPICA: Make it possible to enable runtime GPEs earlier Thread-Topic: [PATCH 2/3] ACPICA: Make it possible to enable runtime GPEs earlier Thread-Index: AQHTEWDc2BzXk7gyuk2HOv4Vi/PTWaJ800cwgABpf4CAAXIcoA== Date: Fri, 11 Aug 2017 06:13:07 +0000 Message-ID: <1AE640813FDE7649BE1B193DEA596E886CF0A0C5@SHSMSX101.ccr.corp.intel.com> References: <12346760.yAFCnkEgf6@aspire.rjw.lan> <51836747.M49Hy56X72@aspire.rjw.lan> <1AE640813FDE7649BE1B193DEA596E886CF06700@SHSMSX101.ccr.corp.intel.com> <3742420.ImyUv4XNlU@aspire.rjw.lan> In-Reply-To: <3742420.ImyUv4XNlU@aspire.rjw.lan> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDcyMGZjNjgtM2RhYi00ZDA4LWE3ZDctZWJhN2U0OTM0M2U1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InFaYU5laVc1M2hhVTloXC9xc0ZNMWJ2RkNDZVh5TzdvNEJqTWRoQmo5WDBJPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4846 Lines: 109 Hi, > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net] > Subject: Re: [PATCH 2/3] ACPICA: Make it possible to enable runtime GPEs earlier > > On Thursday, August 10, 2017 3:52:05 AM CEST Zheng, Lv wrote: > > Hi, Rafael > > > > For this patch, I have a concern. > > > > > From: Rafael J. Wysocki [mailto:rjw@rjwysocki.net] > > > Subject: [PATCH 2/3] ACPICA: Make it possible to enable runtime GPEs earlier > > > > > > From: Rafael J. Wysocki > > > > > > Runtime GPEs have corresponding _Lxx/_Exx methods and are enabled > > > automatically during the initialization of the ACPI subsystem through > > > acpi_update_all_gpes() with the assumption that acpi_setup_gpe_for_wake() > > > will be called in advance for all of the GPEs pointed to by _PRW > > > objects in the namespace that may be affected by acpi_update_all_gpes(). > > > That is, acpi_ev_initialize_gpe_block() can only be called for a GPE > > > block after acpi_setup_gpe_for_wake() has been called for all of the > > > _PRW (wakeup) GPEs in it. > > > > > > The platform firmware on some systems, however, expects GPEs to be > > > enabled before the enumeration of devices which is when > > > acpi_setup_gpe_for_wake() is called and that goes against the above > > > assumption. > > > > > > For this reason, introduce a new flag to be set by > > > acpi_ev_initialize_gpe_block() when automatically enabling a GPE > > > to indicate to acpi_setup_gpe_for_wake() that it needs to drop the > > > reference to the GPE coming from acpi_ev_initialize_gpe_block() > > > and modify acpi_setup_gpe_for_wake() accordingly. These changes > > > allow acpi_setup_gpe_for_wake() and acpi_ev_initialize_gpe_block() > > > to be invoked in any order. > > > > > > Signed-off-by: Rafael J. Wysocki > > > --- > > > drivers/acpi/acpica/evgpeblk.c | 2 ++ > > > drivers/acpi/acpica/evxfgpe.c | 8 ++++++++ > > > include/acpi/actypes.h | 3 ++- > > > 3 files changed, 12 insertions(+), 1 deletion(-) > > > > > > Index: linux-pm/drivers/acpi/acpica/evgpeblk.c > > > =================================================================== > > > --- linux-pm.orig/drivers/acpi/acpica/evgpeblk.c > > > +++ linux-pm/drivers/acpi/acpica/evgpeblk.c > > > @@ -496,6 +496,8 @@ acpi_ev_initialize_gpe_block(struct acpi > > > continue; > > > } > > > > > > + gpe_event_info->flags |= ACPI_GPE_AUTO_ENABLED; > > > + > > > if (event_status & ACPI_EVENT_FLAG_STATUS_SET) { > > > ACPI_INFO(("GPE 0x%02X active on init", > > > gpe_number)); > > > Index: linux-pm/include/acpi/actypes.h > > > =================================================================== > > > --- linux-pm.orig/include/acpi/actypes.h > > > +++ linux-pm/include/acpi/actypes.h > > > @@ -783,7 +783,7 @@ typedef u32 acpi_event_status; > > > * | | | | +-- Type of dispatch:to method, handler, notify, or none > > > * | | | +----- Interrupt type: edge or level triggered > > > * | | +------- Is a Wake GPE > > > - * | +--------- Is GPE masked by the software GPE masking mechanism > > > + * | +--------- Has been enabled automatically at init time > > > * +------------ > > > */ > > > #define ACPI_GPE_DISPATCH_NONE (u8) 0x00 > > > @@ -799,6 +799,7 @@ typedef u32 acpi_event_status; > > > #define ACPI_GPE_XRUPT_TYPE_MASK (u8) 0x08 > > > > > > #define ACPI_GPE_CAN_WAKE (u8) 0x10 > > > +#define ACPI_GPE_AUTO_ENABLED (u8) 0x20 > > > > > > /* > > > * Flags for GPE and Lock interfaces > > > Index: linux-pm/drivers/acpi/acpica/evxfgpe.c > > > =================================================================== > > > --- linux-pm.orig/drivers/acpi/acpica/evxfgpe.c > > > +++ linux-pm/drivers/acpi/acpica/evxfgpe.c > > > @@ -435,6 +435,14 @@ acpi_setup_gpe_for_wake(acpi_handle wake > > > */ > > > gpe_event_info->flags = > > > (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED); > > > + } else if (gpe_event_info->flags & ACPI_GPE_AUTO_ENABLED) { > > > + /* > > > + * A reference to this GPE has been added during the GPE block > > > + * initialization, so drop it now to prevent the GPE from being > > > + * permanently enabled and clear its ACPI_GPE_AUTO_ENABLED flag. > > > + */ > > > + (void)acpi_ev_remove_gpe_reference(gpe_event_info); > > > + gpe_event_info->flags &= ~ACPI_GPE_AUTO_ENABLED; > > > > The problem is if the GPE is shared, how can we know decrement reference > > once can sufficiently convert it into wakeup dispatcher owned GPE? > > Even if it is shared, the current code will not enable it if it sees > ACPI_GPE_CAN_WAKE set. > > We can change that logic, but that should be a separate patch IMO and > this is not related to the problem at hand. OK, I see. We can enhance that on top of these fixes. Thanks, Lv