From: Andreas Mohr <andi@lisas.de>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: Andreas Mohr <andi@lisas.de>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Mauro Carvalho Chehab <mchehab@infradead.org>,
Luca Risolia <luca.risolia@studio.unibo.it>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: V4L2 drivers: potentially dangerous and inefficient msecs_to_jiffies() calculation
Date: Tue, 15 Sep 2009 00:13:29 +0200 [thread overview]
Message-ID: <20090914221328.GA18867@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <4AAEBABA.9060108@gmail.com>
On Mon, Sep 14, 2009 at 11:50:50PM +0200, Jiri Slaby wrote:
> A potential problem here is rather that it may wait longer due to
> returning 1 jiffie. It's then timeout * 1000 * 1. On 250HZ system it
> makes a difference of multiple of 4. Don't think it's a real issue in
> those drivers at all, but it's worth fixing. Care to post a patch?
*sigh*. :) OK, last thing to be done this day.
Generated via precise copy&paste of the change between drivers
(which is a flashing warning that they likely contain too much c&p anyway),
plus:
for file in sn9c102/sn9c102_core.c et61x251/et61x251_core.c zc0301/zc0301_core.c; do diff -upN
linux-2.6.31/drivers/media/video/"$file" linux-2.6.31.patched/drivers/media/video/"$file" >>
/tmp/v4l2_drivers.diff; done
Disclaimer: FULLY UNTESTED, make sure to guard your hen house, use as dog food.
ChangeLog:
Correct dangerous and inefficient msecs_to_jiffies() calculation in some V4L2 drivers
Signed-off-by: Andreas Mohr <andi@lisas.de>
--- linux-2.6.31/drivers/media/video/sn9c102/sn9c102_core.c 2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.patched/drivers/media/video/sn9c102/sn9c102_core.c 2009-09-14 23:58:27.000000000 +0200
@@ -1954,8 +1954,10 @@ sn9c102_read(struct file* filp, char __u
(!list_empty(&cam->outqueue)) ||
(cam->state & DEV_DISCONNECTED) ||
(cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ msecs_to_jiffies(
+ cam->module_param.frame_timeout * 1000
+ )
+ );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
--- linux-2.6.31/drivers/media/video/et61x251/et61x251_core.c 2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.patched/drivers/media/video/et61x251/et61x251_core.c 2009-09-14 23:58:54.000000000 +0200
@@ -1379,8 +1379,10 @@ et61x251_read(struct file* filp, char __
(!list_empty(&cam->outqueue)) ||
(cam->state & DEV_DISCONNECTED) ||
(cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ msecs_to_jiffies(
+ cam->module_param.frame_timeout * 1000
+ )
+ );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
--- linux-2.6.31/drivers/media/video/zc0301/zc0301_core.c 2009-09-10 00:13:59.000000000 +0200
+++ linux-2.6.31.patched/drivers/media/video/zc0301/zc0301_core.c 2009-09-15 00:00:14.000000000 +0200
@@ -819,8 +819,10 @@ zc0301_read(struct file* filp, char __us
(!list_empty(&cam->outqueue)) ||
(cam->state & DEV_DISCONNECTED) ||
(cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ msecs_to_jiffies(
+ cam->module_param.frame_timeout * 1000
+ )
+ );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
next prev parent reply other threads:[~2009-09-14 22:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-14 21:07 Andreas Mohr
2009-09-14 21:34 ` Jiri Slaby
2009-09-14 21:39 ` Andreas Mohr
2009-09-14 21:50 ` Jiri Slaby
2009-09-14 22:13 ` Andreas Mohr [this message]
2009-09-14 21:47 ` Trent Piepho
2009-09-15 19:14 ` Marcin Slusarz
2009-09-15 19:21 ` Andreas Mohr
2009-09-19 10:08 ` Andreas Mohr
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=20090914221328.GA18867@rhlx01.hs-esslingen.de \
--to=andi@lisas.de \
--cc=g.liakhovetski@gmx.de \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=luca.risolia@studio.unibo.it \
--cc=mchehab@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®