Skip to contentSkip to conversation

drm/amd/display: widen dc_hdmi_frl_flags.force_frl_rate to unsigned int

PATCH In review Aurabindo Pillai 2 participants 4 messages Jun 2

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amd/display: widen dc_hdmi_frl_flags.force_frl_rate to unsigned int

dc_hdmi_frl_flags.force_frl_rate mirrors dc_debug_options.force_frl_rate, which was just widened to unsigned int. Match the type here too so the assignment in link_hdmi_frl.c does not narrow from unsigned to signed.

All call sites in link_hdmi_frl.c only compare the value against 0, 0xF, or an hdmi_frl_link_rate enum whose values are non-negative, so the change is behaviour-preserving and does not introduce sign-compare warnings.

---
 drivers/gpu/drm/amd/display/dc/dc_hdmi_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc_hdmi_types.h +1 -1
index 0da03eb794aa..eb6e7f4043fd 100644
@@ -266,7 +266,7 @@ struct dc_hdmi_frl_link_settings {
 };
 
 struct dc_hdmi_frl_flags {
-	int  force_frl_rate;
+	unsigned int force_frl_rate;
 	bool ignore_ffe;
 	int  select_ffe;
 	int  limit_ffe;
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/2 drm/amd/display: use unsigned types for local pipe and REG_GET counters

Two small type fixes that match how the values are actually consumed:

- decide_zstate_support() iterates from 0 to pipe_count, which is unsigned. Make the loop index unsigned int.

- hpo_enc401_read_state() reads HDMI_PIXEL_ENCODING and HDMI_DEEP_COLOR_DEPTH via REG_GET_2(), which internally casts the output pointer to (uint32_t *). Passing the address of an int is a strict-aliasing wart even when the sizes match. Declare the locals as uint32_t.

No behavioural change since the values are only compared against small non-negative constants.

---
 drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c          | 2 +-
 .../amd/display/dc/hpo/dcn401/dcn401_hpo_frl_stream_encoder.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c +1 -1
index 5f088d113b9f..38c79239004c 100644
@@ -1060,7 +1060,7 @@ static bool is_dtbclk_required(struct dc *dc, struct dc_state *context)
 static enum dcn_zstate_support_state  decide_zstate_support(struct dc *dc, struct dc_state *context)
 {
 	int plane_count;
-	int i;
+	unsigned int i;
 
 	plane_count = 0;
 	for (i = 0; i < dc->res_pool->pipe_count; i++) {
drivers/gpu/drm/amd/display/dc/hpo/dcn401/dcn401_hpo_frl_stream_encoder.c +2 -2
index 28cb14dc87b0..85b7a44c0a11 100644
@@ -143,8 +143,8 @@ void hpo_enc401_read_state(
 	struct hpo_frl_stream_encoder *enc,
 	struct hpo_frl_stream_encoder_state *state)
 {
-	int pixel_encoding;
-	int color_depth;
+	uint32_t pixel_encoding;
+	uint32_t color_depth;
 //	int odm_combine;
 	struct dcn401_hpo_frl_stream_encoder *enc401 = DCN401_HPO_FRL_STRENC_FROM_HPO_FRL_STRENC(enc);
 
Signature · 1 line
2.54.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amd/display: use unsigned types for local pipe and REG_GET counters

Quoted 48 lines · Aurabindo Pillai

Two small type fixes that match how the values are actually consumed:

- decide_zstate_support() iterates from 0 to pipe_count, which is unsigned. Make the loop index unsigned int.

- hpo_enc401_read_state() reads HDMI_PIXEL_ENCODING and HDMI_DEEP_COLOR_DEPTH via REG_GET_2(), which internally casts the output pointer to (uint32_t *). Passing the address of an int is a strict-aliasing wart even when the sizes match. Declare the locals as uint32_t.

No behavioural change since the values are only compared against small non-negative constants.

---
  drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c          | 2 +-
  .../amd/display/dc/hpo/dcn401/dcn401_hpo_frl_stream_encoder.c | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c +1 -1
index 5f088d113b9f..38c79239004c 100644
@@ -1060,7 +1060,7 @@ static bool is_dtbclk_required(struct dc *dc, struct dc_state *context)
  static enum dcn_zstate_support_state  decide_zstate_support(struct dc *dc, struct dc_state *context)
  {
  	int plane_count;
-	int i;
+	unsigned int i;
 
  	plane_count = 0;
  	for (i = 0; i < dc->res_pool->pipe_count; i++) {
drivers/gpu/drm/amd/display/dc/hpo/dcn401/dcn401_hpo_frl_stream_encoder.c +2 -2
index 28cb14dc87b0..85b7a44c0a11 100644
@@ -143,8 +143,8 @@ void hpo_enc401_read_state(
  	struct hpo_frl_stream_encoder *enc,
  	struct hpo_frl_stream_encoder_state *state)
  {
-	int pixel_encoding;
-	int color_depth;
+	uint32_t pixel_encoding;
+	uint32_t color_depth;
  //	int odm_combine;
  	struct dcn401_hpo_frl_stream_encoder *enc401 = DCN401_HPO_FRL_STRENC_FROM_HPO_FRL_STRENC(enc);
 
Reviewed-by on v1 1/2
#3 lore raw
In reply to Aurabindo Pillai
Quoted 27 lines · Aurabindo Pillai

dc_hdmi_frl_flags.force_frl_rate mirrors dc_debug_options.force_frl_rate, which was just widened to unsigned int. Match the type here too so the assignment in link_hdmi_frl.c does not narrow from unsigned to signed.

All call sites in link_hdmi_frl.c only compare the value against 0, 0xF, or an hdmi_frl_link_rate enum whose values are non-negative, so the change is behaviour-preserving and does not introduce sign-compare warnings.

---
  drivers/gpu/drm/amd/display/dc/dc_hdmi_types.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc_hdmi_types.h +1 -1
index 0da03eb794aa..eb6e7f4043fd 100644
@@ -266,7 +266,7 @@ struct dc_hdmi_frl_link_settings {
  };
 
  struct dc_hdmi_frl_flags {
-	int  force_frl_rate;
+	unsigned int force_frl_rate;
  	bool ignore_ffe;
  	int  select_ffe;
  	int  limit_ffe;