Re: [PATCH] amdkfd: fix the cwsr trap handler for gfx11

2024-01-31 Thread Jay Cornwall
On 1/31/2024 12:50, Laurent Morichetti wrote:

> Call the 2nd level trap handler if the cwsr handler is entered with any
> one of wave_state, wave_end, or trap_after_inst exceptions.

^ wave_start

A more descriptive title would be helpful. Perhaps something like "Pass debug 
exceptions to second-level trap handler".

Besides that:

Reviewed-by: Jay Cornwall 


[PATCH 21/21] drm/amd/display: 3.2.271

2024-01-31 Thread Hamza Mahfooz
From: Aric Cyr 

This version brings along the following:
- DCN35 fixes
- DMUB fixes
- Link training fixes
- Misc code style fixes
- MST fixes
- ODM fixes
- SubVP fixes

Acked-by: Hamza Mahfooz 
Signed-off-by: Aric Cyr 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 07e6f25269e8..c789cc2e216d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -51,7 +51,7 @@ struct aux_payload;
 struct set_config_cmd_payload;
 struct dmub_notification;
 
-#define DC_VER "3.2.270"
+#define DC_VER "3.2.271"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.43.0



[PATCH 20/21] drm/amd/display: Drop some unnecessary guards

2024-01-31 Thread Hamza Mahfooz
From: Rodrigo Siqueira 

Some of the CONFIG_DRM_AMD_DC_FP was added in some non-related FPU code,
which may cause confusion. This commit dropped some of the unnecessary
guards.

Acked-by: Hamza Mahfooz 
Signed-off-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c  | 2 --
 drivers/gpu/drm/amd/display/dc/dc.h| 2 --
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h   | 2 --
 drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c| 2 --
 drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h | 2 --
 drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h   | 2 --
 drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h   | 2 --
 drivers/gpu/drm/amd/display/dc/link/link_validation.c  | 2 --
 8 files changed, 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 0c6a4ab72b1d..e3e1940198a9 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -707,9 +707,7 @@ void rn_clk_mgr_construct(
int is_green_sardine = 0;
struct clk_log_info log_info = {0};
 
-#if defined(CONFIG_DRM_AMD_DC_FP)
is_green_sardine = 
ASICREV_IS_GREEN_SARDINE(ctx->asic_id.hw_internal_rev);
-#endif
 
clk_mgr->base.ctx = ctx;
clk_mgr->base.funcs = &dcn21_funcs;
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index b510c366ed12..07e6f25269e8 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -,11 +,9 @@ struct dc_sink_dsc_caps {
// 'true' if these are virtual DPCD's DSC caps (immediately upstream of 
sink in MST topology),
// 'false' if they are sink's DSC caps
bool is_virtual_dpcd_dsc;
-#if defined(CONFIG_DRM_AMD_DC_FP)
// 'true' if MST topology supports DSC passthrough for sink
// 'false' if MST topology does not support DSC passthrough
bool is_dsc_passthrough_supported;
-#endif
struct dsc_dec_dpcd_caps dsc_dec_caps;
 };
 
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h 
b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index fb4db3158e8f..aae2f3a2660d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -827,9 +827,7 @@ struct dc_dsc_config {
uint32_t version_minor; /* DSC minor version. Full version is formed as 
1.version_minor. */
bool ycbcr422_simple; /* Tell DSC engine to convert YCbCr 4:2:2 to 
'YCbCr 4:2:2 simple'. */
int32_t rc_buffer_size; /* DSC RC buffer block size in bytes */
-#if defined(CONFIG_DRM_AMD_DC_FP)
bool is_frl; /* indicate if DSC is applied based on HDMI FRL sink's 
capability */
-#endif
bool is_dp; /* indicate if DSC is applied based on DP's capability */
uint32_t mst_pbn; /* pbn of display on dsc mst hub */
const struct dc_dsc_rc_params_override *rc_params_ovrd; /* DM owned 
memory. If not NULL, apply custom dsc rc params */
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c
index 58eb918e2c10..a760f0c6fe98 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c
@@ -98,10 +98,8 @@ static void enable_memory_low_power(struct dc *dc)
for (i = 0; i < dc->res_pool->stream_enc_count; i++)
if (dc->res_pool->stream_enc[i]->vpg)

dc->res_pool->stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->stream_enc[i]->vpg);
-#if defined(CONFIG_DRM_AMD_DC_FP)
for (i = 0; i < dc->res_pool->hpo_dp_stream_enc_count; i++)

dc->res_pool->hpo_dp_stream_enc[i]->vpg->funcs->vpg_powerdown(dc->res_pool->hpo_dp_stream_enc[i]->vpg);
-#endif
}
 
 }
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h 
b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h
index b3c62a82cb1c..554cfab5ab24 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h
@@ -155,7 +155,6 @@ struct hwseq_private_funcs {
void (*setup_hpo_hw_control)(const struct dce_hwseq *hws, bool enable);
void (*enable_plane)(struct dc *dc, struct pipe_ctx *pipe_ctx,
   struct dc_state *context);
-#ifdef CONFIG_DRM_AMD_DC_FP
void (*program_mall_pipe_config)(struct dc *dc, struct dc_state 
*context);
void (*update_force_pstate)(struct dc *dc, struct dc_state *context);
void (*update_mall_sel)(struct dc *dc, struct dc_state *context);
@@ -170,7 +169,6 @@ struct hwseq_private_funcs {
struct dc_state *context,
struct dc *dc);
bool (*is_dp_d

[PATCH 16/21] drm/amd/display: Update phantom pipe enable / disable sequence

2024-01-31 Thread Hamza Mahfooz
From: Alvin Lee 

Previously we would call apply_ctx_to_hw to enable and disable
phantom pipes. However, apply_ctx_to_hw can potentially update
non-phantom pipes as well which is undesired. Instead of calling
apply_ctx_to_hw as a whole, call the relevant helpers for each
phantom pipe when enabling / disabling which will avoid us modifying
hardware state for non-phantom pipes unknowingly.

The use case is for an FRL display where FRL_Update is requested
by the display. In this case link_state_valid flag is cleared in
a passive callback thread and should be handled in the next stream /
link update. However, due to the call to apply_ctx_to_hw for the
phantom pipes during a flip, the main pipes were modified outside
of the desired sequence (driver does not handle link_state_valid = 0
on flips).

Cc: sta...@vger.kernel.org # 6.6+
Reviewed-by: Samson Tam 
Acked-by: Hamza Mahfooz 
Signed-off-by: Alvin Lee 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  4 +-
 .../amd/display/dc/hwss/dce110/dce110_hwseq.c |  4 +-
 .../amd/display/dc/hwss/dce110/dce110_hwseq.h |  4 +
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c   |  2 +-
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.h   |  4 +
 .../amd/display/dc/hwss/dcn32/dcn32_hwseq.c   | 76 ---
 .../amd/display/dc/hwss/dcn32/dcn32_hwseq.h   |  2 +
 .../amd/display/dc/hwss/dcn32/dcn32_init.c|  3 +
 .../drm/amd/display/dc/hwss/hw_sequencer.h|  1 +
 .../display/dc/hwss/hw_sequencer_private.h|  7 ++
 10 files changed, 94 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index c81f8af5d374..72512903f88f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3851,7 +3851,9 @@ static void commit_planes_for_stream(struct dc *dc,
 * programming has completed (we turn on phantom OTG in order
 * to complete the plane disable for phantom pipes).
 */
-   dc->hwss.apply_ctx_to_hw(dc, context);
+
+   if (dc->hwss.disable_phantom_streams)
+   dc->hwss.disable_phantom_streams(dc, context);
}
 
if (update_type != UPDATE_TYPE_FAST)
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
index 88170ab0ec7e..a390a9ef81d2 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
@@ -1528,7 +1528,7 @@ static enum dc_status dce110_enable_stream_timing(
return DC_OK;
 }
 
-static enum dc_status apply_single_controller_ctx_to_hw(
+enum dc_status dce110_apply_single_controller_ctx_to_hw(
struct pipe_ctx *pipe_ctx,
struct dc_state *context,
struct dc *dc)
@@ -2355,7 +2355,7 @@ enum dc_status dce110_apply_ctx_to_hw(
if (pipe_ctx->top_pipe || pipe_ctx->prev_odm_pipe)
continue;
 
-   status = apply_single_controller_ctx_to_hw(
+   status = dce110_apply_single_controller_ctx_to_hw(
pipe_ctx,
context,
dc);
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.h
index 08028a1779ae..ed3cc3648e8e 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.h
@@ -39,6 +39,10 @@ enum dc_status dce110_apply_ctx_to_hw(
struct dc *dc,
struct dc_state *context);
 
+enum dc_status dce110_apply_single_controller_ctx_to_hw(
+   struct pipe_ctx *pipe_ctx,
+   struct dc_state *context,
+   struct dc *dc);
 
 void dce110_enable_stream(struct pipe_ctx *pipe_ctx);
 
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
index 7557e58f58b2..bc0a21957e33 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
@@ -2671,7 +2671,7 @@ void dcn20_setup_vupdate_interrupt(struct dc *dc, struct 
pipe_ctx *pipe_ctx)
tg->funcs->setup_vertical_interrupt2(tg, start_line);
 }
 
-static void dcn20_reset_back_end_for_pipe(
+void dcn20_reset_back_end_for_pipe(
struct dc *dc,
struct pipe_ctx *pipe_ctx,
struct dc_state *context)
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.h
index 90316327e6fc..5c874f7b0683 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.h
@@ -86,6 +86,10 @@ enum dc_status dcn20_enable_stream_timing(
 void dcn20_disable_strea

[PATCH 19/21] drm/amd/display: Trivial code style adjustment

2024-01-31 Thread Hamza Mahfooz
From: Rodrigo Siqueira 

Just adjust the code indentation in the header and add a simple comment
in the dm_cp_psp file.

Acked-by: Hamza Mahfooz 
Signed-off-by: Rodrigo Siqueira 
---
 .../drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h   | 3 +--
 drivers/gpu/drm/amd/display/dc/dm_cp_psp.h | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h
index a34c258c19dc..c76352a817de 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h
@@ -36,8 +36,7 @@
 #define DALSMC_MSG_SetCabForUclkPstate 0x12
 #define DALSMC_Result_OK   0x1
 
-void
-dcn32_smu_send_fclk_pstate_message(struct clk_mgr_internal *clk_mgr, bool 
enable);
+void dcn32_smu_send_fclk_pstate_message(struct clk_mgr_internal *clk_mgr, bool 
enable);
 void dcn32_smu_transfer_wm_table_dram_2_smu(struct clk_mgr_internal *clk_mgr);
 void dcn32_smu_set_pme_workaround(struct clk_mgr_internal *clk_mgr);
 void dcn32_smu_send_cab_for_uclk_message(struct clk_mgr_internal *clk_mgr, 
unsigned int num_ways);
diff --git a/drivers/gpu/drm/amd/display/dc/dm_cp_psp.h 
b/drivers/gpu/drm/amd/display/dc/dm_cp_psp.h
index 4229369c57f4..f4d3f04ec857 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_cp_psp.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_cp_psp.h
@@ -26,6 +26,9 @@
 #ifndef DM_CP_PSP_IF__H
 #define DM_CP_PSP_IF__H
 
+/*
+ * Interface to CPLIB/PSP to enable ASSR
+ */
 struct dc_link;
 
 struct cp_psp_stream_config {
-- 
2.43.0



[PATCH 18/21] drm/amd/display: Disable ODM by default for DCN35

2024-01-31 Thread Hamza Mahfooz
From: Rodrigo Siqueira 

Just ensure that ODM optimization is disabled by default.

Acked-by: Hamza Mahfooz 
Signed-off-by: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c 
b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
index 54249f356987..e534e87cc85b 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
@@ -2132,6 +2132,7 @@ static bool dcn35_resource_construct(
dc->dml2_options.dcn_pipe_count = pool->base.pipe_count;
dc->dml2_options.use_native_pstate_optimization = true;
dc->dml2_options.use_native_soc_bb_construction = true;
+   dc->dml2_options.minimize_dispclk_using_odm = false;
if (dc->config.EnableMinDispClkODM)
dc->dml2_options.minimize_dispclk_using_odm = true;
dc->dml2_options.enable_windowed_mpo_odm = 
dc->config.enable_windowed_mpo_odm;
-- 
2.43.0



[PATCH 17/21] drm/amd/display: Drop legacy code

2024-01-31 Thread Hamza Mahfooz
From: Rodrigo Siqueira 

Display code keeps getting improvements, and because of that, some
legacy code is left behind. This commit drops some of those unused
codes.

Acked-by: Hamza Mahfooz 
Signed-off-by: Rodrigo Siqueira 
---
 .../dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c |  4 
 .../amd/display/dc/clk_mgr/dcn301/dcn301_smu.c  |  4 
 .../amd/display/dc/clk_mgr/dcn31/dcn31_smu.c|  4 
 .../amd/display/dc/clk_mgr/dcn314/dcn314_smu.c  |  6 --
 .../amd/display/dc/clk_mgr/dcn315/dcn315_smu.c  |  4 
 .../amd/display/dc/clk_mgr/dcn316/dcn316_smu.c  |  4 
 .../gpu/drm/amd/display/dc/core/dc_resource.c   | 17 -
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h |  1 -
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 11 ---
 .../gpu/drm/amd/display/dmub/src/dmub_dcn32.c   |  2 --
 10 files changed, 57 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index 8c9d45e5b13b..d72acbb049b1 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -185,10 +185,6 @@ int rn_vbios_smu_set_hard_min_dcfclk(struct 
clk_mgr_internal *clk_mgr, int reque
VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
khz_to_mhz_ceil(requested_dcfclk_khz));
 
-#ifdef DBG
-   smu_print("actual_dcfclk_set_mhz %d is set to : %d\n", 
actual_dcfclk_set_mhz, actual_dcfclk_set_mhz * 1000);
-#endif
-
return actual_dcfclk_set_mhz * 1000;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/dcn301_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/dcn301_smu.c
index e4f96b6fd79d..19e5b3be9275 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/dcn301_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/dcn301_smu.c
@@ -180,10 +180,6 @@ int dcn301_smu_set_hard_min_dcfclk(struct clk_mgr_internal 
*clk_mgr, int request
VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
khz_to_mhz_ceil(requested_dcfclk_khz));
 
-#ifdef DBG
-   smu_print("actual_dcfclk_set_mhz %d is set to : %d\n", 
actual_dcfclk_set_mhz, actual_dcfclk_set_mhz * 1000);
-#endif
-
return actual_dcfclk_set_mhz * 1000;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_smu.c
index 32279c5db724..6904e95113c1 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_smu.c
@@ -202,10 +202,6 @@ int dcn31_smu_set_hard_min_dcfclk(struct clk_mgr_internal 
*clk_mgr, int requeste
VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
khz_to_mhz_ceil(requested_dcfclk_khz));
 
-#ifdef DBG
-   smu_print("actual_dcfclk_set_mhz %d is set to : %d\n", 
actual_dcfclk_set_mhz, actual_dcfclk_set_mhz * 1000);
-#endif
-
return actual_dcfclk_set_mhz * 1000;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_smu.c
index 07baa10a8647..c4af406146b7 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_smu.c
@@ -220,12 +220,6 @@ int dcn314_smu_set_hard_min_dcfclk(struct clk_mgr_internal 
*clk_mgr, int request
VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
khz_to_mhz_ceil(requested_dcfclk_khz));
 
-#ifdef DBG
-   smu_print("actual_dcfclk_set_mhz %d is set to : %d\n",
-   actual_dcfclk_set_mhz,
-   actual_dcfclk_set_mhz * 1000);
-#endif
-
return actual_dcfclk_set_mhz * 1000;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_smu.c
index 1042cf1a3ab0..879f1494c4cd 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_smu.c
@@ -215,10 +215,6 @@ int dcn315_smu_set_hard_min_dcfclk(struct clk_mgr_internal 
*clk_mgr, int request
VBIOSSMC_MSG_SetHardMinDcfclkByFreq,
khz_to_mhz_ceil(requested_dcfclk_khz));
 
-#ifdef DBG
-   smu_print("actual_dcfclk_set_mhz %d is set to : %d\n", 
actual_dcfclk_set_mhz, actual_dcfclk_set_mhz * 1000);
-#endif
-
return actual_dcfclk_set_mhz * 1000;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_smu.c
index 3ed19197a755..8b82092b91cd 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_smu.c
@@ -189,10 +189,6 @@ int dcn316_smu_set_hard_min_dcfclk(struct clk_mgr_internal 
*clk_mgr, int request

[PATCH 15/21] Revert "drm/amd/display: For FPO and SubVP/DRR configs program vmin/max sel"

2024-01-31 Thread Hamza Mahfooz
From: Alvin Lee 

This reverts commit af89970ba286ef0237b971f28721b0d3d0d6b794.

Since, it was causing regression for some DRR scenarios.

Reviewed-by: Aric Cyr 
Reviewed-by: Nevenko Stupar 
Acked-by: Hamza Mahfooz 
Signed-off-by: Alvin Lee 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 45 ---
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 14 --
 drivers/gpu/drm/amd/display/dc/dc.h   |  1 +
 drivers/gpu/drm/amd/display/dc/dc_stream.h|  2 +
 .../display/dc/dcn32/dcn32_resource_helpers.c | 14 ++
 .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c  | 11 +++--
 .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c   |  2 +-
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c   |  8 ++--
 drivers/gpu/drm/amd/display/dc/inc/resource.h |  3 --
 .../dc/resource/dcn32/dcn32_resource.c|  2 +-
 .../dc/resource/dcn32/dcn32_resource.h|  3 ++
 .../dc/resource/dcn321/dcn321_resource.c  |  2 +-
 12 files changed, 41 insertions(+), 66 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 9127805f19f4..c81f8af5d374 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -411,12 +411,9 @@ bool dc_stream_adjust_vmin_vmax(struct dc *dc,
 * avoid conflicting with firmware updates.
 */
if (dc->ctx->dce_version > DCE_VERSION_MAX)
-   if (dc->optimized_required)
+   if (dc->optimized_required || dc->wm_optimized_required)
return false;
 
-   if (!memcmp(&stream->adjust, adjust, sizeof(*adjust)))
-   return true;
-
dc_exit_ips_for_hw_access(dc);
 
stream->adjust.v_total_max = adjust->v_total_max;
@@ -2256,6 +2253,7 @@ void dc_post_update_surfaces_to_stream(struct dc *dc)
}
 
dc->optimized_required = false;
+   dc->wm_optimized_required = false;
 }
 
 bool dc_set_generic_gpio_for_stereo(bool enable,
@@ -2678,6 +2676,8 @@ enum surface_update_type 
dc_check_update_surfaces_for_stream(
} else if (memcmp(&dc->current_state->bw_ctx.bw.dcn.clk, 
&dc->clk_mgr->clks, offsetof(struct dc_clocks, prev_p_state_change_support)) != 
0) {
dc->optimized_required = true;
}
+
+   dc->optimized_required |= dc->wm_optimized_required;
}
 
return type;
@@ -2885,6 +2885,9 @@ static void copy_stream_update_to_stream(struct dc *dc,
if (update->vrr_active_fixed)
stream->vrr_active_fixed = *update->vrr_active_fixed;
 
+   if (update->crtc_timing_adjust)
+   stream->adjust = *update->crtc_timing_adjust;
+
if (update->dpms_off)
stream->dpms_off = *update->dpms_off;
 
@@ -3513,33 +3516,6 @@ static void wait_for_outstanding_hw_updates(struct dc 
*dc, const struct dc_state
}
 }
 
-static void update_drr_for_full_update(struct dc *dc, struct dc_state *context)
-{
-   uint32_t i;
-
-   for (i = 0; i < dc->res_pool->pipe_count; i++) {
-   struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-   struct dc_stream_state *stream = pipe->stream;
-   struct timing_generator *tg = pipe->stream_res.tg;
-   struct drr_params params = {0};
-
-   /* pipe not in use */
-   if (!resource_is_pipe_type(pipe, OTG_MASTER))
-   continue;
-
-   /* skip phantom pipes */
-   if (dc_state_get_pipe_subvp_type(context, pipe) == 
SUBVP_PHANTOM)
-   continue;
-
-   params.vertical_total_min = stream->adjust.v_total_min;
-   params.vertical_total_max = stream->adjust.v_total_max;
-   params.vertical_total_mid = stream->adjust.v_total_mid;
-   params.vertical_total_mid_frame_num = 
stream->adjust.v_total_mid_frame_num;
-   if (pipe->stream_res.tg->funcs->set_drr)
-   tg->funcs->set_drr(pipe->stream_res.tg, ¶ms);
-   }
-}
-
 static void commit_planes_for_stream(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
@@ -3909,10 +3885,6 @@ static void commit_planes_for_stream(struct dc *dc,

pipe_ctx->stream_res.tg->funcs->program_manual_trigger(pipe_ctx->stream_res.tg);
}
 
-   // Update DRR for all pipes
-   if (update_type != UPDATE_TYPE_FAST)
-   update_drr_for_full_update(dc, context);
-
current_stream_mask = get_stream_mask(dc, context);
if (current_stream_mask != context->stream_mask) {
context->stream_mask = current_stream_mask;
@@ -4353,7 +4325,8 @@ static bool full_update_required(struct dc *dc,
stream_update->mst_bw_update ||
stream_update->func_shaper ||
stream_update->lut3d_func ||
-   stream_update->pending_tes

[PATCH 14/21] drm/amd/display: Adjust set_p_state calls to fix logging

2024-01-31 Thread Hamza Mahfooz
From: Ethan Bitnun 

Update the p_state type before update_clocks is called to ensure
accurate values are used for logging.

Reviewed-by: Alvin Lee 
Acked-by: Hamza Mahfooz 
Signed-off-by: Ethan Bitnun 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index e58bd0861dc0..9127805f19f4 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3565,6 +3565,17 @@ static void commit_planes_for_stream(struct dc *dc,
if (update_type == UPDATE_TYPE_FULL)
wait_for_outstanding_hw_updates(dc, context);
 
+   for (i = 0; i < dc->res_pool->pipe_count; i++) {
+   struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
+
+   if (pipe->stream && pipe->plane_state) {
+   set_p_state_switch_method(dc, context, pipe);
+
+   if (dc->debug.visual_confirm)
+   dc_update_visual_confirm_color(dc, context, 
pipe);
+   }
+   }
+
if (update_type == UPDATE_TYPE_FULL) {
dc_allow_idle_optimizations(dc, false);
 
@@ -3599,17 +3610,6 @@ static void commit_planes_for_stream(struct dc *dc,
}
}
 
-   for (i = 0; i < dc->res_pool->pipe_count; i++) {
-   struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-
-   if (pipe->stream && pipe->plane_state) {
-   set_p_state_switch_method(dc, context, pipe);
-
-   if (dc->debug.visual_confirm)
-   dc_update_visual_confirm_color(dc, context, 
pipe);
-   }
-   }
-
if (stream->test_pattern.type != DP_TEST_PATTERN_VIDEO_MODE) {
struct pipe_ctx *mpcc_pipe;
struct pipe_ctx *odm_pipe;
-- 
2.43.0



[PATCH 12/21] drm/amd/display: Fix MST Null Ptr for RV

2024-01-31 Thread Hamza Mahfooz
From: Fangzhi Zuo 

The change try to fix below error specific to RV platform:

BUG: kernel NULL pointer dereference, address: 0008
PGD 0 P4D 0
Oops:  [#1] PREEMPT SMP NOPTI
CPU: 4 PID: 917 Comm: sway Not tainted 6.3.9-arch1-1 #1 
124dc55df4f5272ccb409f39ef4872fc2b3376a2
Hardware name: LENOVO 20NKS01Y00/20NKS01Y00, BIOS R12ET61W(1.31 ) 07/28/2022
RIP: 0010:drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper]
Code: 01 00 00 48 8b 85 60 05 00 00 48 63 80 88 00 00 00 3b 43 28 0f 8d 2e 01 
00 00 48 8b 53 30 48 8d 04 80 48 8d 04 c2 48 8b 40 18 <48> 8>
RSP: 0018:960cc2df77d8 EFLAGS: 00010293
RAX:  RBX: 8afb87e81280 RCX: 0224
RDX: 8afb9ee37c00 RSI: 8afb8da1a578 RDI: 8afb87e81280
RBP: 8afb83d67000 R08: 0001 R09: 8afb9652f850
R10: 960cc2df7908 R11: 0002 R12: 
R13: 8afb8d7688a0 R14: 8afb8da1a578 R15: 0224
FS:  7f4dac35ce00() GS:8afe30b0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0008 CR3: 00010ddc6000 CR4: 003506e0
Call Trace:
 
 ? __die+0x23/0x70
 ? page_fault_oops+0x171/0x4e0
 ? plist_add+0xbe/0x100
 ? exc_page_fault+0x7c/0x180
 ? asm_exc_page_fault+0x26/0x30
 ? drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper 
0e67723696438d8e02b741593dd50d80b44c2026]
 ? drm_dp_atomic_find_time_slots+0x28/0x260 [drm_display_helper 
0e67723696438d8e02b741593dd50d80b44c2026]
 compute_mst_dsc_configs_for_link+0x2ff/0xa40 [amdgpu 
62e600d2a75e9158e1cd0a243bdc8e6da040c054]
 ? fill_plane_buffer_attributes+0x419/0x510 [amdgpu 
62e600d2a75e9158e1cd0a243bdc8e6da040c054]
 compute_mst_dsc_configs_for_state+0x1e1/0x250 [amdgpu 
62e600d2a75e9158e1cd0a243bdc8e6da040c054]
 amdgpu_dm_atomic_check+0xecd/0x1190 [amdgpu 
62e600d2a75e9158e1cd0a243bdc8e6da040c054]
 drm_atomic_check_only+0x5c5/0xa40
 drm_mode_atomic_ioctl+0x76e/0xbc0
 ? _copy_to_user+0x25/0x30
 ? drm_ioctl+0x296/0x4b0
 ? __pfx_drm_mode_atomic_ioctl+0x10/0x10
 drm_ioctl_kernel+0xcd/0x170
 drm_ioctl+0x26d/0x4b0
 ? __pfx_drm_mode_atomic_ioctl+0x10/0x10
 amdgpu_drm_ioctl+0x4e/0x90 [amdgpu 62e600d2a75e9158e1cd0a243bdc8e6da040c054]
 __x64_sys_ioctl+0x94/0xd0
 do_syscall_64+0x60/0x90
 ? do_syscall_64+0x6c/0x90
 entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7f4dad17f76f
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 
08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c>
RSP: 002b:7ffd9ae859f0 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 55e255a55900 RCX: 7f4dad17f76f
RDX: 7ffd9ae85a90 RSI: c03864bc RDI: 000b
RBP: 7ffd9ae85a90 R08: 0003 R09: 0003
R10:  R11: 0246 R12: c03864bc
R13: 000b R14: 55e255a7fc60 R15: 55e255a01eb0
 
Modules linked in: rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device ccm 
cmac algif_hash algif_skcipher af_alg joydev mousedev bnep >
 typec libphy k10temp ipmi_msghandler roles i2c_scmi acpi_cpufreq mac_hid 
nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_mas>
CR2: 0008
---[ end trace  ]---
RIP: 0010:drm_dp_atomic_find_time_slots+0x5e/0x260 [drm_display_helper]
Code: 01 00 00 48 8b 85 60 05 00 00 48 63 80 88 00 00 00 3b 43 28 0f 8d 2e 01 
00 00 48 8b 53 30 48 8d 04 80 48 8d 04 c2 48 8b 40 18 <48> 8>
RSP: 0018:960cc2df77d8 EFLAGS: 00010293
RAX:  RBX: 8afb87e81280 RCX: 0224
RDX: 8afb9ee37c00 RSI: 8afb8da1a578 RDI: 8afb87e81280
RBP: 8afb83d67000 R08: 0001 R09: 8afb9652f850
R10: 960cc2df7908 R11: 0002 R12: 
R13: 8afb8d7688a0 R14: 8afb8da1a578 R15: 0224
FS:  7f4dac35ce00() GS:8afe30b0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 0008 CR3: 00010ddc6000 CR4: 003506e0

With a second DP monitor connected, drm_atomic_state in dm atomic check
sequence does not include the connector state for the old/existing/first
DP monitor. In such case, dsc determination policy would hit a null ptr
when it tries to iterate the old/existing stream that does not have a
valid connector state attached to it. When that happens, dm atomic check
should call drm_atomic_get_connector_state for a new connector state.
Existing dm has already done that, except for RV due to it does not have
official support of dsc where .num_dsc is not defined in dcn10 resource
cap, that prevent from getting drm_atomic_get_connector_state called.
So, skip dsc determination policy for ASICs that don't have DSC support.

Reviewed-by: Wayne Lin 
Acked-by: Hamza Mahfooz 
Signed-off-by: Fangzhi Zuo 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_

[PATCH 11/21] drm/amd/display: correct comment in set_default_brightness_aux()

2024-01-31 Thread Hamza Mahfooz
From: Camille Cho 

0 nits is a valid default value for OLED panels. So, update the relevant
comment to account for that fact.

Reviewed-by: Krunoslav Kovac 
Signed-off-by: Camille Cho 
---
 .../drm/amd/display/dc/link/protocols/link_edp_panel_control.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
index 046d3e205415..443215b96308 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
@@ -287,7 +287,7 @@ bool set_default_brightness_aux(struct dc_link *link)
if (link && link->dpcd_sink_ext_caps.bits.oled == 1) {
if (!read_default_bl_aux(link, &default_backlight))
default_backlight = 15;
-   // if < 1 nits or > 5000, it might be wrong readback
+   // if > 5000, it might be wrong readback. 0 nits is a valid 
default value for OLED panel.
if (default_backlight < 1000 || default_backlight > 500)
default_backlight = 15;
 
-- 
2.43.0



[PATCH 13/21] drm/amd/display: Add delay before logging clks from hw

2024-01-31 Thread Hamza Mahfooz
From: Ethan Bitnun 

Add a small delay before reading clks from hw, to ensure correct values
are used for logging.

Reviewed-by: Alvin Lee 
Acked-by: Hamza Mahfooz 
Signed-off-by: Ethan Bitnun 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c
index 8fa0aae941c3..e64e45e4c833 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c
@@ -509,6 +509,8 @@ static void dcn32_auto_dpm_test_log(
}
}
 
+   msleep(5);
+
mall_ss_size_bytes = context->bw_ctx.bw.dcn.mall_ss_size_bytes;
 
 dispclk_khz_reg= REG_READ(CLK1_CLK0_CURRENT_CNT); // DISPCLK
-- 
2.43.0



[PATCH 06/21] drm/amd/display: Disable timeout in more places for dc_dmub_srv

2024-01-31 Thread Hamza Mahfooz
From: Nicholas Kazlauskas 

[Why]
We're still missing a few and we'd like to avoid continuining when
a hang occurs for debug purposes.

[How]
Add the loop anywhere we try to wait on rptr == wptr in dc_dmub_srv.

Reviewed-by: Ovidiu Bunea 
Acked-by: Hamza Mahfooz 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index 0ccdc0c979a1..838c43b74662 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -74,7 +74,10 @@ void dc_dmub_srv_wait_idle(struct dc_dmub_srv *dc_dmub_srv)
struct dc_context *dc_ctx = dc_dmub_srv->ctx;
enum dmub_status status;
 
-   status = dmub_srv_wait_for_idle(dmub, 10);
+   do {
+   status = dmub_srv_wait_for_idle(dmub, 10);
+   } while (dc_dmub_srv->ctx->dc->debug.disable_timeout && status != 
DMUB_STATUS_OK);
+
if (status != DMUB_STATUS_OK) {
DC_ERROR("Error waiting for DMUB idle: status=%d\n", status);
dc_dmub_srv_log_diagnostic_data(dc_dmub_srv);
@@ -145,7 +148,9 @@ bool dc_dmub_srv_cmd_list_queue_execute(struct dc_dmub_srv 
*dc_dmub_srv,
if (status == DMUB_STATUS_POWER_STATE_D3)
return false;
 
-   dmub_srv_wait_for_idle(dmub, 10);
+   do {
+   status = dmub_srv_wait_for_idle(dmub, 10);
+   } while (dc_dmub_srv->ctx->dc->debug.disable_timeout && 
status != DMUB_STATUS_OK);
 
/* Requeue the command. */
status = dmub_srv_cmd_queue(dmub, &cmd_list[i]);
@@ -186,7 +191,9 @@ bool dc_dmub_srv_wait_for_idle(struct dc_dmub_srv 
*dc_dmub_srv,
 
// Wait for DMUB to process command
if (wait_type != DM_DMUB_WAIT_TYPE_NO_WAIT) {
-   status = dmub_srv_wait_for_idle(dmub, 10);
+   do {
+   status = dmub_srv_wait_for_idle(dmub, 10);
+   } while (dc_dmub_srv->ctx->dc->debug.disable_timeout && status 
!= DMUB_STATUS_OK);
 
if (status != DMUB_STATUS_OK) {
DC_LOG_DEBUG("No reply for DMUB command: status=%d\n", 
status);
-- 
2.43.0



[PATCH 10/21] drm/amd/display: Add left edge pixel for YCbCr422/420 + ODM pipe split

2024-01-31 Thread Hamza Mahfooz
From: George Shen 

[Why]
Currently 3-tap chroma subsampling is used for YCbCr422/420. When ODM
pipesplit is used, pixels on the left edge of ODM slices need one extra
pixel from the right edge of the previous slice to calculate the correct
chroma value.

Without this change, the chroma value is slightly different than
expected. This is usually imperceptible visually, but it impacts test
pattern CRCs for compliance test automation.

[How]
Update logic to use the register for adding extra left edge pixel for
YCbCr422/420 ODM cases.

Reviewed-by: Alvin Lee 
Acked-by: Hamza Mahfooz 
Signed-off-by: George Shen 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  4 ++
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 37 +++
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c   |  7 +++-
 .../gpu/drm/amd/display/dc/inc/core_types.h   |  2 +
 drivers/gpu/drm/amd/display/dc/inc/resource.h |  4 ++
 5 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index eb803d4d3478..e58bd0861dc0 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3090,6 +3090,10 @@ static bool update_planes_and_stream_state(struct dc *dc,
 
if (otg_master && otg_master->stream->test_pattern.type 
!= DP_TEST_PATTERN_VIDEO_MODE)

resource_build_test_pattern_params(&context->res_ctx, otg_master);
+
+   if (otg_master && 
(otg_master->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422 ||
+   
otg_master->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420))
+   
resource_build_subsampling_params(&context->res_ctx, otg_master);
}
}
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 259ccbe858b4..528d3eb245ea 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -822,6 +822,16 @@ static struct rect 
calculate_odm_slice_in_timing_active(struct pipe_ctx *pipe_ct
stream->timing.v_border_bottom +
stream->timing.v_border_top;
 
+   /* Recout for ODM slices after the first slice need one extra left edge 
pixel
+* for 3-tap chroma subsampling.
+*/
+   if (odm_slice_idx > 0 &&
+   (pipe_ctx->stream->timing.pixel_encoding == 
PIXEL_ENCODING_YCBCR422 ||
+   pipe_ctx->stream->timing.pixel_encoding == 
PIXEL_ENCODING_YCBCR420)) {
+   odm_rec.x -= 1;
+   odm_rec.width += 1;
+   }
+
return odm_rec;
 }
 
@@ -1438,6 +1448,7 @@ void resource_build_test_pattern_params(struct 
resource_context *res_ctx,
enum controller_dp_test_pattern controller_test_pattern;
enum controller_dp_color_space controller_color_space;
enum dc_color_depth color_depth = 
otg_master->stream->timing.display_color_depth;
+   enum dc_pixel_encoding pixel_encoding = 
otg_master->stream->timing.pixel_encoding;
int h_active = otg_master->stream->timing.h_addressable +
otg_master->stream->timing.h_border_left +
otg_master->stream->timing.h_border_right;
@@ -1469,10 +1480,36 @@ void resource_build_test_pattern_params(struct 
resource_context *res_ctx,
else
params->width = last_odm_slice_width;
 
+   /* Extra left edge pixel is required for 3-tap chroma 
subsampling. */
+   if (i != 0 && (pixel_encoding == PIXEL_ENCODING_YCBCR422 ||
+   pixel_encoding == PIXEL_ENCODING_YCBCR420)) {
+   params->offset -= 1;
+   params->width += 1;
+   }
+
offset += odm_slice_width;
}
 }
 
+void resource_build_subsampling_params(struct resource_context *res_ctx,
+   struct pipe_ctx *otg_master)
+{
+   struct pipe_ctx *opp_heads[MAX_PIPES];
+   int odm_cnt = 1;
+   int i;
+
+   odm_cnt = resource_get_opp_heads_for_otg_master(otg_master, res_ctx, 
opp_heads);
+
+   /* For ODM slices after the first slice, extra left edge pixel is 
required
+* for 3-tap chroma subsampling.
+*/
+   if (otg_master->stream->timing.pixel_encoding == 
PIXEL_ENCODING_YCBCR422 ||
+   otg_master->stream->timing.pixel_encoding == 
PIXEL_ENCODING_YCBCR420) {
+   for (i = 0; i < odm_cnt; i++)
+   opp_heads[i]->stream_res.left_edge_extra_pixel = (i == 
0) ? false : true;
+   }
+}
+
 bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
 {
const struct dc_plane_state *plane_state = pipe_ctx->plane_state;
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm

[PATCH 09/21] drm/amd/display: Add debug option to force 1-tap chroma subsampling

2024-01-31 Thread Hamza Mahfooz
From: George Shen 

[Why]
Default driver behaviour is 3-tap subsampling, so we should keep
it the same for test patterns as well. However, it is also useful
to force 1-tap subsampling for testing purposes.

Reviewed-by: Michael Strauss 
Acked-by: Hamza Mahfooz 
Signed-off-by: George Shen 
---
 drivers/gpu/drm/amd/display/dc/dc.h  | 1 +
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c | 7 +++
 2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 10a5f53a56db..2dec2507e971 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -991,6 +991,7 @@ struct dc_debug_options {
bool disable_timeout;
bool disable_extblankadj;
unsigned int static_screen_wait_frames;
+   bool force_chroma_subsampling_1tap;
 };
 
 struct gpu_info_soc_bounding_box_v1_0;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c
index 0dec57679269..48a40dcc7050 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c
@@ -23,6 +23,7 @@
  *
  */
 
+#include "core_types.h"
 #include "dm_services.h"
 #include "dcn10_opp.h"
 #include "reg_helper.h"
@@ -160,6 +161,9 @@ static void opp1_set_pixel_encoding(
struct dcn10_opp *oppn10,
const struct clamping_and_pixel_encoding_params *params)
 {
+   bool force_chroma_subsampling_1tap =
+   
oppn10->base.ctx->dc->debug.force_chroma_subsampling_1tap;
+
switch (params->pixel_encoding) {
 
case PIXEL_ENCODING_RGB:
@@ -178,6 +182,9 @@ static void opp1_set_pixel_encoding(
default:
break;
}
+
+   if (force_chroma_subsampling_1tap)
+   REG_UPDATE(FMT_CONTROL, FMT_SUBSAMPLING_MODE, 0);
 }
 
 /**
-- 
2.43.0



[PATCH 08/21] drm/amd/display: Disable idle reallow as part of command/gpint execution

2024-01-31 Thread Hamza Mahfooz
From: Nicholas Kazlauskas 

[Why]
Workaroud for a race condition where DMCUB is in the process of
committing to IPS1 during the handshake causing us to miss the
transition into IPS2 and touch the INBOX1 RPTR causing a HW hang.

[How]
Disable the reallow to ensure that we have enough of a gap between entry
and exit and we're not seeing back-to-back wake_and_executes.

Reviewed-by: Ovidiu Bunea 
Acked-by: Hamza Mahfooz 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dc/dc.h   | 1 +
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  | 4 ++--
 .../gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c| 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 53919c0eb1e3..10a5f53a56db 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -987,6 +987,7 @@ struct dc_debug_options {
bool psp_disabled_wa;
unsigned int ips2_eval_delay_us;
unsigned int ips2_entry_delay_us;
+   bool disable_dmub_reallow_idle;
bool disable_timeout;
bool disable_extblankadj;
unsigned int static_screen_wait_frames;
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index 838c43b74662..a1477906fe4f 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -1374,7 +1374,7 @@ bool dc_wake_and_execute_dmub_cmd_list(const struct 
dc_context *ctx, unsigned in
else
result = dm_execute_dmub_cmd(ctx, cmd, wait_type);
 
-   if (result && reallow_idle)
+   if (result && reallow_idle && !ctx->dc->debug.disable_dmub_reallow_idle)
dc_dmub_srv_apply_idle_power_optimizations(ctx->dc, true);
 
return result;
@@ -1423,7 +1423,7 @@ bool dc_wake_and_execute_gpint(const struct dc_context 
*ctx, enum dmub_gpint_com
 
result = dc_dmub_execute_gpint(ctx, command_code, param, response, 
wait_type);
 
-   if (result && reallow_idle)
+   if (result && reallow_idle && !ctx->dc->debug.disable_dmub_reallow_idle)
dc_dmub_srv_apply_idle_power_optimizations(ctx->dc, true);
 
return result;
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c 
b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
index d74e5c9e00ae..54249f356987 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
@@ -783,6 +783,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.psp_disabled_wa = true,
.ips2_eval_delay_us = 1650,
.ips2_entry_delay_us = 800,
+   .disable_dmub_reallow_idle = true,
.static_screen_wait_frames = 2,
 };
 
-- 
2.43.0



[PATCH 07/21] drm/amd/display: Increase eval/entry delay for DCN35

2024-01-31 Thread Hamza Mahfooz
From: Nicholas Kazlauskas 

[Why]
To match firmware measurements and avoid hanging when accessing HW
that's in idle.

[How]
Increase the delays to what we've measured.

Reviewed-by: Ovidiu Bunea 
Acked-by: Hamza Mahfooz 
Signed-off-by: Nicholas Kazlauskas 
---
 .../gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c 
b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
index 5f7cf01abef9..d74e5c9e00ae 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
@@ -781,8 +781,8 @@ static const struct dc_debug_options debug_defaults_drv = {
.disable_z10 = false,
.ignore_pg = true,
.psp_disabled_wa = true,
-   .ips2_eval_delay_us = 200,
-   .ips2_entry_delay_us = 400,
+   .ips2_eval_delay_us = 1650,
+   .ips2_entry_delay_us = 800,
.static_screen_wait_frames = 2,
 };
 
-- 
2.43.0



[PATCH 05/21] drm/amd/display: Add more checks for exiting idle in DC

2024-01-31 Thread Hamza Mahfooz
From: Nicholas Kazlauskas 

[Why]
Any interface that touches registers needs to wake up the system.

[How]
Add a new interface dc_exit_ips_for_hw_access that wraps the check
for IPS support and insert it into the public DC interfaces that
touch registers.

We don't re-enter, since we expect that the enter/exit to have been done
on the DM side.

Cc: sta...@vger.kernel.org # 6.1+
Reviewed-by: Ovidiu Bunea 
Acked-by: Hamza Mahfooz 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 42 +++
 .../gpu/drm/amd/display/dc/core/dc_stream.c   | 18 
 .../gpu/drm/amd/display/dc/core/dc_surface.c  |  2 +
 drivers/gpu/drm/amd/display/dc/dc.h   |  1 +
 4 files changed, 63 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 2db361aeaf25..eb803d4d3478 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -417,6 +417,8 @@ bool dc_stream_adjust_vmin_vmax(struct dc *dc,
if (!memcmp(&stream->adjust, adjust, sizeof(*adjust)))
return true;
 
+   dc_exit_ips_for_hw_access(dc);
+
stream->adjust.v_total_max = adjust->v_total_max;
stream->adjust.v_total_mid = adjust->v_total_mid;
stream->adjust.v_total_mid_frame_num = adjust->v_total_mid_frame_num;
@@ -457,6 +459,8 @@ bool dc_stream_get_last_used_drr_vtotal(struct dc *dc,
 
int i = 0;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
 
@@ -487,6 +491,8 @@ bool dc_stream_get_crtc_position(struct dc *dc,
bool ret = false;
struct crtc_position position;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *pipe =
&dc->current_state->res_ctx.pipe_ctx[i];
@@ -606,6 +612,8 @@ bool dc_stream_configure_crc(struct dc *dc, struct 
dc_stream_state *stream,
if (pipe == NULL)
return false;
 
+   dc_exit_ips_for_hw_access(dc);
+
/* By default, capture the full frame */
param.windowa_x_start = 0;
param.windowa_y_start = 0;
@@ -665,6 +673,8 @@ bool dc_stream_get_crc(struct dc *dc, struct 
dc_stream_state *stream,
struct pipe_ctx *pipe;
struct timing_generator *tg;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream)
@@ -689,6 +699,8 @@ void dc_stream_set_dyn_expansion(struct dc *dc, struct 
dc_stream_state *stream,
int i;
struct pipe_ctx *pipe_ctx;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
if (dc->current_state->res_ctx.pipe_ctx[i].stream
== stream) {
@@ -724,6 +736,8 @@ void dc_stream_set_dither_option(struct dc_stream_state 
*stream,
if (option > DITHER_OPTION_MAX)
return;
 
+   dc_exit_ips_for_hw_access(stream->ctx->dc);
+
stream->dither_option = option;
 
memset(¶ms, 0, sizeof(params));
@@ -748,6 +762,8 @@ bool dc_stream_set_gamut_remap(struct dc *dc, const struct 
dc_stream_state *stre
bool ret = false;
struct pipe_ctx *pipes;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) {
pipes = &dc->current_state->res_ctx.pipe_ctx[i];
@@ -765,6 +781,8 @@ bool dc_stream_program_csc_matrix(struct dc *dc, struct 
dc_stream_state *stream)
bool ret = false;
struct pipe_ctx *pipes;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
if (dc->current_state->res_ctx.pipe_ctx[i].stream
== stream) {
@@ -791,6 +809,8 @@ void dc_stream_set_static_screen_params(struct dc *dc,
struct pipe_ctx *pipes_affected[MAX_PIPES];
int num_pipes_affected = 0;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < num_streams; i++) {
struct dc_stream_state *stream = streams[i];
 
@@ -1769,6 +1789,8 @@ void dc_enable_stereo(
int i, j;
struct pipe_ctx *pipe;
 
+   dc_exit_ips_for_hw_access(dc);
+
for (i = 0; i < MAX_PIPES; i++) {
if (context != NULL) {
pipe = &context->res_ctx.pipe_ctx[i];
@@ -1788,6 +1810,8 @@ void dc_enable_stereo(
 void dc_trigger_sync(struct dc *dc, struct dc_state *context)
 {
if (context->stream_count > 1 && !dc->debug.disable_timing_sync) {
+   dc_exit_ips_for_hw_access(dc);
+
enable_timing_multisync(dc, context);
program_timing_sync(dc, context);
}
@@ -2044,6 +2068,8 @@ enum dc

[PATCH 03/21] drm/amd/display: set odm_combine_policy based on context in dcn32 resource

2024-01-31 Thread Hamza Mahfooz
From: Wenjing Liu 

[why]
When populating dml pipes, odm combine policy should be assigned based
on the pipe topology of the context passed in. DML pipes could be
repopulated multiple times during single validate bandwidth attempt. We
need to make sure that whenever we repopulate the dml pipes it is always
aligned with the updated context. There is a case where DML pipes get
repopulated during FPO optimization after ODM combine policy is changed.
Since in the current code we reinitlaize ODM combine policy, even though
the current context has ODM combine enabled, we overwrite it despite the
pipes are already split. This causes DML to think that MPC combine is
used so we mistakenly enable MPC combine because we apply pipe split
with ODM combine policy reset. This issue doesn't impact non windowed
MPO with ODM case because the legacy policy has restricted use cases. We
don't encounter the case where both ODM and FPO optimizations are
enabled together. So we decide to leave it as is because it is about to
be replaced anyway.

Cc: sta...@vger.kernel.org # 6.6+
Reviewed-by: Chaitanya Dhere 
Reviewed-by: Alvin Lee 
Acked-by: Hamza Mahfooz 
Signed-off-by: Wenjing Liu 
---
 .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c  | 15 ++
 drivers/gpu/drm/amd/display/dc/inc/resource.h | 20 ---
 .../dc/resource/dcn32/dcn32_resource.c| 16 ++-
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
index a7981a0c4158..4edf7df4c6aa 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
@@ -1289,7 +1289,7 @@ static bool update_pipes_with_split_flags(struct dc *dc, 
struct dc_state *contex
return updated;
 }
 
-static bool should_allow_odm_power_optimization(struct dc *dc,
+static bool should_apply_odm_power_optimization(struct dc *dc,
struct dc_state *context, struct vba_vars_st *v, int *split,
bool *merge)
 {
@@ -1393,9 +1393,12 @@ static void try_odm_power_optimization_and_revalidate(
 {
int i;
unsigned int new_vlevel;
+   unsigned int cur_policy[MAX_PIPES];
 
-   for (i = 0; i < pipe_cnt; i++)
+   for (i = 0; i < pipe_cnt; i++) {
+   cur_policy[i] = pipes[i].pipe.dest.odm_combine_policy;
pipes[i].pipe.dest.odm_combine_policy = 
dm_odm_combine_policy_2to1;
+   }
 
new_vlevel = dml_get_voltage_level(&context->bw_ctx.dml, pipes, 
pipe_cnt);
 
@@ -1404,6 +1407,9 @@ static void try_odm_power_optimization_and_revalidate(
memset(merge, 0, MAX_PIPES * sizeof(bool));
*vlevel = dcn20_validate_apply_pipe_split_flags(dc, context, 
new_vlevel, split, merge);
context->bw_ctx.dml.vba.VoltageLevel = *vlevel;
+   } else {
+   for (i = 0; i < pipe_cnt; i++)
+   pipes[i].pipe.dest.odm_combine_policy = cur_policy[i];
}
 }
 
@@ -1581,7 +1587,7 @@ static void dcn32_full_validate_bw_helper(struct dc *dc,
}
}
 
-   if (should_allow_odm_power_optimization(dc, context, vba, split, merge))
+   if (should_apply_odm_power_optimization(dc, context, vba, split, merge))
try_odm_power_optimization_and_revalidate(
dc, context, pipes, split, merge, vlevel, 
*pipe_cnt);
 
@@ -2210,7 +2216,8 @@ bool dcn32_internal_validate_bw(struct dc *dc,
int i;
 
pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc, context, 
pipes, fast_validate);
-   dcn32_update_dml_pipes_odm_policy_based_on_context(dc, context, 
pipes);
+   if (!dc->config.enable_windowed_mpo_odm)
+   dcn32_update_dml_pipes_odm_policy_based_on_context(dc, 
context, pipes);
 
/* repopulate_pipes = 1 means the pipes were either split or 
merged. In this case
 * we have to re-calculate the DET allocation and run through 
DML once more to
diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h 
b/drivers/gpu/drm/amd/display/dc/inc/resource.h
index 1d51fed12e20..2eae2f3e846d 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/resource.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h
@@ -427,22 +427,18 @@ struct pipe_ctx *resource_get_primary_dpp_pipe(const 
struct pipe_ctx *dpp_pipe);
 int resource_get_mpc_slice_index(const struct pipe_ctx *dpp_pipe);
 
 /*
- * Get number of MPC "cuts" of the plane associated with the pipe. MPC slice
- * count is equal to MPC splits + 1. For example if a plane is cut 3 times, it
- * will have 4 pieces of slice.
- * return - 0 if pipe is not used for a plane with MPCC combine. otherwise
- * the number of MPC "cuts" for the plane.
+ * Get the number of MPC slices associated with the pipe.
+ * The function returns 0 if the pipe is not associated with an MPC combine

[PATCH 01/21] drm/amd/display: Remove Legacy FIXED_VS Transparent LT Sequence

2024-01-31 Thread Hamza Mahfooz
From: Michael Strauss 

The New sequence has been in use in DCN314 with no regressions
introduced. Therefore, it is safe to enable this sequence for all
devices using FIXED_VS retimers. So, remove the legacy codepath and its
associated config flag.

Reviewed-by: Ovidiu Bunea 
Acked-by: Hamza Mahfooz 
Signed-off-by: Michael Strauss 
---
 drivers/gpu/drm/amd/display/dc/dc.h   |   1 -
 .../dc/link/protocols/link_dp_training.c  |   5 +-
 .../link_dp_training_fixed_vs_pe_retimer.c| 350 --
 .../link_dp_training_fixed_vs_pe_retimer.h|   5 -
 .../dc/resource/dcn31/dcn31_resource.c|   2 -
 5 files changed, 1 insertion(+), 362 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 5d95b1e9dafb..74c871917eaf 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -429,7 +429,6 @@ struct dc_config {
bool force_bios_enable_lttpr;
uint8_t force_bios_fixed_vs;
int sdpif_request_limit_words_per_umc;
-   bool use_old_fixed_vs_sequence;
bool dc_mode_clk_limit_support;
bool EnableMinDispClkODM;
bool enable_auto_dpm_test_logs;
diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training.c 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training.c
index 5a0b04518956..e06d3c2d8910 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training.c
@@ -1505,10 +1505,7 @@ enum link_training_result dp_perform_link_training(
 * Non-LT AUX transactions inside training mode.
 */
if ((link->chip_caps & EXT_DISPLAY_PATH_CAPS__DP_FIXED_VS_EN) && 
encoding == DP_8b_10b_ENCODING)
-   if (link->dc->config.use_old_fixed_vs_sequence)
-   status = 
dp_perform_fixed_vs_pe_training_sequence_legacy(link, link_res, <_settings);
-   else
-   status = dp_perform_fixed_vs_pe_training_sequence(link, 
link_res, <_settings);
+   status = dp_perform_fixed_vs_pe_training_sequence(link, 
link_res, <_settings);
else if (encoding == DP_8b_10b_ENCODING)
status = dp_perform_8b_10b_link_training(link, link_res, 
<_settings);
else if (encoding == DP_128b_132b_ENCODING)
diff --git 
a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
index 7087cdc9e977..c36e0e5df447 100644
--- 
a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
+++ 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
@@ -186,356 +186,6 @@ static enum link_training_result 
perform_fixed_vs_pe_nontransparent_training_seq
return status;
 }
 
-
-enum link_training_result dp_perform_fixed_vs_pe_training_sequence_legacy(
-   struct dc_link *link,
-   const struct link_resource *link_res,
-   struct link_training_settings *lt_settings)
-{
-   const uint8_t vendor_lttpr_write_data_reset[4] = {0x1, 0x50, 0x63, 
0xFF};
-   const uint8_t offset = dp_parse_lttpr_repeater_count(
-   link->dpcd_caps.lttpr_caps.phy_repeater_cnt);
-   const uint8_t vendor_lttpr_write_data_intercept_en[4] = {0x1, 0x55, 
0x63, 0x0};
-   const uint8_t vendor_lttpr_write_data_intercept_dis[4] = {0x1, 0x55, 
0x63, 0x68};
-   uint32_t pre_disable_intercept_delay_ms = 0;
-   uint8_t vendor_lttpr_write_data_vs[4] = {0x1, 0x51, 0x63, 0x0};
-   uint8_t vendor_lttpr_write_data_pe[4] = {0x1, 0x52, 0x63, 0x0};
-   const uint8_t vendor_lttpr_write_data_4lane_1[4] = {0x1, 0x6E, 0xF2, 
0x19};
-   const uint8_t vendor_lttpr_write_data_4lane_2[4] = {0x1, 0x6B, 0xF2, 
0x01};
-   const uint8_t vendor_lttpr_write_data_4lane_3[4] = {0x1, 0x6D, 0xF2, 
0x18};
-   const uint8_t vendor_lttpr_write_data_4lane_4[4] = {0x1, 0x6C, 0xF2, 
0x03};
-   const uint8_t vendor_lttpr_write_data_4lane_5[4] = {0x1, 0x03, 0xF3, 
0x06};
-   const uint8_t vendor_lttpr_write_data_dpmf[4] = {0x1, 0x6, 0x70, 0x87};
-   enum link_training_result status = LINK_TRAINING_SUCCESS;
-   uint8_t lane = 0;
-   union down_spread_ctrl downspread = {0};
-   union lane_count_set lane_count_set = {0};
-   uint8_t toggle_rate;
-   uint8_t rate;
-
-   /* Only 8b/10b is supported */
-   ASSERT(link_dp_get_encoding_format(<_settings->link_settings) ==
-   DP_8b_10b_ENCODING);
-
-   if (lt_settings->lttpr_mode == LTTPR_MODE_NON_TRANSPARENT) {
-   status = 
perform_fixed_vs_pe_nontransparent_training_sequence(link, link_res, 
lt_settings);
-   return status;
-   }
-
-   if (offset != 0xFF) {
-   if (offset == 2) {
-   pre_disable_intercept_delay_ms = 
link->dc->debug.fixed_vs_aux

[PATCH 04/21] drm/amd/display: correct static screen event mask

2024-01-31 Thread Hamza Mahfooz
From: Allen Pan 

[Why]
Hardware register definition changed

Reviewed-by: Charlene Liu 
Acked-by: Hamza Mahfooz 
Signed-off-by: Allen Pan 
---
 .../amd/display/dc/hwss/dcn35/dcn35_hwseq.c   | 21 +--
 .../amd/display/dc/hwss/dcn35/dcn35_hwseq.h   |  3 +++
 .../amd/display/dc/hwss/dcn35/dcn35_init.c|  2 +-
 .../amd/display/dc/hwss/dcn351/dcn351_init.c  |  2 +-
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c
index 8b6c49622f3b..4b92df23ff0d 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c
@@ -1342,8 +1342,8 @@ void dcn35_set_drr(struct pipe_ctx **pipe_ctx,
 {
int i = 0;
struct drr_params params = {0};
-   // DRR set trigger event mapped to OTG_TRIG_A (bit 11) for manual 
control flow
-   unsigned int event_triggers = 0x800;
+   // DRR set trigger event mapped to OTG_TRIG_A
+   unsigned int event_triggers = 0x2;//Bit[1]: OTG_TRIG_A
// Note DRR trigger events are generated regardless of whether num 
frames met.
unsigned int num_frames = 2;
 
@@ -1377,3 +1377,20 @@ void dcn35_set_drr(struct pipe_ctx **pipe_ctx,
}
}
 }
+void dcn35_set_static_screen_control(struct pipe_ctx **pipe_ctx,
+   int num_pipes, const struct dc_static_screen_params *params)
+{
+   unsigned int i;
+   unsigned int triggers = 0;
+
+   if (params->triggers.surface_update)
+   triggers |= 0x200;/*bit 9  : 10  */
+   if (params->triggers.cursor_update)
+   triggers |= 0x8;/*bit3*/
+   if (params->triggers.force_trigger)
+   triggers |= 0x1;
+   for (i = 0; i < num_pipes; i++)
+   pipe_ctx[i]->stream_res.tg->funcs->
+   set_static_screen_control(pipe_ctx[i]->stream_res.tg,
+   triggers, params->num_frames);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.h
index fd66316e33de..c354efa6c1b2 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.h
@@ -90,4 +90,7 @@ uint32_t dcn35_get_idle_state(const struct dc *dc);
 void dcn35_set_drr(struct pipe_ctx **pipe_ctx,
int num_pipes, struct dc_crtc_timing_adjust adjust);
 
+void dcn35_set_static_screen_control(struct pipe_ctx **pipe_ctx,
+   int num_pipes, const struct dc_static_screen_params *params);
+
 #endif /* __DC_HWSS_DCN35_H__ */
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c
index 29a93dbc6631..a93073055e7b 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c
@@ -70,7 +70,7 @@ static const struct hw_sequencer_funcs dcn35_funcs = {
.update_bandwidth = dcn20_update_bandwidth,
.set_drr = dcn35_set_drr,
.get_position = dcn10_get_position,
-   .set_static_screen_control = dcn31_set_static_screen_control,
+   .set_static_screen_control = dcn35_set_static_screen_control,
.setup_stereo = dcn10_setup_stereo,
.set_avmute = dcn30_set_avmute,
.log_hw_state = dcn10_log_hw_state,
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c 
b/drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c
index e5cb7fb8b2d4..ab17fa1c64e8 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c
@@ -69,7 +69,7 @@ static const struct hw_sequencer_funcs dcn351_funcs = {
.update_bandwidth = dcn20_update_bandwidth,
.set_drr = dcn10_set_drr,
.get_position = dcn10_get_position,
-   .set_static_screen_control = dcn31_set_static_screen_control,
+   .set_static_screen_control = dcn35_set_static_screen_control,
.setup_stereo = dcn10_setup_stereo,
.set_avmute = dcn30_set_avmute,
.log_hw_state = dcn10_log_hw_state,
-- 
2.43.0



[PATCH 00/21] DC Patches January 31, 2024

2024-01-31 Thread Hamza Mahfooz
This version brings along the following:
* DCN35 fixes
* DMUB fixes
* Link training fixes
* Misc code style fixes
* MST fixes
* ODM fixes
* SubVP fixes

Allen Pan (1):
  drm/amd/display: correct static screen event mask

Alvin Lee (2):
  Revert "drm/amd/display: For FPO and SubVP/DRR configs program
vmin/max sel"
  drm/amd/display: Update phantom pipe enable / disable sequence

Aric Cyr (1):
  drm/amd/display: 3.2.271

Camille Cho (1):
  drm/amd/display: correct comment in set_default_brightness_aux()

Ethan Bitnun (2):
  drm/amd/display: Add delay before logging clks from hw
  drm/amd/display: Adjust set_p_state calls to fix logging

Fangzhi Zuo (1):
  drm/amd/display: Fix MST Null Ptr for RV

George Shen (2):
  drm/amd/display: Add debug option to force 1-tap chroma subsampling
  drm/amd/display: Add left edge pixel for YCbCr422/420 + ODM pipe split

Michael Strauss (2):
  drm/amd/display: Remove Legacy FIXED_VS Transparent LT Sequence
  drm/amd/display: Don't perform rate toggle on DP2-capable FIXED_VS
retimers

Nicholas Kazlauskas (4):
  drm/amd/display: Add more checks for exiting idle in DC
  drm/amd/display: Disable timeout in more places for dc_dmub_srv
  drm/amd/display: Increase eval/entry delay for DCN35
  drm/amd/display: Disable idle reallow as part of command/gpint
execution

Rodrigo Siqueira (4):
  drm/amd/display: Drop legacy code
  drm/amd/display: Disable ODM by default for DCN35
  drm/amd/display: Trivial code style adjustment
  drm/amd/display: Drop some unnecessary guards

Wenjing Liu (1):
  drm/amd/display: set odm_combine_policy based on context in dcn32
resource

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  12 +-
 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |   2 -
 .../dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c   |   4 -
 .../display/dc/clk_mgr/dcn301/dcn301_smu.c|   4 -
 .../amd/display/dc/clk_mgr/dcn31/dcn31_smu.c  |   4 -
 .../display/dc/clk_mgr/dcn314/dcn314_smu.c|   6 -
 .../display/dc/clk_mgr/dcn315/dcn315_smu.c|   4 -
 .../display/dc/clk_mgr/dcn316/dcn316_smu.c|   4 -
 .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |   2 +
 .../dc/clk_mgr/dcn32/dcn32_clk_mgr_smu_msg.h  |   3 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 115 +++---
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  68 ++--
 .../gpu/drm/amd/display/dc/core/dc_stream.c   |  18 +
 .../gpu/drm/amd/display/dc/core/dc_surface.c  |   2 +
 drivers/gpu/drm/amd/display/dc/dc.h   |   9 +-
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  |  17 +-
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h  |   2 -
 drivers/gpu/drm/amd/display/dc/dc_stream.h|   2 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_opp.c  |   7 +
 .../display/dc/dcn32/dcn32_resource_helpers.c |  14 +
 drivers/gpu/drm/amd/display/dc/dm_cp_psp.h|   3 +
 .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c  |  26 +-
 .../amd/display/dc/hwss/dce110/dce110_hwseq.c |   4 +-
 .../amd/display/dc/hwss/dce110/dce110_hwseq.h |   4 +
 .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c   |   2 +-
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c   |  17 +-
 .../amd/display/dc/hwss/dcn20/dcn20_hwseq.h   |   4 +
 .../amd/display/dc/hwss/dcn31/dcn31_hwseq.c   |   2 -
 .../amd/display/dc/hwss/dcn32/dcn32_hwseq.c   |  76 +++-
 .../amd/display/dc/hwss/dcn32/dcn32_hwseq.h   |   2 +
 .../amd/display/dc/hwss/dcn32/dcn32_init.c|   3 +
 .../amd/display/dc/hwss/dcn35/dcn35_hwseq.c   |  21 +-
 .../amd/display/dc/hwss/dcn35/dcn35_hwseq.h   |   3 +
 .../amd/display/dc/hwss/dcn35/dcn35_init.c|   2 +-
 .../amd/display/dc/hwss/dcn351/dcn351_init.c  |   2 +-
 .../drm/amd/display/dc/hwss/hw_sequencer.h|   1 +
 .../display/dc/hwss/hw_sequencer_private.h|   9 +-
 .../gpu/drm/amd/display/dc/inc/core_types.h   |   2 +
 drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h  |   2 -
 .../amd/display/dc/inc/hw/timing_generator.h  |   2 -
 drivers/gpu/drm/amd/display/dc/inc/resource.h |  27 +-
 .../drm/amd/display/dc/link/link_validation.c |   2 -
 .../dc/link/protocols/link_dp_training.c  |   5 +-
 .../link_dp_training_fixed_vs_pe_retimer.c| 372 +-
 .../link_dp_training_fixed_vs_pe_retimer.h|   5 -
 .../link/protocols/link_edp_panel_control.c   |   2 +-
 .../dc/resource/dcn31/dcn31_resource.c|   2 -
 .../dc/resource/dcn32/dcn32_resource.c|  18 +-
 .../dc/resource/dcn32/dcn32_resource.h|   3 +
 .../dc/resource/dcn321/dcn321_resource.c  |   2 +-
 .../dc/resource/dcn35/dcn35_resource.c|   6 +-
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h   |   1 -
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   |  11 -
 .../gpu/drm/amd/display/dmub/src/dmub_dcn32.c |   2 -
 54 files changed, 372 insertions(+), 572 deletions(-)

-- 
2.43.0



[PATCH 02/21] drm/amd/display: Don't perform rate toggle on DP2-capable FIXED_VS retimers

2024-01-31 Thread Hamza Mahfooz
From: Michael Strauss 

[WHY]
Only required if FIXED_VS retimer does not support DP2-capable.

[HOW]
Gate link rate toggle with DP 128b/132b LTTPR channel coding cap check.

Reviewed-by: Charlene Liu 
Acked-by: Hamza Mahfooz 
Signed-off-by: Michael Strauss 
---
 .../link_dp_training_fixed_vs_pe_retimer.c| 22 ++-
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
index c36e0e5df447..b5cf75975fff 100644
--- 
a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
+++ 
b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_training_fixed_vs_pe_retimer.c
@@ -270,18 +270,20 @@ enum link_training_result 
dp_perform_fixed_vs_pe_training_sequence(
 
rate = get_dpcd_link_rate(<_settings->link_settings);
 
-   /* Vendor specific: Toggle link rate */
-   toggle_rate = (rate == 0x6) ? 0xA : 0x6;
+   if 
(!link->dpcd_caps.lttpr_caps.main_link_channel_coding.bits.DP_128b_132b_SUPPORTED)
 {
+   /* Vendor specific: Toggle link rate */
+   toggle_rate = (rate == 0x6) ? 0xA : 0x6;
 
-   if (link->vendor_specific_lttpr_link_rate_wa == rate || 
link->vendor_specific_lttpr_link_rate_wa == 0) {
-   core_link_write_dpcd(
-   link,
-   DP_LINK_BW_SET,
-   &toggle_rate,
-   1);
-   }
+   if (link->vendor_specific_lttpr_link_rate_wa == rate || 
link->vendor_specific_lttpr_link_rate_wa == 0) {
+   core_link_write_dpcd(
+   link,
+   DP_LINK_BW_SET,
+   &toggle_rate,
+   1);
+   }
 
-   link->vendor_specific_lttpr_link_rate_wa = rate;
+   link->vendor_specific_lttpr_link_rate_wa = rate;
+   }
 
core_link_write_dpcd(link, DP_LINK_BW_SET, &rate, 1);
 
-- 
2.43.0



[PATCH] amdkfd: fix the cwsr trap handler for gfx11

2024-01-31 Thread Laurent Morichetti
Call the 2nd level trap handler if the cwsr handler is entered with any
one of wave_state, wave_end, or trap_after_inst exceptions.

Signed-off-by: Laurent Morichetti 
Tested-by: Lancelot Six 
---
 drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h  |  2 +-
 .../drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm  | 17 -
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h 
b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h
index d1caaf0e6a7c..2e9b64edb8d2 100644
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h
@@ -2518,7 +2518,7 @@ static const uint32_t cwsr_trap_gfx11_hex[] = {
0x8b6eff7b, 0x0400,
0xbfa20045, 0xbf830010,
0xb8fbf803, 0xbfa0fffa,
-   0x8b6eff7b, 0x0900,
+   0x8b6eff7b, 0x00160900,
0xbfa20015, 0x8b6eff7b,
0x71ff, 0xbfa10008,
0x8b6fff7b, 0x7080,
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm 
b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm
index 71b3dc0c7363..7568ff3af978 100644
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm
@@ -81,6 +81,11 @@ var SQ_WAVE_TRAPSTS_POST_SAVECTX_SHIFT   = 11
 var SQ_WAVE_TRAPSTS_POST_SAVECTX_SIZE  = 21
 var SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK  = 0x800
 var SQ_WAVE_TRAPSTS_EXCP_HI_MASK   = 0x7000
+#if ASIC_FAMILY >= CHIP_PLUM_BONITO
+var SQ_WAVE_TRAPSTS_WAVE_START_MASK= 0x2
+var SQ_WAVE_TRAPSTS_WAVE_END_MASK  = 0x4
+var SQ_WAVE_TRAPSTS_TRAP_AFTER_INST_MASK   = 0x10
+#endif
 
 var SQ_WAVE_MODE_EXCP_EN_SHIFT = 12
 var SQ_WAVE_MODE_EXCP_EN_ADDR_WATCH_SHIFT  = 19
@@ -92,6 +97,16 @@ var SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK= 0x003F8000
 
 var SQ_WAVE_MODE_DEBUG_EN_MASK = 0x800
 
+#if ASIC_FAMILY < CHIP_PLUM_BONITO
+var S_TRAPSTS_NON_MASKABLE_EXCP_MASK   = 
SQ_WAVE_TRAPSTS_MEM_VIOL_MASK|SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK
+#else
+var S_TRAPSTS_NON_MASKABLE_EXCP_MASK   = SQ_WAVE_TRAPSTS_MEM_VIOL_MASK 
|\
+ 
SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK |\
+ 
SQ_WAVE_TRAPSTS_WAVE_START_MASK   |\
+ SQ_WAVE_TRAPSTS_WAVE_END_MASK 
|\
+ 
SQ_WAVE_TRAPSTS_TRAP_AFTER_INST_MASK
+#endif
+
 // bits [31:24] unused by SPI debug data
 var TTMP11_SAVE_REPLAY_W64H_SHIFT  = 31
 var TTMP11_SAVE_REPLAY_W64H_MASK   = 0x8000
@@ -224,7 +239,7 @@ L_NOT_HALTED:
// Check non-maskable exceptions. memory_violation, illegal_instruction
// and xnack_error exceptions always cause the wave to enter the trap
// handler.
-   s_and_b32   ttmp2, s_save_trapsts, 
SQ_WAVE_TRAPSTS_MEM_VIOL_MASK|SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK
+   s_and_b32   ttmp2, s_save_trapsts, S_TRAPSTS_NON_MASKABLE_EXCP_MASK
s_cbranch_scc1  L_FETCH_2ND_TRAP
 
// Check for maskable exceptions in trapsts.excp and trapsts.excp_hi.

base-commit: 5c75a8a293f3e8f31e5ac10d3a6b87451028e5e6
-- 
2.25.1



Re: [PATCH v3 1/2] drm/buddy: Implement tracking clear page feature

2024-01-31 Thread Matthew Auld

On 30/01/2024 20:30, Arunpravin Paneer Selvam wrote:

Hi Matthew,

On 12/21/2023 12:51 AM, Matthew Auld wrote:

Hi,

On 14/12/2023 13:42, Arunpravin Paneer Selvam wrote:

- Add tracking clear page feature.

- Driver should enable the DRM_BUDDY_CLEARED flag if it
   successfully clears the blocks in the free path. On the otherhand,
   DRM buddy marks each block as cleared.

- Track the available cleared pages size

- If driver requests cleared memory we prefer cleared memory
   but fallback to uncleared if we can't find the cleared blocks.
   when driver requests uncleared memory we try to use uncleared but
   fallback to cleared memory if necessary.

- When a block gets freed we clear it and mark the freed block as 
cleared,

   when there are buddies which are cleared as well we can merge them.
   Otherwise, we prefer to keep the blocks as separated.


I was not involved, but it looks like we have also tried enabling the 
clear-on-free idea for VRAM in i915 and then also tracking that in the 
allocator, however that work unfortunately is not upstream. The code 
is open source though: 
https://github.com/intel-gpu/intel-gpu-i915-backports/blob/backport/main/drivers/gpu/drm/i915/i915_buddy.c#L300


It looks like some of the design differences there are having two 
separate free lists, so mm->clean and mm->dirty (sounds reasonable to 
me). And also the inclusion of a de-fragmentation routine, since buddy 
blocks are now not always merged back, we might choose to run the 
defrag in some cases, which also sounds reasonable. IIRC in amdgpu 
userspace can control the page-size for an allocation, so perhaps you 
would want to run it first if the allocation fails, before trying to 
evict stuff?
I checked the clear-on-free idea implemented in i915. In amdgpu version, 
we are clearing all the blocks in amdgpu free routine and DRM buddy 
expects only the DRM_BUDDY_CLEARED flag. Basically, we are keeping the 
cleared blocks ready to be allocated when the user request for the 
cleared memory. We observed that this improves the performance on games 
and resolves the stutter issues as well. I see i915 active fences part 
does the same job for i915. Could we move this part into i915 free 
routine and set the DRM_BUDDY_CLEARED flag.


On de-fragmentation , I have included a function which can be called at 
places where we get -ENOSPC. This routine will merge back the clear and 
dirty blocks together to form a larger block of requested size. I am 
wondering where we could use this routine as for the non-contiguous 
memory we have the fallback method and for the contiguous memory we have 
the try harder method which searches through the tree.


Don't you also want to call it from your vram manager when the requested 
page size is something large, before trying to evict stuff? That could 
now fail due to fragmention IIUC. Or am I misreading mdgpu_vram_mgr_new()?




I agree we can have 2 lists (clear list and dirty list) and this would 
reduce the search iterations. But we need to handle the 2 lists design 
in all the functions which might require more time for testing on all 
platforms. Could we just go ahead with 1 list (free list) for now and I 
am going to take up this work as my next task.


Sounds good.



Thanks,
Arun.




v1: (Christian)
   - Depends on the flag check DRM_BUDDY_CLEARED, enable the block as
 cleared. Else, reset the clear flag for each block in the list.

   - For merging the 2 cleared blocks compare as below,
 drm_buddy_is_clear(block) != drm_buddy_is_clear(buddy)

Signed-off-by: Arunpravin Paneer Selvam 


Suggested-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |   6 +-
  drivers/gpu/drm/drm_buddy.c   | 169 +++---
  drivers/gpu/drm/i915/i915_ttm_buddy_manager.c |   6 +-
  drivers/gpu/drm/tests/drm_buddy_test.c    |  10 +-
  include/drm/drm_buddy.h   |  18 +-
  5 files changed, 168 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c

index 08916538a615..d0e199cc8f17 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -556,7 +556,7 @@ static int amdgpu_vram_mgr_new(struct 
ttm_resource_manager *man,

  return 0;
    error_free_blocks:
-    drm_buddy_free_list(mm, &vres->blocks);
+    drm_buddy_free_list(mm, &vres->blocks, 0);
  mutex_unlock(&mgr->lock);
  error_fini:
  ttm_resource_fini(man, &vres->base);
@@ -589,7 +589,7 @@ static void amdgpu_vram_mgr_del(struct 
ttm_resource_manager *man,

    amdgpu_vram_mgr_do_reserve(man);
  -    drm_buddy_free_list(mm, &vres->blocks);
+    drm_buddy_free_list(mm, &vres->blocks, 0);
  mutex_unlock(&mgr->lock);
    atomic64_sub(vis_usage, &mgr->vis_usage);
@@ -897,7 +897,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device 
*adev)

  kfree(rsv);
    list_for_each_entry_safe(rsv, temp, &mgr->reserved_p

Re: [PATCH v5 1/3] drm/buddy: Implement tracking clear page feature

2024-01-31 Thread Matthew Auld

On 30/01/2024 19:48, Arunpravin Paneer Selvam wrote:

- Add tracking clear page feature.

- Driver should enable the DRM_BUDDY_CLEARED flag if it
   successfully clears the blocks in the free path. On the otherhand,
   DRM buddy marks each block as cleared.

- Track the available cleared pages size

- If driver requests cleared memory we prefer cleared memory
   but fallback to uncleared if we can't find the cleared blocks.
   when driver requests uncleared memory we try to use uncleared but
   fallback to cleared memory if necessary.

- When a block gets freed we clear it and mark the freed block as cleared,
   when there are buddies which are cleared as well we can merge them.
   Otherwise, we prefer to keep the blocks as separated.

v1: (Christian)
   - Depends on the flag check DRM_BUDDY_CLEARED, enable the block as
 cleared. Else, reset the clear flag for each block in the list.

   - For merging the 2 cleared blocks compare as below,
 drm_buddy_is_clear(block) != drm_buddy_is_clear(buddy)

Signed-off-by: Arunpravin Paneer Selvam 
Suggested-by: Christian König 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c  |   6 +-
  drivers/gpu/drm/drm_buddy.c   | 169 +++---
  drivers/gpu/drm/i915/i915_ttm_buddy_manager.c |   6 +-
  drivers/gpu/drm/tests/drm_buddy_test.c|  10 +-
  include/drm/drm_buddy.h   |  18 +-
  5 files changed, 168 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index 08916538a615..d0e199cc8f17 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -556,7 +556,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager 
*man,
return 0;
  
  error_free_blocks:

-   drm_buddy_free_list(mm, &vres->blocks);
+   drm_buddy_free_list(mm, &vres->blocks, 0);
mutex_unlock(&mgr->lock);
  error_fini:
ttm_resource_fini(man, &vres->base);
@@ -589,7 +589,7 @@ static void amdgpu_vram_mgr_del(struct ttm_resource_manager 
*man,
  
  	amdgpu_vram_mgr_do_reserve(man);
  
-	drm_buddy_free_list(mm, &vres->blocks);

+   drm_buddy_free_list(mm, &vres->blocks, 0);
mutex_unlock(&mgr->lock);
  
  	atomic64_sub(vis_usage, &mgr->vis_usage);

@@ -897,7 +897,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
kfree(rsv);
  
  	list_for_each_entry_safe(rsv, temp, &mgr->reserved_pages, blocks) {

-   drm_buddy_free_list(&mgr->mm, &rsv->allocated);
+   drm_buddy_free_list(&mgr->mm, &rsv->allocated, 0);
kfree(rsv);
}
if (!adev->gmc.is_app_apu)
diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f57e6d74fb0e..d44172f23f05 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -57,6 +57,16 @@ static void list_insert_sorted(struct drm_buddy *mm,
__list_add(&block->link, node->link.prev, &node->link);
  }
  
+static void clear_reset(struct drm_buddy_block *block)

+{
+   block->header &= ~DRM_BUDDY_HEADER_CLEAR;
+}
+
+static void mark_cleared(struct drm_buddy_block *block)
+{
+   block->header |= DRM_BUDDY_HEADER_CLEAR;
+}
+
  static void mark_allocated(struct drm_buddy_block *block)
  {
block->header &= ~DRM_BUDDY_HEADER_STATE;
@@ -223,6 +233,12 @@ static int split_block(struct drm_buddy *mm,
mark_free(mm, block->left);
mark_free(mm, block->right);
  
+	if (drm_buddy_block_is_clear(block)) {

+   mark_cleared(block->left);
+   mark_cleared(block->right);
+   clear_reset(block);
+   }
+
mark_split(block);
  
  	return 0;

@@ -273,6 +289,13 @@ static void __drm_buddy_free(struct drm_buddy *mm,
if (!drm_buddy_block_is_free(buddy))
break;
  
+		if (drm_buddy_block_is_clear(block) !=

+   drm_buddy_block_is_clear(buddy))
+   break;
+
+   if (drm_buddy_block_is_clear(block))
+   mark_cleared(parent);
+
list_del(&buddy->link);
  
  		drm_block_free(mm, block);

@@ -295,6 +318,9 @@ void drm_buddy_free_block(struct drm_buddy *mm,
  {
BUG_ON(!drm_buddy_block_is_allocated(block));
mm->avail += drm_buddy_block_size(mm, block);
+   if (drm_buddy_block_is_clear(block))
+   mm->clear_avail += drm_buddy_block_size(mm, block);
+
__drm_buddy_free(mm, block);
  }
  EXPORT_SYMBOL(drm_buddy_free_block);
@@ -305,10 +331,20 @@ EXPORT_SYMBOL(drm_buddy_free_block);
   * @mm: DRM buddy manager
   * @objects: input list head to free blocks
   */
-void drm_buddy_free_list(struct drm_buddy *mm, struct list_head *objects)
+void drm_buddy_free_list(struct drm_buddy *mm,
+struct list_head *objects,
+unsigned long flags)
  {
struct drm_buddy_block *block, *on;
  
+	if (flags &

[PATCH v2 2/3] drm/amdgpu: implement TLB flush fence

2024-01-31 Thread Shashank Sharma
From: Christian König 

The problem is that when (for example) 4k pages are replaced
with a single 2M page we need to wait for change to be flushed
out by invalidating the TLB before the PT can be freed.

Solve this by moving the TLB flush into a DMA-fence object which
can be used to delay the freeing of the PT BOs until it is signaled.

V2: (Shashank)
- rebase
- set dma_fence_error only in case of error
- add tlb_flush fence only when PT/PD BO is locked (Felix)
- use vm->pasid when f is NULL (Mukul)

Cc: Christian Koenig 
Cc: Felix Kuehling 
Cc: Rajneesh Bhardwaj 
Cc: Alex Deucher 
Signed-off-by: Christian König 
Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/amd/amdgpu/Makefile   |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c|  10 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h|   4 +
 .../gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c  | 106 ++
 4 files changed, 122 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c

diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
b/drivers/gpu/drm/amd/amdgpu/Makefile
index 4c989da4d2f3..fdbb3d770c7b 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -70,7 +70,8 @@ amdgpu-y += amdgpu_device.o amdgpu_doorbell_mgr.o 
amdgpu_kms.o \
amdgpu_cs.o amdgpu_bios.o amdgpu_benchmark.o \
atombios_dp.o amdgpu_afmt.o amdgpu_trace_points.o \
atombios_encoders.o amdgpu_sa.o atombios_i2c.o \
-   amdgpu_dma_buf.o amdgpu_vm.o amdgpu_vm_pt.o amdgpu_ib.o amdgpu_pll.o \
+   amdgpu_dma_buf.o amdgpu_vm.o amdgpu_vm_pt.o amdgpu_vm_tlb_fence.o \
+   amdgpu_ib.o amdgpu_pll.o \
amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \
amdgpu_gtt_mgr.o amdgpu_preempt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o \
amdgpu_atomfirmware.o amdgpu_vf_error.o amdgpu_sched.o \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 0960e0a665d3..67c690044b97 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -932,6 +932,15 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
struct amdgpu_vm *vm,
if (r)
goto error_unlock;
 
+   /* Prepare a TLB flush fence to be attached to PTs */
+   if (!unlocked && params.needs_flush && vm->is_compute_context) {
+   amdgpu_vm_tlb_fence_create(adev, vm, fence);
+
+   /* Makes sure no PD/PT is freed before the flush */
+   dma_resv_add_fence(vm->root.bo->tbo.base.resv, *fence,
+  DMA_RESV_USAGE_BOOKKEEP);
+   }
+
amdgpu_res_first(pages_addr ? NULL : res, offset,
 (last - start + 1) * AMDGPU_GPU_PAGE_SIZE, &cursor);
while (cursor.remaining) {
@@ -2237,6 +2246,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
 
mutex_init(&vm->eviction_lock);
vm->evicting = false;
+   vm->tlb_fence_context = dma_fence_context_alloc(1);
 
r = amdgpu_vm_pt_create(adev, vm, adev->vm_manager.root_level,
false, &root, xcp_id);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index ac9380afcb69..8e6fd25d07b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -332,6 +332,7 @@ struct amdgpu_vm {
atomic64_t  tlb_seq;
uint64_ttlb_seq_va;
uint64_t*tlb_seq_cpu_addr;
+   uint64_ttlb_fence_context;
 
atomic64_t  kfd_last_flushed_seq;
 
@@ -585,5 +586,8 @@ void amdgpu_vm_update_fault_cache(struct amdgpu_device 
*adev,
  uint64_t addr,
  uint32_t status,
  unsigned int vmhub);
+void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev,
+struct amdgpu_vm *vm,
+struct dma_fence **fence);
 
 #endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
new file mode 100644
index ..569681badd7c
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
@@ -0,0 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright 2023 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and th

[PATCH v2 3/3] drm/amdgpu: sync page table freeing with tlb flush

2024-01-31 Thread Shashank Sharma
This patch:
- Attaches the TLB flush fence to the PT objects being freed
- Adds a new ptr in VM to save this last TLB flush fence
- Adds a new lock in VM to prevent out-of-context update of saved
  TLB flush fence
- Adds a new ptr in tlb_flush structure to save vm

The idea is to delay freeing of page table objects until we have the
respective TLB entries flushed.

V2: rebase

Cc: Christian König 
Cc: Alex Deucher 
Cc: Felix Kuehling 
Cc: Rajneesh Bhardwaj 
Signed-off-by: Shashank Sharma 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c|  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h|  4 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 27 +++
 .../gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c  | 13 +++--
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 67c690044b97..b0e81c249e3a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2245,6 +2245,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct 
amdgpu_vm *vm,
vm->generation = 0;
 
mutex_init(&vm->eviction_lock);
+   mutex_init(&vm->tlb_flush_lock);
vm->evicting = false;
vm->tlb_fence_context = dma_fence_context_alloc(1);
 
@@ -2360,7 +2361,9 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, 
struct amdgpu_vm *vm)
}
 
dma_fence_put(vm->last_update);
+   dma_fence_put(vm->tlb_fence_last);
vm->last_update = dma_fence_get_stub();
+   vm->tlb_fence_last = dma_fence_get_stub();
vm->is_compute_context = true;
 
/* Free the shadow bo for compute VM */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 8e6fd25d07b7..b05bc586237f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -334,6 +334,10 @@ struct amdgpu_vm {
uint64_t*tlb_seq_cpu_addr;
uint64_ttlb_fence_context;
 
+   /* Ptr and lock to maintain tlb flush sync */
+   struct mutextlb_flush_lock;
+   struct dma_fence*tlb_fence_last;
+
atomic64_t  kfd_last_flushed_seq;
 
/* How many times we had to re-generate the page tables */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
index 95dc0afdaffb..f1c4418c4d63 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
@@ -631,6 +631,18 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_device *adev,
return r;
 }
 
+static inline
+void amdgpu_vm_attach_tlb_fence(struct amdgpu_bo *bo, struct dma_fence *fence)
+{
+   if (!bo || !fence)
+   return;
+
+   if (!dma_resv_reserve_fences(bo->tbo.base.resv, 1)) {
+   dma_resv_add_fence(bo->tbo.base.resv, fence,
+  DMA_RESV_USAGE_BOOKKEEP);
+   }
+}
+
 /**
  * amdgpu_vm_pt_free - free one PD/PT
  *
@@ -638,6 +650,7 @@ static int amdgpu_vm_pt_alloc(struct amdgpu_device *adev,
  */
 static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base *entry)
 {
+   struct amdgpu_vm *vm;
struct amdgpu_bo *shadow;
 
if (!entry->bo)
@@ -646,9 +659,23 @@ static void amdgpu_vm_pt_free(struct amdgpu_vm_bo_base 
*entry)
entry->bo->vm_bo = NULL;
shadow = amdgpu_bo_shadowed(entry->bo);
if (shadow) {
+   vm = shadow->vm_bo->vm;
+
+   mutex_lock(&vm->tlb_flush_lock);
+   if (vm->tlb_fence_last)
+   amdgpu_vm_attach_tlb_fence(shadow, vm->tlb_fence_last);
+   mutex_unlock(&vm->tlb_flush_lock);
+
ttm_bo_set_bulk_move(&shadow->tbo, NULL);
amdgpu_bo_unref(&shadow);
}
+
+   vm = entry->vm;
+   mutex_lock(&vm->tlb_flush_lock);
+   if (vm->tlb_fence_last)
+   amdgpu_vm_attach_tlb_fence(entry->bo, vm->tlb_fence_last);
+   mutex_unlock(&vm->tlb_flush_lock);
+
ttm_bo_set_bulk_move(&entry->bo->tbo, NULL);
 
spin_lock(&entry->vm->status_lock);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
index 569681badd7c..54ec81d30034 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
@@ -31,6 +31,7 @@
 struct amdgpu_tlb_fence {
struct dma_fencebase;
struct amdgpu_device*adev;
+   struct amdgpu_vm*vm;
struct dma_fence*dependency;
struct work_struct  work;
spinlock_t  lock;
@@ -51,6 +52,7 @@ static const char *amdgpu_tlb_fence_get_timeline_name(struct 
dma_fence *f)
 static void amdgpu_tlb_fence_work(struct work_struct *work)
 {
struct amdgpu_tlb_fence *f = container_of(work, typeof(*f), work);
+   struct amdgpu_vm

[PATCH v2 1/3] drm/amdgpu: replace TLB seq callback with HW seq

2024-01-31 Thread Shashank Sharma
From: Christian König 

The callback we installed for the SDMA update were actually pretty
horrible. since we now have seq64 use that one and HW seq writes
instead.

V2:(Shashank)
 - rebased on amd-drm-staging-next
 - changed amdgpu_seq64_gpu_addr

Cc: Christian König 
Cc: Alex Deucher 
Cc: Felix Kuehling 
Cc: Rajneesh Bhardwaj 
Signed-off-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c   | 14 
 drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h   |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c  | 79 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h  | 27 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c  |  3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c   |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c |  5 ++
 7 files changed, 42 insertions(+), 89 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
index 3d0d56087d41..300dc79fa2b9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
@@ -199,6 +199,20 @@ void amdgpu_seq64_free(struct amdgpu_device *adev, u64 va)
__clear_bit(bit_pos, adev->seq64.used);
 }
 
+/**
+ * amdgpu_seq64_gpu_addr - Calculate GPU addr from va
+ *
+ * @adev: amdgpu_device pointer
+ * @va: virtual address in client address space
+ *
+ * Calculate the GART address for a VA.
+ */
+u64 amdgpu_seq64_gpu_addr(struct amdgpu_device *adev, u64 va)
+{
+   return va - amdgpu_seq64_get_va_base(adev) +
+   amdgpu_bo_gpu_offset(adev->seq64.sbo);
+}
+
 /**
  * amdgpu_seq64_fini - Cleanup seq64 driver
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h
index 4203b2ab318d..63e8ac0a2057 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.h
@@ -43,6 +43,7 @@ void amdgpu_seq64_free(struct amdgpu_device *adev, u64 
gpu_addr);
 int amdgpu_seq64_map(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 struct amdgpu_bo_va **bo_va);
 void amdgpu_seq64_unmap(struct amdgpu_device *adev, struct amdgpu_fpriv 
*fpriv);
+u64 amdgpu_seq64_gpu_addr(struct amdgpu_device *adev, u64 va);
 
 #endif
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ed4a8c5d26d7..0960e0a665d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -111,21 +111,6 @@ struct amdgpu_prt_cb {
struct dma_fence_cb cb;
 };
 
-/**
- * struct amdgpu_vm_tlb_seq_struct - Helper to increment the TLB flush sequence
- */
-struct amdgpu_vm_tlb_seq_struct {
-   /**
-* @vm: pointer to the amdgpu_vm structure to set the fence sequence on
-*/
-   struct amdgpu_vm *vm;
-
-   /**
-* @cb: callback
-*/
-   struct dma_fence_cb cb;
-};
-
 /**
  * amdgpu_vm_set_pasid - manage pasid and vm ptr mapping
  *
@@ -862,23 +847,6 @@ int amdgpu_vm_update_pdes(struct amdgpu_device *adev,
return r;
 }
 
-/**
- * amdgpu_vm_tlb_seq_cb - make sure to increment tlb sequence
- * @fence: unused
- * @cb: the callback structure
- *
- * Increments the tlb sequence to make sure that future CS execute a VM flush.
- */
-static void amdgpu_vm_tlb_seq_cb(struct dma_fence *fence,
-struct dma_fence_cb *cb)
-{
-   struct amdgpu_vm_tlb_seq_struct *tlb_cb;
-
-   tlb_cb = container_of(cb, typeof(*tlb_cb), cb);
-   atomic64_inc(&tlb_cb->vm->tlb_seq);
-   kfree(tlb_cb);
-}
-
 /**
  * amdgpu_vm_update_range - update a range in the vm page table
  *
@@ -911,7 +879,6 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
struct amdgpu_vm *vm,
   struct dma_fence **fence)
 {
struct amdgpu_vm_update_params params;
-   struct amdgpu_vm_tlb_seq_struct *tlb_cb;
struct amdgpu_res_cursor cursor;
enum amdgpu_sync_mode sync_mode;
int r, idx;
@@ -919,12 +886,6 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
struct amdgpu_vm *vm,
if (!drm_dev_enter(adev_to_drm(adev), &idx))
return -ENODEV;
 
-   tlb_cb = kmalloc(sizeof(*tlb_cb), GFP_KERNEL);
-   if (!tlb_cb) {
-   r = -ENOMEM;
-   goto error_unlock;
-   }
-
/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache,
 * heavy-weight flush TLB unconditionally.
 */
@@ -942,6 +903,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
struct amdgpu_vm *vm,
params.immediate = immediate;
params.pages_addr = pages_addr;
params.unlocked = unlocked;
+   params.needs_flush = flush_tlb;
params.allow_override = allow_override;
 
/* Implicitly sync to command submissions in the same VM before
@@ -955,7 +917,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, 
struct amdgpu_vm *vm,
amdgpu_vm_eviction_lock(vm);
if (vm->evicting) {
 

Re: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper

2024-01-31 Thread kernel test robot
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/acpi-bus linus/master v6.8-rc2 
next-20240131]
[cannot apply to drm-misc/drm-misc-next rafael-pm/devprop]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-video-Handle-fetching-EDID-that-is-longer-than-256-bytes/20240131-032909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
patch link:
https://lore.kernel.org/r/20240130192608.11666-3-mario.limonciello%40amd.com
patch subject: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper
config: x86_64-kismet-CONFIG_ACPI_WMI-CONFIG_DRM-0-0 
(https://download.01.org/0day-ci/archive/20240131/202401312256.jbaomfd9-...@intel.com/config)
reproduce: 
(https://download.01.org/0day-ci/archive/20240131/202401312256.jbaomfd9-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202401312256.jbaomfd9-...@intel.com/

kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for ACPI_WMI when 
>> selected by DRM
   .config:248:warning: symbol value 'n' invalid for AIC79XX_CMDS_PER_DEVICE
   .config:250:warning: symbol value 'n' invalid for SATA_MOBILE_LPM_POLICY
   .config:308:warning: symbol value 'n' invalid for 
SQUASHFS_FRAGMENT_CACHE_SIZE
   .config:333:warning: symbol value 'n' invalid for PANEL_LCD_PIN_SDA
   .config:356:warning: symbol value 'n' invalid for PSTORE_BLK_MAX_REASON
   .config:414:warning: symbol value 'n' invalid for FB_OMAP2_NUM_FBS
   .config:459:warning: symbol value 'n' invalid for KFENCE_SAMPLE_INTERVAL
   .config:543:warning: symbol value 'n' invalid for CFAG12864B_RATE
   .config:651:warning: symbol value 'n' invalid for CRYPTO_DEV_QCE_SW_MAX_LEN
   .config:665:warning: symbol value 'n' invalid for BLK_DEV_LOOP_MIN_COUNT
   .config:756:warning: symbol value 'n' invalid for PANEL_LCD_CHARSET
   .config:840:warning: symbol value 'n' invalid for SND_AC97_POWER_SAVE_DEFAULT
   .config:855:warning: symbol value 'n' invalid for MAGIC_SYSRQ_DEFAULT_ENABLE
   .config:893:warning: symbol value 'n' invalid for 
DRM_I915_MAX_REQUEST_BUSYWAIT
   .config:894:warning: symbol value 'n' invalid for RAPIDIO_DISC_TIMEOUT
   .config:917:warning: symbol value 'n' invalid for FAT_DEFAULT_CODEPAGE
   .config:920:warning: symbol value 'n' invalid for SND_AT73C213_TARGET_BITRATE
   .config:966:warning: symbol value 'n' invalid for CMA_SIZE_MBYTES
   .config:967:warning: symbol value 'n' invalid for NET_EMATCH_STACK
   .config:969:warning: symbol value 'n' invalid for VMCP_CMA_SIZE
   .config:1152:warning: symbol value 'n' invalid for NODES_SHIFT
   .config:1247:warning: symbol value 'n' invalid for MTDRAM_ERASE_SIZE
   .config:1307:warning: symbol value 'n' invalid for SERIAL_UARTLITE_NR_UARTS
   .config:1318:warning: symbol value 'n' invalid for AIC7XXX_DEBUG_MASK
   .config:1479:warning: symbol value 'n' invalid for LEGACY_PTY_COUNT
   .config:1645:warning: symbol value 'n' invalid for AIC7XXX_RESET_DELAY_MS
   .config:1682:warning: symbol value 'n' invalid for INPUT_MOUSEDEV_SCREEN_Y
   .config:1861:warning: symbol value 'n' invalid for IBM_EMAC_POLL_WEIGHT
   .config:1936:warning: symbol value 'n' invalid for DRM_I915_STOP_TIMEOUT
   .config:2029:warning: symbol value 'n' invalid for 
USB_GADGET_STORAGE_NUM_BUFFERS
   .config:2151:warning: symbol value 'n' invalid for 
SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_NUM
   .config:2259:warning: symbol value 'n' invalid for SND_HDA_PREALLOC_SIZE
   .config:2310:warning: symbol value 'n' invalid for RCU_FANOUT_LEAF
   .config:2467:warning: symbol value 'n' invalid for PANEL_LCD_BWIDTH
   .config:2523:warning: symbol value 'n' invalid for PANEL_LCD_PIN_E
   .config:2542:warning: symbol value 'n' invalid for PSTORE_BLK_CONSOLE_SIZE
   .config:2725:warning: symbol value 'n' invalid for PANEL_PARPORT
   .config:2745:warning: symbol value 'n' invalid for BOOKE_WDT_DEFAULT_TIMEOUT
   .config:2824:warning: symbol value 'n' invalid for NOUVEAU_DEBUG_DEFAULT
   .config:3026:warning: symbol value 'n' invalid for KCSAN_REPORT_ONCE_IN_MS
   .config:3136:warning: symbol 

Re: [PATCH v2 1/1] drm/virtio: Implement device_attach

2024-01-31 Thread Christian König

Am 31.01.24 um 11:20 schrieb Zhang, Julia:

On 2024/1/30 22:23, Christian König wrote:

Am 30.01.24 um 12:16 schrieb Daniel Vetter:

On Tue, Jan 30, 2024 at 12:10:31PM +0100, Daniel Vetter wrote:

[SNIP]

Hi Sima, Christian,


Yeah, that is really just speculative. All importers need to set the peer2peer 
flag just in case.

I see, I will modify this.


What happens under the hood is that IOMMU redirects the "VRAM" memory access to 
whatever address the DMA-buf on the host is pointing to (system, VRAM, doorbell, IOMMU, 
whatever).

I'm also not 100% sure if all the cache snooping is done correctly in all 
cases, but for now it seems to work.

Frankly the more I look at the original patch that added vram export
support the more this just looks like a "pls revert, this is just too
broken".

The commit I mean is this one: ea5ea3d8a117 ("drm/virtio: support mapping
exported vram"). The commit message definitely needs to cite that one, and
also needs a cc: stable because not rejecting invalid imports is a pretty
big deal.

Yeah, I've pointed out that commit in an internal discussion as well. I was 
just not aware that it's that severely broken.


Yeah we have mentioned this patch before, but I don't totally understand why 
this is too broken. Without exporting vram objects, dGPU prime feature would 
not be realized.
Would you mind to explain more about it. Thanks!


One reason is that using sg tables without struct pages is actually a 
hack we came up with because we couldn't hope to clean up the sg table 
structure any time soon to not include struct page pointers.


Another reason is that using this with devices which don't expect a DMA 
address pointing into a virtual PCI BAR. So doing this without checking 
the peer2peer flag can most likely cause quite a bit of trouble.


Regards,
Christian.



Best regards,
Julia


Regards,
Christian.


[PATCH] drm/amdgpu: Only create mes event log debugfs when mes is enabled

2024-01-31 Thread shaoyunl
Skip the debugfs file creation for mes event log if the GPU
doesn't use MES. This to prevent potential kernel oops when
user try to read the event log in debugfs on a GPU without MES

Signed-off-by: shaoyunl 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
index 0626ac0192a8..dd2b8f3fa2f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -1565,9 +1565,9 @@ void amdgpu_debugfs_mes_event_log_init(struct 
amdgpu_device *adev)
 #if defined(CONFIG_DEBUG_FS)
struct drm_minor *minor = adev_to_drm(adev)->primary;
struct dentry *root = minor->debugfs_root;
-
-   debugfs_create_file("amdgpu_mes_event_log", 0444, root,
-   adev, &amdgpu_debugfs_mes_event_log_fops);
+   if (adev->enable_mes)
+   debugfs_create_file("amdgpu_mes_event_log", 0444, root,
+   adev, &amdgpu_debugfs_mes_event_log_fops);
 
 #endif
 }
-- 
2.34.1



Re: [PATCH 2/2] drm/amdkfd: Relocate TBA/TMA to opposite side of VM hole (v2)

2024-01-31 Thread Christian König




Am 30.01.24 um 21:08 schrieb Felix Kuehling:

The TBA and TMA, along with an unused IB allocation, reside at low
addresses in the VM address space. A stray VM fault which hits these
pages must be serviced by making their page table entries invalid.
The scheduler depends upon these pages being resident and fails,
preventing a debugger from inspecting the failure state.

By relocating these pages above 47 bits in the VM address space they
can only be reached when bits [63:48] are set to 1. This makes it much
less likely for a misbehaving program to generate accesses to them.
The current placement at VA (PAGE_SIZE*2) is readily hit by a NULL
access with a small offset.

v2:
- Move it to the reserved space to avoid concflicts with Mesa
- Add macros to make reserved space management easier

Cc: Arunpravin Paneer Selvam 
Cc: Christian Koenig 
Signed-off-by: Jay Cornwall 
Signed-off-by: Felix Kuehling 
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c  |  4 +--
  drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c|  7 ++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h   | 10 ++-
  drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 30 +++-
  4 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c
index 823d31f4a2a3..53d0a458d78e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c
@@ -28,9 +28,9 @@
  
  uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)

  {
-   uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
+   uint64_t addr = AMDGPU_VA_RESERVED_CSA_START(
+   adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT);


Maybe move the "adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT" part 
into the macro. That should be identical for all use cases.


Apart from that looks really good to me.

Regards,
Christian.

  
-	addr -= AMDGPU_VA_RESERVED_CSA_SIZE;

addr = amdgpu_gmc_sign_extend(addr);
  
  	return addr;

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
index 3d0d56087d41..9e769ef50f2e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
@@ -45,11 +45,8 @@
   */
  static inline u64 amdgpu_seq64_get_va_base(struct amdgpu_device *adev)
  {
-   u64 addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
-
-   addr -= AMDGPU_VA_RESERVED_TOP;
-
-   return addr;
+   return AMDGPU_VA_RESERVED_SEQ64_START(
+   adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT);
  }
  
  /**

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 2c4053b29bb3..c2407f6a7e83 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -137,9 +137,17 @@ struct amdgpu_mem_stats;
  
  /* Reserve space at top/bottom of address space for kernel use */

  #define AMDGPU_VA_RESERVED_CSA_SIZE   (2ULL << 20)
+#define AMDGPU_VA_RESERVED_CSA_START(top)  ((top) \
+- AMDGPU_VA_RESERVED_CSA_SIZE)
  #define AMDGPU_VA_RESERVED_SEQ64_SIZE (2ULL << 20)
+#define AMDGPU_VA_RESERVED_SEQ64_START(top)
(AMDGPU_VA_RESERVED_CSA_START(top) \
+- 
AMDGPU_VA_RESERVED_SEQ64_SIZE)
+#define AMDGPU_VA_RESERVED_TRAP_SIZE   (2ULL << 12)
+#define AMDGPU_VA_RESERVED_TRAP_START(top) 
(AMDGPU_VA_RESERVED_SEQ64_START(top) \
+- AMDGPU_VA_RESERVED_TRAP_SIZE)
  #define AMDGPU_VA_RESERVED_BOTTOM (1ULL << 16)
-#define AMDGPU_VA_RESERVED_TOP (AMDGPU_VA_RESERVED_SEQ64_SIZE 
+ \
+#define AMDGPU_VA_RESERVED_TOP (AMDGPU_VA_RESERVED_TRAP_SIZE + 
\
+AMDGPU_VA_RESERVED_SEQ64_SIZE 
+ \
 AMDGPU_VA_RESERVED_CSA_SIZE)
  
  /* See vm_update_mode */

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 6604a3f99c5e..f899cce25b2a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -36,6 +36,7 @@
  #include 
  #include 
  #include 
+#include "amdgpu_vm.h"
  
  /*

   * The primary memory I/O features being added for revisions of gfxip
@@ -326,10 +327,16 @@ static void kfd_init_apertures_vi(struct 
kfd_process_device *pdd, uint8_t id)
 * with small reserved space for kernel.
 * Set them to CANONICAL addresses.
 */
-   pdd->gpuvm_base = SVM_USER_BASE;
+   pdd->gpuvm_base = max(SVM_USER_BASE, AMDGPU_VA_RESERVED_BOTTOM);
pdd->gpuvm_limit =
pdd->dev->kfd->shared_resources.gpuvm_size - 1;
  
+	/* dGPUs: the reserved space for kernel

+* before SVM
+*/
+   pdd->qpd.cwsr_base = SVM_CWSR_BASE;
+

Re: [PATCH 1/2] drm/amdgpu: Reduce VA_RESERVED_BOTTOM to 64KB

2024-01-31 Thread Christian König

Am 30.01.24 um 21:08 schrieb Felix Kuehling:

The reservation is there to catch NULL pointer dereferences from the
GPU. Reduce the size to 64KB to make sure that shared virtual address
programming models can map all CPU-accessible virtual addresses for GPU
access. This is also the default for CPU virtual address mappings as
seen in /proc/sys/vm/mmap_min_addr.

Signed-off-by: Felix Kuehling 


Reviewed-by: Christian König 


---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 98a57192..2c4053b29bb3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -135,10 +135,10 @@ struct amdgpu_mem_stats;
  #define AMDGPU_IS_MMHUB0(x) ((x) >= AMDGPU_MMHUB0_START && (x) < 
AMDGPU_MMHUB1_START)
  #define AMDGPU_IS_MMHUB1(x) ((x) >= AMDGPU_MMHUB1_START && (x) < 
AMDGPU_MAX_VMHUBS)
  
-/* Reserve 2MB at top/bottom of address space for kernel use */

+/* Reserve space at top/bottom of address space for kernel use */
  #define AMDGPU_VA_RESERVED_CSA_SIZE   (2ULL << 20)
  #define AMDGPU_VA_RESERVED_SEQ64_SIZE (2ULL << 20)
-#define AMDGPU_VA_RESERVED_BOTTOM  (2ULL << 20)
+#define AMDGPU_VA_RESERVED_BOTTOM  (1ULL << 16)
  #define AMDGPU_VA_RESERVED_TOP
(AMDGPU_VA_RESERVED_SEQ64_SIZE + \
 AMDGPU_VA_RESERVED_CSA_SIZE)
  




[PATCH v2] drm/amdgpu: Clear the hotplug interrupt ack bit before hpd initialization

2024-01-31 Thread Qiang Ma
Problem:
The computer in the bios initialization process, unplug the HDMI display,
wait until the system up, plug in the HDMI display, did not enter the
hotplug interrupt function, the display is not bright.

Fix:
After the above problem occurs, and the hpd ack interrupt bit is 1,
the interrupt should be cleared during hpd_init initialization so that
when the driver is ready, it can respond to the hpd interrupt normally.

Signed-off-by: Qiang Ma 
---
v2:
 - Remove unused variable 'tmp'
 - Fixed function spelling errors
 
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c  | 22 ++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c  | 22 ++
 4 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index bb666cb7522e..12a8ba929a72 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -51,6 +51,7 @@
 
 static void dce_v10_0_set_display_funcs(struct amdgpu_device *adev);
 static void dce_v10_0_set_irq_funcs(struct amdgpu_device *adev);
+static void dce_v10_0_hpd_int_ack(struct amdgpu_device *adev, int hpd);
 
 static const u32 crtc_offsets[] = {
CRTC0_REGISTER_OFFSET,
@@ -363,6 +364,7 @@ static void dce_v10_0_hpd_init(struct amdgpu_device *adev)
AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS);
WREG32(mmDC_HPD_TOGGLE_FILT_CNTL + 
hpd_offsets[amdgpu_connector->hpd.hpd], tmp);
 
+   dce_v10_0_hpd_int_ack(adev, amdgpu_connector->hpd.hpd);
dce_v10_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq,
   amdgpu_connector->hpd.hpd);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 7af277f61cca..745e4fdffade 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -51,6 +51,7 @@
 
 static void dce_v11_0_set_display_funcs(struct amdgpu_device *adev);
 static void dce_v11_0_set_irq_funcs(struct amdgpu_device *adev);
+static void dce_v11_0_hpd_int_ack(struct amdgpu_device *adev, int hpd);
 
 static const u32 crtc_offsets[] =
 {
@@ -387,6 +388,7 @@ static void dce_v11_0_hpd_init(struct amdgpu_device *adev)
AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS);
WREG32(mmDC_HPD_TOGGLE_FILT_CNTL + 
hpd_offsets[amdgpu_connector->hpd.hpd], tmp);
 
+   dce_v11_0_hpd_int_ack(adev, amdgpu_connector->hpd.hpd);
dce_v11_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index 143efc37a17f..28c4a735716b 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -272,6 +272,21 @@ static void dce_v6_0_hpd_set_polarity(struct amdgpu_device 
*adev,
WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);
 }
 
+static void dce_v6_0_hpd_int_ack(struct amdgpu_device *adev,
+int hpd)
+{
+   u32 tmp;
+
+   if (hpd >= adev->mode_info.num_hpd) {
+   DRM_DEBUG("invalid hdp %d\n", hpd);
+   return;
+   }
+
+   tmp = RREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd]);
+   tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK;
+   WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);
+}
+
 /**
  * dce_v6_0_hpd_init - hpd setup callback.
  *
@@ -311,6 +326,7 @@ static void dce_v6_0_hpd_init(struct amdgpu_device *adev)
continue;
}
 
+   dce_v6_0_hpd_int_ack(adev, amdgpu_connector->hpd.hpd);
dce_v6_0_hpd_set_polarity(adev, amdgpu_connector->hpd.hpd);
amdgpu_irq_get(adev, &adev->hpd_irq, amdgpu_connector->hpd.hpd);
}
@@ -3088,7 +3104,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
struct amdgpu_irq_src *source,
struct amdgpu_iv_entry *entry)
 {
-   uint32_t disp_int, mask, tmp;
+   uint32_t disp_int, mask;
unsigned hpd;
 
if (entry->src_data[0] >= adev->mode_info.num_hpd) {
@@ -3101,9 +3117,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
mask = interrupt_status_offsets[hpd].hpd;
 
if (disp_int & mask) {
-   tmp = RREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd]);
-   tmp |= DC_HPD1_INT_CONTROL__DC_HPD1_INT_ACK_MASK;
-   WREG32(mmDC_HPD1_INT_CONTROL + hpd_offsets[hpd], tmp);
+   dce_v6_0_hpd_int_ack(adev, hpd);
schedule_delayed_work(&adev->hotplug_work, 0);
DRM_DEBUG("IH: HPD%d\n", hpd + 1);
}
diff --git a/dr

Re: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper

2024-01-31 Thread kernel test robot
Hi Mario,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/acpi-bus linus/master v6.8-rc2 
next-20240131]
[cannot apply to drm-misc/drm-misc-next rafael-pm/devprop]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-video-Handle-fetching-EDID-that-is-longer-than-256-bytes/20240131-032909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
patch link:
https://lore.kernel.org/r/20240130192608.11666-3-mario.limonciello%40amd.com
patch subject: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper
config: i386-buildonly-randconfig-003-20240131 
(https://download.01.org/0day-ci/archive/20240131/202401311847.xfzpeok4-...@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 
6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240131/202401311847.xfzpeok4-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202401311847.xfzpeok4-...@intel.com/

All error/warnings (new ones prefixed by >>):

>> drivers/platform/x86/wmi.c:68:2: error: unknown type name 
>> 'wmi_notify_handler'; did you mean 'acpi_notify_handler'?
  68 | wmi_notify_handler handler;
 | ^~
 | acpi_notify_handler
   include/acpi/actypes.h:1061:8: note: 'acpi_notify_handler' declared here
1061 | void (*acpi_notify_handler) (acpi_handle device, u32 value, void 
*context);
 |^
>> drivers/platform/x86/wmi.c:163:30: error: incomplete definition of type 
>> 'struct acpi_device'
 163 | handle = wblock->acpi_device->handle;
 |  ~~~^
   include/linux/acpi.h:795:8: note: forward declaration of 'struct acpi_device'
 795 | struct acpi_device;
 |^
>> drivers/platform/x86/wmi.c:166:11: error: call to undeclared function 
>> 'acpi_execute_simple_method'; ISO C99 and later do not support implicit 
>> function declarations [-Wimplicit-function-declaration]
 166 | status = acpi_execute_simple_method(handle, method, enable);
 |  ^
   drivers/platform/x86/wmi.c:166:11: note: did you mean 
'acpi_execute_reg_methods'?
   include/acpi/acpixf.h:662:8: note: 'acpi_execute_reg_methods' declared here
 662 | acpi_execute_reg_methods(acpi_handle 
device,
 | ^
   include/acpi/platform/aclinux.h:93:21: note: expanded from macro 
'ACPI_EXTERNAL_RETURN_STATUS'
  93 | static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
 |^
   drivers/platform/x86/wmi.c:210:49: error: incomplete definition of type 
'struct acpi_device'
 210 | return acpi_evaluate_object(wblock->acpi_device->handle, 
"_WED", &input, out);
 | ~~~^
   include/linux/acpi.h:795:8: note: forward declaration of 'struct acpi_device'
 795 | struct acpi_device;
 |^
>> drivers/platform/x86/wmi.c:282:5: warning: no previous prototype for 
>> function 'wmi_instance_count' [-Wmissing-prototypes]
 282 | int wmi_instance_count(const char *guid_string)
 | ^
   drivers/platform/x86/wmi.c:282:1: note: declare 'static' if the function is 
not intended to be used outside of this translation unit
 282 | int wmi_instance_count(const char *guid_string)
 | ^
 | static 
>> drivers/platform/x86/wmi.c:326:13: warning: no previous prototype for 
>> function 'wmi_evaluate_method' [-Wmissing-prototypes]
 326 | acpi_status wmi_evaluate_method(const char *guid_string, u8 
instance, u32 method_id,
 | ^
   drivers/platform/x86/wmi.c:326:1: note: declare 'static' if the function is 
not intended to be used outside of this translation unit
 326 | acpi_status wmi_evaluate_method(const char *guid_string, u8 
instance, u32 method_id,
 | ^
 | static 
   drivers/platform/x86/wmi.c:368:30: error: incomplete definition of type 
'struct acpi_device'
 368 | handle = wblock->acpi_device->handle;
 |  ~~~^
   include

Re: [PATCH v2 1/1] drm/virtio: Implement device_attach

2024-01-31 Thread Zhang, Julia


On 2024/1/30 22:23, Christian König wrote:
> Am 30.01.24 um 12:16 schrieb Daniel Vetter:
>> On Tue, Jan 30, 2024 at 12:10:31PM +0100, Daniel Vetter wrote:
>>> On Mon, Jan 29, 2024 at 06:31:19PM +0800, Julia Zhang wrote:
 As vram objects don't have backing pages and thus can't implement
 drm_gem_object_funcs.get_sg_table callback. This removes drm dma-buf
 callbacks in virtgpu_gem_map_dma_buf()/virtgpu_gem_unmap_dma_buf()
 and implement virtgpu specific map/unmap/attach callbacks to support
 both of shmem objects and vram objects.

 Signed-off-by: Julia Zhang 
 ---
   drivers/gpu/drm/virtio/virtgpu_prime.c | 40 +++---
   1 file changed, 36 insertions(+), 4 deletions(-)

 diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c 
 b/drivers/gpu/drm/virtio/virtgpu_prime.c
 index 44425f20d91a..b490a5343b06 100644
 --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
 +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
 @@ -49,11 +49,26 @@ virtgpu_gem_map_dma_buf(struct dma_buf_attachment 
 *attach,
   {
   struct drm_gem_object *obj = attach->dmabuf->priv;
   struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
 +    struct sg_table *sgt;
 +    int ret;
     if (virtio_gpu_is_vram(bo))
   return virtio_gpu_vram_map_dma_buf(bo, attach->dev, dir);
   -    return drm_gem_map_dma_buf(attach, dir);
 +    sgt = drm_prime_pages_to_sg(obj->dev,
 +    to_drm_gem_shmem_obj(obj)->pages,
 +    obj->size >> PAGE_SHIFT);
 +    if (IS_ERR(sgt))
 +    return sgt;
 +
 +    ret = dma_map_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
 +    if (ret) {
 +    sg_free_table(sgt);
 +    kfree(sgt);
 +    return ERR_PTR(ret);
 +    }
 +
 +    return sgt;
   }
     static void virtgpu_gem_unmap_dma_buf(struct dma_buf_attachment 
 *attach,
 @@ -63,12 +78,29 @@ static void virtgpu_gem_unmap_dma_buf(struct 
 dma_buf_attachment *attach,
   struct drm_gem_object *obj = attach->dmabuf->priv;
   struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
   +    if (!sgt)
 +    return;
 +
   if (virtio_gpu_is_vram(bo)) {
   virtio_gpu_vram_unmap_dma_buf(attach->dev, sgt, dir);
 -    return;
 +    } else {
 +    dma_unmap_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
 +    sg_free_table(sgt);
 +    kfree(sgt);
   }
 +}
 +
 +static int virtgpu_gem_device_attach(struct dma_buf *dma_buf,
 + struct dma_buf_attachment *attach)
 +{
 +    struct drm_gem_object *obj = attach->dmabuf->priv;
 +    struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
 +    int ret = 0;
 +
 +    if (!virtio_gpu_is_vram(bo) && obj->funcs->pin)
 +    ret = obj->funcs->pin(obj);
   -    drm_gem_unmap_dma_buf(attach, sgt, dir);
 +    return ret;
>>> This doesn't look like what I've expected. There should be no need to
>>> change the map/unmap functions, especially not for the usual gem bo case.
>>> We should definitely keep using the exact same code for that. Instead all
>>> I expected is roughly
>>>
>>> virtgpu_gem_device_attach()
>>> {
>>> if (virtio_gpu_is_vram(bo)) {
>>>     if (can_access_virtio_vram_directly(attach->dev)
>>>     return 0;
>>>     else
>>>     return -EBUSY;
>>> } else {
>>>     return drm_gem_map_attach();
>>> }
>>> }
>>>
>>> Note that I think can_access_virtio_vram_directly() needs to be
>>> implemented first. I'm not even sure it's possible, might be that all the
>>> importers need to set the attachment->peer2peer flag. Which is why this
>>> thing exists really. But that's a pile more work to do.
> 
Hi Sima, Christian,

> Yeah, that is really just speculative. All importers need to set the 
> peer2peer flag just in case.

I see, I will modify this.

> 
> What happens under the hood is that IOMMU redirects the "VRAM" memory access 
> to whatever address the DMA-buf on the host is pointing to (system, VRAM, 
> doorbell, IOMMU, whatever).
> 
> I'm also not 100% sure if all the cache snooping is done correctly in all 
> cases, but for now it seems to work.

>>> Frankly the more I look at the original patch that added vram export
>>> support the more this just looks like a "pls revert, this is just too
>>> broken".
>> The commit I mean is this one: ea5ea3d8a117 ("drm/virtio: support mapping
>> exported vram"). The commit message definitely needs to cite that one, and
>> also needs a cc: stable because not rejecting invalid imports is a pretty
>> big deal.
> 
> Yeah, I've pointed out that commit in an internal discussion as well. I was 
> just not aware that it's that severely broken.
> 

Yeah we have mentioned this patch before, but I don't totally understand why 
this 

Re: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper

2024-01-31 Thread kernel test robot
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/acpi-bus linus/master v6.8-rc2 
next-20240131]
[cannot apply to drm-misc/drm-misc-next rafael-pm/devprop]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-video-Handle-fetching-EDID-that-is-longer-than-256-bytes/20240131-032909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
patch link:
https://lore.kernel.org/r/20240130192608.11666-3-mario.limonciello%40amd.com
patch subject: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper
config: i386-buildonly-randconfig-001-20240131 
(https://download.01.org/0day-ci/archive/20240131/202401311759.htfj4nbl-...@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 
6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240131/202401311759.htfj4nbl-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202401311759.htfj4nbl-...@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/acpi/acpi_video.c:642:44: warning: format specifies type 'long' but 
>> the argument has type 'ssize_t' (aka 'int') [-Wformat]
 642 |  "Invalid _DDC data for length 
%ld\n", length);
 |~~~   
  ^~
 |%zd
   include/linux/acpi.h:1219:30: note: expanded from macro 'acpi_handle_debug'
1219 |handle, pr_fmt(fmt), ##__VA_ARGS__)
 |   ~~~ ^~~
   include/linux/dynamic_debug.h:250:59: note: expanded from macro 
'_dynamic_func_call'
 250 | _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, 
##__VA_ARGS__)
 |  
^~~
   include/linux/dynamic_debug.h:248:65: note: expanded from macro 
'_dynamic_func_call_cls'
 248 | __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, 
##__VA_ARGS__)
 |  
  ^~~
   include/linux/dynamic_debug.h:224:15: note: expanded from macro 
'__dynamic_func_call_cls'
 224 | func(&id, ##__VA_ARGS__);   \
 | ^~~
   1 warning generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for ACPI_WMI
   Depends on [n]: X86_PLATFORM_DEVICES [=n] && ACPI [=y]
   Selected by [y]:
   - DRM [=y] && HAS_IOMEM [=y] && (AGP [=n] || AGP [=n]=n) && 
!EMULATED_CMPXCHG && HAS_DMA [=y] && X86 [=y]


vim +642 drivers/acpi/acpi_video.c

^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  612  
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  613  
static int
4be44fcd3bf648 drivers/acpi/video.c  Len Brown 2005-08-05  614  
acpi_video_device_EDID(struct acpi_video_device *device,
4be44fcd3bf648 drivers/acpi/video.c  Len Brown 2005-08-05  615  
   union acpi_object **edid, ssize_t length)
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  616  {
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  617  
int status;
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  618  
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  619  
union acpi_object *obj;
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  620  
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  621  
struct acpi_object_list args = { 1, &arg0 };
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  622  
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  623  
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  624  
*edid = NULL;
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  625  
^1da177e4c3f41 drivers/acpi/video.c  Linus Torvalds2005-04-16  626  
if (!device)
d550d98

Re: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper

2024-01-31 Thread kernel test robot
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on rafael-pm/acpi-bus linus/master v6.8-rc2 
next-20240131]
[cannot apply to drm-misc/drm-misc-next rafael-pm/devprop]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-video-Handle-fetching-EDID-that-is-longer-than-256-bytes/20240131-032909
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next
patch link:
https://lore.kernel.org/r/20240130192608.11666-3-mario.limonciello%40amd.com
patch subject: [PATCH v2 2/4] drm: Add drm_get_acpi_edid() helper
config: x86_64-kismet-CONFIG_ACPI_PLATFORM_PROFILE-CONFIG_HP_WMI-0-0 
(https://download.01.org/0day-ci/archive/20240131/202401311634.fe5cbvwe-...@intel.com/config)
reproduce: 
(https://download.01.org/0day-ci/archive/20240131/202401311634.fe5cbvwe-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202401311634.fe5cbvwe-...@intel.com/

kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for 
>> ACPI_PLATFORM_PROFILE when selected by HP_WMI
   .config:101:warning: symbol value 'n' invalid for RADIO_RTRACK2_PORT
   .config:223:warning: symbol value 'n' invalid for AIC79XX_CMDS_PER_DEVICE
   .config:240:warning: symbol value 'n' invalid for SATA_MOBILE_LPM_POLICY
   .config:310:warning: symbol value 'n' invalid for DRM_I915_TIMESLICE_DURATION
   .config:321:warning: symbol value 'n' invalid for PANEL_LCD_PIN_SDA
   .config:345:warning: symbol value 'n' invalid for PSTORE_BLK_MAX_REASON
   .config:457:warning: symbol value 'n' invalid for KFENCE_SAMPLE_INTERVAL
   .config:633:warning: symbol value 'n' invalid for CRYPTO_DEV_QCE_SW_MAX_LEN
   .config:651:warning: symbol value 'n' invalid for DRM_XE_JOB_TIMEOUT_MIN
   .config:674:warning: symbol value 'n' invalid for FB_GBE_MEM
   .config:739:warning: symbol value 'n' invalid for PANEL_LCD_CHARSET
   .config:836:warning: symbol value 'n' invalid for SND_AC97_POWER_SAVE_DEFAULT
   .config:851:warning: symbol value 'n' invalid for MAGIC_SYSRQ_DEFAULT_ENABLE
   .config:871:warning: symbol value 'n' invalid for 
DRM_I915_MAX_REQUEST_BUSYWAIT
   .config:900:warning: symbol value 'n' invalid for SND_AT73C213_TARGET_BITRATE
   .config:951:warning: symbol value 'n' invalid for DRM_XE_PREEMPT_TIMEOUT_MIN
   .config:961:warning: symbol value 'n' invalid for NET_EMATCH_STACK
   .config:962:warning: symbol value 'n' invalid for VMCP_CMA_SIZE
   .config:1002:warning: symbol value 'n' invalid for 
SQUASHFS_FRAGMENT_CACHE_SIZE
   .config:1113:warning: symbol value 'n' invalid for FB_OMAP2_NUM_FBS
   .config:1237:warning: symbol value 'n' invalid for MTDRAM_ERASE_SIZE
   .config:1253:warning: symbol value 'n' invalid for CFAG12864B_RATE
   .config:1290:warning: symbol value 'n' invalid for SERIAL_UARTLITE_NR_UARTS
   .config:1468:warning: symbol value 'n' invalid for LEGACY_PTY_COUNT
   .config:1528:warning: symbol value 'n' invalid for RAPIDIO_DISC_TIMEOUT
   .config:1568:warning: symbol value 'n' invalid for FAT_DEFAULT_CODEPAGE
   .config:1608:warning: symbol value 'n' invalid for WATCHDOG_OPEN_TIMEOUT
   .config:1615:warning: symbol value 'n' invalid for AIC7XXX_RESET_DELAY_MS
   .config:1638:warning: symbol value 'n' invalid for KCOV_IRQ_AREA_SIZE
   .config:1850:warning: symbol value 'n' invalid for IBM_EMAC_POLL_WEIGHT
   .config:1903:warning: symbol value 'n' invalid for DRM_I915_STOP_TIMEOUT
   .config:2189:warning: symbol value 'n' invalid for 
SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_NUM
   .config:2246:warning: symbol value 'n' invalid for SND_HDA_PREALLOC_SIZE
   .config:2358:warning: symbol value 'n' invalid for DRM_XE_TIMESLICE_MAX
   .config:2452:warning: symbol value 'n' invalid for PANEL_LCD_BWIDTH
   .config:2554:warning: symbol value 'n' invalid for PSTORE_BLK_CONSOLE_SIZE
   .config:2701:warning: symbol value 'n' invalid for PANEL_PARPORT
   .config:2763:warning: symbol value 'n' invalid for BOOKE_WDT_DEFAULT_TIMEOUT
   .config:2798:warning: symbol value 'n' invalid for NOUVEAU_DEBUG_DEFAULT
   .config:2996:warning: symbol value 'n' invalid for KCSAN_REPOR

RE: [PATCH] drm/amdgpu: remove asymmetrical irq disabling in vcn 4.0.5 suspend

2024-01-31 Thread Gopalakrishnan, Veerabadhran (Veera)
[AMD Official Use Only - General]

Looks good to me.

Reviewed-by: Veerabadhran Gopalakrishnan 

Regards,
Veera

-Original Message-
From: Jamadar, Saleemkhan 
Sent: Wednesday, January 31, 2024 1:23 PM
To: Zhang, Yifan ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Gopalakrishnan, 
Veerabadhran (Veera) 
Subject: RE: [PATCH] drm/amdgpu: remove asymmetrical irq disabling in vcn 4.0.5 
suspend

[AMD Official Use Only - General]

Acked-By: Saleemkhan Jamadar 

-Original Message-
From: Zhang, Yifan 
Sent: Tuesday, January 30, 2024 6:45 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Gopalakrishnan, 
Veerabadhran (Veera) ; Jamadar, Saleemkhan 
; Zhang, Yifan 
Subject: [PATCH] drm/amdgpu: remove asymmetrical irq disabling in vcn 4.0.5 
suspend

There is no irq enabled in vcn 4.0.5 resume, causing wrong amdgpu_irq_src 
status.
Beside, current set function callbacks are empty with no real effect.

Signed-off-by: Yifan Zhang 
---
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c   | 17 -
 drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 19 ---
 2 files changed, 36 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
index 169ed400ee7b..8ab01ae919d2 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
@@ -2017,22 +2017,6 @@ static int vcn_v4_0_set_powergating_state(void *handle, 
enum amd_powergating_sta
return ret;
 }

-/**
- * vcn_v4_0_set_interrupt_state - set VCN block interrupt state
- *
- * @adev: amdgpu_device pointer
- * @source: interrupt sources
- * @type: interrupt types
- * @state: interrupt states
- *
- * Set VCN block interrupt state
- */
-static int vcn_v4_0_set_interrupt_state(struct amdgpu_device *adev, struct 
amdgpu_irq_src *source,
-  unsigned type, enum amdgpu_interrupt_state state)
-{
-   return 0;
-}
-
 /**
  * vcn_v4_0_set_ras_interrupt_state - set VCN block RAS interrupt state
  *
@@ -2097,7 +2081,6 @@ static int vcn_v4_0_process_interrupt(struct 
amdgpu_device *adev, struct amdgpu_  }

 static const struct amdgpu_irq_src_funcs vcn_v4_0_irq_funcs = {
-   .set = vcn_v4_0_set_interrupt_state,
.process = vcn_v4_0_process_interrupt,  };

diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c 
b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
index 2eda30e78f61..49e4c3c09aca 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
@@ -269,8 +269,6 @@ static int vcn_v4_0_5_hw_fini(void *handle)
vcn_v4_0_5_set_powergating_state(adev, 
AMD_PG_STATE_GATE);
}
}
-
-   amdgpu_irq_put(adev, &adev->vcn.inst[i].irq, 0);
}

return 0;
@@ -1668,22 +1666,6 @@ static int vcn_v4_0_5_set_powergating_state(void 
*handle, enum amd_powergating_s
return ret;
 }

-/**
- * vcn_v4_0_5_set_interrupt_state - set VCN block interrupt state
- *
- * @adev: amdgpu_device pointer
- * @source: interrupt sources
- * @type: interrupt types
- * @state: interrupt states
- *
- * Set VCN block interrupt state
- */
-static int vcn_v4_0_5_set_interrupt_state(struct amdgpu_device *adev, struct 
amdgpu_irq_src *source,
-   unsigned type, enum amdgpu_interrupt_state state)
-{
-   return 0;
-}
-
 /**
  * vcn_v4_0_5_process_interrupt - process VCN block interrupt
  *
@@ -1726,7 +1708,6 @@ static int vcn_v4_0_5_process_interrupt(struct 
amdgpu_device *adev, struct amdgp  }

 static const struct amdgpu_irq_src_funcs vcn_v4_0_5_irq_funcs = {
-   .set = vcn_v4_0_5_set_interrupt_state,
.process = vcn_v4_0_5_process_interrupt,  };

--
2.37.3