Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3096347pxb; Tue, 12 Jan 2021 06:20:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJ3uRnST1bEY0STUF2P6uhyNQM3q6cG8Aazj0NldtilyOB7k8cSYcAlVVGHqyh/0P0B0R4 X-Received: by 2002:a17:906:2798:: with SMTP id j24mr3452098ejc.328.1610461224504; Tue, 12 Jan 2021 06:20:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610461224; cv=none; d=google.com; s=arc-20160816; b=O588yYhBmDpEtO2JTzijS0OrzAnFu/VIECkGMpK8xv6VHby/wb5MznCMnHI9Da/2aB KcYtLLFDSWfOns4HOfwDthlOYEy+p6Qk+WJSkj92BxipU4eBpirKVOSz+RZwAfgas6He FTRBRu0Ce+zrRLfzTLCCLI+4WxZEY1D8gHRuOFL5+TvXTi0C0wonhcq0K0MEhvUt1Cr9 r/FHRRKpCX4ramBIraPOUqZasQHM/Z3P5tjTUva9XllS4zocp+ce5p13VHO4wn8rtro+ v2NiMrnUcbD0W7Eh2jZk64rHiPW7rKphpPdaBy2lCD/LsHk5AqUewJ8WLUzZSwY7Y21c Qs/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rLiwQ7Aisx/Fct40RlEWj5FexYeUpewbEHaYhQmapwI=; b=NVvDrtqLKKFFySOXwGou2Mko0gczm4OP/9Lj2tbDnsB9R/9wBWqfUSAoXcBQSJ5mkl Jjge7aO8a0/OZvCEC3TEBYX55Za4bG0MPmmQtyVuFzhKJnrn/UtV8lfALpz2NpS8aMzf 0GMJ0q7dv55StDrTYriihT0EUfBezXaulykvGTPaxCBJy7AIi3oTdnA3AfHyevTv8x9d 32C/VR/qJM/FZHsAhI8Sstaf59SVC6nyNi9+HZSzUDTphDqKu0EeFxhgUiWOwGJ1latD F2z2/T0n3sE+TlFWp3lJEXJZQsQi/PeoR8ZGtdJpCOeGKMhDRrkNxuulzIupPyf1atjC IJwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BUyDdDvi; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu21si1404724edb.199.2021.01.12.06.19.59; Tue, 12 Jan 2021 06:20:24 -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=@linaro.org header.s=google header.b=BUyDdDvi; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbhALOSC (ORCPT + 99 others); Tue, 12 Jan 2021 09:18:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbhALOSC (ORCPT ); Tue, 12 Jan 2021 09:18:02 -0500 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6B7C06179F for ; Tue, 12 Jan 2021 06:17:22 -0800 (PST) Received: by mail-ua1-x930.google.com with SMTP id p2so866585uac.3 for ; Tue, 12 Jan 2021 06:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rLiwQ7Aisx/Fct40RlEWj5FexYeUpewbEHaYhQmapwI=; b=BUyDdDviQzrGZtoD8G/L9ZZzmGO6GemK7todlsnlbd0rVa7KTW3u8IrJKPqb/8RHKL xt2iSJp/n2fSg29NSed4RkVMbmCY64pJk4yh7AVcQfnvne84NBA9w56RGBVMYKqI3fRE Tq7hdSv4A9tFde3hyUPmWis4D9CECTR5ZOdPSK7wSCCE/6MsIM8KvytoZYs0X7OeeIYd fmFiJFHJmrcC10fGMedE740yhIxTmzk+SKoFVsQfpm5CfXLl1A5hCR0uMvRGQOAhZ2GM UH1T8K+YAivhtItsg+Q8OspPcDBKzVVBbLJNw/kjIV6J/m/IQ3Xey0Xy8SDGNdYBm/26 yoYw== 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=rLiwQ7Aisx/Fct40RlEWj5FexYeUpewbEHaYhQmapwI=; b=FTNH7bguRTSAg5I8w43CbGecKVbD7Olg6Uup0ZuktK/rqGEq7nNwOJxzkQ0dQsOkLi /0a32puH2U9gORKzXbNBiVeJtS8EIL3Iy10iHg3/yEYUEGJuJsuOmQGB2sNpjfDsqZI2 CHS8EYy4phUipzDSBIBDfnj2g4IjMhxnMOnyP4IfcwT2Ppqoln9za/ClqoYub64/9xBZ W7PlvxqopgbVmyhjtDy2j42WK+PuTpzq8jV0ZaMQ7tA8wuCjjMUr1zkPgAY04gFfzmRE lR9BvZzDupVEnH3RWL2QHbcOJTQZ+WXOrCTWbSOqWWg1hcGr5zaBuD9cCt5SDbiuuLnM P5xA== X-Gm-Message-State: AOAM530s/fhI220C8arVDkgLPf9JDsEMDDMoJ9YMHAWsd9ZmQEsa3HBE QwTzK8b0G8AYmujQ5RSHuTpQiNHqBfYK3TPWs2QIzNxWWEJp1lVK X-Received: by 2002:ab0:2e99:: with SMTP id f25mr3740445uaa.104.1610461041138; Tue, 12 Jan 2021 06:17:21 -0800 (PST) MIME-Version: 1.0 References: <20201217180638.22748-1-digetx@gmail.com> <20201217180638.22748-36-digetx@gmail.com> In-Reply-To: <20201217180638.22748-36-digetx@gmail.com> From: Ulf Hansson Date: Tue, 12 Jan 2021 15:16:44 +0100 Message-ID: Subject: Re: [PATCH v2 35/48] drm/tegra: dc: Support OPP and SoC core voltage scaling To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Mauro Carvalho Chehab , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Linux Kernel Mailing List , Linux Media Mailing List , linux-tegra Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - trimmed cc-list On Thu, 17 Dec 2020 at 19:08, Dmitry Osipenko wrote: > > Add OPP and SoC core voltage scaling support to the display controller > driver. This is required for enabling system-wide DVFS on pre-Tegra186 > SoCs. > > Tested-by: Peter Geis > Tested-by: Nicolas Chauvet > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/tegra/dc.c | 66 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 65 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c > index b6676f1fe358..105ad786e432 100644 > --- a/drivers/gpu/drm/tegra/dc.c > +++ b/drivers/gpu/drm/tegra/dc.c > @@ -11,9 +11,12 @@ > #include > #include > #include > +#include > +#include > #include > #include > > +#include > #include > > #include > @@ -1699,6 +1702,48 @@ int tegra_dc_state_setup_clock(struct tegra_dc *dc, > return 0; > } > > +static void tegra_dc_update_voltage_state(struct tegra_dc *dc, > + struct tegra_dc_state *state) > +{ > + unsigned long rate, pstate; > + struct dev_pm_opp *opp; > + int err; > + > + /* calculate actual pixel clock rate which depends on internal divider */ > + rate = DIV_ROUND_UP(clk_get_rate(dc->clk) * 2, state->div + 2); > + > + /* find suitable OPP for the rate */ > + opp = dev_pm_opp_find_freq_ceil(dc->dev, &rate); > + > + if (opp == ERR_PTR(-ERANGE)) > + opp = dev_pm_opp_find_freq_floor(dc->dev, &rate); > + > + /* -ENOENT means that this device-tree doesn't have OPP table */ > + if (opp == ERR_PTR(-ENOENT)) > + return; > + > + if (IS_ERR(opp)) { > + dev_err(dc->dev, "failed to find OPP for %luHz: %pe\n", > + rate, opp); > + return; > + } > + > + pstate = dev_pm_opp_get_voltage(opp); > + dev_pm_opp_put(opp); > + > + /* > + * The minimum core voltage depends on the pixel clock rate (which > + * depends on internal clock divider of the CRTC) and not on the > + * rate of the display controller clock. This is why we're not using > + * dev_pm_opp_set_rate() API and instead controlling the power domain > + * directly. > + */ > + err = dev_pm_genpd_set_performance_state(dc->dev, pstate); As you state above, in general we should not need to call the dev_pm_genpd_set_performance_state() directly for the consumer driver. Even if this looks like a special case to me, I would appreciate a confirmation from Viresh that this is the way he also would like to move forward from the opp library perspective. > + if (err) > + dev_err(dc->dev, "failed to set power domain state to %lu: %d\n", > + pstate, err); > +} > + [...] Kind regards Uffe