[Intel-gfx] [PATCH v3 01/20] drm/amdgpu: Add error handling to amdgpu_dm_initialize_dp_connector()

Deucher, Alexander Alexander.Deucher at amd.com
Wed Apr 21 15:22:09 UTC 2021


[AMD Official Use Only - Internal Distribution Only]

I'm fine with having these changes go through drm-misc.

Alex

________________________________
From: Lipski, Mikita <Mikita.Lipski at amd.com>
Sent: Wednesday, April 21, 2021 10:23 AM
To: Lyude Paul <lyude at redhat.com>; dri-devel at lists.freedesktop.org <dri-devel at lists.freedesktop.org>; intel-gfx at lists.freedesktop.org <intel-gfx at lists.freedesktop.org>; nouveau at lists.freedesktop.org <nouveau at lists.freedesktop.org>; amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>; Ville Syrjälä <ville.syrjala at linux.intel.com>; Jani Nikula <jani.nikula at linux.intel.com>; Rodrigo Vivi <rodrigo.vivi at intel.com>; Thomas Zimmermann <tzimmermann at suse.de>; Thierry Reding <thierry.reding at gmail.com>
Cc: Wang, Chao-kai (Stylon) <Stylon.Wang at amd.com>; Lipski, Mikita <Mikita.Lipski at amd.com>; Park, Chris <Chris.Park at amd.com>; Brol, Eryk <Eryk.Brol at amd.com>; Li, Sun peng (Leo) <Sunpeng.Li at amd.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha at amd.com>; Lin, Wayne <Wayne.Lin at amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira at amd.com>; open list <linux-kernel at vger.kernel.org>; Kazlauskas, Nicholas <Nicholas.Kazlauskas at amd.com>; Somasundaram, Meenakshikumar <Meenakshikumar.Somasundaram at amd.com>; David Airlie <airlied at linux.ie>; Pillai, Aurabindo <Aurabindo.Pillai at amd.com>; Daniel Vetter <daniel at ffwll.ch>; Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>; Deucher, Alexander <Alexander.Deucher at amd.com>; Cornij, Nikola <Nikola.Cornij at amd.com>; Wentland, Harry <Harry.Wentland at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>
Subject: Re: [PATCH v3 01/20] drm/amdgpu: Add error handling to amdgpu_dm_initialize_dp_connector()

Thanks for the change!

Reviewed-by: Mikita Lipski <Mikita.Lipski at amd.com>

On 2021-04-19 6:55 p.m., Lyude Paul wrote:
> While working on moving i2c device registration into drm_dp_aux_init() - I
> realized that in order to do so we need to make sure that drivers calling
> drm_dp_aux_init() handle any errors it could possibly return. In the
> process of doing that, I noticed that the majority of AMD's code for DP
> connector creation doesn't attempt to do any real error handling.
>
> So, let's fix this and also cleanup amdgpu_dm_initialize_dp_connector()
> while we're at it. This way we can handle the error codes from
> drm_dp_aux_init().
>
> Signed-off-by: Lyude Paul <lyude at redhat.com>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 29 +++++++-----
>   .../display/amdgpu_dm/amdgpu_dm_mst_types.c   | 44 +++++++++++--------
>   .../display/amdgpu_dm/amdgpu_dm_mst_types.h   |  6 +--
>   3 files changed, 45 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index a0c8c41e4e57..fc5d315bbb05 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -7608,10 +7608,9 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
>
>        aconnector->i2c = i2c;
>        res = i2c_add_adapter(&i2c->base);
> -
>        if (res) {
>                DRM_ERROR("Failed to register hw i2c %d\n", link->link_index);
> -             goto out_free;
> +             goto fail_free;
>        }
>
>        connector_type = to_drm_connector_type(link->connector_signal);
> @@ -7625,8 +7624,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
>
>        if (res) {
>                DRM_ERROR("connector_init failed\n");
> -             aconnector->connector_id = -1;
> -             goto out_free;
> +             goto fail_id;
>        }
>
>        drm_connector_helper_add(
> @@ -7643,15 +7641,22 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
>        drm_connector_attach_encoder(
>                &aconnector->base, &aencoder->base);
>
> -     if (connector_type == DRM_MODE_CONNECTOR_DisplayPort
> -             || connector_type == DRM_MODE_CONNECTOR_eDP)
> -             amdgpu_dm_initialize_dp_connector(dm, aconnector, link->link_index);
> -
> -out_free:
> -     if (res) {
> -             kfree(i2c);
> -             aconnector->i2c = NULL;
> +     if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
> +         connector_type == DRM_MODE_CONNECTOR_eDP) {
> +             res = amdgpu_dm_initialize_dp_connector(dm, aconnector, link->link_index);
> +             if (res)
> +                     goto fail_cleanup;
>        }
> +
> +     return 0;
> +fail_cleanup:
> +     drm_connector_cleanup(&aconnector->base);
> +fail_id:
> +     aconnector->connector_id = -1;
> +fail_free:
> +     kfree(i2c);
> +     aconnector->i2c = NULL;
> +
>        return res;
>   }
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> index 73cdb9fe981a..3dee9cce9c9e 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
> @@ -425,33 +425,39 @@ static const struct drm_dp_mst_topology_cbs dm_mst_cbs = {
>        .add_connector = dm_dp_add_mst_connector,
>   };
>
> -void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
> -                                    struct amdgpu_dm_connector *aconnector,
> -                                    int link_index)
> +int amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
> +                                   struct amdgpu_dm_connector *aconnector,
> +                                   int link_index)
>   {
> -     aconnector->dm_dp_aux.aux.name =
> -             kasprintf(GFP_KERNEL, "AMDGPU DM aux hw bus %d",
> -                       link_index);
> -     aconnector->dm_dp_aux.aux.transfer = dm_dp_aux_transfer;
> -     aconnector->dm_dp_aux.ddc_service = aconnector->dc_link->ddc;
> +     struct amdgpu_dm_dp_aux *dm_aux = &aconnector->dm_dp_aux;
> +     int ret;
>
> -     drm_dp_aux_init(&aconnector->dm_dp_aux.aux);
> -     drm_dp_cec_register_connector(&aconnector->dm_dp_aux.aux,
> -                                   &aconnector->base);
> +     dm_aux->aux.name = kasprintf(GFP_KERNEL, "AMDGPU DM aux hw bus %d", link_index);
> +     if (!dm_aux->aux.name)
> +             return -ENOMEM;
> +
> +     dm_aux->aux.transfer = dm_dp_aux_transfer;
> +     dm_aux->ddc_service = aconnector->dc_link->ddc;
> +
> +     drm_dp_aux_init(&dm_aux->aux);
> +     drm_dp_cec_register_connector(&dm_aux->aux, &aconnector->base);
>
>        if (aconnector->base.connector_type == DRM_MODE_CONNECTOR_eDP)
> -             return;
> +             return 0;
>
>        aconnector->mst_mgr.cbs = &dm_mst_cbs;
> -     drm_dp_mst_topology_mgr_init(
> -             &aconnector->mst_mgr,
> -             adev_to_drm(dm->adev),
> -             &aconnector->dm_dp_aux.aux,
> -             16,
> -             4,
> -             aconnector->connector_id);
> +     ret = drm_dp_mst_topology_mgr_init(&aconnector->mst_mgr, adev_to_drm(dm->adev),
> +                                        &dm_aux->aux, 16, 4, aconnector->connector_id);
> +     if (ret)
> +             goto unreg_cec;
>
>        drm_connector_attach_dp_subconnector_property(&aconnector->base);
> +
> +     return 0;
> +unreg_cec:
> +     drm_dp_cec_unregister_connector(&dm_aux->aux);
> +     kfree(dm_aux->aux.name);
> +     return ret;
>   }
>
>   int dm_mst_get_pbn_divider(struct dc_link *link)
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
> index b38bd68121ce..cf771ff58bb3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h
> @@ -31,9 +31,9 @@ struct amdgpu_dm_connector;
>
>   int dm_mst_get_pbn_divider(struct dc_link *link);
>
> -void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
> -                                    struct amdgpu_dm_connector *aconnector,
> -                                    int link_index);
> +int amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm,
> +                                   struct amdgpu_dm_connector *aconnector,
> +                                   int link_index);
>
>   void
>   dm_dp_create_fake_mst_encoders(struct amdgpu_device *adev);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20210421/d11fab1a/attachment-0001.htm>


More information about the Intel-gfx mailing list