Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp319311imm; Mon, 4 Jun 2018 18:33:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKIUbbG9QymCq9TZR6wrmo9BkyY/GaSLOZHtqqbE6rzrAcJd09zdDEaUFVZFgrYRN6EKb6F X-Received: by 2002:a17:902:20c9:: with SMTP id v9-v6mr24162196plg.206.1528162429736; Mon, 04 Jun 2018 18:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528162429; cv=none; d=google.com; s=arc-20160816; b=O33YSXBxHVZFqlQm+N+PoxuWvRmY05KRchPzBZWRqh5tiHhy3/yVqW4gV49yqIDnB3 pENJAKTZ+tZp31oijW3kFHlWuoP4mdB7u6p/tPFOJCno6rwWM6M21nDpvtTIMaf4v6i5 yfdGHE7Ih9V2v4N1w+nvIpVAcQU9+Rk8xrUKGB+CX5qWTNZ6sYlx9HKWJlIM4yUwDcif rNv5SoDWduyETeMkdQ4Kk0AI2tQuMQ+h9m3kB49Mdh6c2wzzVR9JG6XKz/hLmnaDu2or jgVyBS4IhTQYTDp+FLjTZn4WaOKLfBa9us/B8grGBw99VGV87cqf0MrbNmw+xf8mEZ8a r5EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=qm5P7vNf6NkPwQSkM1Bk6pb158gQ75LzxQmXP6MtMLw=; b=JwtsTu/GfYaqhbYUuYrTwA6JbjgvSvh0e/jS3eYICIsaS5AcPnJYC5Yb/sAxUgdMMw yueRgDZbjp7a/vcRod9QDGn1VmjsZ+9YrqSM19Ia9mE9HSrljbohQQGl5XippfxHfB1k posC2Msn60BJf2/nicrjRk90MA7Azt0zPozhe7/GUfW1M6dwjj24KZg31nLq4Bgj13MB fVPFNWPymWIPSREamNoQmJshwOOXEpMg3+EMKh3+RqMa8XbBSgxAbqmIXAj5TuIMzh25 ijL45FA11K5RauSv0kxfK/MvacsuzgmH5c3N75aCEA8QVCLqidnD/oatbMVkounhoROl B0RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RCCV1APY; 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 g6-v6si3003555plp.533.2018.06.04.18.33.35; Mon, 04 Jun 2018 18:33:49 -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=RCCV1APY; 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 S1751368AbeFEBc5 (ORCPT + 99 others); Mon, 4 Jun 2018 21:32:57 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38334 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbeFEBc4 (ORCPT ); Mon, 4 Jun 2018 21:32:56 -0400 Received: by mail-pf0-f193.google.com with SMTP id b74-v6so374277pfl.5 for ; Mon, 04 Jun 2018 18:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qm5P7vNf6NkPwQSkM1Bk6pb158gQ75LzxQmXP6MtMLw=; b=RCCV1APYiM/xjaDLq4+WnSpNhLdjEtwYUtR9jpB5N/95DpcYKQRfFVjtQT4i6X+2oo HPBybAu76IRcme1qpUyCtMlr54pST0EPyXeVL47OOMWwuanPfseNymXc7YwzZJVbONkj 8aTwi2pa+d353KOzOVOceGKJ+UKWM4Dp+KUbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qm5P7vNf6NkPwQSkM1Bk6pb158gQ75LzxQmXP6MtMLw=; b=SgZXHZaF007uZGNhQTZErtfBsCvopVvpPiR/64y3R407eKcbWCBuGQ9lzdfZ0oOf4u 9T34hTbob3EeLxAIqDYOrUgDYry0o57qUfrAdbSmmHKKptyzKfUdqzdbcgaAFpipDH2k 1Kz48wx1ZcaCPqpwxgtWjoN0gv+iBRApP0QzBe0mgwpJSvPLBq5pbJi5bX44fJJAsX05 3CWYLPJMj43BvGGYY6t1xh0CKZUiTEbbXZVavSoq4vnT2q8tiDHmukdU2SEM23BHJ8+N 4VGjwR9A5CiU4Fi3fORTsClieVJi06I98edwXJcjRf5qRZlOM1I/fgY7A5m0m/a3ldQ0 10Sw== X-Gm-Message-State: ALKqPweDexjFOJDz1vLXzj70xhtm4TXEk7zJm2B2h8wJf67lnDwB3fTZ dFrfgbuBTo3MaGGrE9uBwtQUUw== X-Received: by 2002:a62:3745:: with SMTP id e66-v6mr23505208pfa.43.1528162375779; Mon, 04 Jun 2018 18:32:55 -0700 (PDT) Received: from rodete-desktop-imager.corp.google.com ([2620:0:1000:1501:bc2f:3082:9938:5d41]) by smtp.gmail.com with ESMTPSA id l20-v6sm33429528pff.50.2018.06.04.18.32.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Jun 2018 18:32:54 -0700 (PDT) Date: Mon, 4 Jun 2018 18:32:52 -0700 From: Brian Norris To: Ravi Chandra Sadineni Cc: dmitry.torokhov@gmail.com, lee.jones@linaro.org, ravisadineni@google.com, dtor@google.com, tbroch@google.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, rajatja@google.com, bleung@google.com Subject: Re: [PATCH V2] cros_ec_keyb: Mark cros_ec_keyb driver as wake enabled device. Message-ID: <20180605013250.GA41281@rodete-desktop-imager.corp.google.com> References: <20180524234213.GE177107@dtor-ws> <20180526011440.102417-1-ravisadineni@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180526011440.102417-1-ravisadineni@chromium.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, May 25, 2018 at 06:14:40PM -0700, Ravi Chandra Sadineni wrote: > 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. I'm not sure I saw v1? But FYI, if you're not marking the input devices as wake-enabled, then you only have one knob for disabling wakeup on the buttons and switches (e.g., power button) vs. the keyboard. I know you were previously concerned about this, but given that the EC itself usually has full knowledge of these situations (e.g., it knows to disable keyboard wakeup when a convertible is in a tablet orientation, but leave power-button wakeup enabled), this may not be a problem. Anyway, just wanted to highlight that part. > 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 We can use the full word; text is cheap: s/Keyb/keyboard/ > * 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); > + > + I don't think you need two blank lines here. One is enough. > 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 s/keyb/keyboard/ Or, since this is talking about buttons and switches (which don't technically require the "keyboard" part of this driver), you might just leave that off ("If not wake enabled..."). Otherwise, I believe this looks good, though I may have overlooked something: Reviewed-by: Brian Norris And given Lee acked this, and it's mostly a keyboard change, it should probably go through Dmitry? And I'd expect he'd be a better reviewer than me anyway. Brian > * 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 >