linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/8] cec/mc/vb2/dvb: fix epoll support
@ 2019-02-07 11:49 hverkuil-cisco
  2019-02-07 11:49 ` [RFC PATCH 1/8] cec: fix epoll() by calling poll_wait first hverkuil-cisco
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: hverkuil-cisco @ 2019-02-07 11:49 UTC (permalink / raw)
  To: linux-media; +Cc: Michael Ira Krufky, Brad Love, Sakari Ailus

From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

As was reported by Yi Qingliang (http://lkml.iu.edu/hypermail/linux/kernel/1812.3/02144.html)
the epoll support in v4l2 is broken.

After researching this some more it turns out that we never
really understood when poll_wait() should be called, and that in
fact it is broken in quite a few places in our media tree, and not
just v4l2.

The select() call is fairly simplistic: it calls the poll fop
first, then waits for an event if the poll fop returned 0.

The epoll() call is more complicated: epoll_ctl(EPOLL_CTL_ADD) will
call the poll fop which calls poll_wait in turn.

But epoll_wait() just waits for events to arrive on the registered
waitqueues, and does not call the poll fop until it is woken up.

So not calling poll_wait() in the poll fop will cause epoll_wait()
to wait forever (or until the timeout is reached).

This patch series just calls poll_wait() regardless of whether there
is an event pending.

It does this for all the various frameworks that did this wrong.

Note that there is also an extra mem2mem patch that adds a check for
q->error, which I noticed was missing.

I have not tested the videobuf and esp. the dvb-core changes. They
look sane, but it doesn't hurt to give those extra attention.

There are also older drivers that call poll_wait themselves. While
I have some patches for those (look in
https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=poll), they
need more review. I prefer to do the core frameworks first.

Several of the patches in this series should probably be CC-ed to
stable. I'll take a look at that once this RFC series gets the
green light.

Regards,

	Hans

Hans Verkuil (8):
  cec: fix epoll() by calling poll_wait first
  media-request: fix epoll() by calling poll_wait first
  vb2: fix epoll() by calling poll_wait first
  v4l2-ctrls.c: fix epoll() by calling poll_wait first
  v4l2-mem2mem: fix epoll() by calling poll_wait first
  v4l2-mem2mem: add q->error check to v4l2_m2m_poll()
  videobuf: fix epoll() by calling poll_wait first
  dvb-core: fix epoll() by calling poll_wait first

 drivers/media/cec/cec-api.c                   |  2 +-
 .../media/common/videobuf2/videobuf2-core.c   |  4 +--
 .../media/common/videobuf2/videobuf2-v4l2.c   |  4 +--
 drivers/media/dvb-core/dmxdev.c               |  8 +++---
 drivers/media/dvb-core/dvb_ca_en50221.c       |  5 ++--
 drivers/media/media-request.c                 |  3 +--
 drivers/media/v4l2-core/v4l2-ctrls.c          |  2 +-
 drivers/media/v4l2-core/v4l2-mem2mem.c        | 25 ++++++++-----------
 drivers/media/v4l2-core/videobuf-core.c       |  6 ++---
 9 files changed, 26 insertions(+), 33 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-02-08 21:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-07 11:49 [RFC PATCH 0/8] cec/mc/vb2/dvb: fix epoll support hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 1/8] cec: fix epoll() by calling poll_wait first hverkuil-cisco
2019-02-08 20:53   ` Sean Young
2019-02-07 11:49 ` [RFC PATCH 2/8] media-request: " hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 3/8] vb2: " hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 4/8] v4l2-ctrls.c: " hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 5/8] v4l2-mem2mem: " hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 6/8] v4l2-mem2mem: add q->error check to v4l2_m2m_poll() hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 7/8] videobuf: fix epoll() by calling poll_wait first hverkuil-cisco
2019-02-07 11:49 ` [RFC PATCH 8/8] dvb-core: " hverkuil-cisco
2019-02-08 21:12   ` Sean Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).