All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: davinci: Avoid sending to own address
@ 2015-05-13 13:02 Alexander Sverdlin
       [not found] ` <55534B7A.8070105-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Sverdlin @ 2015-05-13 13:02 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, Kevin Hilman,
	Sekhar Nori, Grygorii Strashko, Santosh Shilimkar,
	Vishwanathrao Badarkhe, Manish, Murali Karicheri
  Cc: Lawnick Michael 61283229, Mike Looijmans, Mastalski Bartosz

Sending a message to own address locks the controller up in very bizarre state,
it behaves as slave even if MDR register clearly states master. The controller
remains in this state until reset. To avoid unnecessary timeouts simply avoid
sending to own address. The controller cannot do this any way. Also, do not
enable AAS IRQ, as the slave mode is not supported by the driver and the only
possibility to trigger this IRQ is to send to own address.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
---
Changes in v2:
- rebased on 110bc76729d4 of Linus's tree;

 drivers/i2c/busses/i2c-davinci.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 4788a32..df96ab6 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -41,8 +41,8 @@
 
 #define DAVINCI_I2C_TIMEOUT	(1*HZ)
 #define DAVINCI_I2C_MAX_TRIES	2
-#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_AAS | \
-				 DAVINCI_I2C_IMR_SCD | \
+#define DAVINCI_I2C_OWN_ADDRESS	0x08
+#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_SCD | \
 				 DAVINCI_I2C_IMR_ARDY | \
 				 DAVINCI_I2C_IMR_NACK | \
 				 DAVINCI_I2C_IMR_AL)
@@ -233,7 +233,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 	/* Respond at reserved "SMBus Host" slave address" (and zero);
 	 * we seem to have no option to not respond...
 	 */
-	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
+	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, DAVINCI_I2C_OWN_ADDRESS);
 
 	dev_dbg(dev->dev, "PSC  = %d\n",
 		davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
@@ -390,6 +390,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
 	u16 w;
 	unsigned long time_left;
 
+	if (msg->addr == DAVINCI_I2C_OWN_ADDRESS)
+		return -EIO;
+
 	/* Introduce a delay, required for some boards (e.g Davinci EVM) */
 	if (pdata->bus_delay)
 		udelay(pdata->bus_delay);

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

* Re: [PATCH v2] i2c: davinci: Avoid sending to own address
       [not found] ` <55534B7A.8070105-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
@ 2015-05-14 11:03   ` Grygorii.Strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
  2015-06-02 15:48   ` Wolfram Sang
  2015-06-09 11:10   ` [PATCH v3] " Alexander Sverdlin
  2 siblings, 0 replies; 5+ messages in thread
From: Grygorii.Strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org @ 2015-05-14 11:03 UTC (permalink / raw)
  To: Alexander Sverdlin, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Wolfram Sang, Kevin Hilman, Sekhar Nori, Santosh Shilimkar,
	Vishwanathrao Badarkhe, Manish, Murali Karicheri
  Cc: Lawnick Michael 61283229, Mike Looijmans, Mastalski Bartosz

On 05/13/2015 04:02 PM, Alexander Sverdlin wrote:
> Sending a message to own address locks the controller up in very bizarre state,
> it behaves as slave even if MDR register clearly states master. The controller
> remains in this state until reset. To avoid unnecessary timeouts simply avoid
> sending to own address. The controller cannot do this any way. Also, do not
> enable AAS IRQ, as the slave mode is not supported by the driver and the only
> possibility to trigger this IRQ is to send to own address.
>

Reviewed-by: Grygorii Strashko <grygorii.strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

> Signed-off-by: Alexander Sverdlin <alexander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> ---
> Changes in v2:
> - rebased on 110bc76729d4 of Linus's tree;
>
>   drivers/i2c/busses/i2c-davinci.c |    9 ++++++---
>   1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index 4788a32..df96ab6 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -41,8 +41,8 @@
>
>   #define DAVINCI_I2C_TIMEOUT	(1*HZ)
>   #define DAVINCI_I2C_MAX_TRIES	2
> -#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_AAS | \
> -				 DAVINCI_I2C_IMR_SCD | \
> +#define DAVINCI_I2C_OWN_ADDRESS	0x08
> +#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_SCD | \
>   				 DAVINCI_I2C_IMR_ARDY | \
>   				 DAVINCI_I2C_IMR_NACK | \
>   				 DAVINCI_I2C_IMR_AL)
> @@ -233,7 +233,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
>   	/* Respond at reserved "SMBus Host" slave address" (and zero);
>   	 * we seem to have no option to not respond...
>   	 */
> -	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
> +	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, DAVINCI_I2C_OWN_ADDRESS);
>
>   	dev_dbg(dev->dev, "PSC  = %d\n",
>   		davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
> @@ -390,6 +390,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
>   	u16 w;
>   	unsigned long time_left;
>
> +	if (msg->addr == DAVINCI_I2C_OWN_ADDRESS)
> +		return -EIO;
> +
>   	/* Introduce a delay, required for some boards (e.g Davinci EVM) */
>   	if (pdata->bus_delay)
>   		udelay(pdata->bus_delay);
>


-- 
regards,
-grygorii

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

* Re: [PATCH v2] i2c: davinci: Avoid sending to own address
       [not found] ` <55534B7A.8070105-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
  2015-05-14 11:03   ` Grygorii.Strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
@ 2015-06-02 15:48   ` Wolfram Sang
  2015-06-09 11:10   ` [PATCH v3] " Alexander Sverdlin
  2 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2015-06-02 15:48 UTC (permalink / raw)
  To: Alexander Sverdlin
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Kevin Hilman, Sekhar Nori,
	Grygorii Strashko, Santosh Shilimkar, Vishwanathrao Badarkhe,
	Manish, Murali Karicheri, Lawnick Michael 61283229,
	Mike Looijmans, Mastalski Bartosz

[-- Attachment #1: Type: text/plain, Size: 534 bytes --]

On Wed, May 13, 2015 at 03:02:50PM +0200, Alexander Sverdlin wrote:
> Sending a message to own address locks the controller up in very bizarre state,
> it behaves as slave even if MDR register clearly states master. The controller

Eeks...

>  
> +	if (msg->addr == DAVINCI_I2C_OWN_ADDRESS)
> +		return -EIO;

I think we should return at least -EADDRNOTAVAIL here. Otherwise the
user might wonder if the slave is broken giving always IO errors. Maybe
we should also add a warning message, I leave that decision to you.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH v3] i2c: davinci: Avoid sending to own address
       [not found] ` <55534B7A.8070105-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
  2015-05-14 11:03   ` Grygorii.Strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
  2015-06-02 15:48   ` Wolfram Sang
@ 2015-06-09 11:10   ` Alexander Sverdlin
       [not found]     ` <5576C992.3060604-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
  2 siblings, 1 reply; 5+ messages in thread
From: Alexander Sverdlin @ 2015-06-09 11:10 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang, Kevin Hilman,
	Sekhar Nori, Grygorii Strashko, Santosh Shilimkar,
	Vishwanathrao Badarkhe, Manish, Murali Karicheri
  Cc: Lawnick Michael 61283229, Mike Looijmans, Mastalski Bartosz

Sending a message to own address locks the controller up in very bizarre state,
it behaves as slave even if MDR register clearly states master. The controller
remains in this state until reset. To avoid unnecessary timeouts simply avoid
sending to own address. The controller cannot do this any way. Also, do not
enable AAS IRQ, as the slave mode is not supported by the driver and the only
possibility to trigger this IRQ is to send to own address.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
---
Changes in v3:
- return -EADDRNOTAVAIL instead of -EIO;
- emit a warning
Changes in v2:
- rebased on 110bc76729d4 of Linus's tree;

 drivers/i2c/busses/i2c-davinci.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index ab341aa..3d3ae52 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -41,8 +41,8 @@
 
 #define DAVINCI_I2C_TIMEOUT	(1*HZ)
 #define DAVINCI_I2C_MAX_TRIES	2
-#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_AAS | \
-				 DAVINCI_I2C_IMR_SCD | \
+#define DAVINCI_I2C_OWN_ADDRESS	0x08
+#define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_SCD | \
 				 DAVINCI_I2C_IMR_ARDY | \
 				 DAVINCI_I2C_IMR_NACK | \
 				 DAVINCI_I2C_IMR_AL)
@@ -233,7 +233,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 	/* Respond at reserved "SMBus Host" slave address" (and zero);
 	 * we seem to have no option to not respond...
 	 */
-	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
+	davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, DAVINCI_I2C_OWN_ADDRESS);
 
 	dev_dbg(dev->dev, "PSC  = %d\n",
 		davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
@@ -386,6 +386,11 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
 	u16 w;
 	unsigned long time_left;
 
+	if (msg->addr == DAVINCI_I2C_OWN_ADDRESS) {
+		dev_warn(dev->dev, "transfer to own address aborted\n");
+		return -EADDRNOTAVAIL;
+	}
+
 	/* Introduce a delay, required for some boards (e.g Davinci EVM) */
 	if (pdata->bus_delay)
 		udelay(pdata->bus_delay);

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

* Re: [PATCH v3] i2c: davinci: Avoid sending to own address
       [not found]     ` <5576C992.3060604-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
@ 2015-06-10 13:13       ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2015-06-10 13:13 UTC (permalink / raw)
  To: Alexander Sverdlin
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Kevin Hilman, Sekhar Nori,
	Grygorii Strashko, Santosh Shilimkar, Vishwanathrao Badarkhe,
	Manish, Murali Karicheri, Lawnick Michael 61283229,
	Mike Looijmans, Mastalski Bartosz

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Tue, Jun 09, 2015 at 01:10:10PM +0200, Alexander Sverdlin wrote:
> Sending a message to own address locks the controller up in very bizarre state,
> it behaves as slave even if MDR register clearly states master. The controller
> remains in this state until reset. To avoid unnecessary timeouts simply avoid
> sending to own address. The controller cannot do this any way. Also, do not
> enable AAS IRQ, as the slave mode is not supported by the driver and the only
> possibility to trigger this IRQ is to send to own address.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>

Applied to for-next, thanks!

Please don't send new patch versions as replies to old versions!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-06-10 13:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-13 13:02 [PATCH v2] i2c: davinci: Avoid sending to own address Alexander Sverdlin
     [not found] ` <55534B7A.8070105-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2015-05-14 11:03   ` Grygorii.Strashko-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
2015-06-02 15:48   ` Wolfram Sang
2015-06-09 11:10   ` [PATCH v3] " Alexander Sverdlin
     [not found]     ` <5576C992.3060604-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2015-06-10 13:13       ` Wolfram Sang

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.