[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <EF2E73589CA71846A15D0B2CDF79505D0905DB4657@wm021.weinmann.com>
Date: Mon, 23 Apr 2012 07:39:55 +0200
From: "Voss, Nikolaus" <N.Voss@...nmann.de>
To: "'devel@...nes.com'" <devel@...nes.com>,
"'Wolfram Sang'" <w.sang@...gutronix.de>,
"'linux-arm-kernel@...ts.infradead.org'"
<linux-arm-kernel@...ts.infradead.org>,
"'linux-kernel@...r.kernel.org'" <linux-kernel@...r.kernel.org>,
"'linux-i2c@...r.kernel.org'" <linux-i2c@...r.kernel.org>
CC: "'Hubert Feurstein'" <h.feurstein@...il.com>,
"'rmallon@...il.com'" <rmallon@...il.com>,
"'nicolas.ferre@...el.com'" <nicolas.ferre@...el.com>,
"'balbi@...com'" <balbi@...com>,
"'ben-linux@...ff.org'" <ben-linux@...ff.org>
Subject: RE: [PATCH] i2c-at91: fix data-loss issue
Adrian Yanes wrote on 2012-04-21:
> On the other hand we found that the Underrun Error (UNRE) is not handled
> in the driver. When we send data up > 2-4 bytes (quite random to say
> when it really fails) and we add some dev_dbg() to print
> dev->transfer_status we get 141 (==UNRE). According with the datasheet,
> after the first UNRE received "this action automatically generated a
> STOP bit in Master Mode. Reset by read in TWI_SR when TXCOMP is set."
>
> We thought that one possibility for this was that the board was too slow
> to process the requests or that other interrupts were interfering.
> Disabling the interrupts inside of the twi interrupt handler did not
> help either.
>
> The datasheet does not mention any method to implement some mechanism to
> avoid the UNRE telling the hardware to wait a bit longer for the next
> byte. Thus, one way will be to restart the transfer with the remaining
> bytes (maybe only applicable to at91rm9200) or just to return some
> error/message to userland informing that could not send all the data.
The latter is probably the easiest and most transparent solution.
There is no UNRE on G45, it just pauses the clock on an underrun
condition.
So in case UNRE is set, EIO should be returned similar to the already
handled OVRE:
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index a6f9e73..a84e19b 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -238,6 +238,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
dev_err(dev->dev, "overrun while reading\n");
return -EIO;
}
+ if (dev->transfer_status & AT91_TWI_UNRE && dev->is_rm9200) {
+ dev_err(dev->dev, "underrun while writing\n");
+ return -EIO;
+ }
+
dev_dbg(dev->dev, "transfer complete\n");
return 0;
Powered by blists - more mailing lists