Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4690915img; Tue, 26 Mar 2019 14:50:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxC5RtCX1Yf3IHygIUX1zB8hliGfcR3QIMAOwmMTAF2vCo1H2Y75jRTUmPFWrg/RlLdHY55 X-Received: by 2002:a17:902:1:: with SMTP id 1mr32649645pla.226.1553637033102; Tue, 26 Mar 2019 14:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553637033; cv=none; d=google.com; s=arc-20160816; b=Mc91f1W562PJSrRtwFQX5tSp5pWx5XtbbtqR3VUq3vRXdqbhjzViNDugfKGdzSrh6X c8eFzo/StPTga4Pnlk0ymecNm1OLxx7RYQ5uhc2fLG0dgAlgrfFXtubnt6ndiWKAjrbd s8cn7ZpTvQRFxqwmNCehhR/9IeP7CEl2MLcfgVMIiHpk/jucezSN1YVuZx1gjakLaTUC Ayx/tWgwm9zXORVoqpaNavfQNmyilU3MtdwFTvN1pCdJwnyH6tPeAUiNLzlDcKO3R8lE BYTyy0c6Ht+ejkW0BpRdOEPAy5dfTiWuS1tmQre+S2Sy+dvQwJ0HMWWGEY2PbJlF0Kvl gw/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ckZMXmgmcgR8XrCw5AW2X6vn32D44/9t62wX0hdzI64=; b=MxhXKvOqf5fJRwX5ZdZSZCEhuZkqvrVoffn0OVwH7wXq7M/3sC4mLuWhDQQT7G7DcN A/0EIx2RYvZlyISoPV+WpxPSl3tCkxzKywEyXOvKM9P7pi8qimeoAe5NdkhnV4uY8li5 MN/6DYBbONls2FMGEvQiId7I9mUpT5S+6wDLpwh0nv/IVQVo624STmvhAujIcuJDamaD bDu29QhKN1e1c9jqaecSK3YGqzG0ebHs2TlEs8hC/pAqQVKAgv7vMhXF9hzRDftvKO3u 6FAMz7GK8YbWJGbWL7d/zNKlIXwLmPqp76sbUVeumAGiO/V4lOvP85c4BeH86ydakP/i oUVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g188si16730341pgc.88.2019.03.26.14.50.17; Tue, 26 Mar 2019 14:50:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731859AbfCZVtn (ORCPT + 99 others); Tue, 26 Mar 2019 17:49:43 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:33247 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbfCZVtn (ORCPT ); Tue, 26 Mar 2019 17:49:43 -0400 Received: by mail-ot1-f68.google.com with SMTP id j10so6511765otq.0; Tue, 26 Mar 2019 14:49:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ckZMXmgmcgR8XrCw5AW2X6vn32D44/9t62wX0hdzI64=; b=T8z8/hHhc10aEYB3t6+SoIfRsXIx/AEhiOTJRg4Nkyxm91xyzpNmOrH1OGrXRc205/ KXHjkEQLOra9emSgIGTWx8WCDlu6YJPFFbUY755tsSZSYeiu1WvVfF9CJqkiEkHI/3co Ht0jF9o2Z6+LOZhSlP6gC+2ztQbz0AL3ZZNYX8a6DP8Br5HKdcoIVfsoF7m+NaFjvL50 b4vvjuHT/xF1iNrxCFOVlOHsiyQYjCMVLn+9yFcEiEDSq5wI66qP1Qpv//r9jE9JfhCC d8PTaifC0BOD+L6NrJG3ImqErwtAF29qPyKftnMYHnntv78KsEHnB5d36crxGsIpwLPK hiWA== X-Gm-Message-State: APjAAAWdpW98yRJTd6GVEtijnQ29GSgwFkp5n7A3LNjgEr5jutlIiYZd nkIpwH4Xv0A0iSoIUYTjExS/i1OP8CJ5bLtlxgg= X-Received: by 2002:a9d:6498:: with SMTP id g24mr24900948otl.343.1553636982407; Tue, 26 Mar 2019 14:49:42 -0700 (PDT) MIME-Version: 1.0 References: <20190304030022.22492-1-hu1.chen@intel.com> In-Reply-To: <20190304030022.22492-1-hu1.chen@intel.com> From: "Rafael J. Wysocki" Date: Tue, 26 Mar 2019 22:49:32 +0100 Message-ID: Subject: Re: [PATCH] ACPI / PM: Propagate KEY_POWER wakeup events to user space To: "Chen, Hu" Cc: "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 4, 2019 at 4:18 AM Chen, Hu wrote: > > When the system is woken from S3 by the ACPI fixed power button, send > KEY_POWER to user space. > > I run Android on x86 PC (it's a NUC). Everytime I press the power button > to wake the system, it suspends right away. After some debug, I find > that Android wants to see KEY_POWER at resume. Otherwise, its > opportunistic suspend will kick in shortly. Alas that extra button event will cause other (non-Android) systems to want to power off immediately after resume AFAICS. Something else needs to be done for the Android case. > Signed-off-by: Chen, Hu > --- > drivers/acpi/button.c | 4 +++- > drivers/acpi/sleep.c | 8 ++++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c > index a19ff3977ac4..117718057938 100644 > --- a/drivers/acpi/button.c > +++ b/drivers/acpi/button.c > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > > #define PREFIX "ACPI: " > > @@ -417,7 +418,8 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) > int keycode; > > acpi_pm_wakeup_event(&device->dev); > - if (button->suspended) > + if (button->suspended && > + mem_sleep_current == PM_SUSPEND_TO_IDLE) > break; > > keycode = test_bit(KEY_SLEEP, input->keybit) ? > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c > index 403c4ff15349..c5dcee9f5872 100644 > --- a/drivers/acpi/sleep.c > +++ b/drivers/acpi/sleep.c > @@ -462,6 +462,13 @@ static int find_powerf_dev(struct device *dev, void *data) > return !strcmp(hid, ACPI_BUTTON_HID_POWERF); > } > > +static void pwr_btn_notify(struct device *dev) > +{ > + struct acpi_device *device = to_acpi_device(dev); > + > + device->driver->ops.notify(device, ACPI_FIXED_HARDWARE_EVENT); > +} > + > /** > * acpi_pm_finish - Instruct the platform to leave a sleep state. > * > @@ -505,6 +512,7 @@ static void acpi_pm_finish(void) > find_powerf_dev); > if (pwr_btn_dev) { > pm_wakeup_event(pwr_btn_dev, 0); > + pwr_btn_notify(pwr_btn_dev); > put_device(pwr_btn_dev); > } > } > -- > 2.20.1 >