All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Cc: tfiga@chromium.org, m.szyprowski@samsung.com,
	ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de,
	hverkuil-cisco@xs4all.nl, nicolas@ndufresne.ca,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v21 1/9] media: videobuf2: Update vb2_is_busy() logic
Date: Thu, 21 Mar 2024 14:49:52 +0100	[thread overview]
Message-ID: <20240321144952.5effcb82@coco.lan> (raw)
In-Reply-To: <20240314153226.197445-2-benjamin.gaignard@collabora.com>

Em Thu, 14 Mar 2024 16:32:18 +0100
Benjamin Gaignard <benjamin.gaignard@collabora.com> escreveu:

> Do not rely on the number of allocated buffers to know if the
> queue is busy but on a flag set when at least one buffer has been allocated
> by REQBUFS or CREATE_BUFS ioctl.
> The flag is reset when REQBUFS is called with count = 0 or the file
> handle is closed.
> This is needed because remove buffers feature will be able to remove
> all the buffers from a queue while streaming so relying on the number
> of allocated buffers in the queue won't be possible.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> ---
>  drivers/media/common/videobuf2/videobuf2-core.c | 4 ++++
>  include/media/videobuf2-core.h                  | 4 +++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index b6bf8f232f48..d8b3c04cb3b5 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -854,6 +854,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  		__vb2_queue_free(q, q_num_bufs);
>  		mutex_unlock(&q->mmap_lock);
>  
> +		q->is_busy = 0;
>  		/*
>  		 * In case of REQBUFS(0) return immediately without calling
>  		 * driver's queue_setup() callback and allocating resources.
> @@ -966,6 +967,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  	 */
>  	*count = allocated_buffers;
>  	q->waiting_for_buffers = !q->is_output;
> +	q->is_busy = 1;
>  
>  	return 0;
>  
> @@ -1091,6 +1093,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
>  	 * to the userspace.
>  	 */
>  	*count = allocated_buffers;
> +	q->is_busy = 1;
>  
>  	return 0;
>  
> @@ -2555,6 +2558,7 @@ void vb2_core_queue_release(struct vb2_queue *q)
>  	__vb2_queue_free(q, vb2_get_num_buffers(q));
>  	kfree(q->bufs);
>  	q->bufs = NULL;
> +	q->is_busy = 0;
>  	mutex_unlock(&q->mmap_lock);
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_queue_release);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 8b86996b2719..667bf9ee1101 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -582,6 +582,7 @@ struct vb2_buf_ops {
>   *		released. Used to prevent destroying the queue by other threads.
>   * @is_multiplanar: set if buffer type is multiplanar
>   * @is_output:	set if buffer type is output
> + * @is_busy:	set if at least one buffer has been allocated at some time.
>   * @copy_timestamp: set if vb2-core should set timestamps
>   * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the
>   *		last decoded buffer was already dequeued. Set for capture queues
> @@ -647,6 +648,7 @@ struct vb2_queue {
>  	unsigned int			waiting_in_dqbuf:1;
>  	unsigned int			is_multiplanar:1;
>  	unsigned int			is_output:1;
> +	unsigned int			is_busy:1;
>  	unsigned int			copy_timestamp:1;
>  	unsigned int			last_buffer_dequeued:1;
>  
> @@ -1166,7 +1168,7 @@ static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q)
>   */
>  static inline bool vb2_is_busy(struct vb2_queue *q)
>  {
> -	return vb2_get_num_buffers(q) > 0;
> +	return !!q->is_busy;
>  }
>  
>  /**



Thanks,
Mauro

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Cc: tfiga@chromium.org, m.szyprowski@samsung.com,
	ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de,
	hverkuil-cisco@xs4all.nl, nicolas@ndufresne.ca,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v21 1/9] media: videobuf2: Update vb2_is_busy() logic
Date: Thu, 21 Mar 2024 14:49:52 +0100	[thread overview]
Message-ID: <20240321144952.5effcb82@coco.lan> (raw)
In-Reply-To: <20240314153226.197445-2-benjamin.gaignard@collabora.com>

Em Thu, 14 Mar 2024 16:32:18 +0100
Benjamin Gaignard <benjamin.gaignard@collabora.com> escreveu:

> Do not rely on the number of allocated buffers to know if the
> queue is busy but on a flag set when at least one buffer has been allocated
> by REQBUFS or CREATE_BUFS ioctl.
> The flag is reset when REQBUFS is called with count = 0 or the file
> handle is closed.
> This is needed because remove buffers feature will be able to remove
> all the buffers from a queue while streaming so relying on the number
> of allocated buffers in the queue won't be possible.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> ---
>  drivers/media/common/videobuf2/videobuf2-core.c | 4 ++++
>  include/media/videobuf2-core.h                  | 4 +++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
> index b6bf8f232f48..d8b3c04cb3b5 100644
> --- a/drivers/media/common/videobuf2/videobuf2-core.c
> +++ b/drivers/media/common/videobuf2/videobuf2-core.c
> @@ -854,6 +854,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  		__vb2_queue_free(q, q_num_bufs);
>  		mutex_unlock(&q->mmap_lock);
>  
> +		q->is_busy = 0;
>  		/*
>  		 * In case of REQBUFS(0) return immediately without calling
>  		 * driver's queue_setup() callback and allocating resources.
> @@ -966,6 +967,7 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
>  	 */
>  	*count = allocated_buffers;
>  	q->waiting_for_buffers = !q->is_output;
> +	q->is_busy = 1;
>  
>  	return 0;
>  
> @@ -1091,6 +1093,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
>  	 * to the userspace.
>  	 */
>  	*count = allocated_buffers;
> +	q->is_busy = 1;
>  
>  	return 0;
>  
> @@ -2555,6 +2558,7 @@ void vb2_core_queue_release(struct vb2_queue *q)
>  	__vb2_queue_free(q, vb2_get_num_buffers(q));
>  	kfree(q->bufs);
>  	q->bufs = NULL;
> +	q->is_busy = 0;
>  	mutex_unlock(&q->mmap_lock);
>  }
>  EXPORT_SYMBOL_GPL(vb2_core_queue_release);
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 8b86996b2719..667bf9ee1101 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -582,6 +582,7 @@ struct vb2_buf_ops {
>   *		released. Used to prevent destroying the queue by other threads.
>   * @is_multiplanar: set if buffer type is multiplanar
>   * @is_output:	set if buffer type is output
> + * @is_busy:	set if at least one buffer has been allocated at some time.
>   * @copy_timestamp: set if vb2-core should set timestamps
>   * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the
>   *		last decoded buffer was already dequeued. Set for capture queues
> @@ -647,6 +648,7 @@ struct vb2_queue {
>  	unsigned int			waiting_in_dqbuf:1;
>  	unsigned int			is_multiplanar:1;
>  	unsigned int			is_output:1;
> +	unsigned int			is_busy:1;
>  	unsigned int			copy_timestamp:1;
>  	unsigned int			last_buffer_dequeued:1;
>  
> @@ -1166,7 +1168,7 @@ static inline unsigned int vb2_get_num_buffers(struct vb2_queue *q)
>   */
>  static inline bool vb2_is_busy(struct vb2_queue *q)
>  {
> -	return vb2_get_num_buffers(q) > 0;
> +	return !!q->is_busy;
>  }
>  
>  /**



Thanks,
Mauro

  reply	other threads:[~2024-03-21 13:50 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 15:32 [PATCH v21 0/9] Add REMOVE_BUF ioctl Benjamin Gaignard
2024-03-14 15:32 ` Benjamin Gaignard
2024-03-14 15:32 ` [PATCH v21 1/9] media: videobuf2: Update vb2_is_busy() logic Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 13:49   ` Mauro Carvalho Chehab [this message]
2024-03-21 13:49     ` Mauro Carvalho Chehab
2024-03-14 15:32 ` [PATCH v21 2/9] videobuf2: Add min_reqbufs_allocation field to vb2_queue structure Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 13:52   ` Mauro Carvalho Chehab
2024-03-21 13:52     ` Mauro Carvalho Chehab
2024-08-21 23:28   ` Laurent Pinchart
2024-08-21 23:28     ` Laurent Pinchart
2024-08-22  1:29     ` Tomasz Figa
2024-08-22  1:29       ` Tomasz Figa
2024-08-22  6:11       ` Hans Verkuil
2024-08-22  6:11         ` Hans Verkuil
2024-08-22 12:20         ` Laurent Pinchart
2024-08-22 12:20           ` Laurent Pinchart
2024-08-23  8:08           ` Hans Verkuil
2024-08-23  8:08             ` Hans Verkuil
2024-03-14 15:32 ` [PATCH v21 3/9] media: test-drivers: Set REQBUFS minimum number of buffers Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-18 10:06   ` Hans Verkuil
2024-03-18 10:06     ` Hans Verkuil
2024-03-18 13:06     ` Hans Verkuil
2024-03-18 13:06       ` Hans Verkuil
2024-03-21 13:53   ` Mauro Carvalho Chehab
2024-03-21 13:53     ` Mauro Carvalho Chehab
2024-03-14 15:32 ` [PATCH v21 4/9] media: core: Rework how create_buf index returned value is computed Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-14 15:32 ` [PATCH v21 5/9] media: core: Add bitmap manage bufs array entries Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-14 15:32 ` [PATCH v21 6/9] media: core: Free range of buffers Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 14:18   ` Mauro Carvalho Chehab
2024-03-21 14:18     ` Mauro Carvalho Chehab
2024-03-14 15:32 ` [PATCH v21 7/9] media: v4l2: Add REMOVE_BUFS ioctl Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 14:14   ` Mauro Carvalho Chehab
2024-03-21 14:14     ` Mauro Carvalho Chehab
2024-03-21 14:24     ` Hans Verkuil
2024-03-21 14:24       ` Hans Verkuil
2024-03-21 15:03       ` Mauro Carvalho Chehab
2024-03-21 15:03         ` Mauro Carvalho Chehab
2024-03-22  7:54         ` Hans Verkuil
2024-03-22  7:54           ` Hans Verkuil
2024-03-22  9:51           ` Benjamin Gaignard
2024-03-22  9:51             ` Benjamin Gaignard
2024-03-14 15:32 ` [PATCH v21 8/9] media: v4l2: Add mem2mem helpers for " Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 14:15   ` Mauro Carvalho Chehab
2024-03-21 14:15     ` Mauro Carvalho Chehab
2024-03-14 15:32 ` [PATCH v21 9/9] media: verisilicon: Support removing buffers on capture queue Benjamin Gaignard
2024-03-14 15:32   ` Benjamin Gaignard
2024-03-21 14:16   ` Mauro Carvalho Chehab
2024-03-21 14:16     ` Mauro Carvalho Chehab

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=20240321144952.5effcb82@coco.lan \
    --to=mchehab@kernel.org \
    --cc=benjamin.gaignard@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=nicolas@ndufresne.ca \
    --cc=p.zabel@pengutronix.de \
    --cc=tfiga@chromium.org \
    /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.