]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Fix type mismatches in DC and DMUB modules
authorGaghik Khachatrian <gaghik.khachatrian@amd.com>
Tue, 21 Apr 2026 18:58:16 +0000 (14:58 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 May 2026 13:56:52 +0000 (09:56 -0400)
[Why]
Address signed/unsigned comparison warnings across dc paths to keep
builds warning-clean and improve type safety at comparison boundaries.
Most warnings came from signed loop/index temporaries compared against
unsigned counters and table sizes, plus a smaller number of mixed
signed/unsigned clock, bandwidth, and geometry comparisons.

[How]
Aligned loop/index and bound types in the affected modules and DMUB
sources, including color, freesync, power, stats, and vmid paths.
Used unsigned iterators where bounds/counters are unsigned, preserved
signed types where negative values are meaningful, and updated related
format specifiers where type changes required it. Changes are limited to
warning resolution and type alignment.

No functional behavior change is intended.

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Gaghik Khachatrian <gaghik.khachatrian@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn401.c
drivers/gpu/drm/amd/display/dmub/src/dmub_dcn42.c
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
drivers/gpu/drm/amd/display/modules/power/power.c
drivers/gpu/drm/amd/display/modules/vmid/vmid.c

index e5a78df80d72ffb5ff0b0fe57c5539c18307334f..3444eb7d7d812d96cf15cac6b22b39467a48a6f4 100644 (file)
@@ -535,7 +535,7 @@ void dmub_dcn401_send_reg_inbox0_cmd_msg(struct dmub_srv *dmub,
                union dmub_rb_cmd *cmd)
 {
        uint32_t *dwords = (uint32_t *)cmd;
-       int32_t payload_size_bytes = cmd->cmd_common.header.payload_bytes;
+       uint32_t payload_size_bytes = cmd->cmd_common.header.payload_bytes;
        uint32_t msg_index;
        static_assert(sizeof(*cmd) == 64, "DMUB command size mismatch");
 
index a09aa19ad379632a4aa1dcaed2e91853e9180dde..e86fcfc7498566f7474da9024f173041781c4f5a 100644 (file)
@@ -429,7 +429,7 @@ void dmub_dcn42_send_reg_inbox0_cmd_msg(struct dmub_srv *dmub,
                union dmub_rb_cmd *cmd)
 {
        uint32_t *dwords = (uint32_t *)cmd;
-       int32_t payload_size_bytes = cmd->cmd_common.header.payload_bytes;
+       uint32_t payload_size_bytes = cmd->cmd_common.header.payload_bytes;
        uint32_t msg_index;
        static_assert(sizeof(*cmd) == 64, "DMUB command size mismatch");
 
index 1f225d0d6c44a00309bbff10a08450fa2ff3b0e2..beb97cbdad6e838a83dee0ca4a97c6258da099ce 100644 (file)
@@ -364,7 +364,7 @@ void precompute_pq(void)
 /* one-time pre-compute dePQ values - only for max pixel value 125 FP16 */
 void precompute_de_pq(void)
 {
-       int i;
+       uint32_t i;
        struct fixed31_32  y;
        uint32_t begin_index, end_index;
 
@@ -783,7 +783,7 @@ static struct fixed31_32 calculate_mapped_value(
        struct pwl_float_data *rgb,
        const struct pixel_gamma_point *coeff,
        enum channel_name channel,
-       uint32_t max_index)
+       int32_t max_index)
 {
        const struct gamma_point *point;
 
@@ -1425,7 +1425,7 @@ static void apply_lut_1d(
                uint32_t num_hw_points,
                struct dc_transfer_func_distributed_points *tf_pts)
 {
-       int i = 0;
+       uint32_t i = 0;
        int color = 0;
        struct fixed31_32 *regamma_y;
        struct fixed31_32 norm_y;
@@ -1569,7 +1569,7 @@ static bool calculate_interpolated_hardware_curve(
 {
 
        const struct pixel_gamma_point *coeff = coeff128;
-       uint32_t max_entries = 3 - 1;
+       int32_t max_entries = 3 - 1;
 
        uint32_t i = 0;
 
@@ -1581,7 +1581,7 @@ static bool calculate_interpolated_hardware_curve(
        }
 
        i = 0;
-       max_entries += ramp->num_entries;
+       max_entries += (int32_t)ramp->num_entries;
 
        /* TODO: float point case */
 
@@ -1635,7 +1635,7 @@ static bool map_regamma_hw_to_x_user(
 {
        /* setup to spare calculated ideal regamma values */
 
-       int i = 0;
+       uint32_t i = 0;
        struct hw_x_point *coords = coords_x;
        const struct pwl_float_data_ex *regamma = rgb_regamma;
 
index 5cef60079d67f23084b637663ace132621cb3563..1ee671119ddd066732da9f1537ead37d049c1889 100644 (file)
@@ -125,7 +125,7 @@ struct core_power {
        bool psr_smu_optimizations_support;
        bool multi_disp_optimizations_support;
 
-       int num_entities;
+       unsigned int num_entities;
 };
 
 union dmcu_abm_set_bl_params {
@@ -628,7 +628,7 @@ bool mod_power_hw_init(struct mod_power *mod_power)
        struct dc *dc = NULL;
        struct dmcu *dmcu = NULL;
        struct dmcu_iram_parameters params;
-       int i;
+       unsigned int i;
 
        if (mod_power == NULL)
                return false;
@@ -668,7 +668,7 @@ struct mod_power *mod_power_create(struct dc *dc,
 {
        struct core_power *core_power = NULL;
        int i = 0;
-       int abm_max_config = 0;
+       unsigned int abm_max_config = 0;
        unsigned int inst = 0;
        bool is_brightness_range_valid = false;
 
@@ -854,7 +854,7 @@ fail_dc_null:
 void mod_power_destroy(struct mod_power *mod_power)
 {
        if (mod_power != NULL) {
-               int i;
+               unsigned int i;
                struct core_power *core_power =
                                MOD_POWER_TO_CORE(mod_power);
 
@@ -903,7 +903,7 @@ bool mod_power_add_stream(struct mod_power *mod_power,
 
        DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR,
                                                WPP_BIT_FLAG_Firmware_PsrState,
-                                               "mod_power: add_stream: ERROR: stream=%p num_entities=%d >= MOD_POWER_MAX_CONCURRENT_STREAMS",
+                                               "mod_power: add_stream: ERROR: stream=%p num_entities=%u >= MOD_POWER_MAX_CONCURRENT_STREAMS",
                                                stream,
                                                core_power->num_entities);
 
@@ -913,7 +913,7 @@ bool mod_power_add_stream(struct mod_power *mod_power,
 bool mod_power_remove_stream(struct mod_power *mod_power,
                const struct dc_stream_state *stream)
 {
-       int i = 0;
+       unsigned int i = 0;
        struct core_power *core_power = NULL;
        unsigned int index = 0;
 
@@ -938,7 +938,7 @@ bool mod_power_remove_stream(struct mod_power *mod_power,
                BREAK_TO_DEBUGGER();
                DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR,
                                                        WPP_BIT_FLAG_Firmware_PsrState,
-                                                       "mod_power: remove_stream: ERROR: index=%u >= num_entities=%d stream=%p",
+                                                       "mod_power: remove_stream: ERROR: index=%u >= num_entities=%u stream=%p",
                                                        index,
                                                        core_power->num_entities,
                                                        stream);
@@ -1004,7 +1004,7 @@ bool mod_power_replace_stream(struct mod_power *mod_power,
                BREAK_TO_DEBUGGER();
                DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR,
                                                        WPP_BIT_FLAG_Firmware_PsrState,
-                                                       "mod_power: replace_stream: ERROR: index=%u >= num_entities=%d stream=%p",
+                                                       "mod_power: replace_stream: ERROR: index=%u >= num_entities=%u stream=%p",
                                                        index,
                                                        core_power->num_entities,
                                                        current_stream);
@@ -1432,7 +1432,7 @@ bool mod_power_get_hw_backlight_aux_nits(struct mod_power *mod_power,
 {
        struct core_power *core_power = NULL;
        struct dc_link *link = NULL;
-       unsigned int stream_index;
+       int stream_index;
 
        if (mod_power == NULL)
                return false;
@@ -1910,7 +1910,7 @@ static bool set_psr_enable(struct mod_power *mod_power,
        if (core_power->num_entities == 0) {
                DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR,
                                                        WPP_BIT_FLAG_Firmware_PsrState,
-                                                       "set psr enable: ERROR: stream=%p num_entities=%d",
+                                                       "set psr enable: ERROR: stream=%p num_entities=%u",
                                                        stream,
                                                        core_power->num_entities);
                return false;
@@ -2043,7 +2043,7 @@ bool mod_power_set_psr_event(struct mod_power *mod_power,
        if (core_power->num_entities == 0) {
                DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_ERROR,
                                                        WPP_BIT_FLAG_Firmware_PsrState,
-                                                       "mod_power set_psr_event: ERROR: stream=%p event=%d num_entities=%d",
+                                                       "mod_power set_psr_event: ERROR: stream=%p event=%d num_entities=%u",
                                                        stream,
                                                        (int)event,
                                                        core_power->num_entities);
index 179b505f7777cfb2c4247fb2c039b3ff4359b4c8..32617893ffb295a009acf0bbf2a2c851afbfbea3 100644 (file)
@@ -56,7 +56,7 @@ static void clear_entry_from_vmid_table(struct core_vmid *core_vmid, unsigned in
 
 static void evict_vmids(struct core_vmid *core_vmid)
 {
-       int i;
+       unsigned int i;
        int ord_int = dc_get_vmid_use_vector(core_vmid->dc);
 
        ASSERT(ord_int >= 0 && ord_int <= 0xFFFF);
@@ -72,7 +72,7 @@ static void evict_vmids(struct core_vmid *core_vmid)
 // Return value of -1 indicates vmid table uninitialized or ptb dne in the table
 static int get_existing_vmid_for_ptb(struct core_vmid *core_vmid, uint64_t ptb)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < core_vmid->num_vmid; i++) {
                if (core_vmid->ptb_assigned_to_vmid[i] == ptb)
@@ -85,7 +85,7 @@ static int get_existing_vmid_for_ptb(struct core_vmid *core_vmid, uint64_t ptb)
 // Expected to be called only when there's an available vmid
 static int get_next_available_vmid(struct core_vmid *core_vmid)
 {
-       int i;
+       unsigned int i;
 
        for (i = 1; i < core_vmid->num_vmid; i++) {
                if (core_vmid->ptb_assigned_to_vmid[i] == 0)