Revert "drm/imx: Remove of_node assignment from ipuv3-crtc driver probe"

Submitted by Fabio Estevam on May 17, 2016, 5:11 p.m.

Details

Message ID 1463505092-28018-1-git-send-email-fabio.estevam@nxp.com
State New
Headers show
Series "Revert "drm/imx: Remove of_node assignment from ipuv3-crtc driver probe"" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Fabio Estevam May 17, 2016, 5:11 p.m.
Commit 407c9eba789767 ("drm/imx: Remove of_node assignment from ipuv3-crtc
driver probe") causes the IPU to be non-functional, so better to 
revert it to avoid such regression.

This reverts commit 407c9eba789767feb68b42eb2d65db68584e06c0.

Cc: <stable@vger.kernel.org> # 4.4.x
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index dee8e8b..006753d 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -520,6 +520,28 @@  err_put_resources:
 	return ret;
 }
 
+static struct device_node *ipu_drm_get_port_by_id(struct device_node *parent,
+						  int port_id)
+{
+	struct device_node *port;
+	int id, ret;
+
+	port = of_get_child_by_name(parent, "port");
+	while (port) {
+		ret = of_property_read_u32(port, "reg", &id);
+		if (!ret && id == port_id)
+			return port;
+
+		do {
+			port = of_get_next_child(parent, port);
+			if (!port)
+				return NULL;
+		} while (of_node_cmp(port->name, "port"));
+	}
+
+	return NULL;
+}
+
 static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
 {
 	struct ipu_client_platformdata *pdata = dev->platform_data;
@@ -562,11 +584,23 @@  static const struct component_ops ipu_crtc_ops = {
 static int ipu_drm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct ipu_client_platformdata *pdata = dev->platform_data;
 	int ret;
 
 	if (!dev->platform_data)
 		return -EINVAL;
 
+	if (!dev->of_node) {
+		/* Associate crtc device with the corresponding DI port node */
+		dev->of_node = ipu_drm_get_port_by_id(dev->parent->of_node,
+						      pdata->di + 2);
+		if (!dev->of_node) {
+			dev_err(dev, "missing port@%d node in %s\n",
+				pdata->di + 2, dev->parent->of_node->full_name);
+			return -ENODEV;
+		}
+	}
+
 	ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
 	if (ret)
 		return ret;

Comments

Hi
On Wednesday, May 18, 2016 01:11 AM, Fabio Estevam wrote:
> Commit 407c9eba789767 ("drm/imx: Remove of_node assignment from ipuv3-crtc
> driver probe") causes the IPU to be non-functional, so better to
> revert it to avoid such regression.
>
> This reverts commit 407c9eba789767feb68b42eb2d65db68584e06c0.
>
> Cc: <stable@vger.kernel.org> # 4.4.x
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>

Revert patch tested with 4.6 - imx6d and imx6dl boards

[    2.292032] dwhdmi-imx 120000.hdmi: Detected HDMI controller 0x13:0xa:0xa0:0xc1
[    2.305742] imx-drm display-subsystem: bound 120000.hdmi (ops dw_hdmi_imx_ops)


Regards
Chris

> ---
>   drivers/gpu/drm/imx/ipuv3-crtc.c | 34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>
> diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
> index dee8e8b..006753d 100644
> --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
> +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
> @@ -520,6 +520,28 @@ err_put_resources:
>   	return ret;
>   }
>
> +static struct device_node *ipu_drm_get_port_by_id(struct device_node *parent,
> +						  int port_id)
> +{
> +	struct device_node *port;
> +	int id, ret;
> +
> +	port = of_get_child_by_name(parent, "port");
> +	while (port) {
> +		ret = of_property_read_u32(port, "reg", &id);
> +		if (!ret && id == port_id)
> +			return port;
> +
> +		do {
> +			port = of_get_next_child(parent, port);
> +			if (!port)
> +				return NULL;
> +		} while (of_node_cmp(port->name, "port"));
> +	}
> +
> +	return NULL;
> +}
> +
>   static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
>   {
>   	struct ipu_client_platformdata *pdata = dev->platform_data;
> @@ -562,11 +584,23 @@ static const struct component_ops ipu_crtc_ops = {
>   static int ipu_drm_probe(struct platform_device *pdev)
>   {
>   	struct device *dev = &pdev->dev;
> +	struct ipu_client_platformdata *pdata = dev->platform_data;
>   	int ret;
>
>   	if (!dev->platform_data)
>   		return -EINVAL;
>
> +	if (!dev->of_node) {
> +		/* Associate crtc device with the corresponding DI port node */
> +		dev->of_node = ipu_drm_get_port_by_id(dev->parent->of_node,
> +						      pdata->di + 2);
> +		if (!dev->of_node) {
> +			dev_err(dev, "missing port@%d node in %s\n",
> +				pdata->di + 2, dev->parent->of_node->full_name);
> +			return -ENODEV;
> +		}
> +	}
> +
>   	ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
>   	if (ret)
>   		return ret;
>
Hi Fabio, Chris,

Am Mittwoch, den 18.05.2016, 09:02 +0800 schrieb Chris Ruehl:
> Hi
> On Wednesday, May 18, 2016 01:11 AM, Fabio Estevam wrote:
> > Commit 407c9eba789767 ("drm/imx: Remove of_node assignment from ipuv3-crtc
> > driver probe") causes the IPU to be non-functional, so better to
> > revert it to avoid such regression.
> >
> > This reverts commit 407c9eba789767feb68b42eb2d65db68584e06c0.
> >
> > Cc: <stable@vger.kernel.org> # 4.4.x
> > Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> 
> Revert patch tested with 4.6 - imx6d and imx6dl boards
> 
> [    2.292032] dwhdmi-imx 120000.hdmi: Detected HDMI controller 0x13:0xa:0xa0:0xc1
> [    2.305742] imx-drm display-subsystem: bound 120000.hdmi (ops dw_hdmi_imx_ops)

Could you also test https://patchwork.kernel.org/patch/9081661/ ?

regards
Philipp
Hi Philipp,

On Wed, May 18, 2016 at 5:38 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:

> Could you also test https://patchwork.kernel.org/patch/9081661/ ?

With this patch applied I still do not get HDMI working on a mx6q sabresd board.

Thanks
Hi Fabio,

Am Mittwoch, den 18.05.2016, 07:51 -0300 schrieb Fabio Estevam:
> Hi Philipp,
> 
> On Wed, May 18, 2016 at 5:38 AM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> 
> > Could you also test https://patchwork.kernel.org/patch/9081661/ ?
> 
> With this patch applied I still do not get HDMI working on a mx6q sabresd board.

Thank you for testing. The reason HDMI still doesn't work is that the
ipuv3-crtcs get probed after dw_hdmi-imx, which then calls
drm_of_find_possible_crtcs() in its .bind function. That expects
crtc->port to point to the of_node, which is set by the call to
imx_drm_add_crtc(), still to the crtc devices' of_node instead of the
of_node in platform data. I'll send a new version.

regards
Philipp