From: Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>
To: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
Subject: [PATCH 1/4] i2c-i801: Use wait_event_timeout to wait for interrupts
Date: Mon, 10 Nov 2014 22:30:33 +0100 [thread overview]
Message-ID: <20141110223033.0938cf4e@endymion.delvare> (raw)
In-Reply-To: <20141110222655.13660613-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
Some systems have been reported to have trouble with interrupts. Use
wait_event_timeout() instead of wait_event() so we don't get stuck in
that case, and log the problem.
Signed-off-by: Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
---
drivers/i2c/busses/i2c-i801.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
--- linux-3.18-rc4.orig/drivers/i2c/busses/i2c-i801.c 2014-11-10 22:26:47.212135115 +0100
+++ linux-3.18-rc4/drivers/i2c/busses/i2c-i801.c 2014-11-10 22:29:18.040417276 +0100
@@ -2,7 +2,7 @@
Copyright (c) 1998 - 2002 Frodo Looijaard <frodol-B0qZmFHriGg@public.gmane.org>,
Philip Edelbrock <phil-KXOFo5pg7o1l57MIdRCFDg@public.gmane.org>, and Mark D. Studebaker
<mdsxyz123-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
- Copyright (C) 2007 - 2012 Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>
+ Copyright (C) 2007 - 2014 Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>
Copyright (C) 2010 Intel Corporation,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@@ -373,6 +373,7 @@ static int i801_transaction(struct i801_
{
int status;
int result;
+ const struct i2c_adapter *adap = &priv->adapter;
result = i801_check_pre(priv);
if (result < 0)
@@ -381,7 +382,14 @@ static int i801_transaction(struct i801_
if (priv->features & FEATURE_IRQ) {
outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START,
SMBHSTCNT(priv));
- wait_event(priv->waitq, (status = priv->status));
+ result = wait_event_timeout(priv->waitq,
+ (status = priv->status),
+ adap->timeout);
+ if (!result) {
+ status = -ETIMEDOUT;
+ dev_warn(&priv->pci_dev->dev,
+ "Timeout waiting for interrupt!\n");
+ }
priv->status = 0;
return i801_check_post(priv, status);
}
@@ -529,6 +537,7 @@ static int i801_block_transaction_byte_b
int smbcmd;
int status;
int result;
+ const struct i2c_adapter *adap = &priv->adapter;
result = i801_check_pre(priv);
if (result < 0)
@@ -557,7 +566,14 @@ static int i801_block_transaction_byte_b
priv->data = &data->block[1];
outb_p(priv->cmd | SMBHSTCNT_START, SMBHSTCNT(priv));
- wait_event(priv->waitq, (status = priv->status));
+ result = wait_event_timeout(priv->waitq,
+ (status = priv->status),
+ adap->timeout);
+ if (!result) {
+ status = -ETIMEDOUT;
+ dev_warn(&priv->pci_dev->dev,
+ "Timeout waiting for interrupt!\n");
+ }
priv->status = 0;
return i801_check_post(priv, status);
}
@@ -1215,6 +1231,9 @@ static int i801_probe(struct pci_dev *de
outb_p(inb_p(SMBAUXCTL(priv)) &
~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv));
+ /* Default timeout in interrupt mode: 200 ms */
+ priv->adapter.timeout = HZ / 5;
+
if (priv->features & FEATURE_IRQ) {
init_waitqueue_head(&priv->waitq);
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2014-11-10 21:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-10 21:26 [PATCH 0/4] i2c-i801: Make interrupt mode more robust Jean Delvare
[not found] ` <20141110222655.13660613-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-11-10 21:30 ` Jean Delvare [this message]
2014-11-10 21:31 ` [PATCH 2/4] i2c-i801: Fallback to polling if request_irq() fails Jean Delvare
[not found] ` <20141110223104.6419229d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-11-11 10:57 ` Wolfram Sang
2014-11-11 13:55 ` Jean Delvare
2014-11-10 21:31 ` [PATCH 3/4] i2c-i801: Check if interrupts are disabled Jean Delvare
[not found] ` <20141110223139.02aafde4-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-11-11 10:58 ` Wolfram Sang
2014-11-11 14:32 ` Jean Delvare
[not found] ` <20141111153214.39dfaeb8-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-11-11 14:41 ` Wolfram Sang
2014-11-11 20:06 ` Jean Delvare
[not found] ` <20141111210646.02b77c68-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-11-11 20:13 ` Wolfram Sang
2014-11-10 21:32 ` [PATCH 4/4] i2c-i801: Drop useless debug message Jean Delvare
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=20141110223033.0938cf4e@endymion.delvare \
--to=jdelvare-l3a5bk7wagm@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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