Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp445492imu; Fri, 4 Jan 2019 00:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4P37SS/Fr1IqqLwzdhQh8tBllKRWrmhsLEDUT5hn47ThakxWStmPmkkc087yB6sWKbIfw8 X-Received: by 2002:a17:902:2a66:: with SMTP id i93mr49188736plb.113.1546590109042; Fri, 04 Jan 2019 00:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546590109; cv=none; d=google.com; s=arc-20160816; b=scuRxTJdeF2wflwUUDU2+VK1vmHB54y0uOy5nRe0rZWz4XxiV+YPlDh3QDv48m8j8H 4ir1KaZfX9VlK4yX/YvTVYk+nN6xTb6BJJsD7zsEL7KijzoE7NWwxgorbWZ79GTG5dIf XgRw0BuMIiTu26mkeKHkzXWBQTMbp2nJVwmArZYp1xBfv1OZbQk7L3ZHj4emX2Cdcg78 j+gRC0IeE+ZHysB9O3fEKwrKzW5yp4sru3wr/6Ro2X2eqs2VUqulgyjT4uv3v3kJ7aPz x6abxIeuoKsy7vWJsSN0ElHpLtMn0P3VAmTjZR5izHc2NPSvXmIOv5FyAr+d47fVctqv gJAg== 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 :in-reply-to:references:mime-version:dkim-signature; bh=+T1zAqzsjsRCsWOGvgNAYmKjzogu0XN9kgSsZf8+U7U=; b=FgFdCeK+NObiUFmlJmilBFShFEWg4yn0U7MkbDub7OgVTD9oG0gSvliZI5f++znyy6 zDfhUlb8fG9eFoYwqiJWdnmuahFnKzF3qI4yrm4xnjibircQaemug7rFOyYqfSkmT9xS 34Ztz58RtpXbJIoAGrktrGRTaoVq3I2IDLWzHa/7T40IRF3a6axNHEEJJ86OOPzh5bvU WuMKcnAtuupsRvE/aX682BpUiCxBpKyXwT6yUsrDAZ5GHQft6Ronzl2N16S23hxNf8uf 6PAGHWQ8zAnIWcfansYSWlwTR/lPC1H7JRI0YymdZEdHLBtlUbqikHvnoN1I0rmmL4Jt mnMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gDVU+rXk; 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 b89si10021506pfj.207.2019.01.04.00.21.34; Fri, 04 Jan 2019 00:21:48 -0800 (PST) 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=gDVU+rXk; 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 S1726255AbfADHVW (ORCPT + 99 others); Fri, 4 Jan 2019 02:21:22 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33809 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbfADHVV (ORCPT ); Fri, 4 Jan 2019 02:21:21 -0500 Received: by mail-qt1-f196.google.com with SMTP id r14so39594935qtp.1 for ; Thu, 03 Jan 2019 23:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+T1zAqzsjsRCsWOGvgNAYmKjzogu0XN9kgSsZf8+U7U=; b=gDVU+rXky/kXBWaN88pyA39nTK63YJWyefaj9NMBGWURX5ODdeujeU20uq0qXGtKNt aKDRERNmq5AW1JYCHZH+07WnRTb+I4hC/mx4nPfkA6HhV+DPh/tFVVCbQ/HrxsCGa6q+ RsmVMjnXK2JUXTny+ib8xHKzG9Kq1xbtgrnUU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+T1zAqzsjsRCsWOGvgNAYmKjzogu0XN9kgSsZf8+U7U=; b=iyr+L6sZsZk72s3nostlx8XN0PvD1gG3SsdAyMso+aPnt5Ti+pFVqkMqS8iSDbpJZP OKdeepK6kWajgfP77Mf8meFFaCvyAp2PY96KsibGipbMtp6fB3WQCZebqrfgGoQpCcir YHvGrOnDzkx6V8OqO3m0fl4DwFTjWaqJ5metjZNLFTZ3MW263LZUJl42husvIWHdgG8v +o8CrI5CN99EQdaj9X6V4+5rw/8ZFBRKiZlGIRMV2O0UKYiL0uAyp/sjPz7lXduKITGh rG0QW4s78382wg5iBNHEO1EtDdUtkhVZMoVhBS73biL2TKWb3TNguvh3gFb7jVvyjI8f mCfw== X-Gm-Message-State: AA+aEWYSKhqWvpSZejC4vSHujWgZtjtpZs7dCj0jTd26vgkYWjStoPTn kjw4/t47B54M6sa/Mc7LMrTi/uvBeM53H/8+bTTCyA== X-Received: by 2002:ac8:6b18:: with SMTP id w24mr49651800qts.144.1546586479926; Thu, 03 Jan 2019 23:21:19 -0800 (PST) MIME-Version: 1.0 References: <1546436644-19234-1-git-send-email-henryc.chen@mediatek.com> <1546436644-19234-4-git-send-email-henryc.chen@mediatek.com> <1546524988.6818.54.camel@mtksdaap41> In-Reply-To: <1546524988.6818.54.camel@mtksdaap41> From: Nicolas Boichat Date: Fri, 4 Jan 2019 15:21:09 +0800 Message-ID: Subject: Re: [RFC PATCH 3/7] soc: mediatek: add support for the performance state To: Henry Chen Cc: Viresh Kumar , Stephen Boyd , Rob Herring , Matthias Brugger , Ulf Hansson , Mark Rutland , Fan Chen , Weiyi Lu , James Liao , Kees Cook , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm Mailing List , linux-mediatek@lists.infradead.org, lkml 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 On Thu, Jan 3, 2019 at 10:16 PM Henry Chen wrote: > > On Thu, 2019-01-03 at 09:48 +0800, Nicolas Boichat wrote: > > On Wed, Jan 2, 2019 at 10:01 PM Henry Chen wrote: > > > > > > Support power domain performance state, add header file for scp event. > > > > > > Signed-off-by: Henry Chen > > > --- > > > drivers/soc/mediatek/mtk-scpsys.c | 60 +++++++++++++++++++++++++++++++++++++++ > > > drivers/soc/mediatek/mtk-scpsys.h | 22 ++++++++++++++ > > > 2 files changed, 82 insertions(+) > > > create mode 100644 drivers/soc/mediatek/mtk-scpsys.h > > > > > > diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c > > > index 58d84fe..90102ae 100644 > > > --- a/drivers/soc/mediatek/mtk-scpsys.c > > > +++ b/drivers/soc/mediatek/mtk-scpsys.c > > > @@ -11,7 +11,9 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -22,6 +24,7 @@ > > > #include > > > #include > > > #include > > > +#include "mtk-scpsys.h" > > > > > > #define MTK_POLL_DELAY_US 10 > > > #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ)) > > > @@ -187,6 +190,18 @@ struct scp_soc_data { > > > bool bus_prot_reg_update; > > > }; > > > > > > +BLOCKING_NOTIFIER_HEAD(scpsys_notifier_list); > > > + > > > +int register_scpsys_notifier(struct notifier_block *nb) > > > +{ > > > + return blocking_notifier_chain_register(&scpsys_notifier_list, nb); > > > +} > > > + > > > +int unregister_scpsys_notifier(struct notifier_block *nb) > > > +{ > > > + return blocking_notifier_chain_unregister(&scpsys_notifier_list, nb); > > > +} > > > + > > > static int scpsys_domain_is_on(struct scp_domain *scpd) > > > { > > > struct scp *scp = scpd->scp; > > > @@ -536,6 +551,48 @@ static void init_clks(struct platform_device *pdev, struct clk **clk) > > > clk[i] = devm_clk_get(&pdev->dev, clk_names[i]); > > > } > > > > > > +static int mtk_pd_set_performance(struct generic_pm_domain *genpd, > > > + unsigned int state) > > > +{ > > > + int i; > > > + struct scp_domain *scpd = > > > + container_of(genpd, struct scp_domain, genpd); > > > > nit: This (just) fits in 80 chars. > Try again and get 81 chars :) Really not a big deal, but I did check and I think it fits ,-) struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd); 01234567890123456789012345678901234567890123456789012345678901234567890123456789 > > > > > + struct scp_event_data scpe; > > > + struct scp *scp = scpd->scp; > > > + struct genpd_onecell_data *pd_data = &scp->pd_data; > > > + > > > + for (i = 0; i < pd_data->num_domains; i++) { > > > + if (genpd == pd_data->domains[i]) { > > > + dev_dbg(scp->dev, "%d. %s = %d\n", > > > + i, genpd->name, state); > > > + break; > > > + } > > > + } > > > > Do we need a sanity check here, if i == pd_data->num_domains? > Oops. It needed, thanks for remind. > > > > > + > > > + scpe.event_type = MTK_SCPSYS_PSTATE; > > > + scpe.genpd = genpd; > > > + scpe.domain_id = i; > > > + blocking_notifier_call_chain(&scpsys_notifier_list, state, &scpe); > > > + > > > + return 0; > > > +} > > > + > > > +static unsigned int mtk_pd_get_performance(struct generic_pm_domain *genpd, > > > + struct dev_pm_opp *opp) > > > +{ > > > + struct device_node *np; > > > + unsigned int state; > > > + > > > + np = dev_pm_opp_get_of_node(opp); > > > + > > > + if (of_property_read_u32(np, "mtk,level", &state)) > > > + return 0; > > > + > > > + of_node_put(np); > > > + > > > + return state; > > > +} > > > + > > > static struct scp *init_scp(struct platform_device *pdev, > > > const struct scp_domain_data *scp_domain_data, int num, > > > const struct scp_ctrl_reg *scp_ctrl_reg, > > > @@ -659,6 +716,9 @@ static struct scp *init_scp(struct platform_device *pdev, > > > genpd->power_on = scpsys_power_on; > > > if (MTK_SCPD_CAPS(scpd, MTK_SCPD_ACTIVE_WAKEUP)) > > > genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; > > > + > > > + genpd->set_performance_state = mtk_pd_set_performance; > > > + genpd->opp_to_performance_state = mtk_pd_get_performance; > > > } > > > > > > return scp; > > > diff --git a/drivers/soc/mediatek/mtk-scpsys.h b/drivers/soc/mediatek/mtk-scpsys.h > > > new file mode 100644 > > > index 0000000..c1e8325 > > > --- /dev/null > > > +++ b/drivers/soc/mediatek/mtk-scpsys.h > > > @@ -0,0 +1,22 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 > > > + * > > > + * Copyright (c) 2018 MediaTek Inc. > > > + */ > > > + > > > +#ifndef __MTK_SCPSYS_H__ > > > +#define __MTK_SCPSYS_H__ > > > + > > > +struct scp_event_data { > > > + int event_type; > > > + int domain_id; > > > + struct generic_pm_domain *genpd; > > > +}; > > > + > > > +enum scp_event_type { > > > + MTK_SCPSYS_PSTATE, > > > +}; > > > + > > > +int register_scpsys_notifier(struct notifier_block *nb); > > > +int unregister_scpsys_notifier(struct notifier_block *nb); > > > + > > > +#endif /* __MTK_SCPSYS_H__ */ > > > -- > > > 1.9.1 > > > > >