Received: by 10.192.165.148 with SMTP id m20csp4187114imm; Mon, 23 Apr 2018 21:15:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49g5Zn+14HA8StOfQZS0owBOvn+Bemx6T16/tTZL9kdmQcNoJ8AOTeV4V752YEygc9vfezq X-Received: by 10.101.76.6 with SMTP id u6mr18719591pgq.388.1524543309130; Mon, 23 Apr 2018 21:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524543309; cv=none; d=google.com; s=arc-20160816; b=ir7mp60nzyLwdjqYxQKc/19SLk36xfXZktlU+uXcANU/vd718KTQKRVRNkL1Pbp5fv xpJaGJXJfHj/of48yYC5T+cG4mAc4L5p9RnxbqMMx2oUFFRqIIyOO6G+QBNqrY7rnwr8 39L0AJGsuVMmKbCrqUvswki7R2mK66TyKx+q9GOgroxBhrplSN6H3iVTw+1oyMYU7GmF 2lR51Gare5zea2Ckl+q3de1D3am2AXyVc2rIkEza5C0/0lvgQnwE7M7KY4bN3roHDWdq VaIVcy8IryC6MAEY4IFeXrj/DxRjfatFmQjXXStMvhgnG7EHtDj/Ac/8Ta/CXe8zaSiJ 33jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :in-reply-to:subject:cc:to:user-agent:organization:from:date :message-id:content-transfer-encoding:mime-version:dkim-signature :dkim-filter:arc-authentication-results; bh=Z0i6cLBJT5cmCICYFc6WCnDZpqq2JkW7VfI+F2ztDH4=; b=E8t878li7ZlxFnbHysKqwqrjwx6Hn5i/7KKGmS9p3ajVhwXPw20Im+vVs3TIKPrC9X IZjcAhlNDS3lkZZuirLLMQ9Ydf/V60GqmYBz6Jwn7fojfgjUSStG41I8fA2+2kyFREh3 h9u+JX8u3/hQG4dFi0oACm/RXvAtij54YfHrHM8Qm02+gj7V+PAbtzy3hCHN7n7uzx8/ jvfP1kFqbxoFjU1/rDs/S1QfShwYT1J346nOjrGRrWFhgRkBMuTSGRKfL8LwO5nauxpH 8syld+CP7x1xLp90tXtzhjySS2G6Nzfv6kBr0orrtA/w771IEFCYpvAtnbMDIZu8wbiJ W6mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=sVCv/uPe; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si8472122pfk.350.2018.04.23.21.14.54; Mon, 23 Apr 2018 21:15:09 -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=@samsung.com header.s=mail20170921 header.b=sVCv/uPe; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751443AbeDXEIr (ORCPT + 99 others); Tue, 24 Apr 2018 00:08:47 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:53275 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750739AbeDXEIn (ORCPT ); Tue, 24 Apr 2018 00:08:43 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180424040840epoutp045acd91de5fbe92d417bf1404be1f69ec~oQ7V4-hZG1512615126epoutp04O; Tue, 24 Apr 2018 04:08:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180424040840epoutp045acd91de5fbe92d417bf1404be1f69ec~oQ7V4-hZG1512615126epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1524542920; bh=Z0i6cLBJT5cmCICYFc6WCnDZpqq2JkW7VfI+F2ztDH4=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=sVCv/uPe0fX3/ER/TuOvv1jtYkwzi3FNlAnFCVtROEt4YIen8eMVcwRMqNyuter3P keHHduOmN7GJqGZtkQyMBVpoABE8UXLQ7TlcGPYe2L2sMv8CJHSW+PyI6QOXWbTxKp LOkV4wHLk2R5oku1OgLGjk/owo4pXnLbV1lmPphM= Received: from epsmges2p2.samsung.com (unknown [182.195.40.156]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20180424040838epcas1p17d63b47a3b0b893863717f915d875069~oQ7TvgGKa1843918439epcas1p1n; Tue, 24 Apr 2018 04:08:38 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 6C.C0.04132.6CDAEDA5; Tue, 24 Apr 2018 13:08:38 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20180424040837epcas2p2a71c12f5346b3af23bc736bec388731e~oQ7TPrmjY0724407244epcas2p2J; Tue, 24 Apr 2018 04:08:37 +0000 (GMT) X-AuditID: b6c32a46-145ff70000001024-d4-5adeadc63950 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id A8.8B.03817.5CDAEDA5; Tue, 24 Apr 2018 13:08:37 +0900 (KST) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="UTF-8" Received: from [10.113.63.77] by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P7O001BD8UD4680@mmp2.samsung.com>; Tue, 24 Apr 2018 13:08:37 +0900 (KST) Message-id: <5ADEADC5.8000201@samsung.com> Date: Tue, 24 Apr 2018 13:08:37 +0900 From: Chanwoo Choi Organization: Samsung Electronics User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: Enric Balletbo i Serra , myungjoo.ham@samsung.com, kyungmin.park@samsung.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, heiko@sntech.de, linux-pm@vger.kernel.org, dbasehore@chromium.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Lin Huang , Elaine Zhang , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Jeffy Chen , Ulf Hansson Subject: Re: [PATCH 6/6] devfreq: rk3399_dmc: register devfreq notification to dmc driver. In-reply-to: <20180419104019.24406-7-enric.balletbo@collabora.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGJsWRmVeSWpSXmKPExsWy7bCmqe6xtfeiDK595rZ4tXkPm8X8I+dY LdbcPsRoMXf2JEaL/49es1r82HCK2eL7jbNsFpvP9bBanG16w26x6fE1VovLu+awWXzuPcJo 8enBf2aL240r2Cxa9x5htzi+Ntzi1sSbTA6CHrMbLrJ47Li7hNFj4lldj02rOtk87lzbw+ax eUm9x99Z+1k8+rasYvTYfm0es8fnTXIBXFGpNhmpiSmpRQqpecn5KZl56bZK3sHxzvGmZgaG uoaWFuZKCnmJuam2Si4+AbpumTlA7ygplCXmlAKFAhKLi5X07WyK8ktLUhUy8otLbJWiDQ2N 9AwNzPWMjIC0cayVkSlQSUJqxtTXd5kLDmhWrHyzhbWB8Z9iFyMnh4SAicSRuxeYuxi5OIQE djBKLG98xwLhfGeUWL9gPRNMVee8u0wQiQ2MEn3NO9hAErwCghI/Jt8D6uDgYBaQlzhyKRsk zCygKbF193p2iPq7jBIn32xlh6jXklixah4LiM0ioCpx4eoiVhCbDSi+/8UNsJn8AooSV388 ZgSxRQUiJHbO/wY2SESghVHi3d6/YFcwC6xllli74yvYJ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x6yyjxNE1v5hBEpwCThJz lj5lm8AoMAvJqbMQTp2F5NQFjMyrGCVTC4pz03OLjQqM8lLL9YoTc4tL89L1kvNzNzECY2/b Ya3+HYyPl8QfYhTgYFTi4V3w826UEGtiWXFl7iFGCQ5mJRHevXL3ooR4UxIrq1KL8uOLSnNS iw8xSnOwKInz8ucfixQSSE8sSc1OTS1ILYLJMnFwSjUwsv1pmOZyeMOyJfMOrY7akHggp+O0 0kUF/urW0nO+BcvTs17ufb/m98X8SPWgH/O6Jx8LPfN26Y/QyX/UVVcmVuz+ICeyhOnMp81h f3iaGk/43AhXXZnybcehS1cS7xkZbUg0L1g7t/Ke8pln59NL7G4dsrDYL/eKx+VTGdcMrR0L xGdpPribvE2JpTgj0VCLuag4EQBpxeoNuQIAAA== X-CMS-MailID: 20180424040837epcas2p2a71c12f5346b3af23bc736bec388731e X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180419104130epcas2p4c40667908eb5aecbc80d7c19e4710065 X-RootMTR: 20180419104130epcas2p4c40667908eb5aecbc80d7c19e4710065 References: <20180419104019.24406-1-enric.balletbo@collabora.com> <20180419104019.24406-7-enric.balletbo@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2018년 04월 19일 19:40, Enric Balletbo i Serra wrote: > From: Lin Huang > > Because dmc may also access the PMU_BUS_IDLE_REQ register, we need to > ensure that the pd driver and the dmc driver will not access at this > register at the same time. > > Signed-off-by: Lin Huang > Signed-off-by: Enric Balletbo i Serra > --- > > drivers/devfreq/rk3399_dmc.c | 47 +---------------------- > drivers/soc/rockchip/pm_domains.c | 31 +++++++++++++++ > include/soc/rockchip/rk3399_dmc.h | 63 +++++++++++++++++++++++++++++++ > 3 files changed, 96 insertions(+), 45 deletions(-) > create mode 100644 include/soc/rockchip/rk3399_dmc.h > > diff --git a/drivers/devfreq/rk3399_dmc.c b/drivers/devfreq/rk3399_dmc.c > index 5bfca028eaaf..a1f320634d69 100644 > --- a/drivers/devfreq/rk3399_dmc.c > +++ b/drivers/devfreq/rk3399_dmc.c > @@ -27,51 +27,7 @@ > #include > > #include > - > -struct dram_timing { > - unsigned int ddr3_speed_bin; > - unsigned int pd_idle; > - unsigned int sr_idle; > - unsigned int sr_mc_gate_idle; > - unsigned int srpd_lite_idle; > - unsigned int standby_idle; > - unsigned int auto_pd_dis_freq; > - unsigned int dram_dll_dis_freq; > - unsigned int phy_dll_dis_freq; > - unsigned int ddr3_odt_dis_freq; > - unsigned int ddr3_drv; > - unsigned int ddr3_odt; > - unsigned int phy_ddr3_ca_drv; > - unsigned int phy_ddr3_dq_drv; > - unsigned int phy_ddr3_odt; > - unsigned int lpddr3_odt_dis_freq; > - unsigned int lpddr3_drv; > - unsigned int lpddr3_odt; > - unsigned int phy_lpddr3_ca_drv; > - unsigned int phy_lpddr3_dq_drv; > - unsigned int phy_lpddr3_odt; > - unsigned int lpddr4_odt_dis_freq; > - unsigned int lpddr4_drv; > - unsigned int lpddr4_dq_odt; > - unsigned int lpddr4_ca_odt; > - unsigned int phy_lpddr4_ca_drv; > - unsigned int phy_lpddr4_ck_cs_drv; > - unsigned int phy_lpddr4_dq_drv; > - unsigned int phy_lpddr4_odt; > -}; > - > -struct rk3399_dmcfreq { > - struct device *dev; > - struct devfreq *devfreq; > - struct devfreq_simple_ondemand_data ondemand_data; > - struct clk *dmc_clk; > - struct devfreq_event_dev *edev; > - struct mutex lock; > - struct dram_timing timing; > - struct regulator *vdd_center; > - unsigned long rate, target_rate; > - unsigned long volt, target_volt; > -}; > +#include > > static int rk3399_dmcfreq_target(struct device *dev, unsigned long *freq, > u32 flags) > @@ -394,6 +350,7 @@ static int rk3399_dmcfreq_probe(struct platform_device *pdev) > > data->dev = dev; > platform_set_drvdata(pdev, data); > + pd_register_notify_to_dmc(data->devfreq); > > return 0; > } > diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c > index 53efc386b1ad..7acc836e7eb7 100644 > --- a/drivers/soc/rockchip/pm_domains.c > +++ b/drivers/soc/rockchip/pm_domains.c > @@ -8,6 +8,7 @@ > * published by the Free Software Foundation. > */ > > +#include > #include > #include > #include > @@ -76,9 +77,13 @@ struct rockchip_pmu { > const struct rockchip_pmu_info *info; > struct mutex mutex; /* mutex lock for pmu */ > struct genpd_onecell_data genpd_data; > + struct devfreq *devfreq; > + struct notifier_block dmc_nb; > struct generic_pm_domain *domains[]; > }; > > +static struct rockchip_pmu *dmc_pmu; > + > #define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd) > > #define DOMAIN(pwr, status, req, idle, ack, wakeup) \ > @@ -601,6 +606,30 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, > return error; > } > > +static int dmc_notify(struct notifier_block *nb, unsigned long event, > + void *data) > +{ > + if (event == DEVFREQ_PRECHANGE) > + mutex_lock(&dmc_pmu->mutex); > + else if (event == DEVFREQ_POSTCHANGE) > + mutex_unlock(&dmc_pmu->mutex); > + > + return NOTIFY_OK; > +} > + > +int pd_register_notify_to_dmc(struct devfreq *devfreq) > +{ > + if (!dmc_pmu) > + return -EPROBE_DEFER; > + > + dmc_pmu->devfreq = devfreq; > + dmc_pmu->dmc_nb.notifier_call = dmc_notify; > + devfreq_register_notifier(dmc_pmu->devfreq, &dmc_pmu->dmc_nb, > + DEVFREQ_TRANSITION_NOTIFIER); > + return 0; > +} > +EXPORT_SYMBOL(pd_register_notify_to_dmc); I think that it is not proper to define the nonstandard function for only specific device driver. Maybe, It makes the code more complicated. Between linux kernel frameworks, we have to use the defined function by linux kernel frameworks. If drivers/soc/rockchip/pm_domains.c is able to get the devfreq instance through devicetree, the exported function is not necessary. Sorry for that I'm not sure the alternative. [snip] > diff --git a/include/soc/rockchip/rk3399_dmc.h b/include/soc/rockchip/rk3399_dmc.h > new file mode 100644 > index 000000000000..7ccdfff1a154 > --- /dev/null > +++ b/include/soc/rockchip/rk3399_dmc.h > @@ -0,0 +1,63 @@ [snip] > + > +int pd_register_notify_to_dmc(struct devfreq *devfreq); > + > +#endif > -- Best Regards, Chanwoo Choi Samsung Electronics