[PATCH] drm: radeon: Fix audio get_eld callback

Alex Deucher alexdeucher at gmail.com
Thu Nov 10 15:51:15 UTC 2022


On Thu, Nov 10, 2022 at 8:09 AM Takashi Iwai <tiwai at suse.de> wrote:
>
> 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 at suse.de>
> ---
>
> Note: this is the additional fix on top of the previously submitted
> audio component support for radeon.

Applied.  Thanks.  I'll squash this in with the other patches.

Alex


>
>  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
>


More information about the amd-gfx mailing list