Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1370856imm; Tue, 2 Oct 2018 07:13:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dJB29fI2eTScKtEt7bGkdQZGntZCXIWtsPL69UGMsRClqTCI1eIcey+05MBw402ZhWnSa X-Received: by 2002:a63:6a86:: with SMTP id f128-v6mr14963359pgc.165.1538489614364; Tue, 02 Oct 2018 07:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538489614; cv=none; d=google.com; s=arc-20160816; b=1Lo3jhYTaUUQ6iBKHeFqn7q7bANyi5gpamerjk8TgSSYQ7jUbqykwkDHNPCc5W1VKb Wm09HbwvbZRDVve7yEz9I2VLFSIdb9FpYVJw8Tc/0urN84f94txRhXyk5sa0v//mp2Ez M9SybucC1MEWxo7xExJUHtls6cXo4kxxOsnTJT6PPURHFt7bHnhcvQ5YxxRmGLyj+QPD T9TWZO2wRnjFHH/5DvmK9rSLyqJuy+DTA5qmXqEF2CIvZGiefWFH7GlUV9E322OK2s1r PCC+qI7+eH2xI0lPKgCJseZu1Gdwguww+gsRF8jgEcMzfKew4ykeFlglnz/SyK8k7zlI GpLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=lYXQKsyFuxp3SNRLwNjJSQCFYbn6I3zMEasXm4cgjEU=; b=P+5DUQ2QiHUbLWwW+UixkgCqhdepS8c9KM7Z5ZTT7hUWolgNU5OvB/RFrnCLpfFvsp a0Svg+zzVV5NeuKbafIYoyNGisTL3CwmuEoLntSHZM8Gf3UsjOutoZsFMv8R1kw/SrEb lmdCzhzS9ROvqtNbq8Rnhk4W7HDtIuMvmQhpOOO+9sIc9+l+kivAs4mFHnUxo7qCnXWM 0pkQYTipJUw4NvtA1ERKlzs3YlUIe1bq1Hbvub9SwaRleedTiC9uoZvyNJOnNIogPgBo 8UaT5truabuhcoKQY/8uJSx/CicOXXuANUDi2LlKGZYAmcXp5KeMpU6U5WcjraQmoRxP haLw== 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 e18-v6si7554481pgh.388.2018.10.02.07.13.18; Tue, 02 Oct 2018 07:13:34 -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 S1728896AbeJBU4F (ORCPT + 99 others); Tue, 2 Oct 2018 16:56:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60260 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728488AbeJBUKn (ORCPT ); Tue, 2 Oct 2018 16:10:43 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 74F5EB2F; Tue, 2 Oct 2018 13:27:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ravi Chandra Sadineni , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.18 055/228] ACPI / button: increment wakeup count only when notified Date: Tue, 2 Oct 2018 06:22:32 -0700 Message-Id: <20181002132503.001654655@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132459.032960735@linuxfoundation.org> References: <20181002132459.032960735@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ravi Chandra Sadineni [ Upstream commit 7c058c7c74b3dbeb7d157c273959f87faf710350 ] Because acpi_lid_initialize_state() is called on every system resume and it triggers acpi_lid_notify_state() which invokes acpi_pm_wakeup_event() for the lid device, the lid's wakeup count is incremented even if the lid was not the source of the event that woke up the system. That behavior confuses user space deamons using wakeup_count to identify the potential system wakeup source. To avoid the confusion, only trigger acpi_pm_wakeup_event() in the acpi_button_notify() path and don't do that in the acpi_lid_initialize_state() path. Signed-off-by: Ravi Chandra Sadineni Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/button.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -235,9 +235,6 @@ static int acpi_lid_notify_state(struct 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 signal_wakeup) { int state; @@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct if (state < 0) return state; + if (state && signal_wakeup) + acpi_pm_wakeup_event(&device->dev); + return acpi_lid_notify_state(device, state); } @@ -384,7 +385,7 @@ static void acpi_lid_initialize_state(st (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 ac 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;