All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 i2c/for-next] i1c: i801: recover from hardware PEC errors
@ 2015-04-14  0:11 Ellen Wang
       [not found] ` <1428970319-32544-1-git-send-email-ellen-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Ellen Wang @ 2015-04-14  0:11 UTC (permalink / raw)
  To: jdelvare-l3A5Bk7waGM, wsa-z923LK4zBo2bacvFa/9K2g,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA

On a CRC error while using hardware-supported PEC, an additional
error bit is set in the auxiliary status register.  If this bit
isn't cleared, all subsequent operations will fail, essentially
hanging the controller.

The fix is simple: clear the bit at the same time we clear
the error bits in the main status register.

Signed-off-by: Ellen Wang <ellen-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
---
 drivers/i2c/busses/i2c-i801.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 5ecbb3f..7f3331e 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -129,6 +129,10 @@
 #define SMBAUXCTL_CRC		1
 #define SMBAUXCTL_E32B		2
 
+/* Auxiliary status register bits, ICH4+ only */
+#define SMBAUXSTS_CRCE		1
+#define SMBAUXSTS_STCO		2
+
 /* Other settings */
 #define MAX_RETRIES		400
 
@@ -164,6 +168,8 @@
 #define STATUS_FLAGS		(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR | \
 				 STATUS_ERROR_FLAGS)
 
+#define AUXSTS_ERROR_FLAGS	SMBAUXSTS_CRCE
+
 /* Older devices have their ID defined in <linux/pci_ids.h> */
 #define PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS		0x0f12
 #define PCI_DEVICE_ID_INTEL_BRASWELL_SMBUS		0x2292
@@ -509,6 +515,21 @@ static irqreturn_t i801_isr(int irq, void *dev_id)
 		i801_isr_byte_done(priv);
 
 	/*
+	 * Clear error condition in aux status that may have come from
+	 * a PEC error.  The main status register also should be showing
+	 * an error.  That should be sufficient for reporting purposes.
+	 */
+	if (priv->features & FEATURE_SMBUS_PEC) {
+		u8 auxsts = inb_p(SMBAUXSTS(priv));
+
+		if (auxsts & AUXSTS_ERROR_FLAGS) {
+			dev_dbg(&priv->pci_dev->dev, "irq: auxsts = %02x\n",
+				auxsts);
+			outb_p(auxsts & AUXSTS_ERROR_FLAGS, SMBAUXSTS(priv));
+		}
+	}
+
+	/*
 	 * Clear irq sources and report transaction result.
 	 * ->status must be cleared before the next transaction is started.
 	 */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-04-25 19:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14  0:11 [PATCH v1 i2c/for-next] i1c: i801: recover from hardware PEC errors Ellen Wang
     [not found] ` <1428970319-32544-1-git-send-email-ellen-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-04-15 12:08   ` Jean Delvare
     [not found]     ` <20150415140834.44b1add8-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-04-15 20:46       ` Ellen Wang
     [not found]         ` <552ECE19.4090705-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-04-17  7:17           ` [PATCH v1 i2c/for-next] i2c-i801: " Jean Delvare
     [not found]             ` <20150417091751.1ae986f2-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-04-20 22:52               ` Ellen Wang
     [not found]                 ` <5535833F.7090809-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2015-04-24 10:08                   ` Jean Delvare
     [not found]                     ` <20150424120852.717966f9-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-04-24 11:00                       ` Daniel Kurtz
     [not found]                         ` <CAGS+omCv0UL1hGRME_LiMGZhcd75G6x3eb7F9v5PvoxgwVAGVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-25 19:51                           ` Ellen Wang

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.