Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp139640imm; Fri, 25 May 2018 18:15:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq8XtFLkO2jlTkx6mFk56zWlHC4chChwMonRI+aTN1zCLX+gAFemkSHbpzYhhOO9vH76r0M X-Received: by 2002:a62:5050:: with SMTP id e77-v6mr4777116pfb.16.1527297322682; Fri, 25 May 2018 18:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527297322; cv=none; d=google.com; s=arc-20160816; b=VdyhmijRYezszNza1gJmxBfH5OYTRme/sEtRuQNrMNr8yISyzgy4P+ZcFszQVjLauz aSyLsb5CTI2GpPXfibmJHywuOsJGpS7DqbTXHQzlSBxb3HVZn7L8pGzUf9y0oMAhOqya zCqGyK4wCEGU1PledlAqXm+yeNKL+X5ZjyYzJsO3MAF+pyEAyjNz1C8NuzdEOsc+ZY2W hcXo+VKbfMIcgJBsG/UTa/Fy1NlP6tzByvxyG9TuG5PM766WG8UbxLobzwRS0LdjCUj1 PDBTjE/Ef5GUvaVx7qqzetboFCElpWf/Qq9C1djXJP3zVyEunllPZvPM+8tv0/Jy3QOb TplA== 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=iuJcYSvODwM72jbPC9wD25esdgdAX+zFMCmq3Bcv+qc=; b=mvsnFSn2UwFBfHQFAbQp4s17PDkeAKbrzcReLcGrcTzG5NVlPDHA1ROe3Tqgopmkr6 ESxKIpDY+vE+WD8sgFf9ZMviKDt+IZ2SFm/zWqZ8v8VoAC/kVvZt2ydBDTcj0JaSh+s+ m7cG377mebPTe341gJu1taqQ9wgGL1KACldPYYu6yYixiBsJaH/65E3sRtd1Vc3LVeVP 7d5LuqTJFAPJUFtAbnyDhPI7ie164txbt91DcYlTjegwetNiLgGN3J4QLq07yaUoT0ej YfHS7iHG3cnstw1pzTmagvG0tGhDzpiXY3Z4iD89z46Onsi/dJPtWrjMOi2ov4Y7Xbpu dgDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bMd5w8Ow; 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 r14-v6si24870569pfa.296.2018.05.25.18.15.07; Fri, 25 May 2018 18:15:22 -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=bMd5w8Ow; 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 S1030980AbeEZBO4 (ORCPT + 99 others); Fri, 25 May 2018 21:14:56 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:44558 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030816AbeEZBOy (ORCPT ); Fri, 25 May 2018 21:14:54 -0400 Received: by mail-pl0-f68.google.com with SMTP id z9-v6so704471plk.11 for ; Fri, 25 May 2018 18:14:54 -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=iuJcYSvODwM72jbPC9wD25esdgdAX+zFMCmq3Bcv+qc=; b=bMd5w8OwEaxNRVzh0tDBkpVwdv/D6elyLw2loMZuKDRz5T6BaKlwvmbIPpgBkuTBC6 whGVAUTM9kDJQrIo+HFWIoB9p2lKZf33eI/XJ+9tXjSCL+1EuIX6UEa8F5ae2gDBVOTr eUo/UabpoDKA4yRuFXOMnSVwHVzx839h0ci0U= 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=iuJcYSvODwM72jbPC9wD25esdgdAX+zFMCmq3Bcv+qc=; b=hipOGjW7UrFDS/c/2zW2LefdzqMxA15TVQQIKZRuHjB+bvio9ZTJofdQFM5Datb2BA bsZah6zQDq3fBCidJaA/OPJJHn0O1ZZjq+catTeLUU+mYUJVCf0aG1e5yDOL3gSGfA/c DMtyUsiLlz2gjFj8X937cwuNnfXtKnMtapzS2TTsD4YB2n9f55mZ22Ec/R0txCRKVIug hwURkLpymhkFLuHHMeLhYuQI/IqGbcombF41xOcjuBMlHxNGWlFNKuwDa5JxGi8bP6RH /04HsPCGtI1JC0qLrDpVp5eK+gXZOz8MaUKX45N/HrmwedjCH1vJz3pjBKXsvdDl2R0x zH8w== X-Gm-Message-State: ALKqPwfxN5IlYWusLPf/lueaCyBCL60jxWbnCi0SLL1D4HUot9afipj7 xLCv34CqTbIw4R0VzC4Rdc8DZA== X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr4615690plb.297.1527297294123; Fri, 25 May 2018 18:14:54 -0700 (PDT) Received: from ravisadineni0.mtv.corp.google.com ([2620:0:1000:1501:1f1:adfa:a458:823f]) by smtp.gmail.com with ESMTPSA id 185-v6sm44454759pfu.13.2018.05.25.18.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 18:14:53 -0700 (PDT) From: Ravi Chandra Sadineni To: dmitry.torokhov@gmail.com, lee.jones@linaro.org, ravisadineni@chromium.org, ravisadineni@google.com, dtor@google.com, briannorris@chromium.org Cc: tbroch@google.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, rajatja@google.com, bleung@google.com Subject: [PATCH V2] cros_ec_keyb: Mark cros_ec_keyb driver as wake enabled device. Date: Fri, 25 May 2018 18:14:40 -0700 Message-Id: <20180526011440.102417-1-ravisadineni@chromium.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: <20180524234213.GE177107@dtor-ws> References: <20180524234213.GE177107@dtor-ws> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mark cros_ec_keyb has wake enabled by default. If we see a MKBP event related to keyboard, call pm_wakeup_event() to make sure wakeup triggers are accounted to keyb during suspend resume path. Signed-off-by: Ravi Chandra Sadineni --- V2: Marked the ckdev as wake enabled instead of input devices. drivers/input/keyboard/cros_ec_keyb.c | 21 +++++++++++++++++---- drivers/mfd/cros_ec.c | 19 +++++++------------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 79eb29550c348..a7c96f0317123 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -245,12 +245,17 @@ 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 + * If Keyb is not wake enabled, discard key state changes * during suspend. */ - if (queued_during_suspend) + if (queued_during_suspend + && !device_may_wakeup(ckdev->dev)) return NOTIFY_OK; + if (device_may_wakeup(ckdev->dev)) + pm_wakeup_event(ckdev->dev, 0); + + if (ckdev->ec->event_size != ckdev->cols) { dev_err(ckdev->dev, "Discarded incomplete key matrix event.\n"); @@ -265,18 +270,25 @@ static int cros_ec_keyb_work(struct notifier_block *nb, val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq); dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val); handle_sysrq(val); + + if (device_may_wakeup(ckdev->dev)) + pm_wakeup_event(ckdev->dev, 0); break; case EC_MKBP_EVENT_BUTTON: case EC_MKBP_EVENT_SWITCH: /* - * If EC is not the wake source, discard key state + * If keyb 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 + && !device_may_wakeup(ckdev->dev)) return NOTIFY_OK; + if (device_may_wakeup(ckdev->dev)) + pm_wakeup_event(ckdev->dev, 0); + if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { val = get_unaligned_le32( &ckdev->ec->event_data.data.buttons); @@ -639,6 +651,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev) return err; } + device_init_wakeup(ckdev->dev, true); return 0; } diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index d61024141e2b6..36156a41499c9 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -229,7 +229,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 +253,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; } -- 2.17.0.921.gf22659ad46-goog