From: Brendan McGrath <redmcg@redmandi.dyndns.org>
To: Steven Toth <stoth@kernellabs.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
Linux-Media <linux-media@vger.kernel.org>
Subject: [PATCHv2] [media] saa7164: use an MSI interrupt when available
Date: Fri, 27 Feb 2015 10:29:15 +1100 [thread overview]
Message-ID: <54EFAC4B.6080002@redmandi.dyndns.org> (raw)
In-Reply-To: <CALzAhNX=KCnLmcv3iNtCwH2OLSTErytvK1kZpGCbAyQtmt6How@mail.gmail.com>
From: Brendan McGrath <redmcg@redmandi.dyndns.org>
[media] saa7164: use an MSI interrupt when available
Enhances driver to use an MSI interrupt when available.
Adds the module option 'enable_msi' (type bool) which by default is
enabled. Can be set to 'N' to disable.
Fixes (or can reduce the occurrence of) a crash which is most commonly
reported when multiple saa7164 chips are in use.
Signed-off-by: Brendan McGrath <redmcg@redmandi.dyndns.org>
---
Thanks for the feedback Steven (and thanks for all your hard work on
this driver!).
And thank-you Kyle for taking the time to test this patch. Much appreciated.
drivers/media/pci/saa7164/saa7164-core.c | 40
++++++++++++++++++++++++++++++--
drivers/media/pci/saa7164/saa7164.h | 1 +
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-core.c
b/drivers/media/pci/saa7164/saa7164-core.c
index 4b0bec3..1aff2ee 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -85,6 +85,11 @@ module_param(guard_checking, int, 0644);
MODULE_PARM_DESC(guard_checking,
"enable dma sanity checking for buffer overruns");
+static bool enable_msi = true;
+module_param(enable_msi, bool, 0444);
+MODULE_PARM_DESC(enable_msi,
+ "enable the use of an msi interrupt if available");
+
static unsigned int saa7164_devcount;
static DEFINE_MUTEX(devlist);
@@ -1230,8 +1235,34 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
goto fail_irq;
}
- err = request_irq(pci_dev->irq, saa7164_irq,
- IRQF_SHARED, dev->name, dev);
+ /* irq bit */
+ if (enable_msi)
+ err = pci_enable_msi(pci_dev);
+
+ if (!err && enable_msi) {
+ /* no error - so request an msi interrupt */
+ err = request_irq(pci_dev->irq, saa7164_irq, 0,
+ dev->name, dev);
+
+ if (err) {
+ /* fall back to legacy interrupt */
+ printk(KERN_ERR "%s() Failed to get an MSI interrupt."
+ " Falling back to a shared IRQ\n", __func__);
+ pci_disable_msi(pci_dev);
+ } else {
+ dev->msi = true;
+ }
+ }
+
+ if ((!enable_msi) || err) {
+ dev->msi = false;
+ /* if we have an error (i.e. we don't have an interrupt)
+ or msi is not enabled - fallback to shared interrupt */
+
+ err = request_irq(pci_dev->irq, saa7164_irq,
+ IRQF_SHARED, dev->name, dev);
+ }
+
if (err < 0) {
printk(KERN_ERR "%s: can't get IRQ %d\n", dev->name,
pci_dev->irq);
@@ -1441,6 +1472,11 @@ static void saa7164_finidev(struct pci_dev *pci_dev)
/* unregister stuff */
free_irq(pci_dev->irq, dev);
+ if (dev->msi) {
+ pci_disable_msi(pci_dev);
+ dev->msi = false;
+ }
+
mutex_lock(&devlist);
list_del(&dev->devlist);
mutex_unlock(&devlist);
diff --git a/drivers/media/pci/saa7164/saa7164.h
b/drivers/media/pci/saa7164/saa7164.h
index cd1a07c..6df4b252 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -459,6 +459,7 @@ struct saa7164_dev {
/* Interrupt status and ack registers */
u32 int_status;
u32 int_ack;
+ u32 msi;
struct cmd cmds[SAA_CMD_MAX_MSG_UNITS];
struct mutex lock;
--
1.9.1
On 27/02/15 02:12, Steven Toth wrote:
>> I believe the root cause of the crash is due to a DMA/IRQ race condition. It
>> most commonly occurs when the saa7164 driver is dealing with more than one
>> saa7164 chip (the HVR-2200 and HVR-2250 for example have two - one for each
>> tuner). Given MSI avoids DMA/IRQ race conditions - this would explain why
>> the patch works as a fix.
> Brendan, thanks.
>
> With MSI I've had some people report complete success, others still
> have the issues.
>
> In my experience this does help with i2c timeout issues but not
> completely in every case. I've also seen it with single card instances
> so you descripton above is close - but not quiet accurate in all
> cases.
>
> While I'm generally OK with changing the driver behaviour to enable
> MSI by default, please add a module option to allow the behaviour to
> be disabled, reverting the driver back to existing behaviour.
>
> Once this is done, I'll be happy to Ack it.
>
> Thanks again.
>
> - Steve
>
next prev parent reply other threads:[~2015-02-26 23:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-26 3:19 [PATCH] [media] saa7164: use an MSI interrupt when available Brendan McGrath
2015-02-26 15:12 ` Steven Toth
2015-02-26 20:32 ` Kyle Sanderson
2015-02-26 20:45 ` Steven Toth
2015-02-26 23:06 ` Kyle Sanderson
2015-02-26 23:29 ` Brendan McGrath [this message]
2015-02-27 16:01 ` [PATCHv2] " Steven Toth
2015-03-01 0:14 ` [PATCHv3] " Brendan McGrath
2015-03-04 3:42 ` catchall
2015-03-14 3:27 ` [PATCHv4] " Brendan McGrath
2015-04-08 20:43 ` Mauro Carvalho Chehab
2015-04-10 6:39 ` [PATCHv5] " Brendan McGrath
2015-06-05 4:42 ` Kyle Sanderson
2015-06-05 5:09 ` Brendan McGrath
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=54EFAC4B.6080002@redmandi.dyndns.org \
--to=redmcg@redmandi.dyndns.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=stoth@kernellabs.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 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.