Subject: RE: [PATCH v8 1/4] drm/msm/dp: Add eDP support via aux_bus

Hi Doug,

>On Thu, Apr 21, 2022 at 7:37 AM Sankeerth Billakanti
><[email protected]> wrote:
>>
>> @@ -1530,6 +1532,61 @@ void msm_dp_debugfs_init(struct msm_dp
>*dp_display, struct drm_minor *minor)
>> }
>> }
>>
>> +static int dp_display_get_next_bridge(struct msm_dp *dp) {
>> + int rc;
>> + struct dp_display_private *dp_priv;
>> + struct device_node *aux_bus;
>> + struct device *dev;
>> +
>> + dp_priv = container_of(dp, struct dp_display_private, dp_display);
>> + dev = &dp_priv->pdev->dev;
>> + aux_bus = of_get_child_by_name(dev->of_node, "aux-bus");
>> +
>> + if (aux_bus && dp->is_edp) {
>> + dp_display_host_init(dp_priv);
>> + dp_catalog_ctrl_hpd_config(dp_priv->catalog);
>> + dp_display_host_phy_init(dp_priv);
>> + enable_irq(dp_priv->irq);
>> +
>> + rc = devm_of_dp_aux_populate_ep_devices(dp_priv->aux);
>
>I think a comment was requested above that line saying something like:
>
>/*
> * The code below assumes that the panel will finish probing
> * by the time devm_of_dp_aux_populate_ep_devices() returns.
> * This isn't a great assumption since it will fail if the
> * panel driver is probed asynchronously but is the best we
> * can do without a bigger driver reorganization.
> */
>
>

Will add the comment

>> + of_node_put(aux_bus);
>> + if (rc)
>> + goto edp_error;
>> + } else if (dp->is_edp) {
>> + DRM_ERROR("eDP aux_bus not found\n");
>> + rc = -ENODEV;
>> + goto error;
>
>This goto doesn't add much. Just leave the above like it was in v7.
>return -ENODEV w/ no goto.
>
>

Okay

>> + }
>> +
>> + /*
>> + * External bridges are mandatory for eDP interfaces: one has to
>> + * provide at least an eDP panel (which gets wrapped into panel-
>bridge).
>> + *
>> + * For DisplayPort interfaces external bridges are optional, so
>> + * silently ignore an error if one is not present (-ENODEV).
>> + */
>> + rc = dp_parser_find_next_bridge(dp_priv->parser);
>> + if (rc && dp->is_edp) {
>> + DRM_ERROR("eDP: cannot find the next bridge, rc = %d\n", rc);
>> + goto edp_error;
>> + } else if (rc && rc != -ENODEV) {
>> + DRM_ERROR("DP: cannot find the next bridge, rc = %d\n", rc);
>> + goto error;
>> + }
>
>The above wouldn't be my favorite way of doing this. Instead, I would have
>written:
>
> if (rc) {
> DRM_ERROR("Cannot find the next bridge, rc = %d\n", rc);
> goto err;
> }
> ...
>
>err:
> if (dp->is_edp) {
> disable_irq(...);
> dp_display_host_phy_exit(...);
> dp_display_host_deinit(...);
> }
> return rc;
>

If rc is ENODEV for DP, then we need to return 0. Shall I add like below ?

err:
if (dp->is_edp) {
disable_irq(...);
dp_display_host_phy_exit(...);
dp_display_host_deinit(...);
} else
If (rc == -ENODEV)
rc = 0;
return rc;

>> +
>> + dp->next_bridge = dp_priv->parser->next_bridge;
>> +
>> + return 0;
>> +
>> +edp_error:
>> + disable_irq(dp_priv->irq);
>> + dp_display_host_phy_exit(dp_priv);
>> + dp_display_host_deinit(dp_priv);
>> +error:
>> + return rc;
>> +}
>> +
>> int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device
>*dev,
>> struct drm_encoder *encoder) {
>
>With the above fixes, I'd be happy enough for my Reviewed-by tag with the
>expectation that continued work will happen to continue cleaning this up.
>
>
>-Doug


2022-04-22 21:51:08

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH v8 1/4] drm/msm/dp: Add eDP support via aux_bus

Hi,

On Thu, Apr 21, 2022 at 9:00 AM Sankeerth Billakanti (QUIC)
<[email protected]> wrote:
>
> >> + }
> >> +
> >> + /*
> >> + * External bridges are mandatory for eDP interfaces: one has to
> >> + * provide at least an eDP panel (which gets wrapped into panel-
> >bridge).
> >> + *
> >> + * For DisplayPort interfaces external bridges are optional, so
> >> + * silently ignore an error if one is not present (-ENODEV).
> >> + */
> >> + rc = dp_parser_find_next_bridge(dp_priv->parser);
> >> + if (rc && dp->is_edp) {
> >> + DRM_ERROR("eDP: cannot find the next bridge, rc = %d\n", rc);
> >> + goto edp_error;
> >> + } else if (rc && rc != -ENODEV) {
> >> + DRM_ERROR("DP: cannot find the next bridge, rc = %d\n", rc);
> >> + goto error;
> >> + }
> >
> >The above wouldn't be my favorite way of doing this. Instead, I would have
> >written:
> >
> > if (rc) {
> > DRM_ERROR("Cannot find the next bridge, rc = %d\n", rc);
> > goto err;
> > }
> > ...
> >
> >err:
> > if (dp->is_edp) {
> > disable_irq(...);
> > dp_display_host_phy_exit(...);
> > dp_display_host_deinit(...);
> > }
> > return rc;
> >
>
> If rc is ENODEV for DP, then we need to return 0. Shall I add like below ?
>
> err:
> if (dp->is_edp) {
> disable_irq(...);
> dp_display_host_phy_exit(...);
> dp_display_host_deinit(...);
> } else
> If (rc == -ENODEV)
> rc = 0;
> return rc;

I wouldn't. Then you're essentially going to "err" for a case that you
don't consider an error. I would instead have just handled it right
away.

rc = dp_parser_find_next_bridge(dp_priv->parser);
if (!dp->is_edp && rc == -ENODEV)
return 0;

This also is better IMO because it means you aren't assuming that
`dp_priv->parser->next_bridge` is "valid" (or at least NULL) after
dp_parser_find_next_bridge() returned an error.

-Doug