[bug report] drm/amd/display: Find max flickerless instant vtotal delta

Dan Carpenter dan.carpenter at linaro.org
Fri May 24 10:32:07 UTC 2024


Hello Ethan Bitnun,

Commit bd051aa2fcfb ("drm/amd/display: Find max flickerless instant
vtotal delta") from Apr 1, 2024 (linux-next), leads to the following
Smatch static checker warning:

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:1006 dc_stream_get_max_flickerless_instant_vtotal_delta()
warn: always true condition '((stream->timing.v_total - safe_refresh_v_total) >= 0) => (0-u32max >= 0)'

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:1008 dc_stream_get_max_flickerless_instant_vtotal_delta()
warn: always true condition '((safe_refresh_v_total - stream->timing.v_total) >= 0) => (0-u32max >= 0)'

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c
    990 static unsigned int dc_stream_get_max_flickerless_instant_vtotal_delta(struct dc_stream_state *stream, bool is_gaming, bool increase)
    991 {
    992         if (stream->timing.v_total * stream->timing.h_total == 0)
    993                 return 0;
    994 
    995         int current_refresh_hz = (int)div64_s64((long long)stream->timing.pix_clk_100hz*100, stream->timing.v_total*stream->timing.h_total);
    996 
    997         int safe_refresh_hz = dc_stream_calculate_flickerless_refresh_rate(stream,
    998                                                          dc_stream_get_brightness_millinits_from_refresh(stream, current_refresh_hz),
    999                                                          current_refresh_hz,
    1000                                                          is_gaming,
    1001                                                          increase);
    1002 
    1003         int safe_refresh_v_total = (int)div64_s64((long long)stream->timing.pix_clk_100hz*100, safe_refresh_hz*stream->timing.h_total);
    1004 
    1005         if (increase)
--> 1006                 return ((stream->timing.v_total - safe_refresh_v_total) >= 0) ? (stream->timing.v_total - safe_refresh_v_total) : 0;
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
stream->timing.v_total is u32 so it makes the subtract u32 thus it's
always >= 0.

    1007 
    1008         return ((safe_refresh_v_total - stream->timing.v_total) >= 0) ? (safe_refresh_v_total - stream->timing.v_total) : 0;
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Same.

    1009 }

regards,
dan carpenter


More information about the amd-gfx mailing list