Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp383042imm; Thu, 31 May 2018 02:07:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzOMHH6GQ+i7BkAcyZ15RSBrpB0CPNKKn3rwfVrmI+kapbj+HOOWaSh3XE/Bx1DiwP1vZF X-Received: by 2002:a65:5003:: with SMTP id f3-v6mr4891789pgo.425.1527757633235; Thu, 31 May 2018 02:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527757633; cv=none; d=google.com; s=arc-20160816; b=NxX1kSfr1hSLcYnQtcIPaRSR2j+VzOQDQM5M/g2/CzyFJGHCDyoS2AV3Q4yI/Klznq 1/7B3kW5KFgynDioprwG+lS9tQ82q/DWlofZN4+9X6ab1vHXL8lMvL0nB5xLFIq7MNLH 1XandUL7HuUqFVhAinydWJZTCuOvCVD/OqNdFUTinnm+BlppMyJwKRsk/ywSTZ09vM2G eUzyp2KMY8JwJCdFlxKR1K1VoGSzqosselq1C/3IzmAwz1C0AcGfi6WptS6JlxY2o9PW eE3yKKSLEd7zklII5J0Z1R0WAj3YDXpbTIlPh1Mgi0ohYenVXKfDSBC5L3esi41TC6Fl X4ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=nQvOq0U5G9QO78SCxftJrBdbrC3eAZs37DgP6lMIPAs=; b=QaeABgGXt3KU5ysxgyDEZe1JO9cggKIlg6AJOUXdsyaz+EaR3ccBExX7VFWa5FcOo2 L0ShMEcvPxj1d6bz1b5VzKdwC+bwraoY/ahq1FUAqDKP5DM0JmxFQ+kWKoJQJEs+fvid g5pzQINcmRwZWmw9lvwDUzvBNKnpgyBd5uUDKXLLa8dfduL6ZfAGPrKTWA9GJ3kj1dSy 2zA5QZUM+mjL/QFXqF1nmhx3metS9w0+GJpeyLO1CTa5BeqTuBpyaY3h5AdWluL1zPOp iP0owv9rP4QRYgS1hoqGvWakXNuD+N7YSKie5jmgqQ9+vQjrAZCDv2ACaemTKtLUc3Cv L8bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rGG4WJvb; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13-v6si7500119pgq.585.2018.05.31.02.06.59; Thu, 31 May 2018 02:07:13 -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=@gmail.com header.s=20161025 header.b=rGG4WJvb; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754197AbeEaJFO (ORCPT + 99 others); Thu, 31 May 2018 05:05:14 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:45397 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754026AbeEaJFL (ORCPT ); Thu, 31 May 2018 05:05:11 -0400 Received: by mail-qk0-f193.google.com with SMTP id c198-v6so16658172qkg.12; Thu, 31 May 2018 02:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nQvOq0U5G9QO78SCxftJrBdbrC3eAZs37DgP6lMIPAs=; b=rGG4WJvb/eFiupbbW0zu4xHFXDQZ3ZLbWxUIhvv01wH26vadBsLD4Ymfks/Wwz4taf M4pNFNMRdHieT4kXHrVPqYVMCfpYvGlbPwnoKE6csJkCyie950yo6PY1zNACOp2hskiS lKbSpXrHwPkIjNBipmDQIiNdxcwdgu/cUpZ8qC74v4K1kj3hEBbfnvbyuSI/OyfA4XdG ovAj9paSEL3iedSPV5co8C4i4GR1ugeE7DPDRHLw8Rq7t0yyBbkN8jX2mkVzYgUvI5f9 j6n5Orwh/dDGZSqBvMPhTFNc2A+GSAocy55UAEfryStxrn9TbV3mgGQC/WJ7iOZYm+ny F7Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nQvOq0U5G9QO78SCxftJrBdbrC3eAZs37DgP6lMIPAs=; b=ZERf2RZYfpd4Ps8uJ+Rf8rlnabdA2IFN+pKwfwJJI/8b6TjyyBa0149TgBkZqoB2M6 qUqM242uWlYWNDRp+yeroXbu5PapqWtWgiIUjw0rwQ+AYHqoOfOwclQazIAhalM7sq+m 58t/CJ2lMcx8rDve/4Hl0Xcd2l9HxsASGwL+lTGfr3DkeZZstKLwvSdRaJ0r/6u8jjxg kjrDYDW9+q4gegGrc4OFLjr7mOyR8EZNWN9nCuyUAJJXc2isRFOCNTvG4O7BC51rB5ZB 2+EboETGPzqXqKHh5CQJWM3IkEU1OeP+gd3FuwK/p4xdQlIMRvI26TV6wx85xbAC7GUa hCNw== X-Gm-Message-State: APt69E31AQHfFEgbZ5ZVwDAwlHdrbGXmCYMAyNDmxf5hIIfguS59STWJ Y7eLiFeQJmMw66K1WAcUN/KLvn4TIbVtK6Zq6B4= X-Received: by 2002:a37:4c56:: with SMTP id z83-v6mr5740695qka.302.1527757510040; Thu, 31 May 2018 02:05:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:aed:3102:0:0:0:0:0 with HTTP; Thu, 31 May 2018 02:05:09 -0700 (PDT) In-Reply-To: <20180525203043.249193-12-mka@chromium.org> References: <20180525203043.249193-1-mka@chromium.org> <20180525203043.249193-12-mka@chromium.org> From: Enric Balletbo Serra Date: Thu, 31 May 2018 11:05:09 +0200 Message-ID: Subject: Re: [PATCH 11/11] misc/throttler: Add Chrome OS EC throttler To: Matthias Kaehlcke 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ > -- > 2.17.0.921.gf22659ad46-goog > Reviewed-by: Enric Balletbo i Serra Thanks, Enric