[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221110130925.26928-1-tiwai@suse.de>
Date: Thu, 10 Nov 2022 14:09:25 +0100
From: Takashi Iwai <tiwai@...e.de>
To: Alex Deucher <alexander.deucher@....com>
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] drm: radeon: Fix audio get_eld callback
Check the availability of the audio capability and mode config before
going to the loop for avoiding the access to an unusable state. Also,
change the loop iterations over encoder instead of connector in order
to align with radeon_audio_enable().
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2236
Signed-off-by: Takashi Iwai <tiwai@...e.de>
---
Note: this is the additional fix on top of the previously submitted
audio component support for radeon.
drivers/gpu/drm/radeon/radeon_audio.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c
index 71b67d4efe08..d6ccaf24ee0c 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -747,6 +747,7 @@ static int radeon_audio_component_get_eld(struct device *kdev, int port,
unsigned char *buf, int max_bytes)
{
struct drm_device *dev = dev_get_drvdata(kdev);
+ struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder;
struct radeon_encoder *radeon_encoder;
struct radeon_encoder_atom_dig *dig;
@@ -754,19 +755,19 @@ static int radeon_audio_component_get_eld(struct device *kdev, int port,
int ret = 0;
*enabled = false;
- list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
- const struct drm_connector_helper_funcs *connector_funcs =
- connector->helper_private;
- encoder = connector_funcs->best_encoder(connector);
+ if (!rdev->audio.enabled || !rdev->mode_info.mode_config_initialized)
+ return 0;
- if (!encoder)
- continue;
+ list_for_each_entry(encoder, &rdev->ddev->mode_config.encoder_list, head) {
if (!radeon_encoder_is_digital(encoder))
continue;
radeon_encoder = to_radeon_encoder(encoder);
dig = radeon_encoder->enc_priv;
if (!dig->pin || dig->pin->id != port)
continue;
+ connector = radeon_get_connector_for_encoder(encoder);
+ if (!connector)
+ continue;
*enabled = true;
ret = drm_eld_size(connector->eld);
memcpy(buf, connector->eld, min(max_bytes, ret));
--
2.35.3
Powered by blists - more mailing lists