drm/amd/display: use READ_ONCE() in psr_su_set_dsc_slice_height()
PATCH 1/1 drm/amd/display: use READ_ONCE() in psr_su_set_dsc_slice_height()
This code has two checks for if "stream->timing.dsc_cfg.num_slices_v" is zero so static checkers complain. The second check was added based on real life crashes so it suggests there is a race condition. Use READ_ONCE() to fix this more reliably.
In the original code we returns true for the first zero check and false for the second check. The caller doesn't care about returns so it doesn't matter whether we return true or false.
Fixes 21fc0ff38f57 ("drm/amd/display: fix a divided-by-zero error")
Signed-off-by Dan Carpenter <[email protected]>
---
Untested. Just reviewing static checker warnings. I wanted a chance to use READ_ONCE().
.../gpu/drm/amd/display/modules/power/power_psr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/modules/power/power_psr.c +7 -6
@@ -635,22 +635,23 @@ bool psr_su_set_dsc_slice_height(struct dc *dc, struct dc_link *link, {uint32_t pic_height;uint32_t slice_height; +uint32_t num_slices_v; config->dsc_slice_height =0 ;if (!(link->connector_signal &SIGNAL_TYPE_EDP ) || !dc->caps.edp_dsc_support || link->panel_config.dsc.disable_dsc_edp || - !link->dpcd_caps.dsc_caps.dsc_basic_caps.fields.dsc_support.DSC_SUPPORT || - !stream->timing.dsc_cfg.num_slices_v) + !link->dpcd_caps.dsc_caps.dsc_basic_caps.fields.dsc_support.DSC_SUPPORT)return true; + num_slices_v =READ_ONCE (stream->timing.dsc_cfg.num_slices_v); +if (!num_slices_v) +return false; + pic_height = stream->timing.v_addressable + stream->timing.v_border_top + stream->timing.v_border_bottom; -if (stream->timing.dsc_cfg.num_slices_v ==0 ) -return false; - - slice_height = pic_height / stream->timing.dsc_cfg.num_slices_v; + slice_height = pic_height / num_slices_v; config->dsc_slice_height = (uint16_t )slice_height;if (slice_height) {
Signature · 1 line
2.53.0