From: Shinya Kuribayashi <shinya.kuribayashi-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
To: baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v2 09/22] i2c-designware: Process i2c_msg messages in the interrupt handler
Date: Fri, 06 Nov 2009 21:47:51 +0900 [thread overview]
Message-ID: <4AF41AF7.60605@necel.com> (raw)
In-Reply-To: <4AF419B6.1000802-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
Symptom:
--------
When we're going to send/receive the longer size of data than the Tx
FIFO length, the I2C transaction will be divided into several separated
transactions, limited by the Tx FIFO length.
Details:
--------
As a hardware feature, DW I2C core generates a STOP condition whenever
the Tx FIFO becomes empty (strictly speaking, whenever the last byte in
the Tx FIFO is sent out), even if we have more bytes to be written.
Then, once a new transmit data is written to the Tx FIFO, DW I2C core
will initiate a new transaction, which leads to another START condition.
This explains how the transaction in question goes, and implies that
current tasklet-based dw_i2c_pump_msg() strategy couldn't meet the
timing constraint required for avoiding Tx FIFO underrun.
To avoid this scenario, we must keep providing new transmit data within
a given time period. In case of Fast-mode + 32-byte Tx FIFO, for
instance, it takes about 22.5[us] to process single byte, and 720[us] in
total.
This patch removes the existing tasklet-based "pump" system, and move
its jobs into the interrupt handler.
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
Acked-by: Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>
---
drivers/i2c/busses/i2c-designware.c | 39 ++++++++++++----------------------
1 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index bfb42f0..5fce1a0 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -149,7 +149,6 @@ static char *abort_sources[] = {
* @dev: driver model device node
* @base: IO registers pointer
* @cmd_complete: tx completion indicator
- * @pump_msg: continue in progress transfers
* @lock: protect this struct and IO registers
* @clk: input reference clock
* @cmd_err: run time hadware error code
@@ -175,7 +174,6 @@ struct dw_i2c_dev {
struct device *dev;
void __iomem *base;
struct completion cmd_complete;
- struct tasklet_struct pump_msg;
struct mutex lock;
struct clk *clk;
int cmd_err;
@@ -325,7 +323,7 @@ static int i2c_dw_wait_bus_not_busy(struct dw_i2c_dev *dev)
/*
* Initiate low level master read/write transaction.
* This function is called from i2c_dw_xfer when starting a transfer.
- * This function is also called from dw_i2c_pump_msg to continue a transfer
+ * This function is also called from i2c_dw_isr to continue a transfer
* that is longer than the size of the TX FIFO.
*/
static void
@@ -489,10 +487,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
/* no error */
if (likely(!dev->cmd_err)) {
- /* read rx fifo, and disable the adapter */
- do {
- i2c_dw_read(dev);
- } while (dev->status & STATUS_READ_IN_PROGRESS);
+ /* Disable the adapter */
writel(0, dev->base + DW_IC_ENABLE);
ret = num;
goto done;
@@ -520,20 +515,6 @@ static u32 i2c_dw_func(struct i2c_adapter *adap)
return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR;
}
-static void dw_i2c_pump_msg(unsigned long data)
-{
- struct dw_i2c_dev *dev = (struct dw_i2c_dev *) data;
- u32 intr_mask;
-
- i2c_dw_read(dev);
- i2c_dw_xfer_msg(dev);
-
- intr_mask = DW_IC_INTR_STOP_DET | DW_IC_INTR_TX_ABRT;
- if (dev->status & STATUS_WRITE_IN_PROGRESS)
- intr_mask |= DW_IC_INTR_TX_EMPTY;
- writel(intr_mask, dev->base + DW_IC_INTR_MASK);
-}
-
static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
{
u32 stat;
@@ -604,10 +585,19 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
if (stat & DW_IC_INTR_TX_ABRT) {
dev->cmd_err |= DW_IC_ERR_TX_ABRT;
dev->status = STATUS_IDLE;
- } else if (stat & DW_IC_INTR_TX_EMPTY)
- tasklet_schedule(&dev->pump_msg);
+ }
+
+ if (stat & DW_IC_INTR_TX_EMPTY) {
+ i2c_dw_read(dev);
+ i2c_dw_xfer_msg(dev);
+ }
+
+ /*
+ * No need to modify or disable the interrupt mask here.
+ * i2c_dw_xfer_msg() will take care of it according to
+ * the current transmit status.
+ */
- writel(0, dev->base + DW_IC_INTR_MASK); /* disable interrupts */
if (stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET))
complete(&dev->cmd_complete);
@@ -653,7 +643,6 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
}
init_completion(&dev->cmd_complete);
- tasklet_init(&dev->pump_msg, dw_i2c_pump_msg, (unsigned long) dev);
mutex_init(&dev->lock);
dev->dev = get_device(&pdev->dev);
dev->irq = irq;
--
1.6.5.2
next prev parent reply other threads:[~2009-11-06 12:47 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-06 12:42 [PATCH v2] i2c-designware updates Shinya Kuribayashi
2009-11-06 12:42 ` Shinya Kuribayashi
2009-11-06 12:42 ` Shinya Kuribayashi
[not found] ` <4AF419B6.1000802-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
2009-11-06 12:43 ` [PATCH v2 01/22] i2c-designware: Consolidate to use 32-bit word accesses Shinya Kuribayashi
2009-11-06 12:44 ` [PATCH v2 02/22] i2c-designware: Don't use the IC_CLR_INTR register to clear interrupts Shinya Kuribayashi
2009-11-06 12:45 ` [PATCH v2 03/22] i2c-designware: Use platform_get_irq helper Shinya Kuribayashi
2009-11-06 12:45 ` [PATCH v2 04/22] i2c-designware: i2c_dw_read: Use "struct dw_i2c_dev" pointer Shinya Kuribayashi
2009-11-06 12:46 ` [PATCH v2 05/22] i2c-designware: i2c_dw_xfer_msg: " Shinya Kuribayashi
2009-11-06 12:46 ` [PATCH v2 06/22] i2c-designware: Remove an useless local variable "num" Shinya Kuribayashi
2009-11-06 12:47 ` [PATCH v2 07/22] i2c-designware: Improved _HCNT/_LCNT calculation Shinya Kuribayashi
2009-11-06 12:47 ` [PATCH v2 08/22] i2c-designware: i2c_dw_xfer_msg: Fix i2c_msg search bug Shinya Kuribayashi
2009-11-06 12:47 ` Shinya Kuribayashi [this message]
2009-11-06 12:48 ` [PATCH v2 10/22] i2c-designware: Set Tx/Rx FIFO threshold levels Shinya Kuribayashi
2009-11-06 12:48 ` [PATCH v2 11/22] i2c-designware: Enable RX_FULL interrupt Shinya Kuribayashi
2009-11-06 12:48 ` [PATCH v2 12/22] i2c-designware: Divide i2c_dw_xfer_msg into two functions Shinya Kuribayashi
2009-11-06 12:49 ` [PATCH v2 13/22] i2c-designware: i2c_dw_xfer_msg: Introduce a local "buf" pointer Shinya Kuribayashi
2009-11-06 12:49 ` [PATCH v2 14/22] i2c-designware: Initialize byte count variables just prior to being used Shinya Kuribayashi
2009-11-06 12:50 ` [PATCH v2 15/22] i2c-designware: i2c_dw_func: Set I2C_FUNC_SMBUS_foo bits Shinya Kuribayashi
2009-11-06 12:50 ` [PATCH v2 16/22] i2c-designware: i2c_dw_read: Remove redundant target address checker Shinya Kuribayashi
2009-11-06 12:50 ` [PATCH v2 17/22] i2c-designware: Process all i2c_msg messages in the interrupt handler Shinya Kuribayashi
2009-11-06 12:51 ` [PATCH v2 18/22] i2c-designware: Disable TX_EMPTY when all i2c_msg msgs has been processed Shinya Kuribayashi
2009-11-06 12:51 ` [PATCH v2 19/22] i2c-designware: i2c_dw_xfer_msg: Fix error handling procedures Shinya Kuribayashi
2009-11-06 12:51 ` [PATCH v2 20/22] i2c-designware: Skip RX_FULL and TX_EMPTY bits on tx abort errors Shinya Kuribayashi
2009-11-06 12:51 ` [PATCH v2 21/22] i2c-designware: Tx abort cleanups Shinya Kuribayashi
[not found] ` <4AF41BED.1050406-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
2009-11-12 4:29 ` Shinya Kuribayashi
[not found] ` <4AFB8F3A.6060208-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
2009-11-14 22:22 ` Ben Dooks
[not found] ` <20091114222249.GM13398-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
2009-11-16 11:27 ` Shinya Kuribayashi
2009-11-06 12:52 ` [PATCH v2 22/22] i2c-designware: Cosmetic cleanups Shinya Kuribayashi
2009-11-06 22:25 ` [PATCH v2] i2c-designware updates Ben Dooks
2009-11-06 22:25 ` Ben Dooks
2009-11-06 22:25 ` Ben Dooks
2009-11-16 11:40 ` [PATCH 23/22] i2c-designware: i2c_dw_handle_tx_abort: Use dev_dbg() for NOACK cases Shinya Kuribayashi
2009-11-16 11:40 ` Shinya Kuribayashi
2009-11-16 11:40 ` Shinya Kuribayashi
2009-11-23 23:11 ` [PATCH v2] i2c-designware updates Ben Dooks
2009-11-23 23:11 ` Ben Dooks
2009-11-23 23:11 ` Ben Dooks
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=4AF41AF7.60605@necel.com \
--to=shinya.kuribayashi-jawzhaxaiamavxtiumwx3w@public.gmane.org \
--cc=baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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 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.