Skip to contentSkip to conversation

drm/amd/display: drop redundant memset() in get_available_dsc_slices()

PATCH In review Hamza Mahfooz 4 participants 8 messages May 17, 2023 – Aug 22, 2023

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

PATCH 1/3 drm/amd/display: drop redundant memset() in get_available_dsc_slices()

get_available_dsc_slices() returns the number of indices set, and all of the users of get_available_dsc_slices() don't cross the returned bound when iterating over available_slices[]. So, the memset() in get_available_dsc_slices() is redundant and can be dropped.

Fixes 97bda0322b8a ("drm/amd/display: Add DSC support for Navi (v2)")
---
 drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -2
index b9a05bb025db..58dd62cce4bb 100644
@@ -645,8 +645,6 @@ static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *av
 {
 	int idx = 0;
 
-	memset(available_slices, -1, MIN_AVAILABLE_SLICES_SIZE);
-
 	if (slice_caps.bits.NUM_SLICES_1)
 		available_slices[idx++] = 1;
 
Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/3 drm/amd/display: drop unused function set_abm_event()

set_abm_event() is never actually used. So, drop it.

Fixes b46c01aa0329 ("drm/amd/display: Refactor ABM feature")
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c | 12 ------------
 drivers/gpu/drm/amd/display/dc/inc/hw/abm.h   |  2 --
 2 files changed, 14 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c +0 -12
index a66f83a61402..2fb9572ce25d 100644
@@ -131,17 +131,6 @@ static bool dmub_abm_set_pipe_ex(struct abm *abm, uint32_t otg_inst, uint32_t op
 	return ret;
 }
 
-static bool dmub_abm_set_event_ex(struct abm *abm, unsigned int full_screen, unsigned int video_mode,
-		unsigned int hdr_mode, unsigned int panel_inst)
-{
-	bool ret = false;
-	unsigned int feature_support;
-
-	feature_support = abm_feature_support(abm, panel_inst);
-
-	return ret;
-}
-
 static bool dmub_abm_set_backlight_level_pwm_ex(struct abm *abm,
 		unsigned int backlight_pwm_u16_16,
 		unsigned int frame_ramp,
@@ -167,7 +156,6 @@ static const struct abm_funcs abm_funcs = {
 	.init_abm_config = dmub_abm_init_config_ex,
 	.set_abm_pause = dmub_abm_set_pause_ex,
 	.set_pipe_ex = dmub_abm_set_pipe_ex,
-	.set_abm_event = dmub_abm_set_event_ex,
 	.set_backlight_level_pwm = dmub_abm_set_backlight_level_pwm_ex,
 };
 
drivers/gpu/drm/amd/display/dc/inc/hw/abm.h +0 -2
index db5cf9acafe6..d2190a3320f6 100644
@@ -59,8 +59,6 @@ struct abm_funcs {
 			unsigned int otg_inst,
 			unsigned int option,
 			unsigned int panel_inst);
-	bool (*set_abm_event)(struct abm *abm, unsigned int full_screen, unsigned int video_mode,
-			unsigned int hdr_mode, unsigned int panel_inst);
 };
 
 #endif
Signature · 1 line
2.40.1
Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] drm/amd/display: drop unused function set_abm_event()

Quoted 46 lines · Hamza Mahfooz

set_abm_event() is never actually used. So, drop it.

Fixes b46c01aa0329 ("drm/amd/display: Refactor ABM feature")
---
  drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c | 12 ------------
  drivers/gpu/drm/amd/display/dc/inc/hw/abm.h   |  2 --
  2 files changed, 14 deletions(-)
drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c +0 -12
index a66f83a61402..2fb9572ce25d 100644
@@ -131,17 +131,6 @@ static bool dmub_abm_set_pipe_ex(struct abm *abm, uint32_t otg_inst, uint32_t op
  	return ret;
  }
 
-static bool dmub_abm_set_event_ex(struct abm *abm, unsigned int full_screen, unsigned int video_mode,
-		unsigned int hdr_mode, unsigned int panel_inst)
-{
-	bool ret = false;
-	unsigned int feature_support;
-
-	feature_support = abm_feature_support(abm, panel_inst);
-
-	return ret;
-}
-
  static bool dmub_abm_set_backlight_level_pwm_ex(struct abm *abm,
  		unsigned int backlight_pwm_u16_16,
  		unsigned int frame_ramp,
@@ -167,7 +156,6 @@ static const struct abm_funcs abm_funcs = {
  	.init_abm_config = dmub_abm_init_config_ex,
  	.set_abm_pause = dmub_abm_set_pause_ex,
  	.set_pipe_ex = dmub_abm_set_pipe_ex,
-	.set_abm_event = dmub_abm_set_event_ex,
  	.set_backlight_level_pwm = dmub_abm_set_backlight_level_pwm_ex,
  };
 
drivers/gpu/drm/amd/display/dc/inc/hw/abm.h +0 -0
index db5cf9acafe6..d2190a3320f6 100644

drivers/gpu/drm/amd/display/dc/inc/hw/abm.h struct abm_funcs { · line 64

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/inc/hw/abm.h +0 -2
@@ -59,8 +59,6 @@ struct abm_funcs {
  			unsigned int otg_inst,
  			unsigned int option,
  			unsigned int panel_inst);
-	bool (*set_abm_event)(struct abm *abm, unsigned int full_screen, unsigned int video_mode,
-			unsigned int hdr_mode, unsigned int panel_inst);
  };
 
  #endif
#3 lore raw

PATCH 3/3 drm/amd/display: drop unused count variable in create_eml_sink()

In reply to Hamza Mahfooz

Since, we are only interested in having drm_edid_override_connector_update(), update the value of connector->edid_blob_ptr. We don't care about the return value of drm_edid_override_connector_update() here. So, drop count.

Fixes 068553e14f86 ("drm/amd/display: assign edid_blob_ptr with edid from debugfs")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index 14b296e1d0f6..5a2d04f47276 100644
@@ -6396,9 +6396,8 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
 		/* if connector->edid_override valid, pass
 		 * it to edid_override to edid_blob_ptr
 		 */
-		int count;
 
-		count = drm_edid_override_connector_update(&aconnector->base);
+		drm_edid_override_connector_update(&aconnector->base);
 
 		if (!aconnector->base.edid_blob_ptr) {
 			DRM_ERROR("No EDID firmware found on connector: %s ,forcing to OFF!\n",
Signature · 1 line
2.40.1
Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] drm/amd/display: drop unused count variable in create_eml_sink()

Quoted 17 lines · Hamza Mahfooz

Since, we are only interested in having drm_edid_override_connector_update(), update the value of connector->edid_blob_ptr. We don't care about the return value of drm_edid_override_connector_update() here. So, drop count.

Fixes 068553e14f86 ("drm/amd/display: assign edid_blob_ptr with edid from debugfs")
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 14b296e1d0f6..5a2d04f47276 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void create_eml_sink(struct amdgpu_dm_connector *aconnector) · line 6403

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
@@ -6396,9 +6396,8 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
  		/* if connector->edid_override valid, pass
  		 * it to edid_override to edid_blob_ptr
  		 */
-		int count;
 
-		count = drm_edid_override_connector_update(&aconnector->base);
+		drm_edid_override_connector_update(&aconnector->base);
 
  		if (!aconnector->base.edid_blob_ptr) {
  			DRM_ERROR("No EDID firmware found on connector: %s ,forcing to OFF!\n",
#5 lore raw

Re: [PATCH 3/3] drm/amd/display: drop unused count variable in create_eml_sink()

In reply to Hamza Mahfooz
Quoted 6 lines · Hamza Mahfooz

Since, we are only interested in having drm_edid_override_connector_update(), update the value of connector->edid_blob_ptr. We don't care about the return value of drm_edid_override_connector_update() here. So, drop count.

Fixes 068553e14f86 ("drm/amd/display: assign edid_blob_ptr with edid from debugfs")

The *real* problems with that commit are:

1) It uses drm_edid_override_connector_update() *at all*. Its documentation says:

Only to be used from drm_helper_probe_single_connector_modes() as a fallback for when DDC probe failed during drm_get_edid() and caused the override/firmware EDID to be skipped.

2) It messes with edid_blob_ptr directly. All drivers should stop doing that. It just complicates all the logic in the overrides and the property updates.

BR,
Jani.

Quoted 21 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index 14b296e1d0f6..5a2d04f47276 100644
@@ -6396,9 +6396,8 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
 		/* if connector->edid_override valid, pass
 		 * it to edid_override to edid_blob_ptr
 		 */
-		int count;
 
-		count = drm_edid_override_connector_update(&aconnector->base);
+		drm_edid_override_connector_update(&aconnector->base);
 
 		if (!aconnector->base.edid_blob_ptr) {
 			DRM_ERROR("No EDID firmware found on connector: %s ,forcing to OFF!\n",
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Reviewed-by on v1 1/3
#6 lore raw
In reply to Hamza Mahfooz
Quoted 17 lines · Hamza Mahfooz

get_available_dsc_slices() returns the number of indices set, and all of the users of get_available_dsc_slices() don't cross the returned bound when iterating over available_slices[]. So, the memset() in get_available_dsc_slices() is redundant and can be dropped.

Fixes 97bda0322b8a ("drm/amd/display: Add DSC support for Navi (v2)")
---
  drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -0
index b9a05bb025db..58dd62cce4bb 100644

drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *av · line 650

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -2
@@ -645,8 +645,6 @@ static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *av
  {
  	int idx = 0;
 
-	memset(available_slices, -1, MIN_AVAILABLE_SLICES_SIZE);
-
  	if (slice_caps.bits.NUM_SLICES_1)
  		available_slices[idx++] = 1;
 
Reviewed-by on v1 1/3
#7 lore raw
In reply to Hamza Mahfooz

Le 17/05/2023 à 20:33, Hamza Mahfooz a écrit :

Quoted 17 lines

get_available_dsc_slices() returns the number of indices set, and all of the users of get_available_dsc_slices() don't cross the returned bound when iterating over available_slices[]. So, the memset() in get_available_dsc_slices() is redundant and can be dropped.

Fixes 97bda0322b8a ("drm/amd/display: Add DSC support for Navi (v2)")
---
  drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -0
index b9a05bb025db..58dd62cce4bb 100644

drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *av · line 650

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c +0 -2
@@ -645,8 +645,6 @@ static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int *av
  {
  	int idx = 0;
 
-	memset(available_slices, -1, MIN_AVAILABLE_SLICES_SIZE);
-
  	if (slice_caps.bits.NUM_SLICES_1)
  		available_slices[idx++] = 1;
 

Thanks for it, it went off my radar.

FWIW: