drm/amd/display: Wake DMCUB before executing GPINT commands
Subsystems (3)
PATCH 1/1 drm/amd/display: Wake DMCUB before executing GPINT commands
From: Nicholas Kazlauskas <[email protected]>
stable inclusion
from stable-v6.7.3
commit 2ef98c6d753a7 ("drm/amd/display: Wake DMCUB before executing GPINT commands")
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9BV4C
CVE: CVE-2023-52624
--------------------------------
[ Upstream commit e5ffd1263dd5b ("drm/amd/display: Wake DMCUB before executing GPINT commands") ]
[Why]
DMCUB can be in idle when we attempt to interface with the HW through the GPINT mailbox resulting in a system hang.
[How]
Add dc_wake_and_execute_gpint() to wrap the wake, execute, sleep sequence.
If the GPINT executes successfully then DMCUB will be put back into sleep after the optional response is returned.
It functions similar to the inbox command interface.
This patch comes from following commits:
115c7e7f0501 ("drm/amd/display: Add psr get_state call") 1d496907f1c5 ("drm/amd/display: Engage PSR synchronously") 34ba432c946d ("drm/amd/display: [FW Promotion] Release 0.0.44") 672251b223c1 ("drm/amd/display: [FW Promotion] Release 0.0.40") 04f3c88f0955 ("drm/amd/display: Retry getting PSR state if command times out") b30eda8d416c ("drm/amd/display: Add ETW log to dmub_psr_get_state") f59a66c1915e ("drm/amd/display: use do-while-0 for DC_TRACE_LEVEL_MESSAGE()") e97cc04fe0fb ("drm/amd/display: refactor dmub commands into single function") 522b9a5d5852 ("drm/amd/display: drain dmub inbox if queue is full") 9dce8c2a5f1b ("drm/amd/display: [FW Promotion] Release 0.0.161.0") 276641775848 ("drm/amd/display: [FW Promotion] Release 0.0.162.0") 8774029f76b9 ("drm/amd/display: Add DCN35 CLK_MGR")
65138eb72e1f ("drm/amd/display: Add DCN35 DMUB")
dc01c4b79bfe ("drm/amd/display: Update driver and IPS interop") 5b7954272ae9 ("drm/amd/display: [FW Promotion] Release 0.0.183.0") da2d16fcdda3 ("drm/amd/display: Fix IPS handshake for idle optimizations") 5e8a0d3598b4 ("drm/amd/display: Negate IPS allow and commit bits") 820c3870c491 ("drm/amd/display: Refactor DMCUB enter/exit idle interface") 2ef98c6d753a ("drm/amd/display: Wake DMCUB before executing GPINT commands")
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 +- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 6 +- .../gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c | 5 +- drivers/gpu/drm/amd/display/dc/core/dc.c | 4 +- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 20 +- .../gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 +- drivers/gpu/drm/amd/display/dc/dc.h | 4 +- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 265 +++++++++++++++++- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h | 31 ++ drivers/gpu/drm/amd/display/dc/dc_link.h | 5 +- drivers/gpu/drm/amd/display/dc/dc_types.h | 20 ++ drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | 24 +- drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 140 +++++---- drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h | 3 +- drivers/gpu/drm/amd/display/dc/dm_services.h | 9 + .../drm/amd/display/dc/dm_services_types.h | 6 + .../gpu/drm/amd/display/dc/inc/hw/clk_mgr.h | 1 + drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h | 2 +- .../gpu/drm/amd/display/dc/inc/hw_sequencer.h | 3 +- drivers/gpu/drm/amd/display/dmub/dmub_srv.h | 20 ++ .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 100 ++++++- .../gpu/drm/amd/display/dmub/src/dmub_srv.c | 27 ++ 22 files changed, 616 insertions(+), 99 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -2
@@ -9308,7 +9308,7 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream) &stream,1 , ¶ms); -return dc_link_set_psr_allow_active (link, true, false); +return dc_link_set_psr_allow_active (link, true, false, false); }/*
@@ -9322,7 +9322,7 @@ static bool amdgpu_dm_psr_disable(struct dc_stream_state *stream)DRM_DEBUG_DRIVER ("Disabling psr...\n" ); -return dc_link_set_psr_allow_active (stream->link, false, true); +return dc_link_set_psr_allow_active (stream->link, false, true, false); }/*
@@ -9355,3 +9355,15 @@ void amdgpu_dm_trigger_timing_sync(struct drm_device *dev) }mutex_unlock (&adev->dm.dc_lock); } + +bool dm_execute_dmub_cmd (const struct dc_context *ctx,union dmub_rb_cmd *cmd, +enum dm_dmub_wait_type wait_type) +{ +return dc_dmub_srv_cmd_run (ctx->dmub_srv, cmd, wait_type); +} + +bool dm_execute_dmub_cmd_list (const struct dc_context *ctx,unsigned int count, +union dmub_rb_cmd *cmd,enum dm_dmub_wait_type wait_type) +{ +return dc_dmub_srv_cmd_run_list (ctx->dmub_srv, count, cmd, wait_type); +}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +3 -3
@@ -2210,11 +2210,11 @@ static int psr_get(void *data, u64 *val) {struct amdgpu_dm_connector *connector = data;struct dc_link *link = connector->dc_link; -uint32_t psr_state =0 ; +enum dc_psr_state state =PSR_STATE0 ; -dc_link_get_psr_state (link, &psr_state); +dc_link_get_psr_state (link, &state); - *val = psr_state; + *val = state;return 0 ; }
drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c +3 -2
@@ -95,7 +95,7 @@ void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_mif (edp_link) { clk_mgr->psr_allow_active_cache = edp_link->psr_settings.psr_allow_active; -dc_link_set_psr_allow_active (edp_link, false, false); +dc_link_set_psr_allow_active (edp_link, false, false, false); } }
@@ -105,7 +105,8 @@ void clk_mgr_optimize_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr)struct dc_link *edp_link =get_edp_link (dc);if (edp_link) -dc_link_set_psr_allow_active (edp_link, clk_mgr->psr_allow_active_cache, false); +dc_link_set_psr_allow_active (edp_link, + clk_mgr->psr_allow_active_cache, false, false);if (dc->hwss.optimize_pwr_state) dc->hwss.optimize_pwr_state (dc, dc->current_state);
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -2
@@ -3052,9 +3052,9 @@ bool dc_set_psr_allow_active(struct dc *dc, bool enable)if (link->psr_settings.psr_feature_enabled) {if (enable && !link->psr_settings.psr_allow_active) -return dc_link_set_psr_allow_active (link, true, false); +return dc_link_set_psr_allow_active (link, true, false, false);else if (!enable && link->psr_settings.psr_allow_active) -return dc_link_set_psr_allow_active (link, false, true); +return dc_link_set_psr_allow_active (link, false, true, false); } }
drivers/gpu/drm/amd/display/dc/core/dc_link.c +13 -7
@@ -2584,17 +2584,24 @@ bool dc_link_set_backlight_level(const struct dc_link *link,return true; } -bool dc_link_set_psr_allow_active (struct dc_link *link,bool allow_active,bool wait) +bool dc_link_set_psr_allow_active (struct dc_link *link,bool allow_active, +bool wait,bool force_static) {struct dc *dc = link->ctx->dc;struct dmcu *dmcu = dc->res_pool->dmcu;struct dmub_psr *psr = dc->res_pool->psr; +if (psr ==NULL && force_static) +return false; + link->psr_settings.psr_allow_active = allow_active; -if (psr !=NULL && link->psr_settings.psr_feature_enabled) +if (psr !=NULL && link->psr_settings.psr_feature_enabled) { +if (force_static && psr->funcs->psr_force_static) + psr->funcs->psr_force_static (psr); psr->funcs->psr_enable (psr, allow_active, wait); -else if ((dmcu !=NULL && dmcu->funcs->is_dmcu_initialized (dmcu)) && link->psr_settings.psr_feature_enabled) + }else if ((dmcu !=NULL && dmcu->funcs->is_dmcu_initialized (dmcu)) && + link->psr_settings.psr_feature_enabled) dmcu->funcs->set_psr_enable (dmcu, allow_active, wait);else return false;
@@ -2602,16 +2609,16 @@ bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, boolreturn true; } -bool dc_link_get_psr_state (const struct dc_link *link,uint32_t *psr_state) +bool dc_link_get_psr_state (const struct dc_link *link,enum dc_psr_state *state) {struct dc *dc = link->ctx->dc;struct dmcu *dmcu = dc->res_pool->dmcu;struct dmub_psr *psr = dc->res_pool->psr;if (psr !=NULL && link->psr_settings.psr_feature_enabled) - psr->funcs->psr_get_state (psr, psr_state); + psr->funcs->psr_get_state (psr, state);else if (dmcu !=NULL && link->psr_settings.psr_feature_enabled) - dmcu->funcs->get_psr_state (dmcu, psr_state); + dmcu->funcs->get_psr_state (dmcu, state);return true; }
@@ -2674,7 +2681,6 @@ bool dc_link_setup_psr(struct dc_link *link,if (!dmcu && !psr)return false; -memset (&psr_configuration,0 ,sizeof (psr_configuration)); psr_configuration.bits.ENABLE =1 ;
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +2 -2
@@ -2570,8 +2570,8 @@ static bool handle_hpd_irq_psr_sink(struct dc_link *link) sizeof(psr_error_status.raw));/* PSR error, disable and re-enable PSR */ -dc_link_set_psr_allow_active (link, false, true); -dc_link_set_psr_allow_active (link, true, true); +dc_link_set_psr_allow_active (link, false, true, false); +dc_link_set_psr_allow_active (link, true, true, false);return true; } else if (psr_sink_psr_status.bits.SINK_SELF_REFRESH_STATUS ==
drivers/gpu/drm/amd/display/dc/dc.h +2 -2
@@ -504,6 +504,8 @@ struct dc_debug_options {bool disable_dsc;bool enable_dram_clock_change_one_display_vactive;bool force_ignore_link_settings; +unsigned int ips2_eval_delay_us; +unsigned int ips2_entry_delay_us; };struct dc_debug_data {
@@ -599,9 +601,7 @@ struct dc {/* Require to optimize clocks and bandwidth for added/removed planes */ bool optimized_required;bool wm_optimized_required; -#if defined(CONFIG_DRM_AMD_DC_DCN3_0 )bool idle_optimizations_allowed; -#endif /* Require to maintain clocks and bandwidth for UEFI enabled HW */ int optimize_seamless_boot_streams;
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c +259 -6
286 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h +31 -0
@@ -27,6 +27,7 @@#define _DMUB_DC_SRV_H_#include "os_types.h" +#include "dm_services_types.h" #include "dmub/dmub_srv.h" struct dmub_srv ;
@@ -45,6 +46,8 @@ struct dc_dmub_srv {struct dc_context *ctx;void *dm; + +bool idle_allowed; }; void dc_dmub_srv_cmd_queue(struct dc_dmub_srv *dc_dmub_srv,
@@ -56,6 +59,34 @@ void dc_dmub_srv_wait_idle(struct dc_dmub_srv *dc_dmub_srv);void dc_dmub_srv_wait_phy_init (struct dc_dmub_srv *dc_dmub_srv); +bool dc_dmub_srv_cmd_run (struct dc_dmub_srv *dc_dmub_srv,union dmub_rb_cmd *cmd, +enum dm_dmub_wait_type wait_type); + +bool dc_dmub_srv_cmd_run_list (struct dc_dmub_srv *dc_dmub_srv,unsigned int count, +union dmub_rb_cmd *cmd_list,enum dm_dmub_wait_type wait_type); +bool dc_dmub_srv_notify_stream_mask (struct dc_dmub_srv *dc_dmub_srv,unsigned int stream_mask); + +bool dc_wake_and_execute_dmub_cmd (const struct dc_context *ctx,union dmub_rb_cmd *cmd, +enum dm_dmub_wait_type wait_type); + +bool dc_wake_and_execute_dmub_cmd_list (const struct dc_context *ctx,unsigned int count, +union dmub_rb_cmd *cmd,enum dm_dmub_wait_type wait_type); + +void dc_dmub_srv_apply_idle_power_optimizations (const struct dc *dc,bool allow_idle); + +/** +* dc_wake_and_execute_gpint() +* +* @ctx: DC context +* @command_code: The command ID to send to DMCUB +* @param: The parameter to message DMCUB +* @response: Optional response out value - may be NULL. +* @wait_type: The wait behavior for the execution +*/ +bool dc_wake_and_execute_gpint (const struct dc_context *ctx,enum dmub_gpint_command command_code, +uint16_t param,uint32_t *response, +enum dm_dmub_wait_type wait_type); +#endif /* _DMUB_DC_SRV_H_ */
drivers/gpu/drm/amd/display/dc/dc_link.h +3 -2
@@ -219,9 +219,10 @@ int dc_link_get_backlight_level(const struct dc_link *dc_link);int dc_link_get_target_backlight_pwm (const struct dc_link *link); -bool dc_link_set_psr_allow_active (struct dc_link *dc_link,bool enable,bool wait); +bool dc_link_set_psr_allow_active (struct dc_link *dc_link,bool enable, +bool wait,bool force_static); -bool dc_link_get_psr_state (const struct dc_link *dc_link,uint32_t *psr_state); +bool dc_link_get_psr_state (const struct dc_link *dc_link,enum dc_psr_state *state); bool dc_link_setup_psr(struct dc_link *dc_link, const struct dc_stream_state *stream, struct psr_config *psr_config,
drivers/gpu/drm/amd/display/dc/dc_types.h +20 -0
@@ -674,6 +674,26 @@ struct dc_plane_flip_time {unsigned int prev_update_time_in_us; }; +enum dc_psr_state { +PSR_STATE0 =0x0 , +PSR_STATE1 , + PSR_STATE1a, +PSR_STATE2 , + PSR_STATE2a, +PSR_STATE3 , + PSR_STATE3Init, +PSR_STATE4 , + PSR_STATE4a, + PSR_STATE4b, + PSR_STATE4c, + PSR_STATE4d, +PSR_STATE5 , + PSR_STATE5a, + PSR_STATE5b, + PSR_STATE5c, +PSR_STATE_INVALID =0xFF +}; +struct psr_config {unsigned char psr_version;unsigned int psr_rfb_setup_time;
drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c +12 -12
@@ -99,7 +99,7 @@ bool dce_dmcu_load_iram(struct dmcu *dmcu,return true; } -static void dce_get_dmcu_psr_state (struct dmcu *dmcu,uint32_t *psr_state) +static void dce_get_dmcu_psr_state (struct dmcu *dmcu,enum dc_psr_state *state) {struct dce_dmcu *dmcu_dce =TO_DCE_DMCU (dmcu);
@@ -114,7 +114,7 @@ static void dce_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)REG_WRITE (DMCU_IRAM_RD_CTRL , psr_state_offset);/* Read data from IRAM_RD_DATA in DMCU_IRAM_RD_DATA*/ - *psr_state =REG_READ (DMCU_IRAM_RD_DATA ); + *state = (enum dc_psr_state )REG_READ (DMCU_IRAM_RD_DATA );/* Disable write access to IRAM after finished using IRAM * in order to allow dynamic sleep state
@@ -129,7 +129,7 @@ static void dce_dmcu_set_psr_enable(struct dmcu *dmcu, bool enable, bool wait)unsigned int dmcu_wait_reg_ready_interval =100 ;unsigned int retryCount; -uint32_t psr_state =0 ; +enum dc_psr_state state =PSR_STATE0 ;/* waitDMCUReadyForCmd */ REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0,
@@ -148,12 +148,12 @@ static void dce_dmcu_set_psr_enable(struct dmcu *dmcu, bool enable, bool wait)REG_UPDATE (MASTER_COMM_CNTL_REG ,MASTER_COMM_INTERRUPT ,1 );if (wait == true) {for (retryCount =0 ; retryCount <=100 ; retryCount++) { -dce_get_dmcu_psr_state (dmcu, &psr_state); +dce_get_dmcu_psr_state (dmcu, &state);if (enable) { -if (psr_state !=0 ) +if (state !=PSR_STATE0 )break ; }else { -if (psr_state ==0 ) +if (state ==PSR_STATE0 )break ; }udelay (10 );
@@ -513,7 +513,7 @@ static bool dcn10_dmcu_load_iram(struct dmcu *dmcu,return true; } -static void dcn10_get_dmcu_psr_state (struct dmcu *dmcu,uint32_t *psr_state) +static void dcn10_get_dmcu_psr_state (struct dmcu *dmcu,enum dc_psr_state *state) {struct dce_dmcu *dmcu_dce =TO_DCE_DMCU (dmcu);
@@ -532,7 +532,7 @@ static void dcn10_get_dmcu_psr_state(struct dmcu *dmcu, uint32_t *psr_state)REG_WRITE (DMCU_IRAM_RD_CTRL , psr_state_offset);/* Read data from IRAM_RD_DATA in DMCU_IRAM_RD_DATA*/ - *psr_state =REG_READ (DMCU_IRAM_RD_DATA ); + *state = (enum dc_psr_state )REG_READ (DMCU_IRAM_RD_DATA );/* Disable write access to IRAM after finished using IRAM * in order to allow dynamic sleep state
@@ -547,7 +547,7 @@ static void dcn10_dmcu_set_psr_enable(struct dmcu *dmcu, bool enable, bool wait)unsigned int dmcu_wait_reg_ready_interval =100 ;unsigned int retryCount; -uint32_t psr_state =0 ; +enum dc_psr_state state =PSR_STATE0 ;/* If microcontroller is not running, do nothing */ if (dmcu->dmcu_state !=DMCU_RUNNING )
@@ -575,12 +575,12 @@ static void dcn10_dmcu_set_psr_enable(struct dmcu *dmcu, bool enable, bool wait)*/ if (wait == true) {for (retryCount =0 ; retryCount <=1000 ; retryCount++) { -dcn10_get_dmcu_psr_state (dmcu, &psr_state); +dcn10_get_dmcu_psr_state (dmcu, &state);if (enable) { -if (psr_state !=0 ) +if (state !=PSR_STATE0 )break ; }else { -if (psr_state ==0 ) +if (state ==PSR_STATE0 )break ; }udelay (500 );
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c +91 -49
194 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h +2 -1
@@ -37,8 +37,9 @@ struct dmub_psr {struct dmub_psr_funcs {bool (*psr_copy_settings)(struct dmub_psr *dmub,struct dc_link *link,struct psr_context *psr_context);void (*psr_enable)(struct dmub_psr *dmub,bool enable,bool wait); -void (*psr_get_state)(struct dmub_psr *dmub,uint32_t *psr_state); +void (*psr_get_state)(struct dmub_psr *dmub,enum dc_psr_state *dc_psr_state);void (*psr_set_level)(struct dmub_psr *dmub,uint16_t psr_level); +void (*psr_force_static)(struct dmub_psr *dmub); };struct dmub_psr *dmub_psr_create (struct dc_context *ctx);
drivers/gpu/drm/amd/display/dc/dm_services.h +9 -0
@@ -42,6 +42,7 @@struct dmub_srv ;struct dc_dmub_srv ; +union dmub_rb_cmd ; irq_handler_idx dm_register_interrupt( struct dc_context *ctx,
@@ -294,6 +295,14 @@ unsigned long long dm_get_elapse_time_in_ns(struct dc_context *ctx, __CTX->perf_trace->write_count, &__CTX->perf_trace->last_entry_read,\ &__CTX->perf_trace->last_entry_write, __func__, __LINE__) +/* +* DMUB Interfaces +*/ +bool dm_execute_dmub_cmd (const struct dc_context *ctx,union dmub_rb_cmd *cmd, +enum dm_dmub_wait_type wait_type); + +bool dm_execute_dmub_cmd_list (const struct dc_context *ctx,unsigned int count, +union dmub_rb_cmd *cmd,enum dm_dmub_wait_type wait_type);/* * Debug and verification hooks
drivers/gpu/drm/amd/display/dc/dm_services_types.h +6 -0
@@ -269,4 +269,10 @@ struct dtn_min_clk_info { uint32_t min_memory_clock_khz; }; +enum dm_dmub_wait_type { +DM_DMUB_WAIT_TYPE_NO_WAIT , +DM_DMUB_WAIT_TYPE_WAIT , +DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY , +}; +#endif
drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr.h +1 -0
@@ -231,6 +231,7 @@ struct clk_mgr_funcs {int (*get_dp_ref_clk_frequency)(struct clk_mgr *clk_mgr);void (*set_low_power_state)(struct clk_mgr *clk_mgr); +void (*exit_low_power_state)(struct clk_mgr *clk_mgr);void (*init_clocks)(struct clk_mgr *clk_mgr);
drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h +1 -1
@@ -66,7 +66,7 @@ struct dmcu_funcs {bool (*setup_psr)(struct dmcu *dmcu,struct dc_link *link,struct psr_context *psr_context); -void (*get_psr_state)(struct dmcu *dmcu,uint32_t *psr_state); +void (*get_psr_state)(struct dmcu *dmcu,enum dc_psr_state *dc_psr_state);void (*set_psr_wait_loop)(struct dmcu *dmcu,unsigned int wait_loop_number); void (*get_psr_wait_loop)(struct dmcu *dmcu,
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +2 -1
@@ -213,7 +213,8 @@ struct hw_sequencer_funcs {/* Idle Optimization Related */ bool (*apply_idle_power_optimizations)(struct dc *dc,bool enable);#endif - +void (*set_idle_state)(const struct dc *dc,bool allow_idle); +uint32_t (*get_idle_state)(const struct dc *dc); }; void color_space_to_black_color(
drivers/gpu/drm/amd/display/dmub/dmub_srv.h +20 -0
@@ -264,6 +264,8 @@ struct dmub_srv_hw_funcs {bool (*is_hw_init)(struct dmub_srv *dmub); +bool (*is_hw_powered_up)(struct dmub_srv *dmub); +bool (*is_phy_init)(struct dmub_srv *dmub);bool (*is_auto_load_done)(struct dmub_srv *dmub);
@@ -486,6 +488,24 @@ enum dmub_status dmub_srv_cmd_queue(struct dmub_srv *dmub,*/ enum dmub_status dmub_srv_cmd_execute (struct dmub_srv *dmub); +/** +* dmub_srv_wait_for_hw_pwr_up() - Waits for firmware hardware power up is completed +* @dmub: the dmub service +* @timeout_us: the maximum number of microseconds to wait +* +* Waits until firmware hardware is powered up. The maximum +* wait time is given in microseconds to prevent spinning forever. +* +* Return: +* DMUB_STATUS_OK - success +* DMUB_STATUS_TIMEOUT - timed out +* DMUB_STATUS_INVALID - unspecified error +*/ +enum dmub_status dmub_srv_wait_for_hw_pwr_up (struct dmub_srv *dmub, +uint32_t timeout_us); + +bool dmub_srv_is_hw_pwr_up (struct dmub_srv *dmub); +/** * dmub_srv_wait_for_auto_load() - Waits for firmware auto load to complete * @dmub: the dmub service
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +93 -7
212 lines not on this page · raw message
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c +27 -0
@@ -516,6 +516,33 @@ enum dmub_status dmub_srv_cmd_execute(struct dmub_srv *dmub)return DMUB_STATUS_OK ; } +bool dmub_srv_is_hw_pwr_up (struct dmub_srv *dmub) +{ +if (!dmub->hw_funcs.is_hw_powered_up) +return true; + +return dmub->hw_funcs.is_hw_powered_up (dmub) && + dmub->hw_funcs.is_hw_init (dmub); +} + +enum dmub_status dmub_srv_wait_for_hw_pwr_up (struct dmub_srv *dmub, +uint32_t timeout_us) +{ +uint32_t i; + +if (!dmub->hw_init) +return DMUB_STATUS_INVALID ; + +for (i =0 ; i <= timeout_us; i +=100 ) { +if (dmub_srv_is_hw_pwr_up (dmub)) +return DMUB_STATUS_OK ; + +udelay (100 ); + } + +return DMUB_STATUS_TIMEOUT ; +} +enum dmub_status dmub_srv_wait_for_auto_load (struct dmub_srv *dmub,uint32_t timeout_us) {
Signature · 1 line
2.34.1
Quoted 59 lines · Zhu Wang
From: Nicholas Kazlauskas <[email protected]>
stable inclusion
from stable-v6.7.3
commit2ef98c6d753a7("drm/amd/display: Wake DMCUB before executing GPINT commands")
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9BV4C
CVE: CVE-2023-52624--------------------------------
[ Upstream commit
e5ffd1263dd5b("drm/amd/display: Wake DMCUB before executing GPINT commands") ][Why]
DMCUB can be in idle when we attempt to interface with the HW through the GPINT mailbox resulting in a system hang.[How]
Adddc_wake_and_execute_gpint()to wrap the wake, execute, sleep sequence.If the GPINT executes successfully then DMCUB will be put back into sleep after the optional response is returned.
It functions similar to the inbox command interface.
Cc Mario Limonciello <[email protected]>Cc Alex Deucher <[email protected]>Reviewed-by Hansen Dsouza <[email protected]>Acked-by Wayne Lin <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>Tested-by Daniel Wheeler <[email protected]>Signed-off-by Alex Deucher <[email protected]>This patch comes from following commits:
115c7e7f0501("drm/amd/display: Add psrget_statecall")1d496907f1c5("drm/amd/display: Engage PSR synchronously")34ba432c946d("drm/amd/display: [FW Promotion] Release 0.0.44")672251b223c1("drm/amd/display: [FW Promotion] Release 0.0.40")04f3c88f0955("drm/amd/display: Retry getting PSR state if command times out")b30eda8d416c("drm/amd/display: Add ETW log todmub_psr_get_state")f59a66c1915e("drm/amd/display: use do-while-0 forDC_TRACE_LEVEL_MESSAGE()")e97cc04fe0fb("drm/amd/display: refactor dmub commands into single function")522b9a5d5852("drm/amd/display: drain dmub inbox if queue is full")9dce8c2a5f1b("drm/amd/display: [FW Promotion] Release 0.0.161.0") 276641775848 ("drm/amd/display: [FW Promotion] Release 0.0.162.0")8774029f76b9("drm/amd/display: Add DCN35CLK_MGR")
65138eb72e1f("drm/amd/display: Add DCN35 DMUB")
dc01c4b79bfe("drm/amd/display: Update driver and IPS interop")5b7954272ae9("drm/amd/display: [FW Promotion] Release 0.0.183.0")da2d16fcdda3("drm/amd/display: Fix IPS handshake for idle optimizations")5e8a0d3598b4("drm/amd/display: Negate IPS allow and commit bits")820c3870c491("drm/amd/display: Refactor DMCUB enter/exit idle interface")2ef98c6d753a("drm/amd/display: Wake DMCUB before executing GPINT commands")
Quoted 1 line
Signed-off-by Zhu Wang <[email protected]>
I'm confused, what are we supposed to do with this?
greg k-h
Hi Greg, thanks for your reply. Since there is no patch to fix CVE-2023-52624 in linux-5.10, there is a patch in the linux-6.7 branch to fix it, its commit is 2ef98c6d753a744e333b7e34b9cf687040fba57d ("drm/amd/display: Wake DMCUB before executing GPINT commands"). When we apply this patch to linux-5.10, there are lots of conflicts, and we found there are lots of dependent patches, we do not apply all these patches since some are not meant to fix the cve, so we just get part of them, and for each patch we just get the part which is helpful to fix.
-----邮件原件-----
发件人: Greg KH [mailto:[email protected]]
发送时间: 2024年4月16日 12:49
收件人: wangzhu <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Konstantin Meskhidze (A) <[email protected]>; [email protected]; zhangjialin (F) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] 主题: Re: [PATCH v5.10] drm/amd/display: Wake DMCUB before executing GPINT commands
Quoted 65 lines · Zhu Wang
From: Nicholas Kazlauskas <[email protected]>
stable inclusion
from stable-v6.7.3
commit2ef98c6d753a7("drm/amd/display: Wake DMCUB before executing GPINT commands")
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9BV4C
CVE: CVE-2023-52624Reference:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/com
mit/?id=2ef98c6d753a744e333b7e34b9cf687040fba57d--------------------------------
[ Upstream commit
e5ffd1263dd5b("drm/amd/display: Wake DMCUB before executing GPINT commands") ][Why]
DMCUB can be in idle when we attempt to interface with the HW through the GPINT mailbox resulting in a system hang.[How]
Adddc_wake_and_execute_gpint()to wrap the wake, execute, sleep sequence.If the GPINT executes successfully then DMCUB will be put back into sleep after the optional response is returned.
It functions similar to the inbox command interface.
Cc Mario Limonciello <[email protected]>Cc Alex Deucher <[email protected]>Reviewed-by Hansen Dsouza <[email protected]>Acked-by Wayne Lin <[email protected]>Signed-off-by Nicholas Kazlauskas <[email protected]>Tested-by Daniel Wheeler <[email protected]>Signed-off-by Alex Deucher <[email protected]>This patch comes from following commits:
115c7e7f0501("drm/amd/display: Add psrget_statecall")1d496907f1c5("drm/amd/display: Engage PSR synchronously")34ba432c946d("drm/amd/display: [FW Promotion] Release 0.0.44")
672251b223c1("drm/amd/display: [FW Promotion] Release 0.0.40")04f3c88f0955("drm/amd/display: Retry getting PSR state if command
times out")b30eda8d416c("drm/amd/display: Add ETW log todmub_psr_get_state")f59a66c1915e("drm/amd/display: use do-while-0 forDC_TRACE_LEVEL_MESSAGE()")e97cc04fe0fb("drm/amd/display:
refactor dmub commands into single function")
522b9a5d5852("drm/amd/display: drain dmub inbox if queue is full")9dce8c2a5f1b("drm/amd/display: [FW Promotion] Release 0.0.161.0")
276641775848 ("drm/amd/display: [FW Promotion] Release 0.0.162.0")8774029f76b9("drm/amd/display: Add DCN35CLK_MGR")65138eb72e1f
("drm/amd/display: Add DCN35 DMUB")dc01c4b79bfe("drm/amd/display:
Update driver and IPS interop")
5b7954272ae9("drm/amd/display: [FW Promotion] Release 0.0.183.0")da2d16fcdda3("drm/amd/display: Fix IPS handshake for idle
optimizations")
5e8a0d3598b4("drm/amd/display: Negate IPS allow and commit bits")820c3870c491("drm/amd/display: Refactor DMCUB enter/exit idle
interface")2ef98c6d753a("drm/amd/display: Wake DMCUB before executing GPINT commands")
Quoted 1 line
Signed-off-by Zhu Wang <[email protected]>
I'm confused, what are we supposed to do with this?
greg k-h
Quoted 1 line · wangzhu
Hi Greg, thanks for your reply. Since there is no patch to fix CVE-2023-52624 in linux-5.10, there is a patch in the linux-6.7 branch to fix it, its commit is
2ef98c6d753a744e333b7e34b9cf687040fba57d("drm/amd/display: Wake DMCUB before executing GPINT commands"). When we apply this patch to linux-5.10, there are lots of conflicts, and we found there are lots of dependent patches, we do not apply all these patches since some are not meant to fix the cve, so we just get part of them, and for each patch we just get the part which is helpful to fix.
Why do you think that specific CVE is relevent to the 5.10.y kernel? And if so, what about the ones newer than that, as you know I can not take patches only for older kernels, that would leave newer branches vulnerable to the same bug.
So please submit fixes for all branches that you wish to see resolved at the same time.
thanks,
greg k-h