Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp857912imm; Thu, 31 May 2018 10:34:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJmBSTF0jX3N0GNIsB2OTFBfDns6Yx2VhghI/VurMTR45y3VmvlBYwpH1Bqn3P76fpT8EVV X-Received: by 2002:a62:fc8d:: with SMTP id e135-v6mr7710287pfh.208.1527788056990; Thu, 31 May 2018 10:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527788056; cv=none; d=google.com; s=arc-20160816; b=PTexdCqpBFnNotH1MfnobfcjJUBUi1E85wcg42FzHhwqx3U02VKugcanVRx9QmDDUG 2aOop25UNs7hvdmCua8f2pVjjpph1mhdP3Pm4+X2FchDW5/hFr/MC7eBlGKMakliwydX EfVwXXC8SljFGpOLss8QdWMTVv3uRDhqx3d05tbcaCzn5AjGFD2yvB2dVHKrL5I1b3wY 620uPQkiR0QeZKdKywiI5Nzxh7STwx/SsIFS5C/VCHcrsI+Ms/kUDemZRkDoM5W75+C8 J0hqZGua2Rz8Fgs0Yzds6aFMHbtu7O300xIOEkJQ+CX/bBAVbHLXoRPeQ/wpnKIojS6b h8TA== 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=5eIcm80XtZYEru7soSKRyRL8P7/XJzxTK31oVQu8yuo=; b=pHCBzJFOWoLokach7NkJ+4P3Cj/GLeB7vZLt5Ijm3SJEbMQawtnc6tsLM3uPtAyUQz zf8dddW+/4Lpos19XZX/G+SWyak7pF3axCLf+LKlRFry26I4uTaYzBxLT0ojKNLyHe7c h1MpY6IUZubOJg+hhpKCfnGLCCeZfD17AXcuR2HZNSWw1uYFSOW4CdBIdFXvmI6RGyrI DQVycelEEIj3elqtbplBbF4PWUIYVcAfvXniahBQfYxe8Gzn+QXmG8CmjHlr2UVypEPh AvipN36aMmpzHldS7+B0+TVaGYiij/X6mpmkSlwxVMN5ml0dtgjk/LFrNMmxHdDN5Pkz O7pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cgwtccjV; 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-v6si30696903pgr.72.2018.05.31.10.34.02; Thu, 31 May 2018 10:34:16 -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=cgwtccjV; 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 S1755860AbeEaRdh (ORCPT + 99 others); Thu, 31 May 2018 13:33:37 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39399 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755719AbeEaRde (ORCPT ); Thu, 31 May 2018 13:33:34 -0400 Received: by mail-pl0-f66.google.com with SMTP id f1-v6so13198291plt.6 for ; Thu, 31 May 2018 10:33:33 -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=5eIcm80XtZYEru7soSKRyRL8P7/XJzxTK31oVQu8yuo=; b=cgwtccjVg1xx9eWfawcbWBxyuhurvuDroq9V4DU/Kcl0znCWG1SSJHVS6lgbE5OXF2 wIQ/RRSVfyHC//LiNllPl2/6eAMMJb74Fk8nwqVbFGwBzvMqg8G6/y2rWcr94zYkIS1U R7+WNcRSOX2Z9lGyPhLknC1qu3dFsaBRvGyw4= 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=5eIcm80XtZYEru7soSKRyRL8P7/XJzxTK31oVQu8yuo=; b=pD7tJ1fk/CnjCucmR483r1v2Q2tBXHi2j8T0/ugEo4RReMCVj/u783qdTBoEe8m0kV uS22HgXbk+F94aGToYIU7eUJOU8voBj961unl3cB91tIAtzdII18+j9BxPwN8czxMzVE wqo4V89U5hHlm34AUtwhAL5FDSak3LRqaX+No+DhQF2HvXtRjIzy+IiTSDWY2ewnGQjs E5VEp/ah4jI/NNee1ujSA9v3Uvu7MqxS47pDsermjM8S4xu7eXZ8Z+kpnWoy+koKpPD0 RgtWm6LPZMevIN2qTYGujDQdrbu+oRf6PHhK7o+mSMj8yxUzIjtir06M90UqkwWZzX44 WgkA== X-Gm-Message-State: ALKqPweNRElqb+dxH8+K39PJhaMyb+8VGD7z2o7pRnAODccWq1Ll6Fn7 r2PbLtmlurao4Ullg1pDf15dZw== X-Received: by 2002:a17:902:7d87:: with SMTP id a7-v6mr8127214plm.264.1527788013609; Thu, 31 May 2018 10:33:33 -0700 (PDT) Received: from localhost ([2620:0:1000:1501:8e2d:4727:1211:622]) by smtp.gmail.com with ESMTPSA id j5-v6sm99022181pfe.119.2018.05.31.10.33.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 10:33:32 -0700 (PDT) Date: Thu, 31 May 2018 10:33:31 -0700 From: Matthias Kaehlcke To: Enric Balletbo Serra Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Linux PM list , "devicetree@vger.kernel.org" , linux-kernel , Brian Norris , Douglas Anderson Subject: Re: [PATCH 11/11] misc/throttler: Add Chrome OS EC throttler Message-ID: <20180531173331.GA88063@google.com> References: <20180525203043.249193-1-mka@chromium.org> <20180525203043.249193-12-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 Enric, thanks for the review! I'll address your comments in the next revision. On Thu, May 31, 2018 at 11:05:09AM +0200, Enric Balletbo Serra wrote: > Hi Matthias, > > The patch looks good to me, just three minor comments to be more > coherent with other cros-ec drivers. > > 2018-05-25 22:30 GMT+02:00 Matthias Kaehlcke : > > The driver subscribes to throttling events from the Chrome OS > > embedded controller and enables/disables system throttling based > > on these events. > > > > Signed-off-by: Matthias Kaehlcke > > --- > > drivers/misc/throttler/Kconfig | 15 +++ > > drivers/misc/throttler/Makefile | 1 + > > drivers/misc/throttler/cros_ec_throttler.c | 122 +++++++++++++++++++++ > > 3 files changed, 138 insertions(+) > > create mode 100644 drivers/misc/throttler/cros_ec_throttler.c > > > > diff --git a/drivers/misc/throttler/Kconfig b/drivers/misc/throttler/Kconfig > > index ef8388f6bc0a..652b6817b75c 100644 > > --- a/drivers/misc/throttler/Kconfig > > +++ b/drivers/misc/throttler/Kconfig > > @@ -11,3 +11,18 @@ menuconfig THROTTLER > > Note that you also need a event monitor module usually called > > *_throttler. > > > > +if THROTTLER > > + > > +config CROS_EC_THROTTLER > > + tristate "Throttler event monitor for the Chrome OS Embedded Controller" > > s/Chrome OS/ChromeOS/ This is how other cros-ec drivers refer to the > embedded controller, so will be good if you could maintain this > denomination. > > > + default n > > + depends on MFD_CROS_EC > > + ---help--- > > + This driver adds support to throttle the system in reaction to > > + Chrome OS EC events. > > + > > ditto > > > + To compile this driver as a module, choose M here: the > > + module will be called cros_ec_throttler. > > + > > +endif # THROTTLER > > + > > diff --git a/drivers/misc/throttler/Makefile b/drivers/misc/throttler/Makefile > > index c8d920cee315..d9b2a77dabc9 100644 > > --- a/drivers/misc/throttler/Makefile > > +++ b/drivers/misc/throttler/Makefile > > @@ -1 +1,2 @@ > > obj-$(CONFIG_THROTTLER) += core.o > > +obj-$(CONFIG_CROS_EC_THROTTLER) += cros_ec_throttler.o > > diff --git a/drivers/misc/throttler/cros_ec_throttler.c b/drivers/misc/throttler/cros_ec_throttler.c > > new file mode 100644 > > index 000000000000..ea6bc002d49c > > --- /dev/null > > +++ b/drivers/misc/throttler/cros_ec_throttler.c > > @@ -0,0 +1,122 @@ > > +/* > > + * Driver for throttling triggered by EC events. > > + * > > + * Copyright (C) 2018 Google, Inc. > > + * > > + * This software is licensed under the terms of the GNU General Public > > + * License version 2, as published by the Free Software Foundation, and > > + * may be copied, distributed, and modified under those terms. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + * > > + */ > > + > > Replace this for the SPDX header format > > // SPDX-License-Identifier: GPL-2.0+ > // Driver for throttling triggered by EC events. > // > // Copyright (C) 2018 Google, Inc. > // Author: Matthias Kaehlcke > > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +struct cros_ec_throttler { > > + struct cros_ec_device *ec; > > + struct throttler *throttler; > > + struct notifier_block nb; > > +}; > > + > > +static int cros_ec_throttler_event(struct notifier_block *nb, > > + unsigned long queued_during_suspend, void *_notify) > > +{ > > + struct cros_ec_throttler *cte = > > + container_of(nb, struct cros_ec_throttler, nb); > > nit: Better add a define here instead of split the line like this ? > > > + u32 host_event; > > + > > + host_event = cros_ec_get_host_event(cte->ec); > > + if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_START)) { > > + throttler_set_level(cte->throttler, 1); > > + > > + return NOTIFY_OK; > > + } else if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_STOP)) { > > + throttler_set_level(cte->throttler, 0); > > + > > + return NOTIFY_OK; > > + } > > + > > + return NOTIFY_DONE; > > +} > > + > > +static int cros_ec_throttler_probe(struct platform_device *pdev) > > +{ > > + struct cros_ec_throttler *cte; > > + struct device *dev = &pdev->dev; > > + struct device_node *np = pdev->dev.of_node; > > + int ret; > > + > > + if (!np) { > > + /* should never happen */ > > + return -EINVAL; > > + } > > + > > + cte = devm_kzalloc(dev, sizeof(*cte), GFP_KERNEL); > > + if (!cte) > > + return -ENOMEM; > > + > > + cte->ec = dev_get_drvdata(pdev->dev.parent); > > + > > + cte->throttler = throttler_setup(dev); > > + if (IS_ERR(cte->throttler)) > > + return PTR_ERR(cte->throttler); > > + > > + dev_set_drvdata(dev, cte); > > + > > + cte->nb.notifier_call = cros_ec_throttler_event; > > + ret = blocking_notifier_chain_register(&cte->ec->event_notifier, > > + &cte->nb); > > + if (ret < 0) { > > + dev_err(dev, "failed to register notifier\n"); > > + throttler_teardown(cte->throttler); > > + return ret; > > + } > > + > > + return 0; > > +} > > + > > +static int cros_ec_throttler_remove(struct platform_device *pdev) > > +{ > > + struct cros_ec_throttler *cte = platform_get_drvdata(pdev); > > + > > + blocking_notifier_chain_unregister(&cte->ec->event_notifier, > > + &cte->nb); > > + > > + throttler_teardown(cte->throttler); > > + > > + return 0; > > +} > > + > > +#ifdef CONFIG_OF > > +static const struct of_device_id cros_ec_throttler_of_match[] = { > > + { .compatible = "google,cros-ec-throttler" }, > > + { /* sentinel */ } > > +}; > > +MODULE_DEVICE_TABLE(of, cros_ec_throttler_of_match); > > +#endif /* CONFIG_OF */ > > + > > +static struct platform_driver cros_ec_throttler_driver = { > > + .driver = { > > + .name = "cros-ec-throttler", > > + .of_match_table = of_match_ptr(cros_ec_throttler_of_match), > > + }, > > + .probe = cros_ec_throttler_probe, > > + .remove = cros_ec_throttler_remove, > > +}; > > + > > +module_platform_driver(cros_ec_throttler_driver); > > + > > +MODULE_LICENSE("GPL"); > > +MODULE_AUTHOR("Matthias Kaehlcke "); > > +MODULE_DESCRIPTION("Chrome OS EC Throttler"); > > s/Chrome OS/ChromeOS/ > > > > > Reviewed-by: Enric Balletbo i Serra > > Thanks, > Enric