devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org,
	Philipp Zabel <philipp.zabel@gmail.com>,
	David Airlie <airlied@linux.ie>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	dri-devel@lists.freedesktop.org, kernel@pengutronix.de,
	Grant Likely <grant.likely@linaro.org>,
	Shawn Guo <shawn.guo@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 01/11] staging: imx-drm-core: Use OF graph to find components and connections between encoder and crtcs
Date: Wed, 05 Mar 2014 15:25:33 +0100	[thread overview]
Message-ID: <1394029533.8754.21.camel@paszta.hi.pengutronix.de> (raw)
In-Reply-To: <20140305100516.GV21483@n2100.arm.linux.org.uk>

Am Mittwoch, den 05.03.2014, 10:05 +0000 schrieb Russell King - ARM
Linux:
> On Wed, Mar 05, 2014 at 10:20:52AM +0100, Philipp Zabel wrote:
> > +struct imx_drm_component {
> > +	struct device_node *of_node;
> > +	struct list_head list;
> > +};
> > +
> 
> The only thing this structure appears to be doing is ensuring that a
> single component doesn't get added twice - is that correct? 

I also think of it as an optimization. Now we scan the whole device
graph once in the probe function into a list of needed components that
can be walked quickly every time master_ops' .add_components callback is
run, instead of having to walk the device tree graph over and over.

Functionally, it only protects against duplicate addition.

> If so, (and the troublesome problem with the IPU crtcs is now gone)
> we can modify the core component code such that it does this:
> 
>                 if (c->master && c->master != master)
>                         continue;
> 
>                 if (compare(c->dev, compare_data)) {
> 			if (!c->master)
> 	                        component_attach_master(master, c);
>                         ret = 0;
>                         break;
>                 }
> 
> which will mean that you don't need to build this list anymore to track
> what will be added - though I'd like to think a little more about that
> before making that change.  Please confirm whether this will eliminate
> your list generation.

Yes, I can confirm that with this change, I can remove the list, like
this (tested on i.MX6S with a single LVDS panel):

diff --git a/drivers/staging/imx-drm/imx-drm-core.c
b/drivers/staging/imx-drm/imx-drm-core.c
index 014e546..f6135b9 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -32,11 +32,6 @@
 
 struct imx_drm_crtc;
 
-struct imx_drm_component {
-	struct device_node *of_node;
-	struct list_head list;
-};
-
 struct imx_drm_device {
 	struct drm_device			*drm;
 	struct imx_drm_crtc			*crtc[MAX_CRTC];
@@ -587,72 +582,10 @@ static int compare_of(struct device *dev, void
*data)
 	return dev->of_node == np;
 }
 
-static LIST_HEAD(imx_drm_components);
-
 static int imx_drm_add_components(struct device *master, struct master
*m)
 {
-	struct imx_drm_component *component;
-	int ret;
-
-	list_for_each_entry(component, &imx_drm_components, list) {
-		ret = component_master_add_child(m, compare_of,
-						 component->of_node);
-		if (ret)
-			return ret;
-	}
-	return 0;
-}
-
-static int imx_drm_bind(struct device *dev)
-{
-	return drm_platform_init(&imx_drm_driver, to_platform_device(dev));
-}
-
-static void imx_drm_unbind(struct device *dev)
-{
-	drm_put_dev(dev_get_drvdata(dev));
-}
-
-static const struct component_master_ops imx_drm_ops = {
-	.add_components = imx_drm_add_components,
-	.bind = imx_drm_bind,
-	.unbind = imx_drm_unbind,
-};
-
-static struct imx_drm_component *imx_drm_find_component(struct device
*dev,
-		struct device_node *node)
-{
-	struct imx_drm_component *component;
-
-	list_for_each_entry(component, &imx_drm_components, list)
-		if (component->of_node == node)
-			return component;
-
-	return NULL;
-}
-
-static int imx_drm_add_component(struct device *dev, struct device_node
*node)
-{
-	struct imx_drm_component *component;
-
-	if (imx_drm_find_component(dev, node))
-		return 0;
-
-	component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
-	if (!component)
-		return -ENOMEM;
-
-	component->of_node = node;
-	list_add_tail(&component->list, &imx_drm_components);
-
-	return 0;
-}
-
-static int imx_drm_platform_probe(struct platform_device *pdev)
-{
 	struct device_node *ep, *port, *remote;
-	int ret;
-	int i;
+	int i, ret;
 
 	/*
 	 * Bind the IPU display interface ports first, so that
@@ -660,23 +593,18 @@ static int imx_drm_platform_probe(struct
platform_device *pdev)
 	 * works as expected.
 	 */
 	for (i = 0; ; i++) {
-		port = of_parse_phandle(pdev->dev.of_node, "ports", i);
+		port = of_parse_phandle(master->of_node, "ports", i);
 		if (!port)
 			break;
 
-		ret = imx_drm_add_component(&pdev->dev, port);
-		if (ret < 0)
+		ret = component_master_add_child(m, compare_of, port);
+		if (ret)
 			return ret;
 	}
 
-	if (i == 0) {
-		dev_err(&pdev->dev, "missing 'ports' property\n");
-		return -ENODEV;
-	}
-
 	/* Then bind all encoders */
 	for (i = 0; ; i++) {
-		port = of_parse_phandle(pdev->dev.of_node, "ports", i);
+		port = of_parse_phandle(master->of_node, "ports", i);
 		if (!port)
 			break;
 
@@ -687,14 +615,44 @@ static int imx_drm_platform_probe(struct
platform_device *pdev)
 				continue;
 			}
 
-			ret = imx_drm_add_component(&pdev->dev, remote);
+			ret = component_master_add_child(m, compare_of, remote);
 			of_node_put(remote);
-			if (ret < 0)
+			if (ret)
 				return ret;
 		}
 		of_node_put(port);
 	}
 
+	return 0;
+}
+
+static int imx_drm_bind(struct device *dev)
+{
+	return drm_platform_init(&imx_drm_driver, to_platform_device(dev));
+}
+
+static void imx_drm_unbind(struct device *dev)
+{
+	drm_put_dev(dev_get_drvdata(dev));
+}
+
+static const struct component_master_ops imx_drm_ops = {
+	.add_components = imx_drm_add_components,
+	.bind = imx_drm_bind,
+	.unbind = imx_drm_unbind,
+};
+
+static int imx_drm_platform_probe(struct platform_device *pdev)
+{
+	struct device_node *port;
+	int ret;
+
+	port = of_parse_phandle(pdev->dev.of_node, "ports", 0);
+	if (!port) {
+		dev_err(&pdev->dev, "missing 'ports' property\n");
+		return -ENODEV;
+	}
+
 	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
 	if (ret)
 		return ret;
-- 
1.9.0

regards
Philipp

  reply	other threads:[~2014-03-05 14:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  9:20 [PATCH v5 00/11] imx-drm dt bindings Philipp Zabel
2014-03-05  9:20 ` [PATCH v5 01/11] staging: imx-drm-core: Use OF graph to find components and connections between encoder and crtcs Philipp Zabel
2014-03-05 10:05   ` Russell King - ARM Linux
2014-03-05 14:25     ` Philipp Zabel [this message]
2014-03-05  9:20 ` [PATCH v5 02/11] staging: imx-drm-core: use of_graph_parse_endpoint Philipp Zabel
2014-03-05  9:20 ` [PATCH v5 03/11] staging: imx-drm: Document updated imx-drm device tree bindings Philipp Zabel
2014-03-05  9:20 ` [PATCH v5 04/11] staging: imx-drm: Document imx-hdmi " Philipp Zabel
2014-03-05  9:20 ` [PATCH v5 05/11] imx-drm: imx-hdmi: Fix DDC I2C bus property Philipp Zabel
     [not found] ` <1394011262-16849-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-03-05  9:20   ` [PATCH v5 06/11] imx-drm: imx-tve: " Philipp Zabel
2014-03-06 13:03     ` Russell King - ARM Linux
2014-03-06 13:32       ` Philipp Zabel
2014-03-05  9:21   ` [PATCH v5 09/11] ARM: dts: imx53: Add IPU DI ports and endpoints, move imx-drm node to dtsi Philipp Zabel
2014-03-11  3:46   ` [PATCH v5 00/11] imx-drm dt bindings Shawn Guo
2014-03-11 11:42     ` Philipp Zabel
2014-03-11 13:27       ` Shawn Guo
2014-03-11 13:34         ` Lucas Stach
     [not found]           ` <1394544878.4339.7.camel-WzVe3FnzCwFR6QfukMTsflXZhhPuCNm+@public.gmane.org>
2014-03-11 14:14             ` Shawn Guo
     [not found]     ` <20140311034607.GA26502-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2014-04-07  4:23       ` Shawn Guo
2014-04-07  9:09         ` Russell King - ARM Linux
2014-04-07 13:40           ` Shawn Guo
2014-04-07 10:05         ` Philipp Zabel
2014-04-07 12:34           ` Philipp Zabel
2014-04-07 13:43           ` Shawn Guo
2014-03-05  9:20 ` [PATCH v5 07/11] ARM: dts: imx53-mba53: Fix TVE DDC I2C bus property Philipp Zabel
2014-03-05  9:20 ` [PATCH v5 08/11] ARM: dts: imx51: Add IPU ports and endpoints, move imx-drm node to dtsi Philipp Zabel
2014-03-05  9:21 ` [PATCH v5 10/11] ARM: dts: imx6qdl: Add IPU DI " Philipp Zabel
2014-03-05  9:21 ` [PATCH v5 11/11] staging: imx-drm: Update TODO Philipp Zabel
2014-03-07 17:56 ` [PATCH v5 00/11] imx-drm dt bindings Russell King - ARM Linux
2014-03-07 18:28   ` Greg Kroah-Hartman
2014-03-07 18:57     ` Philipp Zabel
2014-03-07 19:17       ` Russell King - ARM Linux

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=1394029533.8754.21.camel@paszta.hi.pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=airlied@linux.ie \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@arm.linux.org.uk \
    --cc=philipp.zabel@gmail.com \
    --cc=shawn.guo@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).