All of lore.kernel.org
 help / color / mirror / Atom feed
From: Agustin Gutierrez <agustin.gutierrez@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Harry.Wentland@amd.com>, <Sunpeng.Li@amd.com>,
	<Bhawanpreet.Lakha@amd.com>, <Rodrigo.Siqueira@amd.com>,
	<Aurabindo.Pillai@amd.com>, <qingqing.zhuo@amd.com>,
	<mikita.lipski@amd.com>,  <roman.li@amd.com>,
	<Anson.Jacob@amd.com>, <wayne.lin@amd.com>, <stylon.wang@amd.com>,
	<solomon.chiu@amd.com>, <pavle.kotarac@amd.com>,
	<agustin.gutierrez@amd.com>, Jake Wang <haonan.wang2@amd.com>,
	Eric Yang <eric.yang2@amd.com>
Subject: [PATCH 01/27] drm/amd/display: Disable dpp root clock when not being used
Date: Fri, 15 Oct 2021 14:43:06 -0400	[thread overview]
Message-ID: <20211015184332.221091-2-agustin.gutierrez@amd.com> (raw)
In-Reply-To: <20211015184332.221091-1-agustin.gutierrez@amd.com>

From: Jake Wang <haonan.wang2@amd.com>

[Why & How]
Disable root clock for dpp when not being used.

Reviewed-by: Eric Yang <eric.yang2@amd.com>
Acked-by: Agustin Gutierrez Sanchez <agustin.gutierrez@amd.com>
Signed-off-by: Jake Wang <haonan.wang2@amd.com>
---
 .../display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c  |  5 ++-
 .../gpu/drm/amd/display/dc/dcn31/dcn31_dccg.c | 41 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
index d7bf9283dc90..3fae1f1f028d 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
@@ -219,14 +219,17 @@ static void dcn31_update_clocks(struct clk_mgr *clk_mgr_base,
 		update_dispclk = true;
 	}
 
-	/* TODO: add back DTO programming when DPPCLK restore is fixed in FSDL*/
 	if (dpp_clock_lowered) {
 		// increase per DPP DTO before lowering global dppclk
+		dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
 		dcn31_smu_set_dppclk(clk_mgr, clk_mgr_base->clks.dppclk_khz);
 	} else {
 		// increase global DPPCLK before lowering per DPP DTO
 		if (update_dppclk || update_dispclk)
 			dcn31_smu_set_dppclk(clk_mgr, clk_mgr_base->clks.dppclk_khz);
+		// always update dtos unless clock is lowered and not safe to lower
+		if (new_clocks->dppclk_khz >= dc->current_state->bw_ctx.bw.dcn.clk.dppclk_khz)
+			dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
 	}
 
 	// notify DMCUB of latest clocks
diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dccg.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dccg.c
index 9896adf67425..582c500ecb49 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dccg.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dccg.c
@@ -42,6 +42,45 @@
 #define DC_LOGGER \
 	dccg->ctx->logger
 
+static void dccg31_update_dpp_dto(struct dccg *dccg, int dpp_inst, int req_dppclk)
+{
+	struct dcn_dccg *dccg_dcn = TO_DCN_DCCG(dccg);
+
+	if (dccg->ref_dppclk && req_dppclk) {
+		int ref_dppclk = dccg->ref_dppclk;
+		int modulo, phase;
+
+		// phase / modulo = dpp pipe clk / dpp global clk
+		modulo = 0xff;   // use FF at the end
+		phase = ((modulo * req_dppclk) + ref_dppclk - 1) / ref_dppclk;
+
+		if (phase > 0xff) {
+			ASSERT(false);
+			phase = 0xff;
+		}
+
+		REG_SET_2(DPPCLK_DTO_PARAM[dpp_inst], 0,
+				DPPCLK0_DTO_PHASE, phase,
+				DPPCLK0_DTO_MODULO, modulo);
+		REG_UPDATE(DPPCLK_DTO_CTRL,
+				DPPCLK_DTO_ENABLE[dpp_inst], 1);
+	} else {
+		//DTO must be enabled to generate a 0Hz clock output
+		if (dccg->ctx->dc->debug.root_clock_optimization.bits.dpp) {
+			REG_UPDATE(DPPCLK_DTO_CTRL,
+					DPPCLK_DTO_ENABLE[dpp_inst], 1);
+			REG_SET_2(DPPCLK_DTO_PARAM[dpp_inst], 0,
+					DPPCLK0_DTO_PHASE, 0,
+					DPPCLK0_DTO_MODULO, 1);
+		} else {
+			REG_UPDATE(DPPCLK_DTO_CTRL,
+					DPPCLK_DTO_ENABLE[dpp_inst], 0);
+		}
+	}
+	dccg->pipe_dppclk_khz[dpp_inst] = req_dppclk;
+}
+
+
 void dccg31_set_dpstreamclk(
 		struct dccg *dccg,
 		enum hdmistreamclk_source src,
@@ -401,7 +440,7 @@ void dccg31_init(struct dccg *dccg)
 }
 
 static const struct dccg_funcs dccg31_funcs = {
-	.update_dpp_dto = dccg2_update_dpp_dto,
+	.update_dpp_dto = dccg31_update_dpp_dto,
 	.get_dccg_ref_freq = dccg31_get_dccg_ref_freq,
 	.dccg_init = dccg31_init,
 	.set_dpstreamclk = dccg31_set_dpstreamclk,
-- 
2.25.1


  reply	other threads:[~2021-10-15 18:43 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 18:43 [PATCH 00/27] DC Patchset for October 15 Agustin Gutierrez
2021-10-15 18:43 ` Agustin Gutierrez [this message]
2021-10-15 18:43 ` [PATCH 02/27] drm/amd/display: Clear encoder assignment for copied streams Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 03/27] drm/amd/display: Do not skip link training on DP quick hot plug Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 04/27] drm/amd/display: add DP2.0 debug option to set MST_EN for SST stream Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 05/27] drm/amd/display: Clean Up VPG Low Mem Power Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 06/27] drm/amd/display: do not compare integers of different widths Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 07/27] drm/amd/display: correct apg audio channel enable golden value Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 08/27] drm/amd/display: Validate plane rects before use Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 09/27] drm/amd/display: Removed power down on boot from DCN31 Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 10/27] drm/amd/display: Limit display scaling to up to true 4k for DCN 3.1 Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 11/27] drm/amd/display: Fix DP2 SE and LE SYMCLK selection for B0 PHY Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 12/27] drm/amd/display: Fix prefetch bandwidth calculation for DCN3.1 Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 13/27] drm/amd/display: Add missing PSR state Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 14/27] drm/amd/display: Disable dsc root clock when not being used Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 15/27] drm/amd/display: Require immediate flip support for DCN3.1 planes Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 16/27] drm/amd/display: increase Z9 latency to workaround underflow in Z9 Agustin Gutierrez
2021-10-15 23:53   ` Mike Lothian
2021-10-18 17:14     ` Kazlauskas, Nicholas
2021-10-18 22:57       ` Paul Menzel
2021-10-15 18:43 ` [PATCH 17/27] drm/amd/display: Increase watermark latencies for DCN3.1 Agustin Gutierrez
2021-10-18 22:56   ` Paul Menzel
2021-10-15 18:43 ` [PATCH 18/27] drm/amd/display: Disable dpstreamclk, symclk32_se, and symclk32_le Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 19/27] drm/amd/display: Removed z10 save after dsc disable Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 20/27] drm/amd/display: Moved dccg init to after bios golden init Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 21/27] drm/amd/display: Disable hdmistream and hdmichar clocks Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 22/27] drm/amd/display: Change initializer to single brace Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 23/27] drm/amd/display: 3.2.157 Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 24/27] drm/amd/display: Add bios parser support for latest firmware_info Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 25/27] drm/amd/display: [FW Promotion] Release 0.0.88 Agustin Gutierrez
2021-10-15 18:43 ` [PATCH 26/27] Revert "drm/amd/display: Fix error in dmesg at boot" Agustin Gutierrez
2021-10-18 23:23   ` Paul Menzel
2021-10-15 18:43 ` [PATCH 27/27] Revert "drm/amd/display: Add helper for blanking all dp displays" Agustin Gutierrez
2021-10-18 23:25   ` Paul Menzel
2021-10-18 17:01 ` [PATCH 00/27] DC Patchset for October 15 Wheeler, Daniel
  -- strict thread matches above, loose matches on Subject: below --
2021-10-15 18:38 [PATCH 00/27] DC patchset " Agustin Gutierrez
2021-10-15 18:38 ` [PATCH 01/27] drm/amd/display: Disable dpp root clock when not being used Agustin Gutierrez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211015184332.221091-2-agustin.gutierrez@amd.com \
    --to=agustin.gutierrez@amd.com \
    --cc=Anson.Jacob@amd.com \
    --cc=Aurabindo.Pillai@amd.com \
    --cc=Bhawanpreet.Lakha@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Sunpeng.Li@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=eric.yang2@amd.com \
    --cc=haonan.wang2@amd.com \
    --cc=mikita.lipski@amd.com \
    --cc=pavle.kotarac@amd.com \
    --cc=qingqing.zhuo@amd.com \
    --cc=roman.li@amd.com \
    --cc=solomon.chiu@amd.com \
    --cc=stylon.wang@amd.com \
    --cc=wayne.lin@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.