Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1382105ybb; Fri, 29 Mar 2019 03:27:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCBkyVtG1CHJlowI16RhCeuqLWEmVjAtms85HTksQhq4szyt9cs4ph0usMS/pXreHJuMbs X-Received: by 2002:a63:6fcf:: with SMTP id k198mr32527746pgc.158.1553855267212; Fri, 29 Mar 2019 03:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553855267; cv=none; d=google.com; s=arc-20160816; b=HYXfuM23DhmkpXvc2Oz3DTZSUGvEMgtyCZC+CaBfs88exAIhZKgx/VS4wA0q+iPoRY OFODaMqkECtF4pWMRROH/KDNr6sHI5j0WhnExVYERuVfJf4HZcrotGsJXoX10v6PRBc2 oekkwRqd8yQ79IuZbEChe9gtgIHzRni5/wyygpphdjtWgdoykcQnhoeYNa+rAYct3YIN YfV8UT0DRepnyENPjgPZX3oc81Y4afEDSdCDp0bx6g9cehRO3g/ruI2opVIpNzo9+wAl 4IgJ+vY2YpFCwSEB1yuuouNyi50XQZcweMtsuEsEkrbFbbDjv/+FsDhxuKpWHld/g70B c+Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ayo+OfFp5/ZQ6K8ioTtT+1QjiB+iC4hziTM6yt2Y9P0=; b=k6n/rAZ/SzJzqJi6q6vhPKwqdU1ilCJQ9UraOyABPnQdj8noT9KbFkW4bUMvRQd4SX GiWHzZLwHMiiU8p/r7cMm5cvKE5aDRa0GAjeq219tm30OR+XjriWutme7fH1vI5qALa1 2hRSy/OUp8gmWYyPPF9J5OwsS8racHJ6bcrfjvMD3fmFeMTpHMDCyeE4aqmduyaYuV4q K5gZSJBS5un2JW4ZUkVipPbj58eMy00De5GshvY5gmC60xnZc4dPOllNV0zMKQ63cvXC twQAVPQaNG+0yTv2xKtxmsK+c27esNm2O5xrnpPF14QKICXizVEWD3v4xcIOzrKBIP3h YS7w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o16si643080pgj.392.2019.03.29.03.27.31; Fri, 29 Mar 2019 03:27:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728832AbfC2KZb (ORCPT + 99 others); Fri, 29 Mar 2019 06:25:31 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:56714 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbfC2KZb (ORCPT ); Fri, 29 Mar 2019 06:25:31 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 2302E8059A; Fri, 29 Mar 2019 11:25:20 +0100 (CET) Date: Fri, 29 Mar 2019 11:25:20 +0100 From: Pavel Machek To: "Chen, Hu" Cc: hdegoede@redhat.com, "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ACPI / PM: Propagate KEY_POWER to user space when resume Message-ID: <20190329102519.GA11784@atrey.karlin.mff.cuni.cz> References: <20190328103448.20335-1-hu1.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190328103448.20335-1-hu1.chen@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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. > > However, other OS such as Ubuntu doesn't like KEY_POWER at resume. So > add a knob "/sys/module/button/parameters/key_power_at_resume" for users > to select. > > Signed-off-by: Chen, Hu NAK. Fix android, lets not break kernel. Pavel > --- > > drivers/acpi/button.c | 6 +++++- > drivers/acpi/sleep.c | 8 ++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c > index a19ff3977ac4..f98e6d85dd2b 100644 > --- a/drivers/acpi/button.c > +++ b/drivers/acpi/button.c > @@ -129,6 +129,10 @@ struct acpi_button { > bool suspended; > }; > > +/* does userspace want to see KEY_POWER at resume? */ > +static bool key_power_at_resume __read_mostly; > +module_param(key_power_at_resume, bool, 0644); > + > static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); > static struct acpi_device *lid_device; > static u8 lid_init_state = ACPI_BUTTON_LID_INIT_METHOD; > @@ -417,7 +421,7 @@ 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 && !key_power_at_resume) > 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); > } > } -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html