[PATCH v4 5/5] i3c: master: svc: Fix npcm845 DAA process corruption

Stanley Chu posted 5 patches 11 months, 2 weeks ago
There is a newer version of this series
[PATCH v4 5/5] i3c: master: svc: Fix npcm845 DAA process corruption
Posted by Stanley Chu 11 months, 2 weeks ago
From: Stanley Chu <yschu@nuvoton.com>

When MCONFIG.SKEW=0 and MCONFIG.ODHPP=0, the ENTDAA transaction gets
corrupted and results in a no repeated-start condition at the end of
address assignment.

Workaround: Set MCONFIG.SKEW to 1 before initiating the DAA process.
After the DAA process is completed, return MCONFIG.SKEW to its previous
value.

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
 drivers/i3c/master/svc-i3c-master.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 4eb4b8888725..403d625e999e 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -1162,7 +1162,16 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
 	}
 
 	spin_lock_irqsave(&master->xferqueue.lock, flags);
+
+	if (svc_has_quirk(master, SVC_I3C_QUIRK_DAA_CORRUPT))
+		writel(master->mctrl_config | SVC_I3C_MCONFIG_SKEW(1),
+		       master->regs + SVC_I3C_MCONFIG);
+
 	ret = svc_i3c_master_do_daa_locked(master, addrs, &dev_nb);
+
+	if (svc_has_quirk(master, SVC_I3C_QUIRK_DAA_CORRUPT))
+		writel(master->mctrl_config, master->regs + SVC_I3C_MCONFIG);
+
 	spin_unlock_irqrestore(&master->xferqueue.lock, flags);
 
 	svc_i3c_master_clear_merrwarn(master);
-- 
2.34.1
Re: [PATCH v4 5/5] i3c: master: svc: Fix npcm845 DAA process corruption
Posted by Markus Elfring 11 months, 2 weeks ago
…
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -1162,7 +1162,16 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
>  	}
>
>  	spin_lock_irqsave(&master->xferqueue.lock, flags);
…
>  	spin_unlock_irqrestore(&master->xferqueue.lock, flags);
>
>  	svc_i3c_master_clear_merrwarn(master);
…

Under which circumstances would you become interested to apply a statement
like “guard(spinlock_irqsave)(&master->xferqueue.lock);”?
https://elixir.bootlin.com/linux/v6.14-rc4/source/include/linux/spinlock.h#L572

Regards,
Markus
Re: [PATCH v4 5/5] i3c: master: svc: Fix npcm845 DAA process corruption
Posted by Frank Li 11 months, 2 weeks ago
On Mon, Feb 24, 2025 at 04:39:08PM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> When MCONFIG.SKEW=0 and MCONFIG.ODHPP=0, the ENTDAA transaction gets
> corrupted and results in a no repeated-start condition at the end of
> address assignment.

If there are errata doc, provide a link will be appeciated.

>
> Workaround: Set MCONFIG.SKEW to 1 before initiating the DAA process.
> After the DAA process is completed, return MCONFIG.SKEW to its previous
> value.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
>  drivers/i3c/master/svc-i3c-master.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 4eb4b8888725..403d625e999e 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -1162,7 +1162,16 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m)
>  	}
>
>  	spin_lock_irqsave(&master->xferqueue.lock, flags);
> +
> +	if (svc_has_quirk(master, SVC_I3C_QUIRK_DAA_CORRUPT))
> +		writel(master->mctrl_config | SVC_I3C_MCONFIG_SKEW(1),
> +		       master->regs + SVC_I3C_MCONFIG);
> +
>  	ret = svc_i3c_master_do_daa_locked(master, addrs, &dev_nb);
> +
> +	if (svc_has_quirk(master, SVC_I3C_QUIRK_DAA_CORRUPT))
> +		writel(master->mctrl_config, master->regs + SVC_I3C_MCONFIG);
> +
>  	spin_unlock_irqrestore(&master->xferqueue.lock, flags);
>
>  	svc_i3c_master_clear_merrwarn(master);
> --
> 2.34.1
>