media: mali-c55: Require an enabled link to start a video node
Subsystems (2)
PATCH v2 1/1 media: mali-c55: Require an enabled link to start a video node
mali_c55_pipeline_ready() skips queues whose link is disabled, but such a queue can still start streaming on its own, as the video node pads lack MEDIA_PAD_FL_MUST_CONNECT. Stopping it later sees a ready pipeline and disables the ISP under the connected queues still capturing.
Mark the video node pads MUST_CONNECT so that starting a disconnected node fails with -ENOLINK.
---
Changes in v2:
- Add missing Signed-off-by.
- Cc stable, as d5f281f3dd29 is in the stable tree.
Build tested only (W=1, checkpatch --strict clean). Not tested on hardware; the disconnected-node STREAMON/STREAMOFF sequence is from code reading.
drivers/media/platform/arm/mali-c55/mali-c55-capture.c | 2 +- drivers/media/platform/arm/mali-c55/mali-c55-params.c | 2 +- drivers/media/platform/arm/mali-c55/mali-c55-stats.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/arm/mali-c55/mali-c55-capture.c +1 -1
@@ -855,7 +855,7 @@ static int mali_c55_register_cap_dev(struct mali_c55 *mali_c55, goto err_destroy_mutex; } - cap_dev->pad.flags =MEDIA_PAD_FL_SINK ; + cap_dev->pad.flags =MEDIA_PAD_FL_SINK |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (&cap_dev->vdev.entity,1 , &cap_dev->pad);if (ret) goto err_destroy_mutex;
drivers/media/platform/arm/mali-c55/mali-c55-params.c +1 -1
@@ -1014,7 +1014,7 @@ int mali_c55_register_params(struct mali_c55 *mali_c55)INIT_LIST_HEAD (¶ms->buffers.queue);spin_lock_init (¶ms->buffers.lock); - params->pad.flags =MEDIA_PAD_FL_SOURCE ; + params->pad.flags =MEDIA_PAD_FL_SOURCE |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (¶ms->vdev.entity,1 , ¶ms->pad);if (ret) goto err_destroy_mutex;
drivers/media/platform/arm/mali-c55/mali-c55-stats.c +1 -1
@@ -275,7 +275,7 @@ int mali_c55_register_stats(struct mali_c55 *mali_c55)INIT_LIST_HEAD (&stats->buffers.queue);spin_lock_init (&stats->buffers.lock); - stats->pad.flags =MEDIA_PAD_FL_SINK ; + stats->pad.flags =MEDIA_PAD_FL_SINK |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (&stats->vdev.entity,1 , &stats->pad);if (ret) goto err_destroy_mutex;
Signature · 1 line
2.55.0
Quoted 10 lines · David Carlier
mali_c55_pipeline_ready()skips queues whose link is disabled, but such a queue can still start streaming on its own, as the video node pads lackMEDIA_PAD_FL_MUST_CONNECT. Stopping it later sees a ready pipeline and disables the ISP under the connected queues still capturing.Mark the video node pads
MUST_CONNECTso that starting a disconnected node fails with-ENOLINK.Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by David Carlier <[email protected]>
It checks out:
Quoted 3 lines
Changes in v2:
- Add missing Signed-off-by.
- Cc stable, asd5f281f3dd29is in the stable tree.
No Cc: [email protected] actually added?
But Jacopo can certainly add that when applying the patch.
Yours,
Linus Walleij
Quoted 16 lines · Linus Walleij
Quoted 10 lines · David Carlier
mali_c55_pipeline_ready()skips queues whose link is disabled, but such a queue can still start streaming on its own, as the video node pads lackMEDIA_PAD_FL_MUST_CONNECT. Stopping it later sees a ready pipeline and disables the ISP under the connected queues still capturing.Mark the video node pads
MUST_CONNECTso that starting a disconnected node fails with-ENOLINK.Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by David Carlier <[email protected]>It checks out:
Reviewed-by Linus Walleij <[email protected]>
Quoted 7 lines
Quoted 3 lines
Changes in v2:
- Add missing Signed-off-by.
- Cc stable, asd5f281f3dd29is in the stable tree.No Cc: [email protected] actually added?
But Jacopo can certainly add that when applying the patch.
I don't have any C55 with the DS pipe fitted to test with, so I'll just
and I can Cc stable indeed
Quoted 3 lines
Yours,
Linus Walleij
Thanks
j
Jacopo Mondi
maintainerHi David
Quoted 2 lines · David Carlier
mali_c55_pipeline_ready()skips queues whose link is disabled, but such a queue can still start streaming on its own, as the video node pads
Can you elaborate on how this could happen ?
How can streaming start if you VIDIOC_STREAMON() on a capture device without an enabled link to the resizer subdev ?
Quoted 13 lines
lack
MEDIA_PAD_FL_MUST_CONNECT. Stopping it later sees a ready pipeline and disables the ISP under the connected queues still capturing.Mark the video node pads
MUST_CONNECTso that starting a disconnected node fails with-ENOLINK.Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by David Carlier <[email protected]>---
Changes in v2:
- Add missing Signed-off-by.
- Cc stable, asd5f281f3dd29is in the stable tree.
Quoted 6 lines
Build tested only (W=1, checkpatch --strict clean). Not tested on hardware; the disconnected-node STREAMON/STREAMOFF sequence is from code reading.
drivers/media/platform/arm/mali-c55/mali-c55-capture.c | 2 +- drivers/media/platform/arm/mali-c55/mali-c55-params.c | 2 +- drivers/media/platform/arm/mali-c55/mali-c55-stats.c | 2 +-
Why not the resizer ?
Quoted 45 lines
3 files changed, 3 insertions(+), 3 deletions(-)drivers/media/platform/arm/mali-c55/mali-c55-capture.c +1
-1@@ -855,7 +855,7 @@ static int mali_c55_register_cap_dev(struct mali_c55 *mali_c55, goto err_destroy_mutex; } - cap_dev->pad.flags =MEDIA_PAD_FL_SINK ; + cap_dev->pad.flags =MEDIA_PAD_FL_SINK |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (&cap_dev->vdev.entity,1 , &cap_dev->pad);if (ret) goto err_destroy_mutex;drivers/media/platform/arm/mali-c55/mali-c55-params.c +1
-1@@ -1014,7 +1014,7 @@ int mali_c55_register_params(struct mali_c55 *mali_c55)INIT_LIST_HEAD (¶ms->buffers.queue);spin_lock_init (¶ms->buffers.lock); - params->pad.flags =MEDIA_PAD_FL_SOURCE ; + params->pad.flags =MEDIA_PAD_FL_SOURCE |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (¶ms->vdev.entity,1 , ¶ms->pad);if (ret) goto err_destroy_mutex;drivers/media/platform/arm/mali-c55/mali-c55-stats.c +1
-2@@ -275,7 +275,7 @@ int mali_c55_register_stats(struct mali_c55 *mali_c55)INIT_LIST_HEAD (&stats->buffers.queue);spin_lock_init (&stats->buffers.lock); - stats->pad.flags =MEDIA_PAD_FL_SINK ; + stats->pad.flags =MEDIA_PAD_FL_SINK |MEDIA_PAD_FL_MUST_CONNECT ; ret =media_entity_pads_init (&stats->vdev.entity,1 , &stats->pad);if (ret) goto err_destroy_mutex; --2.55.0
A message that is not in the archive (sent off-list or not yet received): CA+XhMqyKNd2maRXmmpL=aOMB-z4X3JgCD5ofiHpMubtFHuS_0g@mail.gmail.com
Jacopo Mondi
maintainerHi David
please don't cut out context from replies, especially if they're not super long.
Quoted 5 lines · David CARLIER
Hi Jacopo,
Quoted 2 lines · Jacopo Mondi
Can you elaborate on how this could happen ?
Quoted 8 lines
Quoted 2 lines
How can streaming start if you
VIDIOC_STREAMON()on a capture device without an enabled link to the resizer subdev ?
video_device_pipeline_alloc_start()only walks enabled links, so with the link disabled the pipeline is the video node pad alone. Nothing in it fails validation, as the only-ENOLINKcheck in__media_pipeline_start()is forMUST_CONNECTpads.start_streaming()then enablescap_dev->rszdirectly rather than through the graph.
What does it mean "rather than through the graph" ? enable_streams() is propagated by drivers along the pipeline by design
Quoted 4 lines
So with the ds link disabled: STREAMON ds, then fr, params and stats (the last one starts the ISP), then STREAMOFF ds.
mali_c55_pipeline_ready()skips ds and returns true, so the ISP is stopped under fr.
so a STREAMOFF on a disconnected capture node could potentially stop the other. Feels like mali_c55_pipeline_ready() is not the right function to use, but if we mandate that a capture node has to be connected if STREAMON is called on it, then we're safe ?
Quoted 6 lines
Quoted 2 lines
Why not the resizer ?
The ISP to resizer links are immutable and enabled, so the sink pads are always connected. Flagging the resizer source pad would break the valid case instead: starting fr walks through the ISP into resizer ds
Is this a typo ? From FR we can't go to the DS resizer.
Quoted 3 lines
and its source pad via the internal route, so fr only capture with ds disabled would fail with
-ENOLINK. The video node pad is where the walk starts and whatpipeline_ready()checks, so the flag goes there.
Anyway, yes, there is a single link between the resizer's source pad and the capture device, if the SINK pad of the capture device is marked as MUST_CONNECT then the link between the two is enabled.
Quoted 2 lines
Cheers.
A message that is not in the archive (sent off-list or not yet received): CA+XhMqwfK+zoXb2_9XBUnjd9cLY_D0WwykbSccQR6kKqriZezA@mail.gmail.com
Jacopo Mondi
maintainerHi David
Quoted 5 lines · David CARLIER
Fair point, sorry for the shortcuts.
Quoted 2 lines
What does it mean "rather than through the graph" ?
enable_streams()is propagated by drivers along the pipeline by design
Quoted 7 lines
Badly worded, sorry. I only meant that
start_streaming()takes the resizer fromcap_dev->rszrather than from the remote end of an enabled link, so it enables it even with the link disabled.Quoted 1 line
Is this a typo ? From FR we can't go to the DS resizer.
Not for data, no. I meant the
media_pipeline_populate()walk: from the
Ah ok
Quoted 4 lines
ISP source video pad it follows the immutable link into the DS resizer sink pad and, through the internal route, its source pad. A
MUST_CONNECTon that pad would then fail FR only streaming with the DS link disabled.
This means (and reading Documentation/admin-guide/media/mali-c55.rst I think it was intended) that if you link-enable the DS-pipe you will have to start streaming on the DS capture node, otherwise streaming will never start due to mali_c55_pipeline_ready() returning false ?
I wish I had a system with a DS pipe to test with.
What I'm after here: I'm trying to figure out if your change introduces any requirement on how pipe have to be handled and if this has any implication on how libcamera works on mali.
A use case is continous capture from DS while only taking seldom pictures from FR. In this case I have to link both pipes, start both of them and feed buffers continuously to DS and only sporadically to FR. The key here is the requirement to call STREAMON on both capture nodes if they're linked.
In other words, if you want to use both pipes you need to link both of them and call STREAMON on both capture devices, even if in a session you will be capturing from one of them.
I think it's fine and matches the documentation in mali-c55.rst and the libcamera pipeline handler.
Quoted 3 lines
Thanks for the reviews.
Cheers.