Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2129618imb; Sun, 3 Mar 2019 19:19:05 -0800 (PST) X-Google-Smtp-Source: APXvYqydo+MQOYR4vsW5bdHOOBlsU9ieFuqJS4x2BuRUPy5zWRFm1GGz6bhyybMEF+XOa/7zH5Do X-Received: by 2002:a63:3d7:: with SMTP id 206mr16145745pgd.350.1551669545233; Sun, 03 Mar 2019 19:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551669545; cv=none; d=google.com; s=arc-20160816; b=RAC6Ifzw3F+XlPhChVEm3jc+sck7G5lr9qFh7zyUuXqR9pMagbPi8Z6UzkomRcvAov sRdq7xEMA1PWwKkcTJ6I6wbTZXT1r5ADltFMapdk3rtWrVb6kTm9Jgd5/Qa/WbXstJca cR3f1n+hNq6qgJgMaewYKLUcwod/LkBkfALgtryQpTCtagfRc0pWREf4CS6MZooMyw51 ww69K6/MI5xaQYmzIz5cg7UcXTLBHmorPCJ6No8DG3DB9+eRugRmOUu3k3+f6quw/6ga EYeN2brmHUHWio/kQqPSwzJ1r8BQDwcGFxNWeCRNZcoyy9SMzFRMg4opL9E5lTeQf1pD RlPw== 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 :message-id:date:subject:cc:from; bh=p+BCB5XJg/v5PULjT+F+aE+SjsWoSd8K0JYYO9XdH0U=; b=QGl0gj9fagpco6KR4AUxbwcR3hj6NiqDjuIHQP05q2QPwe+niRvjxpNCsBixkblvlJ 4tesMuyfPfvN+2HwfGzV31Kln4JvPiCWpVt4piyKj4pYAWQmU1Gylobn5rNrDI/vHcF8 9dUwNqGJN/fid3ROH6k0I9JG2P570nJ7jC9rSjhZUdkySQq/ff0DS6rRWat6joca5vZM qaEyJYbdlKBqS4Ggdkz13EvDatTzsiMTDM26VHFv/5sP2GSbRh02BluSvqJolMrJFavG 4rNrnd1g7FDWq531lOFT+oQPO1SW7cpibbBUPX9mO08/fnrVGtRtxCzrSKfa1OpR10o+ 0X9g== 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 m22si3995890pgv.562.2019.03.03.19.18.47; Sun, 03 Mar 2019 19:19:05 -0800 (PST) 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 S1726037AbfCDDS0 (ORCPT + 99 others); Sun, 3 Mar 2019 22:18:26 -0500 Received: from mga09.intel.com ([134.134.136.24]:10356 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfCDDS0 (ORCPT ); Sun, 3 Mar 2019 22:18:26 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2019 19:18:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,438,1544515200"; d="scan'208";a="279475356" Received: from hu.sh.intel.com ([10.239.158.51]) by orsmga004.jf.intel.com with ESMTP; 03 Mar 2019 19:18:23 -0800 From: "Chen, Hu" Cc: hu1.chen@intel.com, "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI / PM: Propagate KEY_POWER wakeup events to user space Date: Mon, 4 Mar 2019 11:00:21 +0800 Message-Id: <20190304030022.22492-1-hu1.chen@intel.com> X-Mailer: git-send-email 2.20.1 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 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. 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