i2c-rcar: fix MNR interrupt handling
Subsystems (4)
PATCH 1/1 i2c-rcar: fix MNR interrupt handling
Sometimes the MNR and MST interrupts happen simultaneously (stop automatically follows NACK, according to the manuals) and in such case the ID_NACK flag isn't set since the MST interrupt handling precedes MNR and all interrupts are cleared and disabled then, so that MNR interrupt is never noticed -- this causes NACK'ed transfers to be falsely reported as successful. Exchanging MNR and MST handlers fixes this issue, however the MNR bit somehow gets set again even after being explicitly cleared, so I decided to completely suppress handling of all disabled interrupts (which is a good thing anyway)...
---
The patch is against Wolfram Sang's 'linux.git' repo.
drivers/i2c/busses/i2c-rcar.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-rcar.c +9 -6
@@ -367,18 +367,15 @@ static irqreturn_t rcar_i2c_irq(int irq, msr =rcar_i2c_read (priv,ICMSR ); +/* Only handle interrupts that are currently enabled */ + msr &=rcar_i2c_read (priv,ICMIER ); +/* Arbitration lost */ if (msr &MAL ) {rcar_i2c_flags_set (priv, (ID_DONE |ID_ARBLOST )); goto out; } -/* Stop */ -if (msr &MST ) { -rcar_i2c_flags_set (priv,ID_DONE ); - goto out; - } -/* Nack */ if (msr &MNR ) {/* go to stop phase */
@@ -388,6 +385,12 @@ static irqreturn_t rcar_i2c_irq(int irq, goto out; } +/* Stop */ +if (msr &MST ) { +rcar_i2c_flags_set (priv,ID_DONE ); + goto out; + } +if (rcar_i2c_is_recv (priv))rcar_i2c_flags_set (priv,rcar_i2c_irq_recv (priv, msr));else
Wolfram Sang
AppliedQuoted 9 lines · Sergei Shtylyov
Sometimes the MNR and MST interrupts happen simultaneously (stop automatically follows NACK, according to the manuals) and in such case the
ID_NACKflag isn't set since the MST interrupt handling precedes MNR and all interrupts are cleared and disabled then, so that MNR interrupt is never noticed -- this causes NACK'ed transfers to be falsely reported as successful. Exchanging MNR and MST handlers fixes this issue, however the MNR bit somehow gets set again even after being explicitly cleared, so I decided to completely suppress handling of all disabled interrupts (which is a good thing anyway)...
Quoted 3 lines
Signed-off-by Sergei Shtylyov <[email protected]>
Applied to for-current, thanks!
Quoted 23 lines · Sergei Shtylyov
Sometimes the MNR and MST interrupts happen simultaneously (stop automatically follows NACK, according to the manuals) and in such case the
ID_NACKflag isn't set since the MST interrupt handling precedes MNR and all interrupts are cleared and disabled then, so that MNR interrupt is never noticed -- this causes NACK'ed transfers to be falsely reported as successful. Exchanging MNR and MST handlers fixes this issue, however the MNR bit somehow gets set again even after being explicitly cleared, so I decided to completely suppress handling of all disabled interrupts (which is a good thing anyway)...---
The patch is against Wolfram Sang's 'linux.git' repo.drivers/i2c/busses/i2c-rcar.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)Index:
linux/drivers/i2c/busses/i2c-rcar.c
===================================================================
drivers/i2c/busses/i2c-rcar.c static irqreturn_t rcar_i2c_irq(int irq, · line 372
Quoted 6 lines
drivers/i2c/busses/i2c-rcar.c +3
-0@@ -367,18 +367,15 @@ static irqreturn_t rcar_i2c_irq(int irq, msr =rcar_i2c_read (priv,ICMSR ); +/* Only handle interrupts that are currently enabled */ + msr &=rcar_i2c_read (priv,ICMIER ); +
I think it makes sense to check 'msr' for 0 and return IRQ_NONE in this
case. Would you apply such patch (probably to the -next branch)?
WBR, Sergei