linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shinya.kuribayashi@necel.com (Shinya Kuribayashi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 15/16] i2c-designware: i2c_dw_xfer_msg: Mark as completed on an error
Date: Thu, 15 Oct 2009 14:29:43 +0900	[thread overview]
Message-ID: <4AD6B347.7010906@necel.com> (raw)
In-Reply-To: <4AD3EBC4.6030705@necel.com>

Shinya Kuribayashi wrote:
> As wait_for_completion_interruptible_timeout() will be invoked after
> the first call to i2c_dw_xfer_msg() is made whether or not an error is
> detected in it, we need to mark ->cmd_complete as completed to avoid a
> needless HZ timeout.

> diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
> index f7ea032..6f85e28 100644
> --- a/drivers/i2c/busses/i2c-designware.c
> +++ b/drivers/i2c/busses/i2c-designware.c
> @@ -376,6 +376,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
>  			dev_err(dev->dev,
>  				"%s: invalid message length\n", __func__);
>  			dev->msg_err = -EINVAL;
> +			complete(&dev->cmd_complete);
>  			return;
>  		}

It turned out to be incomplete, I confimred with I2C_FUNC_SMBUS_QUICK
flag for testing.

In [PATCH 10/16] (Do dw_i2c_pump_msg's jobs in the interrutp handler),
I deleted the following line from the interrupt handler,
>-	writel(0, dev->base + DW_IC_INTR_MASK);	/* disable interrupts */

so some interrupt bits, namely RX_FULL and somtimes TX_EMPTY, are now
kept _opened_ by default.  In error handling procedures, we need to
disable them or shutdown DW I2C core properly, otherwise those
interrupts continue to be asserted.

In addition, I noticed that we need similar treatments in target addr
inconsistency checking path.

Here's problematic parts.  I'll sort out these bits, later.
---
 drivers/i2c/busses/i2c-designware.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index 060f2dd..70aaaec 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -370,13 +370,21 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
 		 * reprogram the target address in the i2c
 		 * adapter when we are done with this transfer
 		 */
-		if (msgs[dev->msg_write_idx].addr != addr)
+		if (msgs[dev->msg_write_idx].addr != addr) {
+			dev_err(dev->dev,
+				"%s: invalid message address\n", __func__);
+			dev->msg_err = -EINVAL;
+			writel(0, dev->base + DW_IC_ENABLE);
+			complete(&dev->cmd_complete);
 			return;
+		}
 
 		if (msgs[dev->msg_write_idx].len == 0) {
 			dev_err(dev->dev,
 				"%s: invalid message length\n", __func__);
 			dev->msg_err = -EINVAL;
+			writel(0, dev->base + DW_IC_ENABLE);
+			complete(&dev->cmd_complete);
 			return;
 		}
 
@@ -430,8 +438,14 @@ i2c_dw_read(struct dw_i2c_dev *dev)
 			continue;
 
 		/* different i2c client, reprogram the i2c adapter */
-		if (msgs[dev->msg_read_idx].addr != addr)
+		if (msgs[dev->msg_read_idx].addr != addr) {
+			dev_err(dev->dev,
+				"%s: invalid message address\n", __func__);
+			dev->msg_err = -EINVAL;
+			writel(0, dev->base + DW_IC_ENABLE);
+			complete(&dev->cmd_complete);
 			return;
+		}
 
 		if (!(dev->status & STATUS_READ_IN_PROGRESS)) {
 			len = msgs[dev->msg_read_idx].len;
-- 
Shinya Kuribayashi
NEC Electronics

  reply	other threads:[~2009-10-15  5:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-13  2:44 [RFC] i2c-designware patches Shinya Kuribayashi
2009-10-13  2:48 ` [PATCH 01/16] i2c-designware: Consolidate to use 32-bit word accesses Shinya Kuribayashi
2009-10-13  2:48 ` [PATCH 02/16] i2c-designware: Don't use the IC_CLR_INTR register to clear interrupts Shinya Kuribayashi
2009-10-13  2:49 ` [PATCH 03/16] i2c-designware: Use platform_get_irq helper Shinya Kuribayashi
2009-10-13  2:49 ` [PATCH 04/16] i2c-designware: i2c_dw_read: Take "struct dw_i2c_dev" pointer Shinya Kuribayashi
2009-10-13  2:50 ` [PATCH 05/16] i2c-designware: i2c_dw_xfer_msg: " Shinya Kuribayashi
2009-10-13  2:50 ` [PATCH 06/16] i2c-designware: Remove an useless local variable "num" Shinya Kuribayashi
2009-10-13  2:50 ` [PATCH 07/16] i2c-designware: Set a clock name to DesignWare I2C clock source Shinya Kuribayashi
2009-10-13  9:54   ` Mark Brown
2009-10-14  4:19     ` Shinya Kuribayashi
2009-10-13 22:41   ` Ben Dooks
2009-10-14  4:19     ` Shinya Kuribayashi
2009-10-14 10:09       ` Mark Brown
2009-10-14 19:14       ` Russell King - ARM Linux
2009-10-15  3:37         ` Shinya Kuribayashi
2009-10-13  2:51 ` [PATCH 08/16] i2c-designware: Improve _HCNT/_LCNT calculation Shinya Kuribayashi
2009-10-13  2:51 ` [PATCH 09/16] i2c-designware: i2c_dw_xfer_msg: Fix an i2c_msg search bug Shinya Kuribayashi
2009-10-13  2:52 ` [PATCH 10/16] i2c-designware: Do dw_i2c_pump_msg's jobs in the interrutp handler Shinya Kuribayashi
2009-10-13  2:52 ` [PATCH 11/16] i2c-designware: Set Tx/Rx FIFO threshold levels Shinya Kuribayashi
2009-10-13  2:52 ` [PATCH 12/16] i2c-designware: Divide i2c_dw_xfer_msg into two functions Shinya Kuribayashi
2009-10-13  2:53 ` [PATCH 13/16] i2c-designware: i2c_dw_xfer_msg: Introduce a local "buf" pointer Shinya Kuribayashi
2009-10-13  2:53 ` [PATCH 14/16] i2c-designware: Deferred FIFO-data-counting variables initialization Shinya Kuribayashi
2009-10-13  2:53 ` [PATCH 15/16] i2c-designware: i2c_dw_xfer_msg: Mark as completed on an error Shinya Kuribayashi
2009-10-15  5:29   ` Shinya Kuribayashi [this message]
2009-10-13  2:54 ` [PATCH 16/16] i2c-designware: Add I2C_FUNC_SMBUS_* bits Shinya Kuribayashi
2009-10-14 18:53   ` Baruch Siach
2009-10-15  3:22     ` Shinya Kuribayashi
2009-10-13  7:04 ` [RFC] i2c-designware patches Baruch Siach
2009-10-13  8:01   ` Shinya Kuribayashi
2009-10-14 19:02 ` Baruch Siach
2009-10-19  1:23   ` Shinya Kuribayashi

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=4AD6B347.7010906@necel.com \
    --to=shinya.kuribayashi@necel.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).