Skip to contentSkip to conversation

drm/amd/display: Fix incorrect cursor position for dcn401

PATCH In review Aurabindo Pillai 2 participants 14 messages May 23, 2024 – May 27, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/13 drm/amd/display: Fix incorrect cursor position for dcn401

From: "Arvindekar, Sridevi" <[email protected]>

[Why]
Incorrect cursor position calculation in some scenarios. Also for mirror and rotation cases.

[How]
Fix for incorrect cursor position. Added new test scenarios for diags cursor test. Updated CRC for few of the diags cursor test scenarios.

---
 .../amd/display/dc/dpp/dcn401/dcn401_dpp_cm.c | 18 +++++++----
 .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 30 +++++++++++++------
 2 files changed, 34 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp_cm.c +13 -5
index a54b9089f15d..aef73bd1221a 100644
@@ -185,15 +185,23 @@ void dpp401_set_cursor_position(
 		rec_y_offset = y_pos - (cursor_height - y_hotspot);
 	}
 
-	if (rec_x_offset >= (int)param->recout.width)
-		cur_en = 0;  /* not visible beyond right edge*/
+	if (param->rotation == ROTATION_ANGLE_0 && !param->mirror) {
+		if (rec_x_offset >= (int)param->recout.width)
+			cur_en = 0;  /* not visible beyond right edge*/
+
+		if (rec_y_offset >= (int)param->recout.height)
+			cur_en = 0;  /* not visible beyond bottom edge*/
+	} else {
+		if (rec_x_offset > (int)param->recout.width)
+			cur_en = 0;  /* not visible beyond right edge*/
+
+		if (rec_y_offset > (int)param->recout.height)
+			cur_en = 0;  /* not visible beyond bottom edge*/
+	}
 
 	if (rec_x_offset + cursor_width <= 0)
 		cur_en = 0;  /* not visible beyond left edge*/
 
-	if (rec_y_offset >= (int)param->recout.height)
-		cur_en = 0;  /* not visible beyond bottom edge*/
-
 	if (rec_y_offset + cursor_height <= 0)
 		cur_en = 0;  /* not visible beyond top edge*/
 
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +21 -9
index f5333a095adb..407a45a3ae2c 100644
@@ -1126,14 +1126,14 @@ void dcn401_set_cursor_position(struct pipe_ctx *pipe_ctx)
 	 */
 
 	if (param.rotation == ROTATION_ANGLE_90 || param.rotation == ROTATION_ANGLE_270) {
-		x_pos = x_pos * pipe_ctx->stream->dst.width /
+		x_pos = pipe_ctx->stream->dst.x + x_pos * pipe_ctx->stream->dst.width /
 			pipe_ctx->stream->src.height;
-		y_pos = y_pos * pipe_ctx->stream->dst.height /
+		y_pos = pipe_ctx->stream->dst.y + y_pos * pipe_ctx->stream->dst.height /
 			pipe_ctx->stream->src.width;
 	} else {
-		x_pos = x_pos * pipe_ctx->stream->dst.width /
+		x_pos = pipe_ctx->stream->dst.x + x_pos * pipe_ctx->stream->dst.width /
 			pipe_ctx->stream->src.width;
-		y_pos = y_pos * pipe_ctx->stream->dst.height /
+		y_pos = pipe_ctx->stream->dst.y + y_pos * pipe_ctx->stream->dst.height /
 			pipe_ctx->stream->src.height;
 	}
 
@@ -1225,10 +1225,15 @@ void dcn401_set_cursor_position(struct pipe_ctx *pipe_ctx)
 			}
 		}
 	} else if (param.rotation == ROTATION_ANGLE_90) {
-		uint32_t temp_y = pos_cpy.y;
+		if (!param.mirror) {
+			uint32_t temp_y = pos_cpy.y;
+
+			pos_cpy.y = pipe_ctx->plane_res.scl_data.recout.height - pos_cpy.x;
+			pos_cpy.x = temp_y - prev_odm_width;
+		} else {
+			swap(pos_cpy.x, pos_cpy.y);
+		}
 
-		pos_cpy.y = pipe_ctx->plane_res.scl_data.recout.height - pos_cpy.x;
-		pos_cpy.x = temp_y - prev_odm_width;
 	} else if (param.rotation == ROTATION_ANGLE_270) {
 		// Swap axis and mirror vertically
 		uint32_t temp_x = pos_cpy.x;
@@ -1279,8 +1284,15 @@ void dcn401_set_cursor_position(struct pipe_ctx *pipe_ctx)
 				pos_cpy.y = temp_x;
 			}
 		} else {
-			pos_cpy.x = pipe_ctx->plane_res.scl_data.recout.width - pos_cpy.y;
-			pos_cpy.y = temp_x;
+			if (param.mirror) {
+				swap(pos_cpy.x, pos_cpy.y);
+
+				pos_cpy.x = pipe_ctx->plane_res.scl_data.recout.width - pos_cpy.x + 2 * pipe_ctx->plane_res.scl_data.recout.x;
+				pos_cpy.y = (2 * pipe_ctx->plane_res.scl_data.recout.y) + pipe_ctx->plane_res.scl_data.recout.height - pos_cpy.y;
+			} else {
+				pos_cpy.x = pipe_ctx->plane_res.scl_data.recout.width - pos_cpy.y;
+				pos_cpy.y = temp_x;
+			}
 		}
 	} else if (param.rotation == ROTATION_ANGLE_180) {
 		// Mirror horizontally and vertically
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/13 drm/amd/display: Enable ISHARP support for DCN401

From: Samson Tam <[email protected]>

[Why]
Enable sharpener support for DCN401

[How]
- Removed memcmp check that was preventing ISHARP from being enabled.
- Add missing ISHARP register defines, masks, and writes.
- Add programming of Blur and Scale coefficients.
- Program FMT_MODE and NLDELTA registers based on LLS_PREF and pixel
- format
- Only enable ISHARP for YUV420
- Add disabling of ISHARP
- Add debug flags and registry keys for debugging ISHARP.
- Set default to medium level

---
 drivers/gpu/drm/amd/display/dc/dc.h           |   1 +
 .../gpu/drm/amd/display/dc/dc_spl_translate.c |  29 ++--
 .../display/dc/dpp/dcn401/dcn401_dpp_dscl.c   | 149 ++++++++++++++----
 .../dc/resource/dcn401/dcn401_resource.h      |  13 ++
 drivers/gpu/drm/amd/display/dc/spl/dc_spl.c   |  81 ++++++++--
 .../display/dc/spl/dc_spl_isharp_filters.c    |   8 +-
 .../display/dc/spl/dc_spl_isharp_filters.h    |   4 +-
 .../gpu/drm/amd/display/dc/spl/dc_spl_types.h |   3 +
 8 files changed, 223 insertions(+), 65 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
index a711e3fd6f1b..1055970d3888 100644
@@ -1040,6 +1040,7 @@ struct dc_debug_options {
 	unsigned int force_cositing;
 	unsigned int disable_spl;
 	unsigned int force_easf;
+	unsigned int force_sharpness;
 	unsigned int force_lls;
 };
 
drivers/gpu/drm/amd/display/dc/dc_spl_translate.c +19 -10
index 6e37b166802b..bc760448a378 100644
@@ -134,16 +134,25 @@ void translate_SPL_in_params_from_pipe_ctx(struct pipe_ctx *pipe_ctx, struct spl
 		spl_in->prefer_easf = false;
 	else if (pipe_ctx->stream->ctx->dc->debug.force_easf == 2)
 		spl_in->disable_easf = true;
-	// Translate adaptive sharpening preference
-	spl_in->adaptive_sharpness.enable = plane_state->adaptive_sharpness_en;
-	if (plane_state->sharpnessX1000 == 0)	{
-		spl_in->adaptive_sharpness.enable = false;
-	} else if (plane_state->sharpnessX1000 < 999)	{
-		spl_in->adaptive_sharpness.sharpness = SHARPNESS_LOW;
-	} else if (plane_state->sharpnessX1000 < 1999)	{
-		spl_in->adaptive_sharpness.sharpness = SHARPNESS_MID;
-	} else	{	// Any other value is high sharpness
-		spl_in->adaptive_sharpness.sharpness = SHARPNESS_HIGH;
+	/* Translate adaptive sharpening preference */
+	if (pipe_ctx->stream->ctx->dc->debug.force_sharpness > 0) {
+		spl_in->adaptive_sharpness.enable = (pipe_ctx->stream->ctx->dc->debug.force_sharpness > 1) ? true : false;
+		if (pipe_ctx->stream->ctx->dc->debug.force_sharpness == 2)
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_LOW;
+		else if (pipe_ctx->stream->ctx->dc->debug.force_sharpness == 3)
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_MID;
+		else if (pipe_ctx->stream->ctx->dc->debug.force_sharpness >= 4)
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_HIGH;
+	} else {
+		spl_in->adaptive_sharpness.enable = plane_state->adaptive_sharpness_en;
+		if (plane_state->sharpnessX1000 == 0)
+			spl_in->adaptive_sharpness.enable = false;
+		else if (plane_state->sharpnessX1000 < 999)
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_LOW;
+		else if (plane_state->sharpnessX1000 < 1999)
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_MID;
+		else // Any other value is high sharpness
+			spl_in->adaptive_sharpness.sharpness = SHARPNESS_HIGH;
 	}
 	// Translate linear light scaling preference
 	if (pipe_ctx->stream->ctx->dc->debug.force_lls > 0)
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp_dscl.c +116 -33

163 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.h +13 -0
index a638c410e32a..c04c8b8f2114 100644
@@ -387,6 +387,19 @@ bool dcn401_validate_bandwidth(struct dc *dc,
 	SRI_ARR(DSCL_EASF_V_BF3_PWL_SEG5, DSCL, id),                             \
 	SRI_ARR(DSCL_SC_MATRIX_C0C1, DSCL, id),                                  \
 	SRI_ARR(DSCL_SC_MATRIX_C2C3, DSCL, id),                                  \
+	SRI_ARR(ISHARP_MODE, DSCL, id),                                          \
+	SRI_ARR(ISHARP_NOISEDET_THRESHOLD, DSCL, id),                            \
+	SRI_ARR(ISHARP_NOISE_GAIN_PWL, DSCL, id),                                \
+	SRI_ARR(ISHARP_LBA_PWL_SEG0, DSCL, id),                                  \
+	SRI_ARR(ISHARP_LBA_PWL_SEG1, DSCL, id),                                  \
+	SRI_ARR(ISHARP_LBA_PWL_SEG2, DSCL, id),                                  \
+	SRI_ARR(ISHARP_LBA_PWL_SEG3, DSCL, id),                                  \
+	SRI_ARR(ISHARP_LBA_PWL_SEG4, DSCL, id),                                  \
+	SRI_ARR(ISHARP_LBA_PWL_SEG5, DSCL, id),                                  \
+	SRI_ARR(ISHARP_DELTA_CTRL, DSCL, id),                                    \
+	SRI_ARR(ISHARP_DELTA_DATA, DSCL, id),                                    \
+	SRI_ARR(ISHARP_DELTA_INDEX, DSCL, id),                                   \
+	SRI_ARR(ISHARP_NLDELTA_SOFT_CLIP, DSCL, id),                             \
 	SRI_ARR(SCL_VERT_FILTER_INIT_BOT, DSCL, id),                             \
 	SRI_ARR(SCL_VERT_FILTER_INIT_BOT_C, DSCL, id)
 
drivers/gpu/drm/amd/display/dc/spl/dc_spl.c +65 -16

141 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/spl/dc_spl_isharp_filters.c +4 -4
index 26b48b3576a5..8bc838c7c3c5 100644
@@ -241,7 +241,7 @@ static const uint32_t filter_isharp_1D_lut_2p0x[32] = {
 // <CoefType>		LanczosEd
 // <CoefQuant>		S1.10
 //========================================================
-static const uint32_t filter_isharp_wide_6tap_64p[198] = {
+static const uint16_t filter_isharp_wide_6tap_64p[198] = {
 0x0000, 0x0000, 0x0400, 0x0000, 0x0000, 0x0000,
 0x0003, 0x0FF3, 0x0400, 0x000D, 0x0FFD, 0x0000,
 0x0006, 0x0FE7, 0x03FE, 0x001C, 0x0FF9, 0x0000,
@@ -285,7 +285,7 @@ static const uint32_t filter_isharp_wide_6tap_64p[198] = {
 // <CoefType>		Blur & Scale LPF
 // <CoefQuant>		S1.10
 //========================================================
-static const uint32_t filter_isharp_bs_4tap_64p[198] = {
+static const uint16_t filter_isharp_bs_4tap_64p[198] = {
 0x0000, 0x00E5, 0x0237, 0x00E4, 0x0000, 0x0000,
 0x0000, 0x00DE, 0x0237, 0x00EB, 0x0000, 0x0000,
 0x0000, 0x00D7, 0x0236, 0x00F2, 0x0001, 0x0000,
@@ -340,11 +340,11 @@ const uint32_t *spl_get_filter_isharp_1D_lut_2p0x(void)
 {
 	return filter_isharp_1D_lut_2p0x;
 }
-const uint32_t *spl_get_filter_isharp_wide_6tap_64p(void)
+const uint16_t *spl_get_filter_isharp_wide_6tap_64p(void)
 {
 	return filter_isharp_wide_6tap_64p;
 }
-const uint32_t *spl_get_filter_isharp_bs_4tap_64p(void)
+const uint16_t *spl_get_filter_isharp_bs_4tap_64p(void)
 {
 	return filter_isharp_bs_4tap_64p;
 }
drivers/gpu/drm/amd/display/dc/spl/dc_spl_isharp_filters.h +2 -2
index ff189d86e534..1aaf4c50c1bc 100644
@@ -12,6 +12,6 @@ const uint32_t *spl_get_filter_isharp_1D_lut_0p5x(void);
 const uint32_t *spl_get_filter_isharp_1D_lut_1p0x(void);
 const uint32_t *spl_get_filter_isharp_1D_lut_1p5x(void);
 const uint32_t *spl_get_filter_isharp_1D_lut_2p0x(void);
-const uint32_t *spl_get_filter_isharp_bs_4tap_64p(void);
-const uint32_t *spl_get_filter_isharp_wide_6tap_64p(void);
+const uint16_t *spl_get_filter_isharp_bs_4tap_64p(void);
+const uint16_t *spl_get_filter_isharp_wide_6tap_64p(void);
 #endif /* __DC_SPL_ISHARP_FILTERS_H__ */
drivers/gpu/drm/amd/display/dc/spl/dc_spl_types.h +3 -0
index 0c9edee0582e..a8f7fccfa16b 100644
@@ -393,6 +393,9 @@ struct dscl_prog_data {
 	struct isharp_fmt isharp_fmt;   //      ISHARP_FMT
 	const uint32_t *isharp_delta;
 	struct isharp_nldelta_sclip isharp_nldelta_sclip;       //      ISHARP_NLDELTA_SCLIP
+	/* blur and scale filter */
+	const uint16_t *filter_blur_scale_v;
+	const uint16_t *filter_blur_scale_h;
 };
 
 /* SPL input and output definitions */
Signature · 1 line
2.39.2
#2 lore raw

PATCH 3/13 drm/amd/display: Remove unused code

In reply to Aurabindo Pillai

From: Rodrigo Siqueira <[email protected]>

This commit removes some unused code with the required adjustments.

---
 drivers/gpu/drm/amd/display/dc/dc.h                         | 1 -
 drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.h      | 2 +-
 drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c                 | 5 -----
 .../gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c    | 6 +-----
 4 files changed, 2 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/dc.h +0 -1
index 1055970d3888..31e3371b1b2e 100644
@@ -1587,7 +1587,6 @@ struct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
 uint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
 
 void dc_set_disable_128b_132b_stream_overhead(bool disable);
-bool dc_get_disable_128b_132b_stream_overhead(void);
 
 /* The function returns minimum bandwidth required to drive a given timing
  * return - minimum required timing bandwidth in kbps.
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.h +1 -1
index 1aaae7a5bd41..4bc85aaf17da 100644
@@ -726,4 +726,4 @@ void dpp401_set_cursor_matrix(
 	enum dc_color_space color_space,
 	struct dc_csc_transform cursor_csc_color_matrix);
 
-#endif
+#endif /* __DCN401_DPP_H__ */
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -5
index b9d10e95ef7a..a1727e5bf024 100644
@@ -1261,11 +1261,6 @@ void dc_set_disable_128b_132b_stream_overhead(bool disable)
 	disable_128b_132b_stream_overhead = disable;
 }
 
-bool dc_get_disable_128b_132b_stream_overhead(void)
-{
-	return disable_128b_132b_stream_overhead;
-}
-
 void dc_dsc_get_default_config_option(const struct dc *dc, struct dc_dsc_config_options *options)
 {
 	options->dsc_min_slice_height_override = dc->debug.dsc_min_slice_height_override;
drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c +1 -5
index 597817b51228..054607c944a3 100644
@@ -880,12 +880,8 @@ static void dcn401_program_compbuf_segments(struct hubbub *hubbub, unsigned comp
 				+ hubbub2->det3_size + compbuf_size_seg <= hubbub2->crb_size_segs);
 		REG_UPDATE(DCHUBBUB_COMPBUF_CTRL, COMPBUF_SIZE, compbuf_size_seg);
 		hubbub2->compbuf_size_segments = compbuf_size_seg;
-#ifdef DIAGS_BUILD
-		REG_GET(DCHUBBUB_COMPBUF_CTRL, CONFIG_ERROR, &cur_compbuf_size_seg);
-		ASSERT(!cur_compbuf_size_seg);
-#else
+
 		ASSERT(REG_GET(DCHUBBUB_COMPBUF_CTRL, CONFIG_ERROR, &cur_compbuf_size_seg) && !cur_compbuf_size_seg);
-#endif
 	}
 }
 
Signature · 1 line
2.39.2
#3 lore raw

PATCH 4/13 drm/amd/display: Refactor HUBP into component folder.

In reply to Aurabindo Pillai

From: Pinninti <[email protected]>

[why]
cleaning up the code refactor requires hubp to be in its own component.

[how]
move all files under newly created hubp folder and fixing the makefiles.

---
 drivers/gpu/drm/amd/display/dc/dcn401/Makefile           | 1 -
 drivers/gpu/drm/amd/display/dc/hubp/Makefile             | 9 +++++++--
 .../drm/amd/display/dc/{ => hubp}/dcn401/dcn401_hubp.c   | 0
 .../drm/amd/display/dc/{ => hubp}/dcn401/dcn401_hubp.h   | 0
 4 files changed, 7 insertions(+), 3 deletions(-)
 rename drivers/gpu/drm/amd/display/dc/{ => hubp}/dcn401/dcn401_hubp.c (100%)
 rename drivers/gpu/drm/amd/display/dc/{ => hubp}/dcn401/dcn401_hubp.h (100%)
drivers/gpu/drm/amd/display/dc/dcn401/Makefile +0 -1
index f3fdfa1fba37..2989e706bccf 100644
@@ -4,7 +4,6 @@
 
 DCN401 += dcn401_dio_link_encoder.o
 DCN401 += dcn401_dio_stream_encoder.o
-DCN401 += dcn401_hubp.o
 DCN401 += dcn401_mpc.o
 
 AMD_DAL_DCN401 = $(addprefix $(AMDDALPATH)/dc/dcn401/,$(DCN401))
drivers/gpu/drm/amd/display/dc/hubp/Makefile +7 -2
index a25a8b216e15..a2d1128de7a1 100644
@@ -88,5 +88,10 @@ AMD_DISPLAY_FILES += $(AMD_DAL_HUBP_DCN35)
 
 ###############################################################################
 
-###############################################################################
-endif
\ No newline at end of file
+HUBP_DCN401 = dcn401_hubp.o
+
+AMD_DAL_HUBP_DCN401 = $(addprefix $(AMDDALPATH)/dc/hubp/dcn401/,$(HUBP_DCN401))
+
+AMD_DISPLAY_FILES += $(AMD_DAL_HUBP_DCN401)
+
+endif
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c renamed from drivers/gpu/drm/amd/display/dc/dcn401/dcn401_hubp.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/amd/display/dc/dcn401/dcn401_hubp.c
rename to drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c
drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.h renamed from drivers/gpu/drm/amd/display/dc/dcn401/dcn401_hubp.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/amd/display/dc/dcn401/dcn401_hubp.h
rename to drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.h
Signature · 1 line
2.39.2
#4 lore raw

PATCH 5/13 drm/amd/display: Update DML2.1 generated code

In reply to Aurabindo Pillai

Most of the DML code is generated, and it is necessary to update some parts of it from time to time. This commit brings the latest generated code for DML 2.1.

---
 .../dc/dml2/dml21/dml21_translation_helper.c  |   19 +-
 .../amd/display/dc/dml2/dml21/dml21_wrapper.c |    2 +-
 .../dml21/inc/bounding_boxes/dcn4_soc_bb.h    |   27 +-
 .../dml21/inc/dml_top_display_cfg_types.h     |    9 +-
 .../dml21/inc/dml_top_soc_parameter_types.h   |    3 +
 .../display/dc/dml2/dml21/inc/dml_top_types.h |    6 +-
 .../dml2/dml21/src/dml2_core/dml2_core_dcn4.c |  110 +-
 .../src/dml2_core/dml2_core_dcn4_calcs.c      | 2265 ++++++++++-------
 .../dml21/src/dml2_core/dml2_core_shared.c    |  176 +-
 .../src/dml2_core/dml2_core_shared_types.h    |  109 +-
 .../dml2/dml21/src/dml2_dpmm/dml2_dpmm_dcn4.c |   96 +-
 .../dml21/src/dml2_dpmm/dml2_dpmm_factory.c   |    1 +
 .../dml2/dml21/src/dml2_mcg/dml2_mcg_dcn4.c   |  101 +-
 .../dml2/dml21/src/dml2_mcg/dml2_mcg_dcn4.h   |    2 +-
 .../dml2/dml21/src/dml2_pmo/dml2_pmo_dcn3.c   |   29 +-
 .../dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4.c   |   38 +-
 .../dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c  |  175 +-
 .../dml21/src/dml2_pmo/dml2_pmo_factory.h     |    2 +-
 .../lib_float_math.c                          |   16 +-
 .../lib_float_math.h                          |    3 +-
 .../dc/dml2/dml21/src/dml2_top/dml_top.c      |    3 +-
 .../dml2/dml21/src/dml2_top/dml_top_mcache.c  |   37 +-
 .../dml2/dml21/src/dml2_top/dml_top_mcache.h  |    2 +-
 .../dc/dml2/dml21/src/inc/dml2_debug.h        |    2 +-
 .../src/inc/dml2_internal_shared_types.h      |   15 +-
 25 files changed, 2069 insertions(+), 1179 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c +14 -5
index e4c18417b6d7..37998f2c0b14 100644
@@ -338,7 +338,8 @@ void dml21_apply_soc_bb_overrides(struct dml2_initialize_instance_in_out *dml_in
 }
 
 static void populate_dml21_timing_config_from_stream_state(struct dml2_timing_cfg *timing,
-		struct dc_stream_state *stream)
+		struct dc_stream_state *stream,
+		struct dml2_context *dml_ctx)
 {
 	unsigned int hblank_start, vblank_start;
 
@@ -372,7 +373,12 @@ static void populate_dml21_timing_config_from_stream_state(struct dml2_timing_cf
 	timing->drr_config.drr_active_variable = stream->vrr_active_variable;
 	timing->drr_config.drr_active_fixed = stream->vrr_active_fixed;
 	timing->drr_config.disallowed = !stream->allow_freesync;
-	//timing->drr_config.max_instant_vtotal_delta = timing-><drr no flicker delta lum>;
+
+	if (dml_ctx->config.callbacks.get_max_flickerless_instant_vtotal_increase &&
+			stream->ctx->dc->config.enable_fpo_flicker_detection == 1)
+		timing->drr_config.max_instant_vtotal_delta = dml_ctx->config.callbacks.get_max_flickerless_instant_vtotal_increase(stream, false);
+	else
+		timing->drr_config.max_instant_vtotal_delta = 0;
 
 	if (stream->timing.flags.DSC) {
 		timing->dsc.enable = dml2_dsc_enable;
@@ -505,7 +511,8 @@ static void populate_dml21_stream_overrides_from_stream_state(
 		stream_desc->overrides.odm_mode =  dml2_odm_mode_auto;
 		break;
 	}
-	if (!stream->ctx->dc->debug.enable_single_display_2to1_odm_policy)
+	if (!stream->ctx->dc->debug.enable_single_display_2to1_odm_policy ||
+			stream->debug.force_odm_combine_segments > 0)
 		stream_desc->overrides.disable_dynamic_odm = true;
 	stream_desc->overrides.disable_subvp = stream->ctx->dc->debug.force_disable_subvp;
 }
@@ -699,7 +706,7 @@ static const struct scaler_data *get_scaler_data_for_plane(
 			temp_pipe->stream = pipe->stream;
 			temp_pipe->plane_state = pipe->plane_state;
 			temp_pipe->plane_res.scl_data.taps = pipe->plane_res.scl_data.taps;
-
+			temp_pipe->stream_res = pipe->stream_res;
 			dml_ctx->config.callbacks.build_scaling_params(temp_pipe);
 			break;
 		}
@@ -956,7 +963,7 @@ bool dml21_map_dc_state_into_dml_display_cfg(const struct dc *in_dc, struct dc_s
 			disp_cfg_stream_location = dml_dispcfg->num_streams++;
 
 		ASSERT(disp_cfg_stream_location >= 0 && disp_cfg_stream_location <= __DML2_WRAPPER_MAX_STREAMS_PLANES__);
-		populate_dml21_timing_config_from_stream_state(&dml_dispcfg->stream_descriptors[disp_cfg_stream_location].timing, context->streams[stream_index]);
+		populate_dml21_timing_config_from_stream_state(&dml_dispcfg->stream_descriptors[disp_cfg_stream_location].timing, context->streams[stream_index], dml_ctx);
 		populate_dml21_output_config_from_stream_state(&dml_dispcfg->stream_descriptors[disp_cfg_stream_location].output, context->streams[stream_index], &context->res_ctx.pipe_ctx[stream_index]);
 		populate_dml21_stream_overrides_from_stream_state(&dml_dispcfg->stream_descriptors[disp_cfg_stream_location], context->streams[stream_index]);
 
@@ -1007,6 +1014,8 @@ void dml21_copy_clocks_to_dc_state(struct dml2_context *in_ctx, struct dc_state
 	context->bw_ctx.bw.dcn.clk.dcfclk_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.active.dcfclk_khz;
 	context->bw_ctx.bw.dcn.clk.dramclk_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.active.uclk_khz;
 	context->bw_ctx.bw.dcn.clk.fclk_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.active.fclk_khz;
+	context->bw_ctx.bw.dcn.clk.idle_dramclk_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.idle.uclk_khz;
+	context->bw_ctx.bw.dcn.clk.idle_fclk_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.idle.fclk_khz;
 	context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = in_ctx->v21.mode_programming.programming->min_clocks.dcn4.deepsleep_dcfclk_khz;
 	context->bw_ctx.bw.dcn.clk.fclk_p_state_change_support = in_ctx->v21.mode_programming.programming->fclk_pstate_supported;
 	context->bw_ctx.bw.dcn.clk.p_state_change_support = in_ctx->v21.mode_programming.programming->uclk_pstate_supported;
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c +1 -1
index 4e0b7d2d63b2..08f001cb61c5 100644
@@ -59,7 +59,7 @@ static void dml21_apply_debug_options(const struct dc *in_dc, struct dml2_contex
 	pmo_options->disable_svp = ((in_dc->debug.dml21_disable_pstate_method_mask >> 2) & 1) ||
 			in_dc->debug.force_disable_subvp ||
 			disable_fams2;
-	pmo_options->disable_drr_fixed = ((in_dc->debug.dml21_disable_pstate_method_mask >> 3) & 1) ||
+	pmo_options->disable_drr_clamped = ((in_dc->debug.dml21_disable_pstate_method_mask >> 3) & 1) ||
 			disable_fams2;
 	pmo_options->disable_drr_var = ((in_dc->debug.dml21_disable_pstate_method_mask >> 4) & 1) ||
 			disable_fams2;
drivers/gpu/drm/amd/display/dc/dml2/dml21/inc/bounding_boxes/dcn4_soc_bb.h +20 -7
index cb7a210e435a..fe07fcc3d0d5 100644
@@ -120,11 +120,11 @@ static const struct dml2_soc_bb dml2_socbb_dcn401 = {
 				.num_clk_values = 2,
 		},
 		.phyclk_d18 = {
-				.clk_values_khz = {667000, 667000},
+				.clk_values_khz = {625000, 625000},
 				.num_clk_values = 2,
 		},
 		.phyclk_d32 = {
-				.clk_values_khz = {2000000, 2000000},
+				.clk_values_khz = {625000, 625000},
 				.num_clk_values = 2,
 		},
 		.dram_config = {
@@ -289,17 +289,29 @@ static const struct dml2_soc_bb dml2_socbb_dcn401 = {
 		.dram_clk_change_blackout_us = 400,
 		.fclk_change_blackout_us = 0,
 		.g7_ppt_blackout_us = 0,
-		.stutter_enter_plus_exit_latency_us = 21,
-		.stutter_exit_latency_us = 16,
+		.stutter_enter_plus_exit_latency_us = 54,
+		.stutter_exit_latency_us = 41,
 		.z8_stutter_enter_plus_exit_latency_us = 0,
 		.z8_stutter_exit_latency_us = 0,
+		/*
+		.g6_temp_read_blackout_us = {
+			23.00,
+			10.00,
+			10.00,
+			8.00,
+			8.00,
+			5.00,
+			5.00,
+			5.00,
+		},
+		*/
 	},
 
 	 .vmin_limit = {
 		.dispclk_khz = 600 * 1000,
 	 },
 
-	.dprefclk_mhz = 700,
+	.dprefclk_mhz = 720,
 	.xtalclk_mhz = 100,
 	.pcie_refclk_mhz = 100,
 	.dchub_refclk_mhz = 50,
@@ -309,8 +321,8 @@ static const struct dml2_soc_bb dml2_socbb_dcn401 = {
 	.return_bus_width_bytes = 64,
 	.hostvm_min_page_size_kbytes = 0,
 	.gpuvm_min_page_size_kbytes = 256,
-	.phy_downspread_percent = 0,
-	.dcn_downspread_percent = 0,
+	.phy_downspread_percent = 0.38,
+	.dcn_downspread_percent = 0.38,
 	.dispclk_dppclk_vco_speed_mhz = 4500,
 	.do_urgent_latency_adjustment = 0,
 	.mem_word_bytes = 32,
@@ -329,6 +341,7 @@ static const struct dml2_ip_capabilities dml2_dcn401_max_ip_caps = {
 	.max_num_dp2p0_outputs = 4,
 	.rob_buffer_size_kbytes = 192,
 	.config_return_buffer_size_in_kbytes = 1344,
+	.config_return_buffer_segment_size_in_kbytes = 64,
 	.meta_fifo_size_in_kentries = 22,
 	.compressed_buffer_segment_size_in_kbytes = 64,
 	.subvp_drr_scheduling_margin_us = 100,
drivers/gpu/drm/amd/display/dc/dml2/dml21/inc/dml_top_display_cfg_types.h +7 -2
index fbf3e77f3d38..daae77f2672b 100644
@@ -380,7 +380,11 @@ struct dml2_plane_parameters {
 		enum dml2_refresh_from_mall_mode_override refresh_from_mall;
 		unsigned int det_size_override_kb;
 		unsigned int mpcc_combine_factor;
-		long reserved_vblank_time_ns; // 0 = no override, -ve = no reserved time, +ve = explicit reserved time
+
+		// reserved_vblank_time_ns is the minimum time to reserve in vblank for Twait
+		// The actual reserved vblank time used for the corresponding stream in mode_programming would be at least as much as this per-plane override.
+		long reserved_vblank_time_ns;
+		unsigned int max_vactive_det_fill_delay_us; // 0 = no reserved time, +ve = explicit max delay
 		unsigned int gpuvm_min_page_size_kbytes;
 
 		enum dml2_svp_mode_override legacy_svp_config; //TODO remove in favor of svp_config
@@ -407,6 +411,7 @@ struct dml2_stream_parameters {
 		enum dml2_odm_mode odm_mode;
 		bool disable_dynamic_odm;
 		bool disable_subvp;
+		bool disable_fams2_drr;
 		int minimum_vblank_idle_requirement_us;
 		bool minimize_active_latency_hiding;
 
@@ -429,7 +434,7 @@ struct dml2_display_cfg {
 	bool minimize_det_reallocation;
 
 	unsigned int gpuvm_max_page_table_levels;
-	unsigned int hostvm_max_page_table_levels;
+	unsigned int hostvm_max_non_cached_page_table_levels;
 
 	struct dml2_plane_parameters plane_descriptors[DML2_MAX_PLANES];
 	struct dml2_stream_parameters stream_descriptors[DML2_MAX_PLANES];
drivers/gpu/drm/amd/display/dc/dml2/dml21/inc/dml_top_soc_parameter_types.h +3 -0
index 7d6461ca09bf..065b2afab6fb 100644
@@ -169,8 +169,11 @@ struct dml2_ip_capabilities {
 	unsigned int max_num_dp2p0_outputs;
 	unsigned int rob_buffer_size_kbytes;
 	unsigned int config_return_buffer_size_in_kbytes;
+	unsigned int config_return_buffer_segment_size_in_kbytes;
 	unsigned int meta_fifo_size_in_kentries;
 	unsigned int compressed_buffer_segment_size_in_kbytes;
+	unsigned int max_flip_time_us;
+	unsigned int hostvm_mode;
 	unsigned int subvp_drr_scheduling_margin_us;
 	unsigned int subvp_prefetch_end_to_mall_start_us;
 	unsigned int subvp_fw_processing_delay;
drivers/gpu/drm/amd/display/dc/dml2/dml21/inc/dml_top_types.h +4 -2
index 7dcc9cef2b58..8aa77bb190ea 100644
@@ -72,9 +72,10 @@ struct dml2_pmo_options {
 	bool disable_vblank;
 	bool disable_svp;
 	bool disable_drr_var;
-	bool disable_drr_fixed;
+	bool disable_drr_clamped;
 	bool disable_drr_var_when_var_active;
 	bool disable_fams2;
+	bool disable_vactive_det_fill_bw_pad; /* dml2_project_dcn4x_stage2_auto_drr_svp and above only */
 	bool disable_dyn_odm;
 	bool disable_dyn_odm_for_multi_stream;
 	bool disable_dyn_odm_for_stream_with_svp;
@@ -331,7 +332,6 @@ struct dml2_mode_support_info {
 	bool DTBCLKRequiredMoreThanSupported;
 	bool LinkCapacitySupport;
 	bool ROBSupport;
-	bool ROBUrgencyAvoidance;
 	bool OutstandingRequestsSupport;
 	bool OutstandingRequestsUrgencyAvoidance;
 	bool PTEBufferSizeNotExceeded;
@@ -659,6 +659,7 @@ struct dml2_display_cfg_programming {
 			double DSCDelay[DML2_MAX_PLANES];
 			double MaxActiveDRAMClockChangeLatencySupported[DML2_MAX_PLANES];
 			unsigned int PrefetchMode[DML2_MAX_PLANES]; // LEGACY_ONLY
+			bool ROBUrgencyAvoidance;
 		} misc;
 
 		struct dml2_mode_support_info mode_support_info;
@@ -715,4 +716,5 @@ struct dml2_unit_test_in_out {
 	struct dml2_instance *dml2_instance;
 };
 
+
 #endif
drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4.c +101 -9

173 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.c +1382 -883

2,634 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.c +78 -98

176 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_core/dml2_core_shared_types.h +105 -4

109 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_dpmm/dml2_dpmm_dcn4.c +83 -13

96 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_dpmm/dml2_dpmm_factory.c +1 -0
index 0f67cf67e4db..657ec2e1b119 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_mcg/dml2_mcg_dcn4.c +70 -31

101 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_mcg/dml2_mcg_dcn4.h +1 -1
index 2419d2dd6b3b..19d178651435 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn3.c +24 -5
index 7cedb191140e..671f9ac2627c 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4.c +19 -19
index 34d991d44e73..8952dd7e36cb 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.c +105 -70

175 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_factory.h +1 -1
index 0cdf4f4ccfc0..9d3dc5e94be1 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_standalone_libraries/lib_float_math.c +13 -3
index 178bb21bcdc0..defe13436a2c 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_standalone_libraries/lib_float_math.h +2 -1
index 8f595b441dd0..537cf6fd4c15 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_top/dml_top.c +2 -1
index 5ba849aad9d0..1142fdade334 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_top/dml_top_mcache.c +21 -16
index 188e482d3396..7afd417071a5 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/dml2_top/dml_top_mcache.h +1 -1
index 55a1ae4655ce..bb12e4c30690 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/inc/dml2_debug.h +1 -1
index f118b6911210..0403238df107 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/display/dc/dml2/dml21/src/inc/dml2_internal_shared_types.h +10 -5
index d873a6895a32..dd90c5df5a5a 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.39.2

Part of the diff is not shown here. View the raw message.

#5 lore raw

PATCH 6/13 drm/amd/display: Remove unnecessary HPD entry for DCN401

In reply to Aurabindo Pillai

Drop the extra HPD irq entry for DCN401.

---
 drivers/gpu/drm/amd/display/dc/irq/dcn401/irq_service_dcn401.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/dc/irq/dcn401/irq_service_dcn401.c +0 -2
index 0b3d4616b774..859d19360e9a 100644
@@ -301,12 +301,10 @@ irq_source_info_dcn401[DAL_IRQ_SOURCES_NUMBER] = {
 	hpd_int_entry(1),
 	hpd_int_entry(2),
 	hpd_int_entry(3),
-	hpd_int_entry(4),
 	hpd_rx_int_entry(0),
 	hpd_rx_int_entry(1),
 	hpd_rx_int_entry(2),
 	hpd_rx_int_entry(3),
-	hpd_rx_int_entry(4),
 	i2c_int_entry(1),
 	i2c_int_entry(2),
 	i2c_int_entry(3),
Signature · 1 line
2.39.2
#6 lore raw

PATCH 7/13 drm/amd/display: Use DCN 410 includes for DCN401

In reply to Aurabindo Pillai

DCN401 is using DCN 320 headers, which does not have all the right registers for DCN401. This commit just replace DCN320 includes with the one from DCN410.

---
 .../gpu/drm/amd/display/dc/irq/dcn401/irq_service_dcn401.c    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/irq/dcn401/irq_service_dcn401.c +2 -2
index 859d19360e9a..b43c9524b0de 100644
@@ -6,8 +6,8 @@
 #include "include/logger_interface.h"
 #include "../dce110/irq_service_dce110.h"
 
-#include "dcn/dcn_3_2_0_offset.h"
-#include "dcn/dcn_3_2_0_sh_mask.h"
+#include "dcn/dcn_4_1_0_offset.h"
+#include "dcn/dcn_4_1_0_sh_mask.h"
 
 #include "irq_service_dcn401.h"
 
Signature · 1 line
2.39.2
#7 lore raw

PATCH 8/13 drm/amd/display: Remove incorrect FP context start

In reply to Aurabindo Pillai

All the DC_FP_START/END should be used before call anything from DML2, for this reason, the use of those guards inside DML it is not correct. This commit removes two unnecessary DC_FP_START/END from a dml2 function.

---
 drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c +0 -2
index 22f6a59d8ed2..5fe1110c4816 100644
@@ -759,7 +759,6 @@ static void dml2_init(const struct dc *in_dc, const struct dml2_configuration_op
 
 bool dml2_create(const struct dc *in_dc, const struct dml2_configuration_options *config, struct dml2_context **dml2)
 {
-	DC_FP_START();
 	// TODO : Temporarily add DCN_VERSION_3_2 for N-1 validation. Remove DCN_VERSION_3_2 after N-1 validation phase is complete.
 	if ((in_dc->debug.using_dml21) && (in_dc->ctx->dce_version == DCN_VERSION_4_01 || in_dc->ctx->dce_version == DCN_VERSION_3_2)) {
 		return dml21_create(in_dc, dml2, config);
@@ -773,7 +772,6 @@ bool dml2_create(const struct dc *in_dc, const struct dml2_configuration_options
 
 	dml2_init(in_dc, config, dml2);
 
-	DC_FP_END();
 	return true;
 }
 
Signature · 1 line
2.39.2
#8 lore raw

PATCH 9/13 drm/amd/display: Fix null pointer dereference for dcn401

In reply to Aurabindo Pillai

When ODM slice happens on DCN401, there is a null pointer exception caused by that. This commit address this issue by checking if the required data structures are initialized.

---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +5 -3
index ce1991e06049..beca40f8694f 100644
@@ -2083,8 +2083,10 @@ int resource_get_odm_slice_dst_width(struct pipe_ctx *otg_master,
 			timing->h_border_left +
 			timing->h_border_right;
 	int width = h_active / count;
-	bool two_pixel_alignment_required =
-			otg_master->stream_res.tg->funcs->is_two_pixels_per_container(timing);
+	bool two_pixel_alignment_required = false;
+
+	if (otg_master && otg_master->stream_res.tg && otg_master->stream)
+		two_pixel_alignment_required = otg_master->stream_res.tg->funcs->is_two_pixels_per_container(timing);
 
 	if ((width % 2) && two_pixel_alignment_required)
 		width++;
@@ -2124,7 +2126,7 @@ struct rect resource_get_odm_slice_src_rect(struct pipe_ctx *pipe_ctx)
 	odm_slice_dst = resource_get_odm_slice_dst_rect(opp_head);
 	odm_slice_src = odm_slice_dst;
 
-	if (opp->funcs->opp_get_left_edge_extra_pixel_count)
+	if (opp && opp->funcs->opp_get_left_edge_extra_pixel_count)
 		left_edge_extra_pixel_count =
 				opp->funcs->opp_get_left_edge_extra_pixel_count(
 						opp, pipe_ctx->stream->timing.pixel_encoding,
Signature · 1 line
2.39.2
#9 lore raw

PATCH 10/13 drm/amd/display: Add missing registers for DCN401

In reply to Aurabindo Pillai

From: Rodrigo Siqueira <[email protected]>

---
 .../include/asic_reg/dcn/dcn_4_1_0_offset.h   | 51 ++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_4_1_0_offset.h +50 -1
index cd9d01fc12af..5dabf0abccce 100644
@@ -258,6 +258,17 @@
 #define regHDMISTREAMCLK0_DTO_PARAM                                                                     0x005b
 #define regHDMISTREAMCLK0_DTO_PARAM_BASE_IDX                                                            2
 
+// base address: 0x0
+
+
+// base address: 0x30
+
+
+// addressBlock: dcn_dcec_dmu_fgsec_dispdec
+// base address: 0x0
+#define regDMCUB_RBBMIF_SEC_CNTL                                                                        0x017a
+#define regDMCUB_RBBMIF_SEC_CNTL_BASE_IDX                                                               2
+
 // addressBlock: dcn_dcec_dmu_rbbmif_dispdec
 // base address: 0x0
 #define regRBBMIF_TIMEOUT                                                                               0x017f
@@ -861,6 +872,10 @@
 #define regDWB_OVERFLOW_COUNTER_BASE_IDX                                                                2
 #define regDWB_SOFT_RESET                                                                               0x323b
 #define regDWB_SOFT_RESET_BASE_IDX                                                                      2
+#define regDWB_DEBUG_CTRL                                                                               0x323c
+#define regDWB_DEBUG_CTRL_BASE_IDX                                                                      2
+#define regDWB_DEBUG                                                                                    0x323d
+#define regDWB_DEBUG_BASE_IDX                                                                           2
 
 
 // addressBlock: dcn_dcec_wb0_dispdec_dwbcp_dispdec
@@ -1073,6 +1088,10 @@
 #define regMCIF_WB_ARBITRATION_CONTROL_BASE_IDX                                                         2
 #define regMCIF_WB_SCLK_CHANGE                                                                          0x027f
 #define regMCIF_WB_SCLK_CHANGE_BASE_IDX                                                                 2
+#define regMCIF_WB_TEST_DEBUG_INDEX                                                                     0x0280
+#define regMCIF_WB_TEST_DEBUG_INDEX_BASE_IDX                                                            2
+#define regMCIF_WB_TEST_DEBUG_DATA                                                                      0x0281
+#define regMCIF_WB_TEST_DEBUG_DATA_BASE_IDX                                                             2
 #define regMCIF_WB_BUF_1_ADDR_Y                                                                         0x0282
 #define regMCIF_WB_BUF_1_ADDR_Y_BASE_IDX                                                                2
 #define regMCIF_WB_BUF_1_ADDR_C                                                                         0x0284
@@ -7706,7 +7725,10 @@
 #define regMPC_OUT3_CSC_C31_C32_B_BASE_IDX                                                              3
 #define regMPC_OUT3_CSC_C33_C34_B                                                                       0x033e
 #define regMPC_OUT3_CSC_C33_C34_B_BASE_IDX                                                              3
-
+#define regMPC_OCSC_TEST_DEBUG_INDEX                                                                    0x035b
+#define regMPC_OCSC_TEST_DEBUG_INDEX_BASE_IDX                                                           3
+#define regMPC_OCSC_TEST_DEBUG_DATA                                                                     0x035c
+#define regMPC_OCSC_TEST_DEBUG_DATA_BASE_IDX                                                            3
 
 // addressBlock: dcn_dcec_opp_abm0_dispdec
 // base address: 0x0
@@ -12857,6 +12879,8 @@
 #define regHDMI_TB_ENC_CRC_CNTL_BASE_IDX                                                                3
 #define regHDMI_TB_ENC_CRC_RESULT_0                                                                     0x0904
 #define regHDMI_TB_ENC_CRC_RESULT_0_BASE_IDX                                                            3
+#define regHDMI_TB_ENC_ENCRYPTION_CONTROL                                                               0x0907
+#define regHDMI_TB_ENC_ENCRYPTION_CONTROL_BASE_IDX                                                      3
 #define regHDMI_TB_ENC_MODE                                                                             0x0908
 #define regHDMI_TB_ENC_MODE_BASE_IDX                                                                    3
 #define regHDMI_TB_ENC_INPUT_FIFO_STATUS                                                                0x0909
@@ -14297,6 +14321,8 @@
 #define regRDPCSTX0_RDPCSTX_PATTERN_DETECT_CTRL_BASE_IDX                                                2
 #define regRDPCSTX0_RDPCSTX_CNTL4                                                                       0x293c
 #define regRDPCSTX0_RDPCSTX_CNTL4_BASE_IDX                                                              2
+#define regRDPCSTX0_RDPCSTX_DEBUG_CONFIG                                                                0x293d
+#define regRDPCSTX0_RDPCSTX_DEBUG_CONFIG_BASE_IDX                                                       2
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL0                                                                   0x2940
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL0_BASE_IDX                                                          2
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL1                                                                   0x2941
@@ -14347,6 +14373,8 @@
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL16_BASE_IDX                                                         2
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL17                                                                  0x295a
 #define regRDPCSTX0_RDPCSTX_PHY_CNTL17_BASE_IDX                                                         2
+#define regRDPCSTX0_RDPCSTX_DEBUG_CONFIG2                                                               0x295b
+#define regRDPCSTX0_RDPCSTX_DEBUG_CONFIG2_BASE_IDX                                                      2
 #define regRDPCSTX0_RDPCS_CNTL3                                                                         0x295c
 #define regRDPCSTX0_RDPCS_CNTL3_BASE_IDX                                                                2
 #define regRDPCSTX0_RDPCS_TX_PLL_UPDATE_ADDR_OVRRD                                                      0x295d
@@ -14383,6 +14411,8 @@
 #define regRDPCSTX1_RDPCSTX_PATTERN_DETECT_CTRL_BASE_IDX                                                2
 #define regRDPCSTX1_RDPCSTX_CNTL4                                                                       0x2a14
 #define regRDPCSTX1_RDPCSTX_CNTL4_BASE_IDX                                                              2
+#define regRDPCSTX1_RDPCSTX_DEBUG_CONFIG                                                                0x2a15
+#define regRDPCSTX1_RDPCSTX_DEBUG_CONFIG_BASE_IDX                                                       2
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL0                                                                   0x2a18
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL0_BASE_IDX                                                          2
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL1                                                                   0x2a19
@@ -14433,6 +14463,8 @@
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL16_BASE_IDX                                                         2
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL17                                                                  0x2a32
 #define regRDPCSTX1_RDPCSTX_PHY_CNTL17_BASE_IDX                                                         2
+#define regRDPCSTX1_RDPCSTX_DEBUG_CONFIG2                                                               0x2a33
+#define regRDPCSTX1_RDPCSTX_DEBUG_CONFIG2_BASE_IDX                                                      2
 #define regRDPCSTX1_RDPCS_CNTL3                                                                         0x2a34
 #define regRDPCSTX1_RDPCS_CNTL3_BASE_IDX                                                                2
 #define regRDPCSTX1_RDPCS_TX_PLL_UPDATE_ADDR_OVRRD                                                      0x2a35
@@ -14469,6 +14501,8 @@
 #define regRDPCSTX2_RDPCSTX_PATTERN_DETECT_CTRL_BASE_IDX                                                2
 #define regRDPCSTX2_RDPCSTX_CNTL4                                                                       0x2aec
 #define regRDPCSTX2_RDPCSTX_CNTL4_BASE_IDX                                                              2
+#define regRDPCSTX2_RDPCSTX_DEBUG_CONFIG                                                                0x2aed
+#define regRDPCSTX2_RDPCSTX_DEBUG_CONFIG_BASE_IDX                                                       2
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL0                                                                   0x2af0
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL0_BASE_IDX                                                          2
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL1                                                                   0x2af1
@@ -14519,6 +14553,8 @@
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL16_BASE_IDX                                                         2
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL17                                                                  0x2b0a
 #define regRDPCSTX2_RDPCSTX_PHY_CNTL17_BASE_IDX                                                         2
+#define regRDPCSTX2_RDPCSTX_DEBUG_CONFIG2                                                               0x2b0b
+#define regRDPCSTX2_RDPCSTX_DEBUG_CONFIG2_BASE_IDX                                                      2
 #define regRDPCSTX2_RDPCS_CNTL3                                                                         0x2b0c
 #define regRDPCSTX2_RDPCS_CNTL3_BASE_IDX                                                                2
 #define regRDPCSTX2_RDPCS_TX_PLL_UPDATE_ADDR_OVRRD                                                      0x2b0d
@@ -14555,6 +14591,8 @@
 #define regRDPCSTX3_RDPCSTX_PATTERN_DETECT_CTRL_BASE_IDX                                                2
 #define regRDPCSTX3_RDPCSTX_CNTL4                                                                       0x2bc4
 #define regRDPCSTX3_RDPCSTX_CNTL4_BASE_IDX                                                              2
+#define regRDPCSTX3_RDPCSTX_DEBUG_CONFIG                                                                0x2bc5
+#define regRDPCSTX3_RDPCSTX_DEBUG_CONFIG_BASE_IDX                                                       2
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL0                                                                   0x2bc8
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL0_BASE_IDX                                                          2
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL1                                                                   0x2bc9
@@ -14605,6 +14643,8 @@
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL16_BASE_IDX                                                         2
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL17                                                                  0x2be2
 #define regRDPCSTX3_RDPCSTX_PHY_CNTL17_BASE_IDX                                                         2
+#define regRDPCSTX3_RDPCSTX_DEBUG_CONFIG2                                                               0x2be3
+#define regRDPCSTX3_RDPCSTX_DEBUG_CONFIG2_BASE_IDX                                                      2
 #define regRDPCSTX3_RDPCS_CNTL3                                                                         0x2be4
 #define regRDPCSTX3_RDPCS_CNTL3_BASE_IDX                                                                2
 #define regRDPCSTX3_RDPCS_TX_PLL_UPDATE_ADDR_OVRRD                                                      0x2be5
@@ -15392,6 +15432,15 @@
 #define ixOTG2_OTG_DOUT_INTERFACE_01_A                                                                 0x0043
 #define ixOTG2_OTG_DOUT_INTERFACE_01_B                                                                 0x0044
 #define ixOTG2_OTG_DOUT_INTERFACE_02                                                                   0x0045
+#define ixDCIO_DEBUG_ID                                                                                0x0000
+#define ixDCIO_DEBUG1B                                                                                 0x001b
+#define ixDCIO_DEBUG1C                                                                                 0x001c
+#define ixDCIO_DEBUG1D                                                                                 0x001d
+#define ixDCIO_DEBUG1E                                                                                 0x001e
+#define ixDCIO_DEBUG1F                                                                                 0x001f
+#define ixDCIO_DEBUG20                                                                                 0x0020
+#define ixDCIO_DEBUG21                                                                                 0x0021
+#define ixDCIO_DEBUG22                                                                                 0x0022
 
 
 // addressBlock: otg3_otgdebugind
Signature · 1 line
2.39.2
#10 lore raw

PATCH 11/13 drm/amd/display: Move some init routines to dm_sw_init()

In reply to Aurabindo Pillai

Move creation of CGS device node and the DAL allocation list from amdgpu_dm_init() to dm_sw_init() which runs before dmub's sw init hook.

This is required for communicating with the VBIOS DMUB image from the VBIOS that was loaded for early pre-os boot.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +11 -9
index 1e263b357c13..bb4573603479 100644
@@ -1662,13 +1662,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
 	init_data.driver = adev;
 
-	adev->dm.cgs_device = amdgpu_cgs_create_device(adev);
-
-	if (!adev->dm.cgs_device) {
-		DRM_ERROR("amdgpu: failed to create cgs device.\n");
-		goto error;
-	}
-
+	/* cgs_device was created in dm_sw_init() */
 	init_data.cgs_device = adev->dm.cgs_device;
 
 	init_data.dce_environment = DCE_ENV_PRODUCTION_DRV;
@@ -1752,8 +1746,6 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 	if (amdgpu_ip_version(adev, DCE_HWIP, 0) >= IP_VERSION(3, 0, 0))
 		init_data.num_virtual_links = 1;
 
-	INIT_LIST_HEAD(&adev->dm.da_list);
-
 	retrieve_dmi_info(&adev->dm);
 
 	/* Display Core create. */
@@ -2321,6 +2313,16 @@ static int dm_sw_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int r;
 
+	adev->dm.cgs_device = amdgpu_cgs_create_device(adev);
+
+	if (!adev->dm.cgs_device) {
+		DRM_ERROR("amdgpu: failed to create cgs device.\n");
+		return -EINVAL;
+	}
+
+	/* Moved from dm init since we need to use allocations for storing bounding box data */
+	INIT_LIST_HEAD(&adev->dm.da_list);
+
 	r = dm_dmub_sw_init(adev);
 	if (r)
 		return r;
Signature · 1 line
2.39.2
#11 lore raw

PATCH 12/13 drm/amd/display: Add new GPINT command definitions

In reply to Aurabindo Pillai

New commands for enabling copy of DC bounding box values from VBIOS DMUB

---
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +31 -0
index abf248d46b1c..f52716c54180 100644
@@ -952,6 +952,37 @@ enum dmub_gpint_command {
 	 */
 	DMUB_GPINT__REPLAY_RESIDENCY = 14,
 
+	/**
+	 * DESC: Copy bounding box to the host.
+	 * ARGS: Version of bounding box to copy
+	 * RETURN: Result of copying bounding box
+	 */
+	DMUB_GPINT__BB_COPY = 96,
+
+	/**
+	 * DESC: Updates the host addresses bit48~bit63 for bounding box.
+	 * ARGS: The word3 for the 64 bit address
+	 */
+	DMUB_GPINT__SET_BB_ADDR_WORD3 = 97,
+
+	/**
+	 * DESC: Updates the host addresses bit32~bit47 for bounding box.
+	 * ARGS: The word2 for the 64 bit address
+	 */
+	DMUB_GPINT__SET_BB_ADDR_WORD2 = 98,
+
+	/**
+	 * DESC: Updates the host addresses bit16~bit31 for bounding box.
+	 * ARGS: The word1 for the 64 bit address
+	 */
+	DMUB_GPINT__SET_BB_ADDR_WORD1 = 99,
+
+	/**
+	 * DESC: Updates the host addresses bit0~bit15 for bounding box.
+	 * ARGS: The word0 for the 64 bit address
+	 */
+	DMUB_GPINT__SET_BB_ADDR_WORD0 = 100,
+
 	/**
 	 * DESC: Updates the trace buffer lower 32-bit mask.
 	 * ARGS: The new mask
Signature · 1 line
2.39.2
#12 lore raw

PATCH 13/13 drm/amd/display: Enable copying of bounding box data from VBIOS DMUB

In reply to Aurabindo Pillai

Allocate some memory, send the address in chunks to dmub, and finally ask it to copy the bounding box data into the newly allocated memory.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 121 ++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  10 ++
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  24 +---
 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +
 drivers/gpu/drm/amd/display/dc/dc.h           |   3 +
 .../dc/dml2/dml21/dml21_translation_helper.c  |   6 +-
 .../drm/amd/display/dc/dml2/dml2_wrapper.h    |   1 +
 7 files changed, 146 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +121 -0
index bb4573603479..74accbcaae28 100644
@@ -1627,6 +1627,117 @@ static void retrieve_dmi_info(struct amdgpu_display_manager *dm)
 	}
 }
 
+void*
+dm_allocate_gpu_mem(
+		struct amdgpu_device *adev,
+		enum dc_gpu_mem_alloc_type type,
+		size_t size,
+		long long *addr)
+{
+	struct dal_allocation *da;
+	u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
+		AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
+	int ret;
+
+	da = kzalloc(sizeof(struct dal_allocation), GFP_KERNEL);
+	if (!da)
+		return NULL;
+
+	ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
+				      domain, &da->bo,
+				      &da->gpu_addr, &da->cpu_ptr);
+
+	*addr = da->gpu_addr;
+
+	if (ret) {
+		kfree(da);
+		return NULL;
+	}
+
+	/* add da to list in dm */
+	list_add(&da->list, &adev->dm.da_list);
+
+	return da->cpu_ptr;
+}
+
+static enum dmub_status
+dm_dmub_send_vbios_gpint_command(struct amdgpu_device *adev,
+				 enum dmub_gpint_command command_code,
+				 uint16_t param,
+				 uint32_t timeout_us)
+{
+	union dmub_gpint_data_register reg, test;
+	uint32_t i;
+
+	/* Assume that VBIOS DMUB is ready to take commands */
+
+	reg.bits.status = 1;
+	reg.bits.command_code = command_code;
+	reg.bits.param = param;
+
+	cgs_write_register(adev->dm.cgs_device, 0x34c0 + 0x01f8, reg.all);
+
+	for (i = 0; i < timeout_us; ++i) {
+		udelay(1);
+
+		/* Check if our GPINT got acked */
+		reg.bits.status = 0;
+		test = (union dmub_gpint_data_register)
+			cgs_read_register(adev->dm.cgs_device, 0x34c0 + 0x01f8);
+
+		if (test.all == reg.all)
+			return DMUB_STATUS_OK;
+	}
+
+	return DMUB_STATUS_TIMEOUT;
+}
+
+static struct dml2_soc_bb *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev)
+{
+	struct dml2_soc_bb *bb;
+	long long addr;
+	int i = 0;
+	uint16_t chunk;
+	enum dmub_gpint_command send_addrs[] = {
+		DMUB_GPINT__SET_BB_ADDR_WORD0,
+		DMUB_GPINT__SET_BB_ADDR_WORD1,
+		DMUB_GPINT__SET_BB_ADDR_WORD2,
+		DMUB_GPINT__SET_BB_ADDR_WORD3,
+	};
+	enum dmub_status ret;
+
+	switch (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
+	case IP_VERSION(4, 0, 1):
+		break;
+	default:
+		return NULL;
+	}
+
+	bb =  dm_allocate_gpu_mem(adev,
+				  DC_MEM_ALLOC_TYPE_GART,
+				  sizeof(struct dml2_soc_bb),
+				  &addr);
+	if (!bb)
+		return NULL;
+
+	for (i = 0; i < 4; i++) {
+		/* Extract 16-bit chunk */
+		chunk = ((uint64_t) addr >> (i * 16)) & 0xFFFF;
+		/* Send the chunk */
+		ret = dm_dmub_send_vbios_gpint_command(adev, send_addrs[i], chunk, 30000);
+		if (ret != DMUB_STATUS_OK)
+			/* No need to free bb here since it shall be done unconditionally <elsewhere> */
+			return NULL;
+	}
+
+	/* Now ask DMUB to copy the bb */
+	ret = dm_dmub_send_vbios_gpint_command(adev, DMUB_GPINT__BB_COPY, 1, 200000);
+	if (ret != DMUB_STATUS_OK)
+		return NULL;
+
+	return bb;
+}
+
 static int amdgpu_dm_init(struct amdgpu_device *adev)
 {
 	struct dc_init_data init_data;
@@ -1748,6 +1859,11 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
 	retrieve_dmi_info(&adev->dm);
 
+	if (adev->dm.bb_from_dmub)
+		init_data.bb_from_dmub = adev->dm.bb_from_dmub;
+	else
+		init_data.bb_from_dmub = NULL;
+
 	/* Display Core create. */
 	adev->dm.dc = dc_create(&init_data);
 
@@ -2305,6 +2421,8 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
+	adev->dm.bb_from_dmub = dm_dmub_get_vbios_bounding_box(adev);
+
 	return 0;
 }
 
@@ -2334,6 +2452,9 @@ static int dm_sw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	kfree(adev->dm.bb_from_dmub);
+	adev->dm.bb_from_dmub = NULL;
+
 	kfree(adev->dm.dmub_fb_info);
 	adev->dm.dmub_fb_info = NULL;
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +10 -0
index a01f3f5bf2c0..94fc4c15d2db 100644
@@ -578,6 +578,11 @@ struct amdgpu_display_manager {
 	 * Guards access to DPIA AUX
 	 */
 	struct mutex dpia_aux_lock;
+
+	/*
+	 * Bounding box data read from dmub during early initialization for DCN4+
+	 */
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 enum dsc_clock_force_state {
@@ -964,4 +969,9 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
 
 int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth);
 struct idle_workqueue *idle_create_workqueue(struct amdgpu_device *adev);
+
+void *dm_allocate_gpu_mem(struct amdgpu_device *adev,
+						  enum dc_gpu_mem_alloc_type type,
+						  size_t size,
+						  long long *addr);
 #endif /* __AMDGPU_DM_H__ */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -23
index 6d0f78b9ec0c..8eb2f10f2c38 100644
@@ -1045,30 +1045,8 @@ void *dm_helpers_allocate_gpu_mem(
 		long long *addr)
 {
 	struct amdgpu_device *adev = ctx->driver_context;
-	struct dal_allocation *da;
-	u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
-		AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
-	int ret;
-
-	da = kzalloc(sizeof(struct dal_allocation), GFP_KERNEL);
-	if (!da)
-		return NULL;
-
-	ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
-				      domain, &da->bo,
-				      &da->gpu_addr, &da->cpu_ptr);
-
-	*addr = da->gpu_addr;
-
-	if (ret) {
-		kfree(da);
-		return NULL;
-	}
-
-	/* add da to list in dm */
-	list_add(&da->list, &adev->dm.da_list);
 
-	return da->cpu_ptr;
+	return dm_allocate_gpu_mem(adev, type, size, addr);
 }
 
 void dm_helpers_free_gpu_mem(
drivers/gpu/drm/amd/display/dc/core/dc.c +5 -0
index 3a2101b052ea..1526ab0b4884 100644
@@ -1014,6 +1014,11 @@ static bool dc_construct(struct dc *dc,
 
 	dc->dcn_ip = dcn_ip;
 
+	if (init_params->bb_from_dmub)
+		dc->dml2_options.bb_from_dmub = init_params->bb_from_dmub;
+	else
+		dc->dml2_options.bb_from_dmub = NULL;
+
 	if (!dc_construct_ctx(dc, init_params)) {
 		dm_error("%s: failed to create ctx\n", __func__);
 		goto fail;
drivers/gpu/drm/amd/display/dc/dc.h +3 -0
index 31e3371b1b2e..d0ed01ac460d 100644
@@ -1067,6 +1067,8 @@ struct dchub_init_data {
 	bool dchub_info_valid;
 };
 
+struct dml2_soc_bb;
+
 struct dc_init_data {
 	struct hw_asic_id asic_id;
 	void *driver; /* ctx */
@@ -1099,6 +1101,7 @@ struct dc_init_data {
 	uint32_t *dcn_reg_offsets;
 	uint32_t *nbio_reg_offsets;
 	uint32_t *clk_reg_offsets;
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 struct dc_callback_init {
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c +5 -1
index 37998f2c0b14..9f641ffdc924 100644
@@ -26,7 +26,11 @@ static void dml21_init_socbb_params(struct dml2_initialize_instance_in_out *dml_
 		break;
 	case DCN_VERSION_4_01:
 	default:
-		soc_bb = &dml2_socbb_dcn401;
+		if (config->bb_from_dmub)
+			soc_bb = config->bb_from_dmub;
+		else
+			soc_bb = &dml2_socbb_dcn401;
+
 		qos_params = &dml_dcn401_soc_qos_params;
 	}
 
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h +1 -0
index dcb4e6f4d916..20b3970c0857 100644
@@ -236,6 +236,7 @@ struct dml2_configuration_options {
 
 	bool use_clock_dc_limits;
 	bool gpuvm_enable;
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 /*
Signature · 1 line
2.39.2
maintainer Acked-by on v1 13/13
#13 lore raw

Re: [PATCH 13/13] drm/amd/display: Enable copying of bounding box data from VBIOS DMUB

Quoted 4 lines · Aurabindo Pillai

Allocate some memory, send the address in chunks to dmub, and finally ask it to copy the bounding box data into the newly allocated memory.

The entire series is

Harry

Quoted 291 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 121 ++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  10 ++
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  24 +---
 drivers/gpu/drm/amd/display/dc/core/dc.c      |   5 +
 drivers/gpu/drm/amd/display/dc/dc.h           |   3 +
 .../dc/dml2/dml21/dml21_translation_helper.c  |   6 +-
 .../drm/amd/display/dc/dml2/dml2_wrapper.h    |   1 +
 7 files changed, 146 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +121 -0
index bb4573603479..74accbcaae28 100644
@@ -1627,6 +1627,117 @@ static void retrieve_dmi_info(struct amdgpu_display_manager *dm)
 	}
 }
 
+void*
+dm_allocate_gpu_mem(
+		struct amdgpu_device *adev,
+		enum dc_gpu_mem_alloc_type type,
+		size_t size,
+		long long *addr)
+{
+	struct dal_allocation *da;
+	u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
+		AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
+	int ret;
+
+	da = kzalloc(sizeof(struct dal_allocation), GFP_KERNEL);
+	if (!da)
+		return NULL;
+
+	ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
+				      domain, &da->bo,
+				      &da->gpu_addr, &da->cpu_ptr);
+
+	*addr = da->gpu_addr;
+
+	if (ret) {
+		kfree(da);
+		return NULL;
+	}
+
+	/* add da to list in dm */
+	list_add(&da->list, &adev->dm.da_list);
+
+	return da->cpu_ptr;
+}
+
+static enum dmub_status
+dm_dmub_send_vbios_gpint_command(struct amdgpu_device *adev,
+				 enum dmub_gpint_command command_code,
+				 uint16_t param,
+				 uint32_t timeout_us)
+{
+	union dmub_gpint_data_register reg, test;
+	uint32_t i;
+
+	/* Assume that VBIOS DMUB is ready to take commands */
+
+	reg.bits.status = 1;
+	reg.bits.command_code = command_code;
+	reg.bits.param = param;
+
+	cgs_write_register(adev->dm.cgs_device, 0x34c0 + 0x01f8, reg.all);
+
+	for (i = 0; i < timeout_us; ++i) {
+		udelay(1);
+
+		/* Check if our GPINT got acked */
+		reg.bits.status = 0;
+		test = (union dmub_gpint_data_register)
+			cgs_read_register(adev->dm.cgs_device, 0x34c0 + 0x01f8);
+
+		if (test.all == reg.all)
+			return DMUB_STATUS_OK;
+	}
+
+	return DMUB_STATUS_TIMEOUT;
+}
+
+static struct dml2_soc_bb *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev)
+{
+	struct dml2_soc_bb *bb;
+	long long addr;
+	int i = 0;
+	uint16_t chunk;
+	enum dmub_gpint_command send_addrs[] = {
+		DMUB_GPINT__SET_BB_ADDR_WORD0,
+		DMUB_GPINT__SET_BB_ADDR_WORD1,
+		DMUB_GPINT__SET_BB_ADDR_WORD2,
+		DMUB_GPINT__SET_BB_ADDR_WORD3,
+	};
+	enum dmub_status ret;
+
+	switch (amdgpu_ip_version(adev, DCE_HWIP, 0)) {
+	case IP_VERSION(4, 0, 1):
+		break;
+	default:
+		return NULL;
+	}
+
+	bb =  dm_allocate_gpu_mem(adev,
+				  DC_MEM_ALLOC_TYPE_GART,
+				  sizeof(struct dml2_soc_bb),
+				  &addr);
+	if (!bb)
+		return NULL;
+
+	for (i = 0; i < 4; i++) {
+		/* Extract 16-bit chunk */
+		chunk = ((uint64_t) addr >> (i * 16)) & 0xFFFF;
+		/* Send the chunk */
+		ret = dm_dmub_send_vbios_gpint_command(adev, send_addrs[i], chunk, 30000);
+		if (ret != DMUB_STATUS_OK)
+			/* No need to free bb here since it shall be done unconditionally <elsewhere> */
+			return NULL;
+	}
+
+	/* Now ask DMUB to copy the bb */
+	ret = dm_dmub_send_vbios_gpint_command(adev, DMUB_GPINT__BB_COPY, 1, 200000);
+	if (ret != DMUB_STATUS_OK)
+		return NULL;
+
+	return bb;
+}
+
 static int amdgpu_dm_init(struct amdgpu_device *adev)
 {
 	struct dc_init_data init_data;
@@ -1748,6 +1859,11 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
 	retrieve_dmi_info(&adev->dm);
 
+	if (adev->dm.bb_from_dmub)
+		init_data.bb_from_dmub = adev->dm.bb_from_dmub;
+	else
+		init_data.bb_from_dmub = NULL;
+
 	/* Display Core create. */
 	adev->dm.dc = dc_create(&init_data);
 
@@ -2305,6 +2421,8 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
 		return -EINVAL;
 	}
 
+	adev->dm.bb_from_dmub = dm_dmub_get_vbios_bounding_box(adev);
+
 	return 0;
 }
 
@@ -2334,6 +2452,9 @@ static int dm_sw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+	kfree(adev->dm.bb_from_dmub);
+	adev->dm.bb_from_dmub = NULL;
+
 	kfree(adev->dm.dmub_fb_info);
 	adev->dm.dmub_fb_info = NULL;
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +10 -0
index a01f3f5bf2c0..94fc4c15d2db 100644
@@ -578,6 +578,11 @@ struct amdgpu_display_manager {
 	 * Guards access to DPIA AUX
 	 */
 	struct mutex dpia_aux_lock;
+
+	/*
+	 * Bounding box data read from dmub during early initialization for DCN4+
+	 */
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 enum dsc_clock_force_state {
@@ -964,4 +969,9 @@ amdgpu_dm_find_first_crtc_matching_connector(struct drm_atomic_state *state,
 
 int convert_dc_color_depth_into_bpc(enum dc_color_depth display_color_depth);
 struct idle_workqueue *idle_create_workqueue(struct amdgpu_device *adev);
+
+void *dm_allocate_gpu_mem(struct amdgpu_device *adev,
+						  enum dc_gpu_mem_alloc_type type,
+						  size_t size,
+						  long long *addr);
 #endif /* __AMDGPU_DM_H__ */
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -23
index 6d0f78b9ec0c..8eb2f10f2c38 100644
@@ -1045,30 +1045,8 @@ void *dm_helpers_allocate_gpu_mem(
 		long long *addr)
 {
 	struct amdgpu_device *adev = ctx->driver_context;
-	struct dal_allocation *da;
-	u32 domain = (type == DC_MEM_ALLOC_TYPE_GART) ?
-		AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM;
-	int ret;
-
-	da = kzalloc(sizeof(struct dal_allocation), GFP_KERNEL);
-	if (!da)
-		return NULL;
-
-	ret = amdgpu_bo_create_kernel(adev, size, PAGE_SIZE,
-				      domain, &da->bo,
-				      &da->gpu_addr, &da->cpu_ptr);
-
-	*addr = da->gpu_addr;
-
-	if (ret) {
-		kfree(da);
-		return NULL;
-	}
-
-	/* add da to list in dm */
-	list_add(&da->list, &adev->dm.da_list);
 
-	return da->cpu_ptr;
+	return dm_allocate_gpu_mem(adev, type, size, addr);
 }
 
 void dm_helpers_free_gpu_mem(
drivers/gpu/drm/amd/display/dc/core/dc.c +5 -0
index 3a2101b052ea..1526ab0b4884 100644
@@ -1014,6 +1014,11 @@ static bool dc_construct(struct dc *dc,
 
 	dc->dcn_ip = dcn_ip;
 
+	if (init_params->bb_from_dmub)
+		dc->dml2_options.bb_from_dmub = init_params->bb_from_dmub;
+	else
+		dc->dml2_options.bb_from_dmub = NULL;
+
 	if (!dc_construct_ctx(dc, init_params)) {
 		dm_error("%s: failed to create ctx\n", __func__);
 		goto fail;
drivers/gpu/drm/amd/display/dc/dc.h +3 -0
index 31e3371b1b2e..d0ed01ac460d 100644
@@ -1067,6 +1067,8 @@ struct dchub_init_data {
 	bool dchub_info_valid;
 };
 
+struct dml2_soc_bb;
+
 struct dc_init_data {
 	struct hw_asic_id asic_id;
 	void *driver; /* ctx */
@@ -1099,6 +1101,7 @@ struct dc_init_data {
 	uint32_t *dcn_reg_offsets;
 	uint32_t *nbio_reg_offsets;
 	uint32_t *clk_reg_offsets;
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 struct dc_callback_init {
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c +5 -1
index 37998f2c0b14..9f641ffdc924 100644
@@ -26,7 +26,11 @@ static void dml21_init_socbb_params(struct dml2_initialize_instance_in_out *dml_
 		break;
 	case DCN_VERSION_4_01:
 	default:
-		soc_bb = &dml2_socbb_dcn401;
+		if (config->bb_from_dmub)
+			soc_bb = config->bb_from_dmub;
+		else
+			soc_bb = &dml2_socbb_dcn401;
+
 		qos_params = &dml_dcn401_soc_qos_params;
 	}
 
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h +1 -0
index dcb4e6f4d916..20b3970c0857 100644
@@ -236,6 +236,7 @@ struct dml2_configuration_options {
 
 	bool use_clock_dc_limits;
 	bool gpuvm_enable;
+	struct dml2_soc_bb *bb_from_dmub;
 };
 
 /*