diff mbox series

[PATCHv5] i2c: cadence: Fix the hold bit setting

Message ID 1549349115-30606-1-git-send-email-shubhrajyoti.datta@xilinx.com
State Superseded
Headers show
Series [PATCHv5] i2c: cadence: Fix the hold bit setting | expand

Commit Message

Shubhrajyoti Datta Feb. 5, 2019, 6:45 a.m. UTC
In case the hold bit is not needed we are carrying the old values.
Fix the same by resetting the bit when not needed.

Fixes the sporadic i2c bus lockups on National Instruments
Zynq-based devices.


Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller")
Acked-by: Michal Simek <michal.simek@xilinx.com>
Reported-and-tested-by: Kyle Roeschley <kyle.roeschley@ni.com>
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
v5:
fix some typos
v4:
update fixes tag
v3:
Add fixes and Ack
v2:
Update commit log
Also check if the hold_flag

 drivers/i2c/busses/i2c-cadence.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--
2.1.1

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

Comments

Shubhrajyoti Datta Feb. 5, 2019, 11:13 a.m. UTC | #1
Hi,

Please ignore will resend.

On Tue, Feb 5, 2019 at 12:15 PM Shubhrajyoti Datta
<shubhrajyoti.datta@xilinx.com> wrote:
>
> In case the hold bit is not needed we are carrying the old values.
> Fix the same by resetting the bit when not needed.
>
> Fixes the sporadic i2c bus lockups on National Instruments
> Zynq-based devices.
>
>
> Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller")
> Acked-by: Michal Simek <michal.simek@xilinx.com>
> Reported-and-tested-by: Kyle Roeschley <kyle.roeschley@ni.com>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v5:
> fix some typos
> v4:
> update fixes tag
> v3:
> Add fixes and Ack
> v2:
> Update commit log
> Also check if the hold_flag
>
>  drivers/i2c/busses/i2c-cadence.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index 9260574..42c38fd 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -628,8 +628,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
>          * Check for the message size against FIFO depth and set the
>          * 'hold bus' bit if it is greater than FIFO depth.
>          */
> -       if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
> +       if ((id->recv_count > CDNS_I2C_FIFO_DEPTH)  || id->bus_hold_flag)
>                 ctrl_reg |= CDNS_I2C_CR_HOLD;
> +       else
> +               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
>
>         cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
>
> @@ -686,8 +688,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)
>          * Check for the message size against FIFO depth and set the
>          * 'hold bus' bit if it is greater than FIFO depth.
>          */
> -       if (id->send_count > CDNS_I2C_FIFO_DEPTH)
> +       if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
>                 ctrl_reg |= CDNS_I2C_CR_HOLD;
> +       else
> +               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
> +
>         cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
>
>         /* Clear the interrupts in interrupt status register. */
> --
> 2.1.1
>
> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
Peter Rosin Feb. 5, 2019, 12:28 p.m. UTC | #2
On 2019-02-05 07:45, Shubhrajyoti Datta wrote:
> In case the hold bit is not needed we are carrying the old values.
> Fix the same by resetting the bit when not needed.
> 
> Fixes the sporadic i2c bus lockups on National Instruments
> Zynq-based devices.
> 
> 
> Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller")
> Acked-by: Michal Simek <michal.simek@xilinx.com>
> Reported-and-tested-by: Kyle Roeschley <kyle.roeschley@ni.com>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v5:
> fix some typos
> v4:
> update fixes tag
> v3:
> Add fixes and Ack
> v2:
> Update commit log
> Also check if the hold_flag
> 
>  drivers/i2c/busses/i2c-cadence.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
> index 9260574..42c38fd 100644
> --- a/drivers/i2c/busses/i2c-cadence.c
> +++ b/drivers/i2c/busses/i2c-cadence.c
> @@ -628,8 +628,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
>          * Check for the message size against FIFO depth and set the
>          * 'hold bus' bit if it is greater than FIFO depth.
>          */
> -       if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
> +       if ((id->recv_count > CDNS_I2C_FIFO_DEPTH)  || id->bus_hold_flag)
>                 ctrl_reg |= CDNS_I2C_CR_HOLD;
> +       else
> +               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;

If you're resending anyway, I'd write this as

               ctrl_reg &= ~CDNS_I2C_CR_HOLD;

That's more in line with what the original code looks like.

> 
>         cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
> 
> @@ -686,8 +688,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)
>          * Check for the message size against FIFO depth and set the
>          * 'hold bus' bit if it is greater than FIFO depth.
>          */
> -       if (id->send_count > CDNS_I2C_FIFO_DEPTH)
> +       if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
>                 ctrl_reg |= CDNS_I2C_CR_HOLD;
> +       else
> +               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;

Same here, of course.

Cheers,
Peter

> +
>         cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
> 
>         /* Clear the interrupts in interrupt status register. */
> --
> 2.1.1
> 
> This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
>
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 9260574..42c38fd 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -628,8 +628,10 @@  static void cdns_i2c_mrecv(struct cdns_i2c *id)
         * Check for the message size against FIFO depth and set the
         * 'hold bus' bit if it is greater than FIFO depth.
         */
-       if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
+       if ((id->recv_count > CDNS_I2C_FIFO_DEPTH)  || id->bus_hold_flag)
                ctrl_reg |= CDNS_I2C_CR_HOLD;
+       else
+               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;

        cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);

@@ -686,8 +688,11 @@  static void cdns_i2c_msend(struct cdns_i2c *id)
         * Check for the message size against FIFO depth and set the
         * 'hold bus' bit if it is greater than FIFO depth.
         */
-       if (id->send_count > CDNS_I2C_FIFO_DEPTH)
+       if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
                ctrl_reg |= CDNS_I2C_CR_HOLD;
+       else
+               ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
+
        cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);

        /* Clear the interrupts in interrupt status register. */