All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Scally <djrscally@gmail.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	jorhand@linux.microsoft.com, andriy.shevchenko@linux.intel.com,
	Tsuchiya Yuto <kitakar@gmail.com>
Subject: Re: cio2 ipu3 module to automatically connect sensors via swnodes
Date: Sat, 12 Sep 2020 08:45:10 +0100	[thread overview]
Message-ID: <70b214fd-d199-ccb2-2a84-dc1f6f7c759f@gmail.com> (raw)
In-Reply-To: <20200909134053.GA3699980@kuha.fi.intel.com>

Hello Heikki

On 09/09/2020 14:40, Heikki Krogerus wrote:
> I'm almost certain that my graph patch is broken. My tests did not
> cover nearly as much that is needed to properly test the patch. I
> think at least the refcount handling is totally broken in
> software_node_graph_get_next_endpoint(), so that function at least
> needs to be rewritten.
>
> Unfortunately I do not have time to work on that patch right now.
>
> thanks,

I managed to get to the bottom of the remaining issue (which was the 
cause of the problem I originally posted here about - that's now all 
resolved).  In addition to the refcount handling problems, 
software_node_graph_get_next_endpoint() was occasionally passing an 
invalid combination of parameters to software_node_get_next_child(); 
sometimes it would pass an existing endpoint as old in combination with 
a port which was not the endpoint's parent. Applying this on top of your 
patch seems to stop both of those errors:

---
  drivers/base/swnode.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 5cf9f1eef96f..80255e0b7739 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -563,6 +563,7 @@ software_node_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  {
  	struct swnode *swnode = to_swnode(fwnode);
  	struct fwnode_handle *old = endpoint;
+	struct fwnode_handle *parent_of_old;
  	struct fwnode_handle *parent;
  	struct fwnode_handle *port;
  
@@ -581,10 +582,22 @@ software_node_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  	}
  
  	for (; port; port = swnode_graph_find_next_port(parent, port)) {
+
+		if (old) {
+			parent_of_old = software_node_get_parent(old);
+
+			if (parent_of_old != port)
+				old = NULL;
+
+			fwnode_handle_put(parent_of_old);
+		}
+
  		endpoint = software_node_get_next_child(port, old);
  		fwnode_handle_put(old);
  		if (endpoint)
  			break;
+		else
+			fwnode_handle_put(port);
  	}
  
  	fwnode_handle_put(port);
-- 
2.25.1

Following that change, everything seems to be working ok. The module linking sensors to the cio2 infrastructure can correctly link multiple sensors now, and the reference count issues that prevented that module from unloading are resolved too.

Getting those patches and the bridge module upstream would be a good step to getting working cameras on ACPI platforms using ipu3. I'd like to take that on if you haven't the time; would you be ok with me applying my changes on top of your original patch, and submitting the combined result as a v2? And then I'll tackle any changes that come back - might take me a little while but I should be able to manage it.

Thanks
Dan


  parent reply	other threads:[~2020-09-12  7:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-05  8:19 cio2 ipu3 module to automatically connect sensors via swnodes Daniel Scally
2020-09-07  9:44 ` Andy Shevchenko
2020-09-07 10:49   ` Kieran Bingham
2020-09-07 11:45     ` Dan Scally
2020-09-08  8:03 ` Sakari Ailus
2020-09-08  9:40   ` Dan Scally
2020-09-08 13:56     ` Andy Shevchenko
2020-09-09  9:29     ` Sakari Ailus
2020-09-09 13:40 ` Heikki Krogerus
2020-09-09 14:33   ` Dan Scally
2020-09-12  7:45   ` Dan Scally [this message]
2020-09-14 14:58     ` Andy Shevchenko
2020-09-14 15:08       ` Dan Scally

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=70b214fd-d199-ccb2-2a84-dc1f6f7c759f@gmail.com \
    --to=djrscally@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jorhand@linux.microsoft.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=kitakar@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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.