All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Kuogee Hsieh <quic_khsieh@quicinc.com>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Jagan Teki <jagan@amarulasolutions.com>
Subject: Re: [PATCH v3] drm: of: Properly try all possible cases for bridge/panel detection
Date: Thu, 31 Mar 2022 20:16:38 -0700	[thread overview]
Message-ID: <YkZulslrzeurp43U@ripper> (raw)
In-Reply-To: <20220329132732.628474-1-paul.kocialkowski@bootlin.com>

On Tue 29 Mar 06:27 PDT 2022, Paul Kocialkowski wrote:

> While bridge/panel detection was initially relying on the usual
> port/ports-based of graph detection, it was recently changed to
> perform the lookup on any child node that is not port/ports
> instead when such a node is available, with no fallback on the
> usual way.
> 
> This results in breaking detection when a child node is present
> but does not contain any panel or bridge node, even when the
> usual port/ports-based of graph is there.
> 
> In order to support both situations properly, this commit reworks
> the logic to try both options and not just one of the two: it will
> only return -EPROBE_DEFER when both have failed.
> 

Thanks for your patch Paul, it fixed a regression on a device where I
have a eDP bridge with an of_graph and a aux-bus defined.

But unfortunately it does not resolve the regression I have for the
USB based DisplayPort setup described below.


In the Qualcomm DisplayPort driver We're calling:

	devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);

and with the following DT snippet the behavior changed:

displayport-controller@ae90000 {
	compatible = "qcom,sc8180x-dp";
	...

	operating-points-v2 = <&dp0_opp_table>;

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dp0_in: endpoint {
				remote-endpoint = <&display_driver>;
			};
		};
	};

	dp0_opp_table: opp-table {
		...;
	};
};

Prior to the introduction of 80253168dbfd ("drm: of: Lookup if child
node has panel or bridge") this would return -ENODEV, so we could
differentiate the case when we have a statically defined eDP panel from
that of a dynamically attached (over USB) DP panel.

Prior to your change, above case without the opp-table node would have
still returned -ENODEV.

But now this will just return -EPROBE_DEFER in both cases.


I thought the appropriate method of referencing the dsi panel was to
actually reference that using the of_graph, even though it's a child of
the dsi controller - that's at least how we've done it in e.g. [1].
I find this to be much nicer than to just blindly define that all
children of any sort of display controller must be a bridge or a panel.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sdm845-mtp.dts#n436

Regards,
Bjorn

> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Fixes: 80253168dbfd ("drm: of: Lookup if child node has panel or bridge")
> ---
> 
> Changes since v2:
> - Removed unnecessary else statement and added a comment about
>   clearing the panel pointer on error.
> 
> Changes since v1:
> - Renamed remote to node;
> - Renamed helper to find_panel_or_bridge;
> - Cleared bridge pointer early;
> - Returned early to make the code more concise;
> 
> ---
>  drivers/gpu/drm/drm_of.c | 99 ++++++++++++++++++++--------------------
>  1 file changed, 50 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index 9d90cd75c457..8716da6369a6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -219,6 +219,29 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
>  }
>  EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
>  
> +static int find_panel_or_bridge(struct device_node *node,
> +				struct drm_panel **panel,
> +				struct drm_bridge **bridge)
> +{
> +	if (panel) {
> +		*panel = of_drm_find_panel(node);
> +		if (!IS_ERR(*panel))
> +			return 0;
> +
> +		/* Clear the panel pointer in case of error. */
> +		*panel = NULL;
> +	}
> +
> +	/* No panel found yet, check for a bridge next. */
> +	if (bridge) {
> +		*bridge = of_drm_find_bridge(node);
> +		if (*bridge)
> +			return 0;
> +	}
> +
> +	return -EPROBE_DEFER;
> +}
> +
>  /**
>   * drm_of_find_panel_or_bridge - return connected panel or bridge device
>   * @np: device tree node containing encoder output ports
> @@ -241,66 +264,44 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
>  				struct drm_panel **panel,
>  				struct drm_bridge **bridge)
>  {
> -	int ret = -EPROBE_DEFER;
> -	struct device_node *remote;
> +	struct device_node *node;
> +	int ret;
>  
>  	if (!panel && !bridge)
>  		return -EINVAL;
> +
>  	if (panel)
>  		*panel = NULL;
> -
> -	/**
> -	 * Devices can also be child nodes when we also control that device
> -	 * through the upstream device (ie, MIPI-DCS for a MIPI-DSI device).
> -	 *
> -	 * Lookup for a child node of the given parent that isn't either port
> -	 * or ports.
> -	 */
> -	for_each_available_child_of_node(np, remote) {
> -		if (of_node_name_eq(remote, "port") ||
> -		    of_node_name_eq(remote, "ports"))
> -			continue;
> -
> -		goto of_find_panel_or_bridge;
> +	if (bridge)
> +		*bridge = NULL;
> +
> +	/* Check for a graph on the device node first. */
> +	if (of_graph_is_present(np)) {
> +		node = of_graph_get_remote_node(np, port, endpoint);
> +		if (node) {
> +			ret = find_panel_or_bridge(node, panel, bridge);
> +			of_node_put(node);
> +
> +			if (!ret)
> +				return 0;
> +		}
>  	}
>  
> -	/*
> -	 * of_graph_get_remote_node() produces a noisy error message if port
> -	 * node isn't found and the absence of the port is a legit case here,
> -	 * so at first we silently check whether graph presents in the
> -	 * device-tree node.
> -	 */
> -	if (!of_graph_is_present(np))
> -		return -ENODEV;
> -
> -	remote = of_graph_get_remote_node(np, port, endpoint);
> -
> -of_find_panel_or_bridge:
> -	if (!remote)
> -		return -ENODEV;
> +	/* Otherwise check for any child node other than port/ports. */
> +	for_each_available_child_of_node(np, node) {
> +		if (of_node_name_eq(node, "port") ||
> +		    of_node_name_eq(node, "ports"))
> +			continue;
>  
> -	if (panel) {
> -		*panel = of_drm_find_panel(remote);
> -		if (!IS_ERR(*panel))
> -			ret = 0;
> -		else
> -			*panel = NULL;
> -	}
> -
> -	/* No panel found yet, check for a bridge next. */
> -	if (bridge) {
> -		if (ret) {
> -			*bridge = of_drm_find_bridge(remote);
> -			if (*bridge)
> -				ret = 0;
> -		} else {
> -			*bridge = NULL;
> -		}
> +		ret = find_panel_or_bridge(node, panel, bridge);
> +		of_node_put(node);
>  
> +		/* Stop at the first found occurrence. */
> +		if (!ret)
> +			return 0;
>  	}
>  
> -	of_node_put(remote);
> -	return ret;
> +	return -EPROBE_DEFER;
>  }
>  EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
>  
> -- 
> 2.35.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Kuogee Hsieh <quic_khsieh@quicinc.com>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Linus Walleij <linus.walleij@linaro.org>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v3] drm: of: Properly try all possible cases for bridge/panel detection
Date: Thu, 31 Mar 2022 20:16:38 -0700	[thread overview]
Message-ID: <YkZulslrzeurp43U@ripper> (raw)
In-Reply-To: <20220329132732.628474-1-paul.kocialkowski@bootlin.com>

On Tue 29 Mar 06:27 PDT 2022, Paul Kocialkowski wrote:

> While bridge/panel detection was initially relying on the usual
> port/ports-based of graph detection, it was recently changed to
> perform the lookup on any child node that is not port/ports
> instead when such a node is available, with no fallback on the
> usual way.
> 
> This results in breaking detection when a child node is present
> but does not contain any panel or bridge node, even when the
> usual port/ports-based of graph is there.
> 
> In order to support both situations properly, this commit reworks
> the logic to try both options and not just one of the two: it will
> only return -EPROBE_DEFER when both have failed.
> 

Thanks for your patch Paul, it fixed a regression on a device where I
have a eDP bridge with an of_graph and a aux-bus defined.

But unfortunately it does not resolve the regression I have for the
USB based DisplayPort setup described below.


In the Qualcomm DisplayPort driver We're calling:

	devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);

and with the following DT snippet the behavior changed:

displayport-controller@ae90000 {
	compatible = "qcom,sc8180x-dp";
	...

	operating-points-v2 = <&dp0_opp_table>;

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dp0_in: endpoint {
				remote-endpoint = <&display_driver>;
			};
		};
	};

	dp0_opp_table: opp-table {
		...;
	};
};

Prior to the introduction of 80253168dbfd ("drm: of: Lookup if child
node has panel or bridge") this would return -ENODEV, so we could
differentiate the case when we have a statically defined eDP panel from
that of a dynamically attached (over USB) DP panel.

Prior to your change, above case without the opp-table node would have
still returned -ENODEV.

But now this will just return -EPROBE_DEFER in both cases.


I thought the appropriate method of referencing the dsi panel was to
actually reference that using the of_graph, even though it's a child of
the dsi controller - that's at least how we've done it in e.g. [1].
I find this to be much nicer than to just blindly define that all
children of any sort of display controller must be a bridge or a panel.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sdm845-mtp.dts#n436

Regards,
Bjorn

> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Fixes: 80253168dbfd ("drm: of: Lookup if child node has panel or bridge")
> ---
> 
> Changes since v2:
> - Removed unnecessary else statement and added a comment about
>   clearing the panel pointer on error.
> 
> Changes since v1:
> - Renamed remote to node;
> - Renamed helper to find_panel_or_bridge;
> - Cleared bridge pointer early;
> - Returned early to make the code more concise;
> 
> ---
>  drivers/gpu/drm/drm_of.c | 99 ++++++++++++++++++++--------------------
>  1 file changed, 50 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index 9d90cd75c457..8716da6369a6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -219,6 +219,29 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
>  }
>  EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
>  
> +static int find_panel_or_bridge(struct device_node *node,
> +				struct drm_panel **panel,
> +				struct drm_bridge **bridge)
> +{
> +	if (panel) {
> +		*panel = of_drm_find_panel(node);
> +		if (!IS_ERR(*panel))
> +			return 0;
> +
> +		/* Clear the panel pointer in case of error. */
> +		*panel = NULL;
> +	}
> +
> +	/* No panel found yet, check for a bridge next. */
> +	if (bridge) {
> +		*bridge = of_drm_find_bridge(node);
> +		if (*bridge)
> +			return 0;
> +	}
> +
> +	return -EPROBE_DEFER;
> +}
> +
>  /**
>   * drm_of_find_panel_or_bridge - return connected panel or bridge device
>   * @np: device tree node containing encoder output ports
> @@ -241,66 +264,44 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,
>  				struct drm_panel **panel,
>  				struct drm_bridge **bridge)
>  {
> -	int ret = -EPROBE_DEFER;
> -	struct device_node *remote;
> +	struct device_node *node;
> +	int ret;
>  
>  	if (!panel && !bridge)
>  		return -EINVAL;
> +
>  	if (panel)
>  		*panel = NULL;
> -
> -	/**
> -	 * Devices can also be child nodes when we also control that device
> -	 * through the upstream device (ie, MIPI-DCS for a MIPI-DSI device).
> -	 *
> -	 * Lookup for a child node of the given parent that isn't either port
> -	 * or ports.
> -	 */
> -	for_each_available_child_of_node(np, remote) {
> -		if (of_node_name_eq(remote, "port") ||
> -		    of_node_name_eq(remote, "ports"))
> -			continue;
> -
> -		goto of_find_panel_or_bridge;
> +	if (bridge)
> +		*bridge = NULL;
> +
> +	/* Check for a graph on the device node first. */
> +	if (of_graph_is_present(np)) {
> +		node = of_graph_get_remote_node(np, port, endpoint);
> +		if (node) {
> +			ret = find_panel_or_bridge(node, panel, bridge);
> +			of_node_put(node);
> +
> +			if (!ret)
> +				return 0;
> +		}
>  	}
>  
> -	/*
> -	 * of_graph_get_remote_node() produces a noisy error message if port
> -	 * node isn't found and the absence of the port is a legit case here,
> -	 * so at first we silently check whether graph presents in the
> -	 * device-tree node.
> -	 */
> -	if (!of_graph_is_present(np))
> -		return -ENODEV;
> -
> -	remote = of_graph_get_remote_node(np, port, endpoint);
> -
> -of_find_panel_or_bridge:
> -	if (!remote)
> -		return -ENODEV;
> +	/* Otherwise check for any child node other than port/ports. */
> +	for_each_available_child_of_node(np, node) {
> +		if (of_node_name_eq(node, "port") ||
> +		    of_node_name_eq(node, "ports"))
> +			continue;
>  
> -	if (panel) {
> -		*panel = of_drm_find_panel(remote);
> -		if (!IS_ERR(*panel))
> -			ret = 0;
> -		else
> -			*panel = NULL;
> -	}
> -
> -	/* No panel found yet, check for a bridge next. */
> -	if (bridge) {
> -		if (ret) {
> -			*bridge = of_drm_find_bridge(remote);
> -			if (*bridge)
> -				ret = 0;
> -		} else {
> -			*bridge = NULL;
> -		}
> +		ret = find_panel_or_bridge(node, panel, bridge);
> +		of_node_put(node);
>  
> +		/* Stop at the first found occurrence. */
> +		if (!ret)
> +			return 0;
>  	}
>  
> -	of_node_put(remote);
> -	return ret;
> +	return -EPROBE_DEFER;
>  }
>  EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
>  
> -- 
> 2.35.1
> 

  parent reply	other threads:[~2022-04-01  3:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 13:27 [PATCH v3] drm: of: Properly try all possible cases for bridge/panel detection Paul Kocialkowski
2022-03-29 13:27 ` Paul Kocialkowski
2022-03-30  8:25 ` (subset) " Maxime Ripard
2022-03-30  8:25   ` Maxime Ripard
2022-04-01  3:16 ` Bjorn Andersson [this message]
2022-04-01  3:16   ` Bjorn Andersson
2022-04-01  7:44   ` Paul Kocialkowski
2022-04-01  7:44     ` Paul Kocialkowski
2022-04-03  3:38     ` Bjorn Andersson
2022-04-03  3:38       ` Bjorn Andersson
2022-04-05 17:00     ` Thierry Reding
2022-04-05 17:00       ` Thierry Reding
2022-04-06  8:30       ` Paul Kocialkowski
2022-04-06  8:30         ` Paul Kocialkowski
2022-04-20 20:51       ` Rob Clark
2022-04-20 20:51         ` Rob Clark
2022-04-05 21:21 ` Linus Walleij
2022-04-05 21:21   ` Linus Walleij
2022-04-16 22:21 ` Paul Cercueil
2022-04-16 22:21   ` Paul Cercueil
2022-04-19  9:56   ` Paul Kocialkowski
2022-04-19  9:56     ` Paul Kocialkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YkZulslrzeurp43U@ripper \
    --to=bjorn.andersson@linaro.org \
    --cc=airlied@linux.ie \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jagan@amarulasolutions.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=quic_khsieh@quicinc.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.