Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp651465imm; Wed, 4 Jul 2018 03:41:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdnzE2xCKvoqO/i8imdjzF+g4D6digrk7q+MP46KduNlj8xst8xzTQz20ZauuFDy0/RKf5a X-Received: by 2002:a62:640b:: with SMTP id y11-v6mr1629572pfb.204.1530700897049; Wed, 04 Jul 2018 03:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530700897; cv=none; d=google.com; s=arc-20160816; b=hFTxSoGq+ZxgGfJUwrUMf8mliC8FmPFg4eX/4za2W5SVnWUWErQvzfxYs9pO16VGMA xn7d4XUGi4DtTt5FuZEiGNesWwBELy75F2YoKfwbHtU2NNJnVuo8MM+7ONZaUYlTlpEA z3hYVmWwGMw3R/m1besM4j4+U4KjC2OVnpeQ9HalpRsOWELpmuu9uStnH+mqOmlGqoK4 Nfzn8TvqY9x980fIrFJZZHC3jGCJmeLsqkjAMece7Tx+D2xBuPjfa7lssR6ltad51lpq 4YjAUWy+KNrknwe27V8oiXcreqm4PfQTfQ8GfQv7GxtusySiJMj+VpX+kyy5hMA+6Lay 80YQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vgCV4EzreZjHtTRoYUVn1g/PGCUjGZF1B0iayNsN7D8=; b=v91L90tQPFJjMw/TZkngkZ+86gCa+1LwqpKbm+dG/OVktDurYh8wQK/ctII3MILPo+ ZfUuswXT+yhe81ZUR62U13HpE8YqwscQqmQpkhE4GOZK6hwune19JUj0DxKBoLM0HQGy 64GnW3UgcSzPX+GI/CCUzk+SqAlqjxI5OtI2/OYQqyfAVuxfGWJhEZluOvDav623u8wM bMAixL5ox6GQOmpyB42kG6Zvx0zq3s9TKvZEU3+bNLqoWvkNcOKN/H5ZmeuggaRfT8MA gBmYYVAfghXgaBJpZbpVQk5TclVo10zz/GLUDhktKL+XKkpIwizwZy8mMHPrVJjO+6GW tyew== 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 i14-v6si3419000pfj.190.2018.07.04.03.41.22; Wed, 04 Jul 2018 03:41:37 -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 S933239AbeGDKke (ORCPT + 99 others); Wed, 4 Jul 2018 06:40:34 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:50489 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbeGDKkd (ORCPT ); Wed, 4 Jul 2018 06:40:33 -0400 Received: from 79.184.254.38.ipv4.supernova.orange.pl (79.184.254.38) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id ad63a7152df4bc8e; Wed, 4 Jul 2018 12:40:31 +0200 From: "Rafael J. Wysocki" To: Ravi Chandra Sadineni Cc: lenb@kernel.org, ravisadineni@google.com, 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: Re: [PATCH V3] ACPI LID: increment wakeup count only when notified. Date: Wed, 04 Jul 2018 12:39:08 +0200 Message-ID: <1749498.FF42dzjKYz@aspire.rjw.lan> In-Reply-To: <20180627175502.178725-1-ravisadineni@chromium.org> References: <2352530.ePvj7nqZEq@aspire.rjw.lan> <20180627175502.178725-1-ravisadineni@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, June 27, 2018 7:55:02 PM CEST Ravi Chandra Sadineni wrote: > 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 > --- > v3: Change is_notification to signal_wakeup > 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..40ed3ec9fc94c 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 signal_wakeup) > { > int state; > > @@ -374,6 +372,9 @@ static int acpi_lid_update_state(struct acpi_device *device) > 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(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; > > Applied, thanks!