Skip to contentSkip to conversation

vb2: about vb2_queue->queued_count

DISCUSSION Uwe Kleine-König 2 participants 6 messages Jun 8, 2011 – Jun 13, 2011 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hello,

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable the overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Now if the new video starts I call vb2_queue_init in the .vidioc_reqbufs callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q->queued_list is reset to be empty.

__vb2_queue_cancel has a similar problem, &q->queued_list is reset, but queued_count is not.

OTOH queued_count seems to be read only by vb2_wait_for_all_buffers which currently has no users. :-)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#1 lore raw

Hello,

Quoted 8 lines · Uwe Kleine-König

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable the overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Quoted 7 lines

Now if the new video starts I call vb2_queue_init in the .vidioc_reqbufs callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q->queued_list is reset to be empty.

__vb2_queue_cancel has a similar problem, &q->queued_list is reset, but queued_count is not.

Thanks again for finding the bug. You are right, __vb2_queue_cancel should reset queued_count too. I will post a patch soon.

Quoted 2 lines

OTOH queued_count seems to be read only by vb2_wait_for_all_buffers which currently has no users. :-)

Right, no mainline drive use it right now, but this function might be convenient for some standard drivers.

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung Poland R&D Center
#2 lore raw
Quoted 17 lines · Marek Szyprowski

Hello,

Quoted 13 lines · Uwe Kleine-König

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable the overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Now if the new video starts I call vb2_queue_init in the .vidioc_reqbufs callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q->queued_list is reset to be empty.

Quoted 5 lines
Quoted 2 lines

__vb2_queue_cancel has a similar problem, &q->queued_list is reset, but queued_count is not.

Thanks again for finding the bug. You are right, __vb2_queue_cancel should reset queued_count too. I will post a patch soon.

IMHO vb2_queue_init should reset queued_count, too. Not sure if you just skipped to mention it here ....

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

Hello,

Quoted 19 lines · Uwe Kleine-König
Quoted 13 lines · Marek Szyprowski

Hello,

Quoted 9 lines · Uwe Kleine-König

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable the overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Now if the new video starts I call vb2_queue_init in

the .vidioc_reqbufs

Quoted 4 lines
Quoted 4 lines

callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q->queued_list is reset to be empty.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

__vb2_queue_cancel has a similar problem, &q->queued_list is reset, but queued_count is not.

Thanks again for finding the bug. You are right, __vb2_queue_cancel

should

Quoted 1 line

reset queued_count too. I will post a patch soon.

IMHO vb2_queue_init should reset queued_count, too. Not sure if you just skipped to mention it here ....

vb2_queue_init assumes that the called allocated vb2_queue with kzalloc() or did memset(q, 0, sizeof(struct vb2_queue)), so it is not really required to explicitly set queued_count to zero.

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung Poland R&D Center
#4 lore raw

Hello,

Quoted 25 lines · Marek Szyprowski
Quoted 23 lines · Uwe Kleine-König
Quoted 13 lines · Marek Szyprowski

Hello,

Quoted 9 lines · Uwe Kleine-König

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable the overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Now if the new video starts I call vb2_queue_init in

the .vidioc_reqbufs

Quoted 8 lines
Quoted 6 lines

callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q->queued_list is reset to be empty.

__vb2_queue_cancel has a similar problem, &q->queued_list is reset, but queued_count is not.

Thanks again for finding the bug. You are right, __vb2_queue_cancel

Quoted 8 lines
Quoted 4 lines

should

Quoted 1 line

reset queued_count too. I will post a patch soon.

IMHO vb2_queue_init should reset queued_count, too. Not sure if you just skipped to mention it here ....

vb2_queue_init assumes that the called allocated vb2_queue with kzalloc() or did memset(q, 0, sizeof(struct vb2_queue)), so it is not really required to explicitly set queued_count to zero.

Hmmm, I call vb2_queue_init in the callback .vidioc_reqbufs, because AFAICT this is the only place where I get the needed info to set q->type. As this looks wrong now, can you hint where to initialize the queue instead?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw

Hello,

Quoted 35 lines · Uwe Kleine-König
Quoted 11 lines · Marek Szyprowski
Quoted 9 lines · Uwe Kleine-König
Quoted 8 lines · Marek Szyprowski

Hello,

Quoted 4 lines · Uwe Kleine-König

I'm still debugging my new video overlay device driver. The current problem is again when playing back a second video.

After streamoff is called at the end of the first video, I disable

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

overlay and call vb2_buffer_done on the last buffer. This is exited early because vb->state == VB2_BUF_STATE_DEQUEUED.
This results in vb->vb2_queue->queued_count being 1.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Now if the new video starts I call vb2_queue_init in

the .vidioc_reqbufs

Quoted 2 lines
Quoted 2 lines

callback on my queue (that still has queued_count == 1). After vb2_queue_init returns queued_count is still 1 though q-

queued_list is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

reset to be empty.

__vb2_queue_cancel has a similar problem, &q->queued_list is reset,

but

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

queued_count is not.

Thanks again for finding the bug. You are right, __vb2_queue_cancel

should

Quoted 1 line

reset queued_count too. I will post a patch soon.

IMHO vb2_queue_init should reset queued_count, too. Not sure if you

just

Quoted 2 lines
Quoted 1 line

skipped to mention it here ....

Quoted 8 lines
Quoted 2 lines

vb2_queue_init assumes that the called allocated vb2_queue with kzalloc() or did memset(q, 0, sizeof(struct vb2_queue)), so it is not really

required

Quoted 1 line

to explicitly set queued_count to zero.

Hmmm, I call vb2_queue_init in the callback .vidioc_reqbufs, because AFAICT this is the only place where I get the needed info to set q->type. As this looks wrong now, can you hint where to initialize the queue instead?

Huh, this design doesn't look good. vb2_queue_init should be called during driver initialization, and .videoc_reqbufs should be just a proxy to vb2_reqbus() (same with querybuf, qbuf, dqbuf, streamon, streamoff, read and poll). Why do you want to play with q->type? Can't you just set it correctly to V4L2_BUF_TYPE_VIDEO_CAPTURE in driver probe?

Best regards

Signature · 2 lines
Marek Szyprowski
Samsung Poland R&D Center