Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp347473ybb; Thu, 28 Mar 2019 03:53:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqykH8ZpLGZKmsJwzBCUKfJHLCr+mrF+H+yfCY1Um4l5Udd4ie9/tF2WjAPP9DebvmPupOYN X-Received: by 2002:aa7:9151:: with SMTP id 17mr5150223pfi.192.1553770427933; Thu, 28 Mar 2019 03:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553770427; cv=none; d=google.com; s=arc-20160816; b=N9fVYbuBr/WGsWWY92EJW1youVinEDrSlnr4qETf7TxRL8x8Oak8CWZwm74/x6zQjU 7ni5LOVD5J+gFqeo/YVxihtUcV4A8FStEri0xyM3xiNEcYnIYkU8J9Pvp9N79ccTuE+E PRB9VS2H20STYPuVpe0Qg4m1VT0jtIVwQhX0Rsh04+fT2LGlzMVXRFK45anhUmPm3K+D DIyJ1+c8D/yRKhxEsyT3W9JBXOgwsrh55S8mCMQOUxCzTOmiHje9ancI+ODqH8sHz1jf HuWVINGwLc3vlbfx9xahRdGc7ddcLJ1IpbqSwzGq8SXnXP65obn3GsuM0HfKrgy0y5kf p7gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=G1GqItkqUgfs2hQvbZiJF4qZeWb2sXRNf7n8P4nhZVg=; b=tHQPVoYkgy66eXh8delfFvOe5NkXBvadpKM581+tEG+1hJWF7/LjIyR1HUOnSoTD4Z lvHGr18HLUEirpqYbw9plhuwmegsxa8WTCBV/MV8eRBFa7goyUTf8rHFPxRIguqZmSKF 9TT6v9cvdsB9fD/IWSl9S27U/oHY+hFE4IM+QIDKphktCnyj+cD0ULZ8uW4tfp3LaPFB vrcYKvIIE0yC3D2XTzjeqXL9/ybfszJd9K3ygUdC9tjNYci9hjow+wEBrb36jjOru3lq S3Qg6XzFgEjPsfS1ygSC0fa1eiKxA8BEwcZvwuBvDiUeGODubbxRSH2vnTxWsFGZWNsV vSuw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si17108878pgx.484.2019.03.28.03.53.31; Thu, 28 Mar 2019 03:53: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbfC1Kw4 (ORCPT + 99 others); Thu, 28 Mar 2019 06:52:56 -0400 Received: from mga12.intel.com ([192.55.52.136]:53260 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbfC1Kw4 (ORCPT ); Thu, 28 Mar 2019 06:52:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 03:52:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="311114446" Received: from hu.sh.intel.com ([10.239.158.51]) by orsmga005.jf.intel.com with ESMTP; 28 Mar 2019 03:52:54 -0700 From: "Chen, Hu" Cc: hdegoede@redhat.com, "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ACPI / PM: Propagate KEY_POWER to user space when resume Date: Thu, 28 Mar 2019 18:34:48 +0800 Message-Id: <20190328103448.20335-1-hu1.chen@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) 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 --- 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); } } -- 2.20.1