From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Antti Palosaari <crope@iki.fi>
Cc: linux-media <linux-media@vger.kernel.org>
Subject: Re: DVBv5 test report
Date: Mon, 23 Jan 2012 15:16:23 -0200 [thread overview]
Message-ID: <4F1D95E7.50709@redhat.com> (raw)
In-Reply-To: <4F1D898A.8020802@iki.fi>
Em 23-01-2012 14:23, Antti Palosaari escreveu:
> On 01/19/2012 03:31 PM, Mauro Carvalho Chehab wrote:
>> [PATCH] dvb-usb: Don't abort stop on -EAGAIN/-EINTR
>>
>> Note: this patch is not complete. if the DVB demux device is opened on
>> block mode, it should instead be returning -EAGAIN.
>>
>> Signed-off-by: Mauro Carvalho Chehab<mchehab@redhat.com>
>>
>> diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
>> index ddf282f..215ce75 100644
>> --- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
>> +++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
>> @@ -30,7 +30,9 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
>> usb_urb_kill(&adap->fe_adap[adap->active_fe].stream);
>>
>> if (adap->props.fe[adap->active_fe].streaming_ctrl != NULL) {
>> - ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 0);
>> + do {
>> + ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 0);
>> + } while ((ret == -EAGAIN) || (ret == -EINTR));
>> if (ret< 0) {
>> err("error while stopping stream.");
>> return ret;
>>
>
> That fixes it. But it loops do {...} while around 100 times every I stop zap. Over 100 times is rather much...
Yes, this sounds too much.
The issue here is caused by the usage of mutex_lock_interruptible() inside the
streaming_ctrl() callbacks, when the stream should stop.
The new wait_queue wakeup inside the code made the issue more visible, but it
could still happen without it, as a break could be hit during stream_ctl()
stop call anyway.
There are two possible fixes for it:
1) The above solution.
Eventually, a schedule() could be added there:
do {
ret = adap->props.fe[adap->active_fe].streaming_ctrl(adap, 0);
if (ret == -EINTR)
shedule();
} while (ret == -EINTR);
2)
Don't use mutex_lock_interruptible inside the driver's streaming_ctrl,
if the second parameter is 0 (stop).
IMHO, (1) is cleaner, due to a few reasons:
- inside the drivers, the code will be symmetrical: it will call the same function for
both onoff = 1 and onoff = 0.
- The patch is on just one place;
- with (2), extra care is needed when merging patches, as regressions and
broken drivers could pass unnoticed.
>
> And I think -EINTR is the only code to look, -EAGAIN is maybe for I2C and can be switched to native -EINTR also.
Drivers need to be checked, if only -EINTR is added there, as drivers may
be doing things like:
if (mutex_lock_interruptible(...))
return -EAGAIN;
Regards,
Mauro
prev parent reply other threads:[~2012-01-23 17:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 22:05 DVBv5 test report Antti Palosaari
2012-01-19 11:33 ` Mauro Carvalho Chehab
2012-01-19 11:57 ` Antti Palosaari
2012-01-19 13:31 ` Mauro Carvalho Chehab
2012-01-19 15:53 ` Antti Palosaari
2012-01-19 16:08 ` Mauro Carvalho Chehab
2012-01-19 17:12 ` Antti Palosaari
2012-01-23 16:23 ` Antti Palosaari
2012-01-23 17:16 ` Mauro Carvalho Chehab [this message]
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=4F1D95E7.50709@redhat.com \
--to=mchehab@redhat.com \
--cc=crope@iki.fi \
--cc=linux-media@vger.kernel.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.