Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2055825pxu; Sun, 6 Dec 2020 17:21:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNRrmoaQwVZDV73TI/LM97wL1kjhH/pnJOWOHiQbwSaSsXrPSUUk3VvIYSFOfD58U7Bo3L X-Received: by 2002:a17:907:3312:: with SMTP id ym18mr17016811ejb.437.1607304103585; Sun, 06 Dec 2020 17:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607304103; cv=none; d=google.com; s=arc-20160816; b=vrCxvq960cQ8g/Dq3uKZxgUgiRVfUCYbtdzJlAIVKxp8vacpB/29t43EmQJNezK8fZ M2TtwHFXMUqFL4fJ8xF60uVKfyT0y/JDBBm2knCaxY6Z+sT4TdvHPQsLQPqRGWwZWU2U MkcNlYTUDwIVEkuCPCVggDAAkQeYN00FZ7IN5yBzYzK9oO3YTbqOGjqsxQDdvZAYL+FY N+j4xrb7Jk2JVmdJGVTr1oFpPvRbDfcrjV31ca2JIJwsK04kllb3V0cz3R7kfNJlYg7m P/OP4o0qxLd+Fr++LgVl+4Ma2e0AuXm1HhFDpsWRZGD1hfDuwaWOEujIrytJ7hUkc0Fl lrQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:cc:to:subject :dkim-signature:dkim-filter; bh=R6YhQOE3M+CfVudE0G4ymskj0c0R7p2I/IAq/vW4XxI=; b=WEPrX+VHcsZ439iW6D61gdqWS0xJIdSxDbJCXWqFHUTiqQ1gd2PR+3+j1NzzzrcdMN /w9KFp+E7++ramktPYyz6lRVz4mF0uHnpddfsVIk+o8mdYnN8qVvOeenm+Y9krIkbehX Ce2kyQPIm3AzSkewp2gtyOsn0qpLFlZtase6R/90zJuqAcSQNUg2cPW71dGq1DOTZ4m6 avEClKEabUeittI2RhsBVVK4UpAKRSixaAVPbzQ4HOjgaNkBQfdDXBcMHj/qRAzgx9uR t/gR5DAhzdU3MBHsoFj+PyZ/EuROy3ZhqspCY3gkXHKU1D9Zhk4VOi+Vb/o2lvZRsMCi afdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jsKcwaOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w10si5591736ejn.255.2020.12.06.17.21.20; Sun, 06 Dec 2020 17:21:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jsKcwaOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728458AbgLGBS7 (ORCPT + 99 others); Sun, 6 Dec 2020 20:18:59 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:47293 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgLGBS6 (ORCPT ); Sun, 6 Dec 2020 20:18:58 -0500 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20201207011813epoutp03346d675f0f515e2eeaf30a339802d4f3~OSmAfHb3W0783307833epoutp03z for ; Mon, 7 Dec 2020 01:18:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20201207011813epoutp03346d675f0f515e2eeaf30a339802d4f3~OSmAfHb3W0783307833epoutp03z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1607303893; bh=R6YhQOE3M+CfVudE0G4ymskj0c0R7p2I/IAq/vW4XxI=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=jsKcwaOqewN9pEw5Wy/AXPgFXxnwiLlhkJoN3L6kqCw08+Av6jKIAFuQ/hqxODZXa j4uDvI36+2KDlq89dpOmetGIcTDMSTrT2gpOVkNNIRGL222taQX65bo831kp81i8rD EcVQd8hAFPhKkhKhg8znJ+ZsrXq9UMsNA7DWd2tw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20201207011812epcas1p106676f3a6f58b6282cff82413a11ab1d~OSl-vXCos3244732447epcas1p1J; Mon, 7 Dec 2020 01:18:12 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.157]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Cq56B1N2dzMqYkv; Mon, 7 Dec 2020 01:18:10 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 91.04.02418.2D28DCF5; Mon, 7 Dec 2020 10:18:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20201207011809epcas1p3124acd8fe6ffd2eb9ff34267e8939e75~OSl8m_cUv1075810758epcas1p37; Mon, 7 Dec 2020 01:18:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201207011809epsmtrp1472f329c13c1e28a72c18fcfa7343d7e~OSl8lGBd71882218822epsmtrp15; Mon, 7 Dec 2020 01:18:09 +0000 (GMT) X-AuditID: b6c32a35-c23ff70000010972-36-5fcd82d227f1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 55.02.13470.1D28DCF5; Mon, 7 Dec 2020 10:18:09 +0900 (KST) Received: from [10.113.221.102] (unknown [10.113.221.102]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201207011809epsmtip2247c50f337957e050ac5783d70302f82~OSl8Px-xL0365903659epsmtip2R; Mon, 7 Dec 2020 01:18:09 +0000 (GMT) Subject: Re: [PATCH v11 09/10] PM / devfreq: tegra30: Support interconnect and OPPs from device-tree To: Dmitry Osipenko , Thierry Reding , Jonathan Hunter , Georgi Djakov , Rob Herring , Michael Turquette , Stephen Boyd , Peter De Schrijver , MyungJoo Ham , Kyungmin Park , Mikko Perttunen , Viresh Kumar , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski Cc: linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org From: Chanwoo Choi Organization: Samsung Electronics Message-ID: <42927892-d4a7-9368-480b-14c0d06e7116@samsung.com> Date: Mon, 7 Dec 2020 10:32:58 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Thunderbird/59.0 MIME-Version: 1.0 In-Reply-To: <20201203192439.16177-10-digetx@gmail.com> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFJsWRmVeSWpSXmKPExsWy7bCmge6lprPxBkePslq8+/SU1WL+kXOs Fqs/Pma0uPL1PZvF9L2b2CxaZi1isTh/fgO7xdana5gszja9Ybe4vGsOm8Xn3iOMFp1fZrFZ XDzlanG7cQWbxaS1Uxktzj7ztmjde4Td4t+1jSwWP3fNY7HY/OAYm4OIx/sbreweO2fdZfe4 dO4Ps8emVZ1sHneu7WHzuN99nMmjt/kdm0ffllWMHp83yQVwRmXbZKQmpqQWKaTmJeenZOal 2yp5B8c7x5uaGRjqGlp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z31kuV+N8D3ne VVdiKc5INNRiLipOBABoDeQ/agMAAA== X-CMS-MailID: 20201207011809epcas1p3124acd8fe6ffd2eb9ff34267e8939e75 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20201203192723epcas1p372e53c3e1443b7cd3010c44faff735ec References: <20201203192439.16177-1-digetx@gmail.com> <20201203192439.16177-10-digetx@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/4/20 4:24 AM, Dmitry Osipenko wrote: > This patch moves ACTMON driver away from generating OPP table by itself, > transitioning it to use the table which comes from device-tree. This > change breaks compatibility with older device-trees and brings support > for the interconnect framework to the driver. This is a mandatory change > which needs to be done in order to implement interconnect-based memory > DVFS, i.e. device-trees need to be updated. Now ACTMON issues a memory > bandwidth requests using dev_pm_opp_set_bw() instead of driving EMC clock > rate directly. > > Tested-by: Peter Geis > Tested-by: Nicolas Chauvet > Acked-by: Chanwoo Choi > Signed-off-by: Dmitry Osipenko > --- > drivers/devfreq/tegra30-devfreq.c | 79 +++++++++++++++---------------- > 1 file changed, 37 insertions(+), 42 deletions(-) > > diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c > index 38cc0d014738..145ef91ae092 100644 > --- a/drivers/devfreq/tegra30-devfreq.c > +++ b/drivers/devfreq/tegra30-devfreq.c > @@ -19,6 +19,8 @@ > #include > #include > > +#include > + > #include "governor.h" > > #define ACTMON_GLB_STATUS 0x0 > @@ -155,6 +157,7 @@ struct tegra_devfreq_device { > > struct tegra_devfreq { > struct devfreq *devfreq; > + struct opp_table *opp_table; > > struct reset_control *reset; > struct clk *clock; > @@ -612,34 +615,19 @@ static void tegra_actmon_stop(struct tegra_devfreq *tegra) > static int tegra_devfreq_target(struct device *dev, unsigned long *freq, > u32 flags) > { > - struct tegra_devfreq *tegra = dev_get_drvdata(dev); > - struct devfreq *devfreq = tegra->devfreq; > struct dev_pm_opp *opp; > - unsigned long rate; > - int err; > + int ret; > > opp = devfreq_recommended_opp(dev, freq, flags); > if (IS_ERR(opp)) { > dev_err(dev, "Failed to find opp for %lu Hz\n", *freq); > return PTR_ERR(opp); > } > - rate = dev_pm_opp_get_freq(opp); > - dev_pm_opp_put(opp); > - > - err = clk_set_min_rate(tegra->emc_clock, rate * KHZ); > - if (err) > - return err; > - > - err = clk_set_rate(tegra->emc_clock, 0); > - if (err) > - goto restore_min_rate; > > - return 0; > - > -restore_min_rate: > - clk_set_min_rate(tegra->emc_clock, devfreq->previous_freq); > + ret = dev_pm_opp_set_bw(dev, opp); > + dev_pm_opp_put(opp); > > - return err; > + return ret; > } > > static int tegra_devfreq_get_dev_status(struct device *dev, > @@ -655,7 +643,7 @@ static int tegra_devfreq_get_dev_status(struct device *dev, > stat->private_data = tegra; > > /* The below are to be used by the other governors */ > - stat->current_frequency = cur_freq; > + stat->current_frequency = cur_freq * KHZ; > > actmon_dev = &tegra->devices[MCALL]; > > @@ -705,7 +693,12 @@ static int tegra_governor_get_target(struct devfreq *devfreq, > target_freq = max(target_freq, dev->target_freq); > } > > - *freq = target_freq; > + /* > + * tegra-devfreq driver operates with KHz units, while OPP table > + * entries use Hz units. Hence we need to convert the units for the > + * devfreq core. > + */ > + *freq = target_freq * KHZ; > > return 0; > } > @@ -774,6 +767,7 @@ static struct devfreq_governor tegra_devfreq_governor = { > > static int tegra_devfreq_probe(struct platform_device *pdev) > { > + u32 hw_version = BIT(tegra_sku_info.soc_speedo_id); > struct tegra_devfreq_device *dev; > struct tegra_devfreq *tegra; > struct devfreq *devfreq; > @@ -822,11 +816,25 @@ static int tegra_devfreq_probe(struct platform_device *pdev) > return err; > } > > + tegra->opp_table = dev_pm_opp_set_supported_hw(&pdev->dev, > + &hw_version, 1); > + err = PTR_ERR_OR_ZERO(tegra->opp_table); > + if (err) { > + dev_err(&pdev->dev, "Failed to set supported HW: %d\n", err); > + return err; > + } > + > + err = dev_pm_opp_of_add_table(&pdev->dev); > + if (err) { > + dev_err(&pdev->dev, "Failed to add OPP table: %d\n", err); > + goto put_hw; > + } > + > err = clk_prepare_enable(tegra->clock); > if (err) { > dev_err(&pdev->dev, > "Failed to prepare and enable ACTMON clock\n"); > - return err; > + goto remove_table; > } > > err = reset_control_reset(tegra->reset); > @@ -850,23 +858,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev) > dev->regs = tegra->regs + dev->config->offset; > } > > - for (rate = 0; rate <= tegra->max_freq * KHZ; rate++) { > - rate = clk_round_rate(tegra->emc_clock, rate); > - > - if (rate < 0) { > - dev_err(&pdev->dev, > - "Failed to round clock rate: %ld\n", rate); > - err = rate; > - goto remove_opps; > - } > - > - err = dev_pm_opp_add(&pdev->dev, rate / KHZ, 0); > - if (err) { > - dev_err(&pdev->dev, "Failed to add OPP: %d\n", err); > - goto remove_opps; > - } > - } > - > platform_set_drvdata(pdev, tegra); > > tegra->clk_rate_change_nb.notifier_call = tegra_actmon_clk_notify_cb; > @@ -882,7 +873,6 @@ static int tegra_devfreq_probe(struct platform_device *pdev) > } > > tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock); > - tegra_devfreq_profile.initial_freq /= KHZ; > > devfreq = devfreq_add_device(&pdev->dev, &tegra_devfreq_profile, > "tegra_actmon", NULL); > @@ -902,6 +892,10 @@ static int tegra_devfreq_probe(struct platform_device *pdev) > reset_control_reset(tegra->reset); > disable_clk: > clk_disable_unprepare(tegra->clock); > +remove_table: > + dev_pm_opp_of_remove_table(&pdev->dev); > +put_hw: > + dev_pm_opp_put_supported_hw(tegra->opp_table); > > return err; > } > @@ -913,11 +907,12 @@ static int tegra_devfreq_remove(struct platform_device *pdev) > devfreq_remove_device(tegra->devfreq); > devfreq_remove_governor(&tegra_devfreq_governor); > > - dev_pm_opp_remove_all_dynamic(&pdev->dev); > - > reset_control_reset(tegra->reset); > clk_disable_unprepare(tegra->clock); > > + dev_pm_opp_of_remove_table(&pdev->dev); > + dev_pm_opp_put_supported_hw(tegra->opp_table); > + > return 0; > } > > Applied it. Thanks for your work for a long time. -- Best Regards, Chanwoo Choi Samsung Electronics