From: Mauro Carvalho Chehab <mchehab@infradead.org>
To: "Devin Heitmueller" <devin.heitmueller@gmail.com>
Cc: "Jonathan Corbet" <corbet@lwn.net>, "Alan Cox" <alan@redhat.com>,
video4linux-list@redhat.com, linux-kernel@vger.kernel.org,
"Alan Cox" <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH] video4linux: Push down the BKL
Date: Tue, 27 May 2008 18:00:48 -0300 [thread overview]
Message-ID: <20080527180048.6a27dbf7@gaivota> (raw)
In-Reply-To: <412bdbff0805271226t41fe55b0jd0b8e3c737f34734@mail.gmail.com>
Hi Devin,
On Tue, 27 May 2008 15:26:27 -0400
"Devin Heitmueller" <devin.heitmueller@gmail.com> wrote:
> Hello Mauro,
>
> On Tue, May 27, 2008 at 2:59 PM, Mauro Carvalho Chehab
> <mchehab@infradead.org> wrote:
> > For example, em28xx has already a lock at the operations that change values at
> > "dev" struct, including open() method. However, since the lock is not called at
> > get operations, it needs to be fixed. I would also change it from mutex to a
> > read/write semaphore, since two (or more) get operations can safely happen in
> > parallel.
>
> Please bear in mind that we have not worked out the locking semantics
> for hybrid tuner devices, and it's entirely possible that the get()
> routines will need to switch the tuner mode, which would eliminate any
> benefits of converting to a read/write semaphore.
Arjan pointed some good reasons about why we shouldn't use r/w semaphores. So,
it seems better to keep using mutexes.
> I'm not sure yet exactly how that's going to work, but it's something
> that might prompt you to defer converting it from a mutex until we
> have that worked out.
The hybrid device mode lock is somewhat complex. The simplest solution would be
to block an open() call, if the device is already used by a different mode.
This will minimize things like firmware reload, on xc3028 devices, where you
have different firmwares for analog and digital modes.
Also, some USB devices (like HVR-900/HVR-950) switches off analog audio and tv
demod chips when in digital mode (the reverse is also true - e.g. digital demod
is switched off at analog mode).
So, if you are in digital mode, on HVR-900, and changes to analog, you'll need
to re-initialize tvp5150/msp3400. The current code for those devices handles
this at open(). If we let this to happen later, we'll need to re-send the video
and audio parameters to all I2C connected devices, when switching mode.
On the other hand, some userspace apps, like mythtv, opens both analog and
digital API's. I'm not sure if it does this at the same time, but, if so, a
lock at open() will cause a regression there (someone told me that this is the
case - I didn't test it here yet).
One possible solution of providing a proper code to change mode, and not
blocking open() would be to write something like this:
static int check_and_switch_mode(void *priv, int digital)
{
struct dev_foo *dev = priv;
mutex_lock(dev->lock);
if (digital)
return change_to_digital(dev);
else
return change_to_analog(dev);
mutex_unlock(dev->lock);
}
Since this should be called for every valid V4L2 and DVB ioctl, the better
place for it would be to add this as a new function callback, at video_ioctl2.
Something like [1]:
--- a/linux/drivers/media/video/videodev.c Tue May 27 16:02:56 2008 -0300
+++ b/linux/drivers/media/video/videodev.c Tue May 27 17:34:04 2008 -0300
@@ -821,6 +821,10 @@
v4l_print_ioctl(vfd->name, cmd);
printk("\n");
}
+
+ if (_IOC_TYPE(cmd)=='v') || _IOC_TYPE(cmd)=='V') &&
+ vfd->vidioc_switch_mode)
+ ret=vfd->vidioc_switch_mode(fh, 0);
#ifdef CONFIG_VIDEO_V4L1_COMPAT
/***********************************************************
And something like this, at dvb core [2]:
diff -r b94d587ee596 linux/drivers/media/dvb/dvb-core/dvb_frontend.c
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c Tue May 27 16:02:56 2008 -0300
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c Tue May 27 17:35:57 2008 -0300
@@ -784,6 +784,9 @@
cmd == FE_DISEQC_RECV_SLAVE_REPLY))
return -EPERM;
+ if (fe->ops.switch_mode)
+ err = fe->ops.switch_mode(fe, 1);
+
if (down_interruptible (&fepriv->sem))
return -ERESTARTSYS;
[1] The code can be more conservative, changing mode only if S_STD or a video
stream ioctl is called.
[2] We need to think more about the proper places for the DVB changing mode. I
suspect that we'll need to add the mode change callback there and/or at other
different places.
PS.: I suspect that the real code will be much more complex than the above skeletons.
Cheers,
Mauro
next prev parent reply other threads:[~2008-05-27 21:01 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-22 21:37 [PATCH] video4linux: Push down the BKL Alan Cox
2008-05-23 2:08 ` Andy Walls
2008-05-23 6:16 ` Hans Verkuil
2008-05-23 6:28 ` Hans Verkuil
2008-05-26 16:39 ` Mauro Carvalho Chehab
2008-05-23 9:09 ` Alan Cox
2008-05-26 16:34 ` Mauro Carvalho Chehab
2008-05-26 16:46 ` Hans Verkuil
2008-05-26 21:14 ` Mauro Carvalho Chehab
2008-05-23 13:56 ` Jonathan Corbet
2008-05-23 15:39 ` Alan Cox
2008-05-23 16:09 ` Jonathan Corbet
2008-05-23 18:58 ` Alan Cox
2008-05-23 19:05 ` Hans Verkuil
2008-05-25 23:46 ` Mike Isely
2008-05-26 16:59 ` Mauro Carvalho Chehab
2008-05-26 20:23 ` Alan Cox
2008-05-26 21:10 ` Mauro Carvalho Chehab
2008-05-26 22:01 ` Alan Cox
2008-05-27 13:10 ` Mauro Carvalho Chehab
2008-05-27 15:41 ` Jonathan Corbet
2008-05-27 16:31 ` Mauro Carvalho Chehab
2008-05-27 16:37 ` Jonathan Corbet
2008-05-27 18:59 ` Mauro Carvalho Chehab
2008-05-27 19:26 ` Devin Heitmueller
2008-05-27 21:00 ` Mauro Carvalho Chehab [this message]
2008-05-27 21:22 ` Devin Heitmueller
2008-05-27 23:48 ` Andy Walls
2008-05-28 0:46 ` Devin Heitmueller
2008-05-28 2:37 ` Andy Walls
2008-05-28 2:47 ` Devin Heitmueller
2008-05-28 8:34 ` Alan Cox
2008-05-28 6:13 ` Hans Verkuil
2008-05-27 19:50 ` Arjan van de Ven
2008-05-27 20:24 ` Mauro Carvalho Chehab
2008-05-27 18:14 ` Alan Cox
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=20080527180048.6a27dbf7@gaivota \
--to=mchehab@infradead.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=alan@redhat.com \
--cc=corbet@lwn.net \
--cc=devin.heitmueller@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=video4linux-list@redhat.com \
/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