Skip to contentSkip to conversation

v4l2-async: Match parent devices

PATCH In review Kieran Bingham 4 participants 5 messages Dec 6, 2017 – Dec 7, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 v4l2-async: Match parent devices

From: Kieran Bingham <[email protected]>

Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes first, but to also perform a cross reference comparison against the parent fwnodes of each other.

This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node.

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the changes on the of_node_full_name() functionality.

I believe it is correct now to *just* do the pointer matching, as that matches the current implementation, and converting to device_nodes will be just as equal as the fwnodes, as they are simply containers.

Let me know if you are happy to maintain your SOB on this patch - and if we need to work towards getting this integrated upstream, especially in light of your new endpoint matching work.

--
Regards

Kieran

v2:
- Added documentation comments
- simplified the OF match by adding match_fwnode_of()

v3:
- Fix comments
- Fix sd_parent, and asd_parent usage

v4:
- Clean up and simplify match_fwnode and comparisons

v5:
- Updated for v4.15-rc1:
of_node no longer specifies a full path, and only returns the basename with of_node_full_name(), thus this ends up matching "endpoint" for all endpoints. Fall back to pointer matching, whilst maintaining the parent comparisons.

---
 drivers/media/v4l2-core/v4l2-async.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-async.c +16 -1
index fcadad305336..780bda70d8b3 100644
@@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
 	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
 }
 
+/*
+ * As a measure to support drivers which have not been converted to use
+ * endpoint matching, we also find the parent devices for cross-matching.
+ *
+ * This also allows continued support for matching subdevices which will not
+ * have an endpoint themselves.
+ */
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
+	struct fwnode_handle *sd_parent, *asd_parent;
+
+	sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
+	asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
+
+	return sd->fwnode == asd_fwnode ||
+	       sd->fwnode == asd_parent ||
+	       sd_parent == asd_fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
Signature · 1 line
2.7.4
#1 lore raw

Hi Kieran,

Quoted 9 lines · Kieran Bingham

From: Kieran Bingham <[email protected]>

Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes first, but to also perform a cross reference comparison against the parent fwnodes of each other.

Quoted 6 lines

This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node.

please append:

Thanks
j

Quoted 76 lines

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the changes on the of_node_full_name() functionality.

I believe it is correct now to *just* do the pointer matching, as that matches the current implementation, and converting to device_nodes will be just as equal as the fwnodes, as they are simply containers.

Let me know if you are happy to maintain your SOB on this patch - and if we need to work towards getting this integrated upstream, especially in light of your new endpoint matching work.

--
Regards

Kieran

v2:
- Added documentation comments
- simplified the OF match by adding match_fwnode_of()

v3:
- Fix comments
- Fix sd_parent, and asd_parent usage

v4:
- Clean up and simplify match_fwnode and comparisons

v5:
- Updated for v4.15-rc1:
of_node no longer specifies a full path, and only returns the basename with of_node_full_name(), thus this ends up matching "endpoint" for all endpoints. Fall back to pointer matching, whilst maintaining the parent comparisons.

---
 drivers/media/v4l2-core/v4l2-async.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-async.c +16 -2
index fcadad305336..780bda70d8b3 100644
@@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
 	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
 }
 
+/*
+ * As a measure to support drivers which have not been converted to use
+ * endpoint matching, we also find the parent devices for cross-matching.
+ *
+ * This also allows continued support for matching subdevices which will not
+ * have an endpoint themselves.
+ */
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
+	struct fwnode_handle *sd_parent, *asd_parent;
+
+	sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
+	asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
+
+	return sd->fwnode == asd_fwnode ||
+	       sd->fwnode == asd_parent ||
+	       sd_parent == asd_fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
--

2.7.4

#2 lore raw

Hi Jacopo,

Quoted 16 lines · jacopo mondi

Hi Kieran,

Quoted 13 lines · Kieran Bingham

From: Kieran Bingham <[email protected]>

Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes first, but to also perform a cross reference comparison against the parent fwnodes of each other.

This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node.

Quoted 6 lines
Quoted 2 lines

please append:

Ahh yes of course!

Quoted 79 lines

Thanks
j

Quoted 76 lines

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the changes on the of_node_full_name() functionality.

I believe it is correct now to *just* do the pointer matching, as that matches the current implementation, and converting to device_nodes will be just as equal as the fwnodes, as they are simply containers.

Let me know if you are happy to maintain your SOB on this patch - and if we need to work towards getting this integrated upstream, especially in light of your new endpoint matching work.

--
Regards

Kieran

v2:
- Added documentation comments
- simplified the OF match by adding match_fwnode_of()

v3:
- Fix comments
- Fix sd_parent, and asd_parent usage

v4:
- Clean up and simplify match_fwnode and comparisons

v5:
- Updated for v4.15-rc1:
of_node no longer specifies a full path, and only returns the basename with of_node_full_name(), thus this ends up matching "endpoint" for all endpoints. Fall back to pointer matching, whilst maintaining the parent comparisons.

---
 drivers/media/v4l2-core/v4l2-async.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-async.c +16 -2
index fcadad305336..780bda70d8b3 100644
@@ -71,9 +71,24 @@ static bool match_devname(struct v4l2_subdev *sd,
 	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
 }
 
+/*
+ * As a measure to support drivers which have not been converted to use
+ * endpoint matching, we also find the parent devices for cross-matching.
+ *
+ * This also allows continued support for matching subdevices which will not
+ * have an endpoint themselves.
+ */
 static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-	return sd->fwnode == asd->match.fwnode.fwnode;
+	struct fwnode_handle *asd_fwnode = asd->match.fwnode.fwnode;
+	struct fwnode_handle *sd_parent, *asd_parent;
+
+	sd_parent = fwnode_graph_get_port_parent(sd->fwnode);
+	asd_parent = fwnode_graph_get_port_parent(asd_fwnode);
+
+	return sd->fwnode == asd_fwnode ||
+	       sd->fwnode == asd_parent ||
+	       sd_parent == asd_fwnode;
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
--

2.7.4

maintainer
#3 lore raw
In reply to Kieran Bingham
Quoted 23 lines · Kieran Bingham

From: Kieran Bingham <[email protected]>

Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes first, but to also perform a cross reference comparison against the parent fwnodes of each other.

This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node.

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the changes on the of_node_full_name() functionality.

Quoted 7 lines

I believe it is correct now to *just* do the pointer matching, as that matches the current implementation, and converting to device_nodes will be just as equal as the fwnodes, as they are simply containers.

Let me know if you are happy to maintain your SOB on this patch - and if we need to work towards getting this integrated upstream, especially in light of your new endpoint matching work.

I'd really want to avoid resorting to matching opportunistically --- please see my reply to Niklas on "[RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match".

Signature · 4 lines
Regards,

Sakari Ailus
[email protected]
#4 lore raw

Hi Sakari,

Quoted 28 lines · Sakari Ailus
Quoted 27 lines · Kieran Bingham

From: Kieran Bingham <[email protected]>

Devices supporting multiple endpoints on a single device node must set their subdevice fwnode to the endpoint to allow distinct comparisons.

Adapt the match_fwnode call to compare against the provided fwnodes first, but to also perform a cross reference comparison against the parent fwnodes of each other.

This allows notifiers to pass the endpoint for comparison and still support existing subdevices which store their default parent device node.

---

Hi Sakari,

Since you signed-off on this patch - it has had to be reworked due to the changes on the of_node_full_name() functionality.

I believe it is correct now to *just* do the pointer matching, as that matches the current implementation, and converting to device_nodes will be just as equal as the fwnodes, as they are simply containers.

Quoted 7 lines
Quoted 3 lines

Let me know if you are happy to maintain your SOB on this patch - and if we need to work towards getting this integrated upstream, especially in light of your new endpoint matching work.

I'd really want to avoid resorting to matching opportunistically --- please see my reply to Niklas on "[RFC 1/1] v4l: async: Use endpoint node, not device node, for fwnode match".

I agree here ... This patch is a workaround to support non-endpoint matching in a transitioning world. Moving to full endpoint matching will support complex devices and simple devices ...

If we can go straight to that - then that's fine too. --
Kieran