diff mbox series

[2/2] i2c: rcar: explain the lockless design

Message ID 20190303150314.6528-3-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series i2c: rcar: improve concurrency | expand

Commit Message

Wolfram Sang March 3, 2019, 3:03 p.m. UTC
To make sure people can understand the lockless design of this driver
without the need to dive into git history, add a comment giving an
overview of the situation.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-rcar.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Simon Horman March 6, 2019, 12:59 p.m. UTC | #1
On Sun, Mar 03, 2019 at 04:03:14PM +0100, Wolfram Sang wrote:
> To make sure people can understand the lockless design of this driver
> without the need to dive into git history, add a comment giving an
> overview of the situation.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/i2c/busses/i2c-rcar.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index 6410896f717b..3ce74edcd70c 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -611,6 +611,15 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
>  	return true;
>  }
>  
> +/*
> + * This driver has a lock-free design because there are IP cores (at least
> + * R-Car Gen2) which have an inherent race condition in their hardware design.
> + * There, we need to clear RCAR_BUS_MASK_DATA bits as soon as possible after
> + * the interrupt was generated, otherwise an unwanted repeated message gets
> + * generated. It turned out that taking a spinlock at the beginning of the ISR
> + * was already causing repeated messages. Thus, this driver was converted to
> + * the now lockless behaviour. Please keep this in mind when hacking the driver.
> + */
>  static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
>  {
>  	struct rcar_i2c_priv *priv = ptr;
> -- 
> 2.11.0
>
Wolfram Sang March 9, 2019, 10:11 a.m. UTC | #2
On Sun, Mar 03, 2019 at 04:03:14PM +0100, Wolfram Sang wrote:
> To make sure people can understand the lockless design of this driver
> without the need to dive into git history, add a comment giving an
> overview of the situation.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 6410896f717b..3ce74edcd70c 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -611,6 +611,15 @@  static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
 	return true;
 }
 
+/*
+ * This driver has a lock-free design because there are IP cores (at least
+ * R-Car Gen2) which have an inherent race condition in their hardware design.
+ * There, we need to clear RCAR_BUS_MASK_DATA bits as soon as possible after
+ * the interrupt was generated, otherwise an unwanted repeated message gets
+ * generated. It turned out that taking a spinlock at the beginning of the ISR
+ * was already causing repeated messages. Thus, this driver was converted to
+ * the now lockless behaviour. Please keep this in mind when hacking the driver.
+ */
 static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
 {
 	struct rcar_i2c_priv *priv = ptr;