From patchwork Tue Aug 16 01:32:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1069732 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7G1XXbC017786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 16 Aug 2011 01:33:54 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qt8Wq-0000Ha-7H; Tue, 16 Aug 2011 01:33:16 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qt8Wp-0003WH-A4; Tue, 16 Aug 2011 01:33:15 +0000 Received: from smtp-out.google.com ([216.239.44.51]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qt8Wm-0003Vy-33 for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2011 01:33:13 +0000 Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id p7G1WrHN020057; Mon, 15 Aug 2011 18:32:53 -0700 Received: from peppermint.mtv.corp.google.com (peppermint.mtv.corp.google.com [172.22.73.61]) by hpaq6.eem.corp.google.com with ESMTP id p7G1WnCa010541; Mon, 15 Aug 2011 18:32:50 -0700 Received: by peppermint.mtv.corp.google.com (Postfix, from userid 121310) id 6E06F19AA3B; Mon, 15 Aug 2011 18:32:49 -0700 (PDT) From: Doug Anderson To: Ben Dooks , Stephen Warren , Vincent Palatin , Rhyland Klein , Felipe Balbi Subject: [PATCH v2] i2c: tegra: Check for overflow errors with BUG_ON. Date: Mon, 15 Aug 2011 18:32:16 -0700 Message-Id: <1313458336-31456-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1313434172-18319-1-git-send-email-dianders@chromium.org> References: <1313434172-18319-1-git-send-email-dianders@chromium.org> X-System-Of-Record: true X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110815_213312_466469_0EE5F399 X-CRM114-Status: GOOD ( 15.70 ) X-Spam-Score: -3.3 (---) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-3.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [216.239.44.51 listed in list.dnswl.org] -1.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Lucas De Marchi , Doug Anderson , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Rakesh Iyer , linux-i2c@vger.kernel.org, Jean Delvare , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 01:33:54 +0000 (UTC) This change doesn't fix any known problems but turns on the overflow detection feature of the i2c controller in the hopes of flushing out any current (or future) bugs in the i2c driver. Inspired by a change on nvidia's git server: http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=commit;h=266d1b7397284505e55d06254b497cb32be07b69 Signed-off-by: Doug Anderson Acked-by: Stephen Warren Reviewed-by: Felipe Balbi Acked-by: Rhyland Klein --- This takes Felipe Balbi's suggestion of making the overflow error non-fatal. drivers/i2c/busses/i2c-tegra.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 2440b74..34634b7 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -83,6 +83,7 @@ #define I2C_ERR_NO_ACK 0x01 #define I2C_ERR_ARBITRATION_LOST 0x02 #define I2C_ERR_UNKNOWN_INTERRUPT 0x04 +#define I2C_ERR_FIFO_OVERFLOW 0x08 #define PACKET_HEADER0_HEADER_SIZE_SHIFT 28 #define PACKET_HEADER0_PACKET_ID_SHIFT 16 @@ -367,7 +368,8 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) { u32 status; - const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; + const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST | + I2C_INT_TX_FIFO_OVERFLOW; struct tegra_i2c_dev *i2c_dev = dev_id; status = i2c_readl(i2c_dev, I2C_INT_STATUS); @@ -389,6 +391,14 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id) } if (unlikely(status & status_err)) { + /* + * Overflow should be impossible unless we've got a + * bug in the driver, but check anyway. + */ + if (status & I2C_INT_TX_FIFO_OVERFLOW) { + WARN_ON(1); + i2c_dev->msg_err |= I2C_ERR_FIFO_OVERFLOW; + } if (status & I2C_INT_NO_ACK) i2c_dev->msg_err |= I2C_ERR_NO_ACK; if (status & I2C_INT_ARBITRATION_LOST) @@ -423,7 +433,7 @@ err: /* An error occurred, mask all interrupts */ tegra_i2c_mask_irq(i2c_dev, I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST | I2C_INT_PACKET_XFER_COMPLETE | I2C_INT_TX_FIFO_DATA_REQ | - I2C_INT_RX_FIFO_DATA_REQ); + I2C_INT_RX_FIFO_DATA_REQ | I2C_INT_TX_FIFO_OVERFLOW); i2c_writel(i2c_dev, status, I2C_INT_STATUS); if (i2c_dev->is_dvc) dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS); @@ -473,7 +483,8 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (!(msg->flags & I2C_M_RD)) tegra_i2c_fill_tx_fifo(i2c_dev); - int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; + int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST | + I2C_INT_TX_FIFO_OVERFLOW; if (msg->flags & I2C_M_RD) int_mask |= I2C_INT_RX_FIFO_DATA_REQ; else if (i2c_dev->msg_buf_remaining)