Skip to contentSkip to conversation

drm/edid: don't log errors on absent CEA SAD blocks

PATCH In review Jean Delvare 3 participants 8 messages Aug 30, 2019 – Sep 2, 2019

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

cover drm/edid: don't log errors on absent CEA SAD blocks

Hi all,

This is my attempt to fix bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

[PATCH 1/3] drm/amd: be quiet when no SAD block is found [PATCH 2/3] drm/radeon: be quiet when no SAD block is found [PATCH 3/3] drm/edid: no CEA extension is not an error

Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 1/3 drm/amd: be quiet when no SAD block is found

It is fine for displays without audio functionality to not provide any SAD block in their EDID. Do not log an error in that case, just return quietly.

This fixes half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc "David (ChunMing) Zhou" <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c                    |    4 ++--
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c                    |    4 ++--
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c                     |    4 ++--
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c                     |    4 ++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c |    7 +++----
 5 files changed, 11 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -2
@@ -1345,10 +1345,10 @@ static void dce_v10_0_audio_write_sad_re
 	}
 
 	sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), &sads);
-	if (sad_count <= 0) {
+	if (sad_count < 0)
 		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return;
-	}
 	BUG_ON(!sads);
 
 	for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -2
@@ -1371,10 +1371,10 @@ static void dce_v11_0_audio_write_sad_re
 	}
 
 	sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), &sads);
-	if (sad_count <= 0) {
+	if (sad_count < 0)
 		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return;
-	}
 	BUG_ON(!sads);
 
 	for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -2
@@ -1248,10 +1248,10 @@ static void dce_v6_0_audio_write_sad_reg
 	}
 
 	sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), &sads);
-	if (sad_count <= 0) {
+	if (sad_count < 0)
 		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return;
-	}
 
 	for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
 		u32 tmp = 0;
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -2
@@ -1298,10 +1298,10 @@ static void dce_v8_0_audio_write_sad_reg
 	}
 
 	sad_count = drm_edid_to_sad(amdgpu_connector_edid(connector), &sads);
-	if (sad_count <= 0) {
+	if (sad_count < 0)
 		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return;
-	}
 	BUG_ON(!sads);
 
 	for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +3 -4
@@ -98,11 +98,10 @@ enum dc_edid_status dm_helpers_parse_edi
 			(struct edid *) edid->raw_edid);
 
 	sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
-	if (sad_count <= 0) {
-		DRM_INFO("SADs count is: %d, don't need to read it\n",
-				sad_count);
+	if (sad_count < 0)
+		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return result;
-	}
 
 	edid_caps->audio_mode_count = sad_count < DC_MAX_AUDIO_DESC_COUNT ? sad_count : DC_MAX_AUDIO_DESC_COUNT;
 	for (i = 0; i < edid_caps->audio_mode_count; ++i) {
Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw

PATCH 2/3 drm/edid: don't log errors on absent CEA SAD blocks

In reply to Jean Delvare

It is fine for displays without audio functionality to not provide any SAD block in their EDID. Do not log an error in that case, just return quietly.

Inspired by a similar fix to the amdgpu driver in the context of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Cc "David (ChunMing) Zhou" <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/radeon/radeon_audio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_audio.c +2 -2
@@ -367,10 +367,10 @@ static void radeon_audio_write_sad_regs(
 		return;
 
 	sad_count = drm_edid_to_sad(radeon_connector_edid(connector), &sads);
-	if (sad_count <= 0) {
+	if (sad_count < 0)
 		DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
+	if (sad_count <= 0)
 		return;
-	}
 	BUG_ON(!sads);
 
 	if (radeon_encoder->audio && radeon_encoder->audio->write_sad_regs)
Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

Re: [PATCH 2/3] drm/radeon: be quiet when no SAD block is found

Oops, sorry, I messed up the subject line of that one, which should really read "drm/radeon: be quiet when no SAD block is found".

Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 3/3 drm/edid: no CEA extension is not an error

In reply to Jean Delvare

It is fine for displays without audio functionality to not implement CEA extension in their EDID. Do not return an error in that case, instead return 0 as if there was a CEA extension with no audio or speaker block.

This fixes half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_edid.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_edid.c +2 -2
@@ -4130,7 +4130,7 @@ int drm_edid_to_sad(struct edid *edid, s
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}
 
 	if (cea_revision(cea) < 3) {
@@ -4191,7 +4191,7 @@ int drm_edid_to_speaker_allocation(struc
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}
 
 	if (cea_revision(cea) < 3) {
Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 3/3
#5 lore raw

Re: [PATCH 3/3] drm/edid: no CEA extension is not an error

Quoted 21 lines · Jean Delvare

It is fine for displays without audio functionality to not implement CEA extension in their EDID. Do not return an error in that case, instead return 0 as if there was a CEA extension with no audio or speaker block.

This fixes half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_edid.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

drivers/gpu/drm/drm_edid.c int drm_edid_to_sad(struct edid *edid, s · line 4134

Quoted 6 lines
drivers/gpu/drm/drm_edid.c +1 -1
@@ -4130,7 +4130,7 @@ int drm_edid_to_sad(struct edid *edid, s
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}

Seems reasonable. Maybe the cea_revision<3 branches should alse return 0?

Either way

Quoted 19 lines
drivers/gpu/drm/drm_edid.c +1 -1
 	if (cea_revision(cea) < 3) {
@@ -4191,7 +4191,7 @@ int drm_edid_to_speaker_allocation(struc
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}
 
 	if (cea_revision(cea) < 3) {
Signature · 7 lines
-- 
Jean Delvare
SUSE L3 Support
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

Re: [PATCH 3/3] drm/edid: no CEA extension is not an error

Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Jean Delvare

It is fine for displays without audio functionality to not implement CEA extension in their EDID. Do not return an error in that case, instead return 0 as if there was a CEA extension with no audio or speaker block.

This fixes half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_edid.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines

drivers/gpu/drm/drm_edid.c int drm_edid_to_sad(struct edid *edid, s · line 4134

Quoted 9 lines
drivers/gpu/drm/drm_edid.c +1 -1
@@ -4130,7 +4130,7 @@ int drm_edid_to_sad(struct edid *edid, s
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}  

Seems reasonable. Maybe the cea_revision<3 branches should alse return 0?

I wasn't sure about that one, as I'm not familiar with this CEA extension thing.

If revision < 3 means the data is invalid then returning an error is fine. If on the other hand revision < 3 simply means that the block types we are looking for were not defined back then yes returning 0 instead would be better.

I'll do whatever developers more familiar with this topic think is better.

Quoted 2 lines

Either way

Thanks,

Signature · 6 lines
Jean Delvare
SUSE L3 Support
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [PATCH 3/3] drm/edid: no CEA extension is not an error

Quoted 32 lines · Jean Delvare
Quoted 19 lines · Ville Syrjälä
Quoted 18 lines · Jean Delvare

It is fine for displays without audio functionality to not implement CEA extension in their EDID. Do not return an error in that case, instead return 0 as if there was a CEA extension with no audio or speaker block.

This fixes half of bug fdo#107825:
https://bugs.freedesktop.org/show_bug.cgi?id=107825

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/drm_edid.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines

drivers/gpu/drm/drm_edid.c int drm_edid_to_sad(struct edid *edid, s · line 4134

Quoted 9 lines
drivers/gpu/drm/drm_edid.c +1 -1
@@ -4130,7 +4130,7 @@ int drm_edid_to_sad(struct edid *edid, s
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
 		DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
-		return -ENOENT;
+		return 0;
 	}  

Seems reasonable. Maybe the cea_revision<3 branches should alse return 0?

Quoted 7 lines

I wasn't sure about that one, as I'm not familiar with this CEA extension thing.

If revision < 3 means the data is invalid then returning an error is fine. If on the other hand revision < 3 simply means that the block types we are looking for were not defined back then yes returning 0 instead would be better.

That is indeed the case. A quick read through the code showed that we're not 100% consistent in checing for that though. I just send a few patches to fix that up.

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel