Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1410327pxb; Fri, 1 Oct 2021 10:02:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg0MU2fET57V1iuLKzcPTsBIFTGR1p2G9D/7n2smBo73z69UtJyWBM5BIApmbdPEqCmm9E X-Received: by 2002:aa7:cccb:: with SMTP id y11mr10622752edt.277.1633107734252; Fri, 01 Oct 2021 10:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633107734; cv=none; d=google.com; s=arc-20160816; b=QF/edSV/5cBWT3QNq+IlG8/7Hcqk50mxULjCTrmHb6p8B84wVYCONJgcnfRIDL5Lv+ P5zfBSVEYH1yQHeSTFpipqatxFA0ghZ/F4Dht57KgynxCcLm7D734zT0DFuYT8XMZ3u1 7dv5JXuUFsifD7Q54LS39hVWFfAO7Pjmt6obzf3rQIVuD2zxAsRNmPwQKWvxct1q9zIU 4uMKYEgtXjI4rtU19B3Ru0P+B2LgzVR4/Qrwdidm8usq2R4ahCRetFIK0RcZ0IinZ3kQ pXjbZGoj/w0bxOS580SX31sFTfA2BfcKyw7DNjipmkj5KhGQott3f9l4IJQ4mail0ilP mpNA== 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=xnpGYuY4J1MVx4KDnwBO9exyn8J4DWmp5PYIqZLE1ug=; b=eSb51M2/7obiyOMGYfAGeI88qYtn33Q2iSRQzCtofgWxwQKO/iwK6EMv36wcMvyoMO F1MftKwuMIcUeqsjRwcEHEbRd7mnwWw9J+y6WRLB7o+n8SBZ0/DyPVIjIJiNQrwUGRJD /jj8xXsyVGi1DjGEa7WQLHwb6D66GYk1ttZLpjld1i/lS/OtnHiqE9ik+xnBTLLj9u1I d6mp2UFYFwNqcHn7c3aH7SqnnOwx9nE7Sw+NUUkw4/cWZJ6wvK8HTPOalmrxZQJla/0V sraMjSneQKY+Eojyy0ldpf0oomGUOelZd5JnNnjM5q5BO8JbEy++AFL5s3Bz8PYjcRit hbsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=soKJl7cw; 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 g22si7521811edr.31.2021.10.01.10.01.48; Fri, 01 Oct 2021 10:02:14 -0700 (PDT) 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=soKJl7cw; 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 S231696AbhJAN3q (ORCPT + 99 others); Fri, 1 Oct 2021 09:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbhJAN3o (ORCPT ); Fri, 1 Oct 2021 09:29:44 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18B7EC0613E4 for ; Fri, 1 Oct 2021 06:28:00 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id x27so38389142lfa.9 for ; Fri, 01 Oct 2021 06:28:00 -0700 (PDT) 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=xnpGYuY4J1MVx4KDnwBO9exyn8J4DWmp5PYIqZLE1ug=; b=soKJl7cwWQ3W4UwDFjN+58V2v5RYuIU0YxRyxYMaINgwEK5Kb355awQUMWcroWHbJo Me+RUP02Enm/bzqDvehZEy7fQWF2sFk9LJqMd5m/oBPklwKMhRK7hJMny9eAuGu48VPg MSymtPMTr3GkgTLH1I0AnDMIx+ROIV7T3NCdZ0xbue3PhEXGHJsxVY0jL8xMzXcrMbrF kX9nrs5tMRkTdxtvQynLy7JVj76hAaAk5aVHedbxGyXGBw0WCCM+yzL88UZ1fDKJWz6p 2U52t9cbC9WvtuCg3In2JTTZikJOCaAF8ZLYIYIgSv9a8V8aXXGALPL3LrFK+MyO1ntj GZzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xnpGYuY4J1MVx4KDnwBO9exyn8J4DWmp5PYIqZLE1ug=; b=3KPgPdnvHdH6ZUScIq85ip0cTZYteXjai8365/9NgM4lxoFcEY/KgIMDPGMX+Kfzih RNZzOC1115v5yRa4njrUvmBWgTYNE2C41+/W8lgrMi+xXaVUhhepTarWfAMMC6vOcVqV WFkF8xWEtywuJ2gtRUXjG66bRTVO1piieJaqcooHZboKyqCoePEmY7Vg09hdezPwcYfL LFkoltiQ1Ldyki59CS/cBf8S8MVAB3gQDr7FUJ25ljLnJXNCjFm2lvEYYPKBCg+BeAbB zyyat9uMq6xbaWYWQ2Hndro9Y18/hLisTpvM658eCY25Uax7jjg8Owv6zTs+pdrAIRd/ ranA== X-Gm-Message-State: AOAM530/huKvFypeoGyzIfuWMnWnG9jdqskOrgmZU4suyD+DQ9vQDKv+ pGYjrWK5cmQVFCdxaBBkeVErK1qNBnZ4AuGvdylFLQ== X-Received: by 2002:a05:651c:20b:: with SMTP id y11mr12340667ljn.463.1633094876449; Fri, 01 Oct 2021 06:27:56 -0700 (PDT) MIME-Version: 1.0 References: <20210926224058.1252-1-digetx@gmail.com> <20210926224058.1252-12-digetx@gmail.com> In-Reply-To: <20210926224058.1252-12-digetx@gmail.com> From: Ulf Hansson Date: Fri, 1 Oct 2021 15:27:20 +0200 Message-ID: Subject: Re: [PATCH v13 11/35] drm/tegra: dc: Support OPP and SoC core voltage scaling To: Dmitry Osipenko , Viresh Kumar Cc: Thierry Reding , Jonathan Hunter , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Peter Chen , Lee Jones , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Nishanth Menon , Adrian Hunter , Michael Turquette , Linux Kernel Mailing List , linux-tegra , Linux PM , Linux USB List , linux-staging@lists.linux.dev, linux-pwm@vger.kernel.org, linux-mmc , dri-devel , DTML , linux-clk , Mark Brown , Vignesh Raghavendra , Richard Weinberger , Miquel Raynal , Lucas Stach , Stefan Agner , Mauro Carvalho Chehab , David Heidelberg Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Sept 2021 at 00:42, 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 # Ouya T30 > Tested-by: Paul Fertser # PAZ00 T20 > Tested-by: Nicolas Chauvet # PAZ00 T20 and TK1 T124 > Tested-by: Matt Merhar # Ouya T30 > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/tegra/dc.c | 74 ++++++++++++++++++++++++++++++++++++++ > drivers/gpu/drm/tegra/dc.h | 2 ++ > 2 files changed, 76 insertions(+) > > diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c > index a29d64f87563..d4047a14e2b6 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 > @@ -1762,6 +1765,47 @@ 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; > + > + if (!dc->has_opp_table) > + return; > + > + /* 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); > + > + if (IS_ERR(opp)) { > + dev_err(dc->dev, "failed to find OPP for %luHz: %pe\n", > + rate, opp); > + return; > + } > + > + pstate = dev_pm_opp_get_required_pstate(opp, 0); > + 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); > + if (err) > + dev_err(dc->dev, "failed to set power domain state to %lu: %d\n", > + pstate, err); Yeah, the above code looks very similar to the code I pointed to in patch6. Perhaps we need to discuss with Viresh, whether it makes sense to fold in a patch adding an opp helper function after all, to avoid the open coding. Viresh? [...] Kind regards Uffe