Re: [PATCH] zr36067: Debugging cleanups (updated again)

Jean Delvare <[email protected]>
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <[email protected]>
Hi Trent, Ronald,

On Fri, 25 May 2007 09:39:34 -0700 (PDT), Trent Piepho wrote:
> I've made a mutli-threaded test application, and the way poll works isn't
> right.  Keep in mind I'm talking about a single process with multiple
> threads sharing the same file descriptor.
> 
> My test will call select() on the zoran capture fd in one thread.  Then,
> while that thread is blocked inside select(), another thread will call
> REQBUFS/QBUF/STREAMON.
> 
> If you don't call poll_wait() to add the v4l capture queue, it doesn't
> work.  select() blocks (poll returning POLLNVAL doesn't cause select to
> return an error) and never returns.  The other thread queues and captures a
> frame, but since the capq wasn't added select never wakes up and sees that
> a frame is ready.
> 
> This is what the log looks like:
> [these syscalls by thread 1]
> DC10plus[0]: VIDIOC_S_FMT - type=1, size=192x128, fmt=0x56595559 (YUYV)
> DC10plus[0]: zoran_poll() - active=F, sync_tail=0/U, pend_tail=0, pend_head=0
> DC10plus[0]: zoran_poll() - no buffers queued
> [thread 1 is now blocked inside select()]
> [following syscalls by thread 2]
> DC10plus[0]: VIDIOC_REQBUFS - type=1
> DC10plus[0]: VIDIOC_QBUF - type=1, index=0
> DC10plus[0]: VIDIOC_QBUF - type=1, index=1
> DC10plus[0]: VIDIOC_STREAMON
> DC10plus[0]: set_vfe() - width = 192, height = 128
> [frame is ready, but select() did not wake, zr->v4l_capq wasn't added]
> [process will just sit here until you interrupt it with a signal]
> 
> After my latest patch, attached, this is what happens:
> 
> [these syscalls by thread 1]
> DC10plus[0]: VIDIOC_S_FMT - type=1, size=192x128, fmt=0x56595559 (YUYV)
> DC10plus[0]: zoran_poll() - active=F, sync_tail=0/U, pend_tail=0, pend_head=0
> [thread 1 is now blocked inside select()]
> [following syscalls by thread 2]
> DC10plus[0]: VIDIOC_REQBUFS - type=1
> DC10plus[0]: VIDIOC_QBUF - type=1, index=0
> DC10plus[0]: VIDIOC_QBUF - type=1, index=1
> DC10plus[0]: VIDIOC_STREAMON
> DC10plus[0]: set_vfe() - width = 192, height = 128
> [kernel select() checks poll status again, since capture started]
> DC10plus[0]: zoran_poll() - active=L, sync_tail=0/P, pend_tail=0, pend_head=2
> [frame still in PEND state, continue to block on select()]
> [frame captured, select() wakes and checks poll status]
> DC10plus[0]: zoran_poll() - active=L, sync_tail=0/D, pend_tail=1, pend_head=2
> [select returns and thread 1 calls DQBUF]
> DC10plus[0]: VIDIOC_DQBUF - type=1

I'm now using this 3rd version of the poll patch, and it works OK for
me.

Thanks,
-- 
Jean Delvare

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.