Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4362124imm; Mon, 11 Jun 2018 11:01:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJRiAaxPeDUL5DDbT4F8m5dTkUMP4UPblodViVfmibxY/LqvNpS6cvuEwGdxLfHmAz0/mHv X-Received: by 2002:a63:7001:: with SMTP id l1-v6mr184672pgc.358.1528740076546; Mon, 11 Jun 2018 11:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528740076; cv=none; d=google.com; s=arc-20160816; b=b1qCIs0oyVPaomPhvZYnD/O5x0LNIaWvlJ/dWw1GaIDD/aXxQgwfx7JSXQfJWVkllr rgSXVaiuu7Ubaw0pPS5Ap7/j+CV8bK/QQTYg9iI0s3n5YNTWoapPPImDzQwusf5W41cc UfXcUe6igIKwP2G+5lowcd5rGxXa1rKtKKzevwpUEsCb2ROD434y7R33ArQYU6F664ja PxQaA2e7nA+HpvF0GOtVXbr5erBpBlB1qveA180qnBcEV3hnYIRFetH+hhVq2y51+nzz ijJ0flb9jHPlADsy7zQCc9WgLkiJzcE2D7ZHP51ftgnJ+6BWSUzXv9eUMq6BSpAQEJON kK3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=zpWNBfoGxwT7agTpDOavD9TWXLeX5cvkMqjV9IQ59+I=; b=xdPgCacfZSPieAAnkVaEoCO7hv/24vwdwNg9uMDhhn0Ef32IsqSfduC2egtcEOv2HY cQVa23VykPmsnfX82EabjINRXsqZ7IksXds7ljyqBxaKuYmgh8artAPFGZtgN5yZKyXP Crp8bhhMue8NPp0IcSpwQtPkqwU6Yyj3gaBCkUYEZr71aNIUDyrYN4ZWfPyJimMILv5U Ht6kmLv+ZD1PlZH0jGu7lmkDAAnvyjFWfQJGtoXGu9uv/qcxKzyVaYZYohLy7UiFX4rX U1Ke7M9b5/HANg+FRua5Mtbh2+lBVYVvzfBL2OpaU8JlqxpbsEcLYhqj0FU3/cPZYVtz c6WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jGvhzr07; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12-v6si30050016pgp.561.2018.06.11.11.01.01; Mon, 11 Jun 2018 11:01:16 -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; dkim=pass header.i=@chromium.org header.s=google header.b=jGvhzr07; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933577AbeFKR7D (ORCPT + 99 others); Mon, 11 Jun 2018 13:59:03 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36893 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932647AbeFKR7B (ORCPT ); Mon, 11 Jun 2018 13:59:01 -0400 Received: by mail-pf0-f195.google.com with SMTP id y5-v6so9731494pfn.4 for ; Mon, 11 Jun 2018 10:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zpWNBfoGxwT7agTpDOavD9TWXLeX5cvkMqjV9IQ59+I=; b=jGvhzr07gSVdx+gdIr0uitQjVSklkbD3tPTsIfwYza2U+nEg1Zi/QsoqQU4HK2WFNg thr7+9xUY2TdPEEh0cGC77bg+/5bkSgbprdvcCsU4Rk77t3wh9v3fx3iLdXt8UIWRTn2 rh+KlnY+Y5XAtJ8LwwVxH8Dn17SB2JEOYkuj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zpWNBfoGxwT7agTpDOavD9TWXLeX5cvkMqjV9IQ59+I=; b=bTqNY8e9T36ArkGQFpLaKoBxnAHF2SUZ8zX3yA2nQER95SgaCz+kuXBakvn/AgSSea WbpV0k1J4KPS1HiTIkeg0WqNP0fNsgon0rTTWG9UhHUDVAngPQwhkc64UNKo9eyD/RJ2 gbDFd8FiWQy+xPKY8fk20wTUEuiTvK1Ct1u/F4gdosqPiGy1dHdFa6CwFFPWL7TXw5h6 BmozmGtFk2H/Oyf01/niN709apwFJyCu5q2jbspjhOPwxv4le+zf5mXy3L6GDb7bng2M 7fJ5bzH/kQ80vyBzKD0P2mBeLYkkycmLmLfxkKDmJi0mJpMdL5QlP/jmSFKZwA0J79tM XgYw== X-Gm-Message-State: APt69E1FbIa2VMCTOXQ8ivJGWmLUCM5P0HklwuBrSpd8s1SxH+vtWvsi 5zqU33+MTkdGDosX4yWqavELeAzwIsc= X-Received: by 2002:a62:ca99:: with SMTP id y25-v6mr166675pfk.187.1528739941289; Mon, 11 Jun 2018 10:59:01 -0700 (PDT) Received: from ravisadineni0.mtv.corp.google.com ([2620:0:1000:1501:1f1:adfa:a458:823f]) by smtp.gmail.com with ESMTPSA id w19-v6sm78377806pgv.59.2018.06.11.10.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 10:59:00 -0700 (PDT) From: Ravi Chandra Sadineni To: rjw@rjwysocki.net, lenb@kernel.org, ravisadineni@chromium.org, ravisadineni@google.com Cc: dmitry.torokhov@gmail.com, tbroch@google.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, rajatja@google.com, bleung@google.com, furquan@chromium.org Subject: [PATCH V2] ACPI LID: increment wakeup count only when notified. Date: Mon, 11 Jun 2018 10:57:59 -0700 Message-Id: <20180611175759.181681-1-ravisadineni@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a-goog In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently ACPI LID increments wakeup count irrespective of the wake source. This is because we call acpi_lid_initialize_state on every resume. Userland deamons using wakeup_count to identify the potential wake source for the last wake will be thrown off by this. Instead increment the wakeup count only when there is a FIXED_HARDWARE/NOTFIY_STATUS event. Signed-off-by: Ravi Chandra Sadineni --- V2: Increment the wakeup count only when the lid is open. drivers/acpi/button.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 2345a5ee2dbbc..d2fe03e4faf05 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -235,9 +235,6 @@ static int acpi_lid_notify_state(struct acpi_device *device, int state) button->last_time = ktime_get(); } - if (state) - acpi_pm_wakeup_event(&device->dev); - ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, device); if (ret == NOTIFY_DONE) ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, @@ -366,7 +363,8 @@ int acpi_lid_open(void) } EXPORT_SYMBOL(acpi_lid_open); -static int acpi_lid_update_state(struct acpi_device *device) +static int acpi_lid_update_state(struct acpi_device *device, + bool is_notification) { int state; @@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct acpi_device *device) if (state < 0) return state; + if (state && is_notification) + acpi_pm_wakeup_event(&device->dev); + return acpi_lid_notify_state(device, state); } @@ -384,7 +385,7 @@ static void acpi_lid_initialize_state(struct acpi_device *device) (void)acpi_lid_notify_state(device, 1); break; case ACPI_BUTTON_LID_INIT_METHOD: - (void)acpi_lid_update_state(device); + (void)acpi_lid_update_state(device, false); break; case ACPI_BUTTON_LID_INIT_IGNORE: default: @@ -409,7 +410,7 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) users = button->input->users; mutex_unlock(&button->input->mutex); if (users) - acpi_lid_update_state(device); + acpi_lid_update_state(device, true); } else { int keycode; -- 2.18.0.rc1.242.g61856ae69a-goog