diff mbox series

[3/5] v4l2-async: Flag when media graph is complete

Message ID 20200610230541.1603067-4-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State New, archived
Headers show
Series media-device: Report if graph is complete | expand

Commit Message

Niklas Söderlund June 10, 2020, 11:05 p.m. UTC
When the notifier completes set the complete flag in the struct
media_device. This flag can can then be reported to user-space to let it
know the graph is complete.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/v4l2-core/v4l2-async.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Laurent Pinchart June 11, 2020, 3:10 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Thu, Jun 11, 2020 at 01:05:39AM +0200, Niklas Söderlund wrote:
> When the notifier completes set the complete flag in the struct
> media_device. This flag can can then be reported to user-space to let it
> know the graph is complete.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 8bde33c21ce45f98..331594ca5b3bb723 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -217,6 +217,11 @@ v4l2_async_notifier_try_complete(struct v4l2_async_notifier *notifier)
>  	if (!v4l2_async_notifier_can_complete(notifier))
>  		return 0;
>  
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	if (notifier->v4l2_dev->mdev)
> +		notifier->v4l2_dev->mdev->complete = true;
> +#endif

Does this work with sub-notifiers ?

> +
>  	return v4l2_async_notifier_call_complete(notifier);

Isn't there a race here, if we report the complete flag before the
notifier calls the .complete() operation ?

>  }
>
Sakari Ailus June 11, 2020, 10:50 a.m. UTC | #2
Hi Niklas,

On Thu, Jun 11, 2020 at 01:05:39AM +0200, Niklas Söderlund wrote:
> When the notifier completes set the complete flag in the struct
> media_device. This flag can can then be reported to user-space to let it
> know the graph is complete.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 8bde33c21ce45f98..331594ca5b3bb723 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -217,6 +217,11 @@ v4l2_async_notifier_try_complete(struct v4l2_async_notifier *notifier)
>  	if (!v4l2_async_notifier_can_complete(notifier))
>  		return 0;
>  
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	if (notifier->v4l2_dev->mdev)
> +		notifier->v4l2_dev->mdev->complete = true;
> +#endif
> +
>  	return v4l2_async_notifier_call_complete(notifier);
>  }
>  

Do we need this? Could you not use the complete callback from the main
notifier, that gets called only when all async subdevs have been bound?
Sakari Ailus June 11, 2020, 10:52 a.m. UTC | #3
On Thu, Jun 11, 2020 at 01:50:19PM +0300, Sakari Ailus wrote:
> Hi Niklas,
> 
> On Thu, Jun 11, 2020 at 01:05:39AM +0200, Niklas Söderlund wrote:
> > When the notifier completes set the complete flag in the struct
> > media_device. This flag can can then be reported to user-space to let it
> > know the graph is complete.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> >  drivers/media/v4l2-core/v4l2-async.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> > index 8bde33c21ce45f98..331594ca5b3bb723 100644
> > --- a/drivers/media/v4l2-core/v4l2-async.c
> > +++ b/drivers/media/v4l2-core/v4l2-async.c
> > @@ -217,6 +217,11 @@ v4l2_async_notifier_try_complete(struct v4l2_async_notifier *notifier)
> >  	if (!v4l2_async_notifier_can_complete(notifier))
> >  		return 0;
> >  
> > +#if defined(CONFIG_MEDIA_CONTROLLER)
> > +	if (notifier->v4l2_dev->mdev)
> > +		notifier->v4l2_dev->mdev->complete = true;
> > +#endif
> > +
> >  	return v4l2_async_notifier_call_complete(notifier);
> >  }
> >  
> 
> Do we need this? Could you not use the complete callback from the main
> notifier, that gets called only when all async subdevs have been bound?

Ah. Please ignore the comment. Something like this is needed for the flag.
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 8bde33c21ce45f98..331594ca5b3bb723 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -217,6 +217,11 @@  v4l2_async_notifier_try_complete(struct v4l2_async_notifier *notifier)
 	if (!v4l2_async_notifier_can_complete(notifier))
 		return 0;
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	if (notifier->v4l2_dev->mdev)
+		notifier->v4l2_dev->mdev->complete = true;
+#endif
+
 	return v4l2_async_notifier_call_complete(notifier);
 }