v4l: async: make v4l2 coexists with devicetree nodes in a dt overlay
Subsystems (2)
PATCH 1/1 v4l: async: make v4l2 coexists with devicetree nodes in a dt overlay
In asd's configured with V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, its of_node pointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to use of_node_cmp() so that we continue matching after the overlay has been removed and reapplied.
---
Hi,
I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
drivers/media/v4l2-core/v4l2-async.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-async.c +2 -1
@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->of_node == asd->match.of.node; +return !of_node_cmp (of_node_full_name (sd->of_node), +of_node_full_name (asd->match.of.node)); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)
Signature · 1 line
2.1.4
Hello Javi,
Quoted 7 lines · Javi Merino
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.
I'm still not that familiar with DT overlays (and I guess others aren't either) so I think that including an example of a base tree and overlay DTS where this is an issue, could make things more clear in the commit.
IIUC, it should be something like this?
-- base tree --
&i2c1 {
camera: camera@10 {
reg = <0x10>;
port {
cam_ep: endpoint {
...
};
};
};
};&media_bridge {
...
ports {
port@0 {
reg = <0>;
ep: endpoint {
remote-endpoint = <&cam_ep>;
};
};
};
};-- overlay --
/plugin/;
/ {
...
fragment@0 {
target = <&camera>;
__overlay__ {
compatible = "foo,bar";
...
port {
cam_ep: endpoint {
...
};
};
};
}
}Quoted 11 lines
Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <[email protected]>Signed-off-by Javi Merino <[email protected]>---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
I also couldn't think a better way to do this, since IIUC the node's name is the only thing that doesn't change, and is available at the time the bridge driver calls v4l2_async_notifier_register() when parsing the base tree.
Quoted 9 lines
drivers/media/v4l2-core/v4l2-async.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-async.c +0
-0
drivers/media/v4l2-core/v4l2-async.c static bool match_devname(struct v4l2_subdev *sd, · line 49
Quoted 9 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->of_node == asd->match.of.node; +return !of_node_cmp (of_node_full_name (sd->of_node), +of_node_full_name (asd->match.of.node)); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)
Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
Quoted 45 lines · Javier Martinez Canillas
Hello Javi,
Quoted 7 lines · Javi Merino
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.I'm still not that familiar with DT overlays (and I guess others aren't either) so I think that including an example of a base tree and overlay DTS where this is an issue, could make things more clear in the commit.
IIUC, it should be something like this?
-- base tree --
&i2c1 { camera: camera@10 { reg = <0x10>; port { cam_ep: endpoint { ... }; }; }; };&media_bridge { ... ports { port@0 { reg = <0>; ep: endpoint { remote-endpoint = <&cam_ep>; }; }; }; };-- overlay --
/plugin/;
Quoted 15 lines
/ {
...
fragment@0 {
target = <&camera>;
__overlay__ {
compatible = "foo,bar";
...
port {
cam_ep: endpoint {
...
};
};
};
}
}Yes, that's right. What I have is that the whole camera can be plugged or unplugged, so the overlay adds/removes the camera node:
/ {
fragment@0 {
target-path = "/i2c0";
__overlay__ {
my_cam {
compatible = "foo,bar";
port {
camera0: endpoint {
remote-endpoint = <&vin2a>;
...
};
};
};
};
};I will add it to the commit message.
Quoted 42 lines
Quoted 11 lines
Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <[email protected]>Signed-off-by Javi Merino <[email protected]>---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
I also couldn't think a better way to do this, since IIUC the node's name is the only thing that doesn't change, and is available at the time the bridge driver calls
v4l2_async_notifier_register()when parsing the base tree.Quoted 9 lines
drivers/media/v4l2-core/v4l2-async.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-async.c +0
-0drivers/media/v4l2-core/v4l2-async.c static bool match_devname(struct v4l2_subdev *sd, · line 49
Quoted 9 lines
drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->of_node == asd->match.of.node; +return !of_node_cmp (of_node_full_name (sd->of_node), +of_node_full_name (asd->match.of.node)); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)Reviewed-by Javier Martinez Canillas <[email protected]>Best regards,
Signature · 3 lines
Javier Martinez Canillas Open Source Group Samsung Research America
Hi Javi,
Quoted 11 lines · Javi Merino
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <[email protected]>Signed-off-by Javi Merino <[email protected]>
Quoted 6 lines
---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
First I have to admit that I'm not an expert when it comes to DT overlays.
That said, my understanding is that the sub-device and the async sub-device are supposed to point to the exactly same DT node. I wonder if there's actually anything wrong in the current code.
If the overlay has changed between probing the driver for the async notifier and the async sub-device, there should be no match here, should there? The two nodes actually point to a node in a different overlay in that case.
Quoted 18 lines
drivers/media/v4l2-core/v4l2-async.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->of_node == asd->match.of.node; +return !of_node_cmp (of_node_full_name (sd->of_node), +of_node_full_name (asd->match.of.node)); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Quoted 1 line · Sakari Ailus
Hi Javi,
Hi Sakari,
Quoted 21 lines · Javi Merino
Quoted 11 lines
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <[email protected]>Signed-off-by Javi Merino <[email protected]>Quoted 6 lines
---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
First I have to admit that I'm not an expert when it comes to DT overlays.
Quoted 7 lines
That said, my understanding is that the sub-device and the async sub-device are supposed to point to the exactly same DT node. I wonder if there's actually anything wrong in the current code.
If the overlay has changed between probing the driver for the async notifier and the async sub-device, there should be no match here, should there? The two nodes actually point to a node in a different overlay in that case.
Overlays are parts of the devicetree that can be added and removed. When the overlay is applied, the camera driver is probed and does v4l2_async_register_subdev(). However, v4l2_async_belongs() fails. The problem is with comparing pointers. I haven't looked at the implementation of overlays in detail, but what I see is that the of_node pointer changes when you remove and reapply an overlay (I guess it's dynamically allocated and when you remove the overlay, it's freed).
Cheers,
Javi
Quoted 24 lines
Quoted 18 lines
drivers/media/v4l2-core/v4l2-async.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-async.c +2
-1@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,static bool match_of (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd) { -return sd->of_node == asd->match.of.node; +return !of_node_cmp (of_node_full_name (sd->of_node), +of_node_full_name (asd->match.of.node)); }static bool match_custom (struct v4l2_subdev *sd,struct v4l2_async_subdev *asd)Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Hi Javi,
Quoted 34 lines · Javi Merino
Quoted 1 line · Sakari Ailus
Hi Javi,
Hi Sakari,
Quoted 21 lines · Javi Merino
Quoted 11 lines
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]>Signed-off-by Javi Merino <[email protected]>Quoted 6 lines
---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
First I have to admit that I'm not an expert when it comes to DT overlays.
Quoted 7 lines
That said, my understanding is that the sub-device and the async sub-device are supposed to point to the exactly same DT node. I wonder if there's actually anything wrong in the current code.
If the overlay has changed between probing the driver for the async notifier and the async sub-device, there should be no match here, should there? The two nodes actually point to a node in a different overlay in that case.
Quoted 8 lines
Overlays are parts of the devicetree that can be added and removed. When the overlay is applied, the camera driver is probed and does
v4l2_async_register_subdev(). However,v4l2_async_belongs()fails. The problem is with comparing pointers. I haven't looked at the implementation of overlays in detail, but what I see is that theof_nodepointer changes when you remove and reapply an overlay (I guess it's dynamically allocated and when you remove the overlay, it's freed).
The concern here which we were discussing was whether the overlay should be relied on having compliant configuration compared to the part which was not part of the overlay.
As external components are involved, quite possibly also the ISP DT node will require changes, not just the image source (TV tuner, camera sensor etc.). This could be because of number of CSI-2 lanes or parallel bus width, for instance.
I'd also be interested in having an actual driver implement support for removing and adding a DT overlay first so we'd see how this would actually work. We need both in order to be able to actually remove and add DT overlays _without_ unbinding the ISP driver. Otherwise it should already work in the current codebase.
Signature · 8 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Nov 25, 2016 at 10:21:21AM +0200, Sakari Ailus wrote:
Hi Sakari,
Quoted 53 lines · Javi Merino
Quoted 34 lines · Sakari Ailus
Quoted 1 line
Hi Javi,
Hi Sakari,
Quoted 21 lines · Javi Merino
Quoted 11 lines
In asd's configured with
V4L2_ASYNC_MATCH_OF, if the v4l2 subdev is in a devicetree overlay, itsof_nodepointer will be different each time the overlay is applied. We are not interested in matching the pointer, what we want to match is that the path is the one we are expecting. Change to useof_node_cmp()so that we continue matching after the overlay has been removed and reapplied.Cc Mauro Carvalho Chehab <[email protected]>Cc Javier Martinez Canillas <[email protected]>Cc Sakari Ailus <sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]>Signed-off-by Javi Merino <[email protected]>Quoted 6 lines
---
Hi,I feel it is a bit of a hack, but I couldn't think of anything better. I'm ccing devicetree@ and Pantelis because there may be a simpler solution.
First I have to admit that I'm not an expert when it comes to DT overlays.
Quoted 7 lines
That said, my understanding is that the sub-device and the async sub-device are supposed to point to the exactly same DT node. I wonder if there's actually anything wrong in the current code.
If the overlay has changed between probing the driver for the async notifier and the async sub-device, there should be no match here, should there? The two nodes actually point to a node in a different overlay in that case.
Quoted 8 lines
Overlays are parts of the devicetree that can be added and removed. When the overlay is applied, the camera driver is probed and does
v4l2_async_register_subdev(). However,v4l2_async_belongs()fails. The problem is with comparing pointers. I haven't looked at the implementation of overlays in detail, but what I see is that theof_nodepointer changes when you remove and reapply an overlay (I guess it's dynamically allocated and when you remove the overlay, it's freed).The concern here which we were discussing was whether the overlay should be relied on having compliant configuration compared to the part which was not part of the overlay.
As external components are involved, quite possibly also the ISP DT node will require changes, not just the image source (TV tuner, camera sensor etc.). This could be because of number of CSI-2 lanes or parallel bus width, for instance.
Quoted 5 lines
I'd also be interested in having an actual driver implement support for removing and adding a DT overlay first so we'd see how this would actually work. We need both in order to be able to actually remove and add DT overlays _without_ unbinding the ISP driver. Otherwise it should already work in the current codebase.
Unfortunately, the driver I'm working on is not upstream and I can't submit it to mainline. This patch fixes the issue for me, so I thought it could be useful fix for the kernel.
Cheers,
Javi
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html