All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-media@vger.kernel.org, Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: ->poll() instances shouldn't be indefinitely blocking
Date: Fri, 27 Nov 2015 13:18:43 -0200	[thread overview]
Message-ID: <20151127131843.0416fe2b@recife.lan> (raw)
In-Reply-To: <20151127050026.GX22011@ZenIV.linux.org.uk>

Em Fri, 27 Nov 2015 05:00:26 +0000
Al Viro <viro@ZenIV.linux.org.uk> escreveu:

> Take a look at this:
> static unsigned int gsc_m2m_poll(struct file *file,
>                                         struct poll_table_struct *wait)
> {
>         struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
>         struct gsc_dev *gsc = ctx->gsc_dev;
>         int ret;
> 
>         if (mutex_lock_interruptible(&gsc->lock))
>                 return -ERESTARTSYS;
> 
>         ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
>         mutex_unlock(&gsc->lock);
> 
>         return ret;
> }
> 
> a) ->poll() should not return -E...; callers expect just a bitmap of
> POLL... values.

Yeah. We fixed issues like that on other drivers along the time. I guess
this is a some bad code that people just cut-and-paste from legacy drivers
without looking into it.

The same kind of crap were found (and fixed) on other drivers, like
the fix on this changeset: 45053edc05 ('[media] saa7164: fix poll bugs').

> b) sure, it's nice that if this thing hangs, we'll be able to kill it.
> However, if one's ->poll() can hang indefinitely, it means bad things
> for poll(2), select(2), etc. semantics.  What the hell had been intended
> there?

I guess there was no special intent. It is just a bad driver code that
was replicated from other drivers.

> c) a bunch of v4l2_m2m_poll() callers are also taking some kind of
> mutex; AFAICS, all of those appear bogus (the rest of them do not
> play wiht ERESTARTSYS, just plain mutex_lock() for those).
> 
> What's going on there?

  reply	other threads:[~2015-11-27 15:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  5:00 ->poll() instances shouldn't be indefinitely blocking Al Viro
2015-11-27 15:18 ` Mauro Carvalho Chehab [this message]
2015-11-27 17:49   ` Linus Torvalds
2015-11-30  3:04     ` Al Viro
2015-12-04  6:38       ` more POLL... fun Al Viro
2015-12-04  9:16         ` Arnd Bergmann
2015-12-04 15:21           ` Al Viro
2015-12-04 17:13             ` Arnd Bergmann
2015-12-04 17:30               ` Al Viro
2015-12-04 17:34                 ` Arnd Bergmann
2015-12-06 23:58                 ` Michael Ellerman
2017-02-16  5:59                 ` Michael Ellerman

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=20151127131843.0416fe2b@recife.lan \
    --to=mchehab@osg.samsung.com \
    --cc=hverkuil@xs4all.nl \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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.