From patchwork Wed May 23 18:29:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ravi Chandra Sadineni X-Patchwork-Id: 10422039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 391776053B for ; Wed, 23 May 2018 18:30:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 285B829153 for ; Wed, 23 May 2018 18:30:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CA0E29138; Wed, 23 May 2018 18:30:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8508D29151 for ; Wed, 23 May 2018 18:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933706AbeEWSaW (ORCPT ); Wed, 23 May 2018 14:30:22 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41654 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933649AbeEWSaV (ORCPT ); Wed, 23 May 2018 14:30:21 -0400 Received: by mail-pl0-f65.google.com with SMTP id az12-v6so13528348plb.8 for ; Wed, 23 May 2018 11:30:21 -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; bh=zmnoAhTTRhXeJ9lF8QLMRP1Rxh5H864FyY9IIffgPrY=; b=J/4piaB+n5o3JTFYusgPolvIioDR+BuPRJtAq0aGmPTRAfaoZMajrcYjbNU2P62lJA /7g9nG4qjtC5ewmGeCsR7W7H0DfOMJC0IzNVIW6wGi1x4sHiocKYMfMT/NpXuFnJnpGf BOOD09JTv4/9a7knQFseSebSRM3OGhLMCJxYY= 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; bh=zmnoAhTTRhXeJ9lF8QLMRP1Rxh5H864FyY9IIffgPrY=; b=ME5bhZGW7ABUyULnKyifmgO5cj2/GgEhOObpFJ/FKj6r4SFx64rUZiFaBIqovmniJE fWLqPK9L+PVsmPC/pzZecso8087rUgL5YbRJvTKY//3yKGb6RbxHat/YmxvLSp0yR//T QiBeQY5uCQ5qHgsr/ii/Mw0+pMqjfl8EniVHCf7W9MBHa6td7Q1OmiFpWxac5um462mT XX4cpA46kVlGzyzpB6JM1DujXLxCjIQGAl40lZxgPrPocYbUDzMmQfHG9jNrsYIsss4s uJmxJhxCnU6gXr1zNfjd6ckRnHjZ89N1WbMh2IGr8S/PQGoMRA14pGPtUyijYKf/pgvj zjlA== X-Gm-Message-State: ALKqPwcshzKFg6k7qxBA3ihU+auwm9wZHVPbA95jUghWnYMj6eZ2/n/V IjaZPp7iKbZycvJhFy56WobwWA== X-Google-Smtp-Source: AB8JxZqES4ARa1tJuc23yFeOd1WuYxmSgcvTsVxx13Xezx6g/R5ZdWtF2pB6o6RSDD8vGwUlErLNgw== X-Received: by 2002:a17:902:a512:: with SMTP id s18-v6mr3969260plq.223.1527100221209; Wed, 23 May 2018 11:30:21 -0700 (PDT) Received: from ravisadineni0.mtv.corp.google.com ([2620:0:1000:1501:1f1:adfa:a458:823f]) by smtp.gmail.com with ESMTPSA id u86-v6sm41880109pfg.71.2018.05.23.11.30.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 11:30:20 -0700 (PDT) From: Ravi Chandra Sadineni To: dmitry.torokhov@gmail.com, lee.jones@linaro.org, ravisadineni@chromium.org, ravisadineni@google.com, dtor@google.com Cc: tbroch@google.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, rajatja@google.com, bleung@google.com Subject: [PATCH] cros_ec_keyb: Increment the wakeup count to the specific mfd device. Date: Wed, 23 May 2018 11:29:58 -0700 Message-Id: <20180523182958.25195-1-ravisadineni@chromium.org> X-Mailer: git-send-email 2.13.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the IRQ is processed during resume, increment the wakeup count to the specific mfd device based on the event, if the mfd device is wake enabled. This helps in identifying the specific device that caused the wake. Signed-off-by: Ravi Chandra Sadineni --- drivers/input/keyboard/cros_ec_keyb.c | 20 +++++++++++++++----- drivers/mfd/cros_ec.c | 25 +++++++++++-------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 79eb29550c348..9b39289774405 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -245,12 +245,16 @@ static int cros_ec_keyb_work(struct notifier_block *nb, switch (ckdev->ec->event_data.event_type) { case EC_MKBP_EVENT_KEY_MATRIX: /* - * If EC is not the wake source, discard key state changes - * during suspend. + * If keyb input device is not wake enabled, discard key + * state changes during suspend. */ - if (queued_during_suspend) + if (queued_during_suspend && ckdev->idev + && !device_may_wakeup(&ckdev->idev->dev)) return NOTIFY_OK; + else if (queued_during_suspend && ckdev->idev) + pm_wakeup_event(&ckdev->idev->dev, 0); + if (ckdev->ec->event_size != ckdev->cols) { dev_err(ckdev->dev, "Discarded incomplete key matrix event.\n"); @@ -270,13 +274,17 @@ static int cros_ec_keyb_work(struct notifier_block *nb, case EC_MKBP_EVENT_BUTTON: case EC_MKBP_EVENT_SWITCH: /* - * If EC is not the wake source, discard key state + * If bs is not wake enabled, discard key state * changes during suspend. Switches will be re-checked in * cros_ec_keyb_resume() to be sure nothing is lost. */ - if (queued_during_suspend) + if (queued_during_suspend && ckdev->bs_idev + && !device_may_wakeup(&ckdev->bs_idev->dev)) return NOTIFY_OK; + else if (queued_during_suspend && ckdev->bs_idev) + pm_wakeup_event(&ckdev->bs_idev->dev, 0); + if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { val = get_unaligned_le32( &ckdev->ec->event_data.data.buttons); @@ -522,6 +530,7 @@ static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev) return ret; } + device_init_wakeup(&idev->dev, true); return 0; } @@ -598,6 +607,7 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) return err; } + device_init_wakeup(&idev->dev, true); return 0; } diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index d61024141e2b6..df9520365e54b 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -64,12 +64,14 @@ static irqreturn_t ec_irq_thread(int irq, void *data) * cros_ec_get_next_event() returned an error (default value for * wake_event is true) */ - if (wake_event && device_may_wakeup(ec_dev->dev)) + if (device_may_wakeup(ec_dev->dev) && wake_event + && ec_dev->wake_enabled) pm_wakeup_event(ec_dev->dev, 0); if (ret > 0) blocking_notifier_call_chain(&ec_dev->event_notifier, - 0, ec_dev); + wake_event && ec_dev->wake_enabled, + ec_dev); return IRQ_HANDLED; } @@ -229,7 +231,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) } EXPORT_SYMBOL(cros_ec_suspend); -static void cros_ec_drain_events(struct cros_ec_device *ec_dev) +static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev) { while (cros_ec_get_next_event(ec_dev, NULL) > 0) blocking_notifier_call_chain(&ec_dev->event_notifier, @@ -253,21 +255,16 @@ int cros_ec_resume(struct cros_ec_device *ec_dev) dev_dbg(ec_dev->dev, "Error %d sending resume event to ec", ret); - /* - * In some cases, we need to distinguish between events that occur - * during suspend if the EC is not a wake source. For example, - * keypresses during suspend should be discarded if it does not wake - * the system. - * - * If the EC is not a wake source, drain the event queue and mark them - * as "queued during suspend". - */ if (ec_dev->wake_enabled) { disable_irq_wake(ec_dev->irq); ec_dev->wake_enabled = 0; - } else { - cros_ec_drain_events(ec_dev); } + /* + * Let the mfd devices know about events that occur during + * suspend. This way the clients know what to do with them. + */ + cros_ec_report_events_during_suspend(ec_dev); + return 0; }