All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: tmio: Always check for errors after receiving an IRQ
@ 2023-10-14 21:56 Marek Vasut
  2023-10-26  8:42 ` Yoshihiro Shimoda
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2023-10-14 21:56 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Jaehoon Chung, Nobuhiro Iwamatsu, Peng Fan

Unconditionally check for errors even after successful reception
of IRQ flag, since the hardware may set both an IRQ completion
flag and an error flag at the same time.

This mode of failure happens in case of an error during transfer,
in which case the hardware may set the expected IRQ completion
flag as well as error flags. The later is currently not checked
by the driver and such an error is not detected. Improve the
error detection.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Peng Fan <peng.fan@nxp.com>
---
 drivers/mmc/tmio-common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index d1e26815996..83eaf361f0c 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -122,7 +122,10 @@ static int tmio_sd_wait_for_irq(struct udevice *dev, struct mmc_cmd *cmd,
 	long wait = 1000000;
 	int ret;
 
-	while (!(tmio_sd_readl(priv, reg) & flag)) {
+	while (true) {
+		if (tmio_sd_readl(priv, reg) & flag)
+			return tmio_sd_check_error(dev, cmd);
+
 		if (wait-- < 0) {
 			dev_err(dev, "timeout\n");
 			return -ETIMEDOUT;
-- 
2.42.0


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

* RE: [PATCH] mmc: tmio: Always check for errors after receiving an IRQ
  2023-10-14 21:56 [PATCH] mmc: tmio: Always check for errors after receiving an IRQ Marek Vasut
@ 2023-10-26  8:42 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 2+ messages in thread
From: Yoshihiro Shimoda @ 2023-10-26  8:42 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Jaehoon Chung, Nobuhiro Iwamatsu, Peng Fan, Nguyen Hong Thuan

Hello Marek-san,

> From: U-Boot  On Behalf Of Marek Vasut, Sent: Sunday, October 15, 2023 6:56 AM
> 
> Unconditionally check for errors even after successful reception
> of IRQ flag, since the hardware may set both an IRQ completion
> flag and an error flag at the same time.
> 
> This mode of failure happens in case of an error during transfer,
> in which case the hardware may set the expected IRQ completion
> flag as well as error flags. The later is currently not checked
> by the driver and such an error is not detected. Improve the
> error detection.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
> Cc: Peng Fan <peng.fan@nxp.com>
> ---

Thank you for the patch. It looks good to me. So,

Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Also, our outsourcing member tested it on R-Car H3 Salvator-XS and
it works without any regression. So,

Tested-by: Thuan Nguyen Hong <thuan.nguyen-hong@banvien.com.vn>

Best regards,
Yoshihiro Shimoda

>  drivers/mmc/tmio-common.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
> index d1e26815996..83eaf361f0c 100644
> --- a/drivers/mmc/tmio-common.c
> +++ b/drivers/mmc/tmio-common.c
> @@ -122,7 +122,10 @@ static int tmio_sd_wait_for_irq(struct udevice *dev, struct mmc_cmd *cmd,
>  	long wait = 1000000;
>  	int ret;
> 
> -	while (!(tmio_sd_readl(priv, reg) & flag)) {
> +	while (true) {
> +		if (tmio_sd_readl(priv, reg) & flag)
> +			return tmio_sd_check_error(dev, cmd);
> +
>  		if (wait-- < 0) {
>  			dev_err(dev, "timeout\n");
>  			return -ETIMEDOUT;
> --
> 2.42.0


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

end of thread, other threads:[~2023-10-26  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-14 21:56 [PATCH] mmc: tmio: Always check for errors after receiving an IRQ Marek Vasut
2023-10-26  8:42 ` Yoshihiro Shimoda

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.