* [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used
@ 2023-02-15 11:08 Christophe JAILLET
2023-02-15 13:09 ` Miquel Raynal
2023-03-07 19:21 ` Miquel Raynal
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-02-15 11:08 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-mtd
wait_for_completion_timeout() and readl_poll_timeout() don't handle their
return value the same way.
wait_for_completion_timeout() returns 0 on time out (and >0 in all other
cases)
readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout.
In order for the error handling path to work in both cases, the logic
against wait_for_completion_timeout() needs to be inverted.
Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
This is really spurious.
If I'm right, this means that it never worked!
Can any one with the hardware test?
---
drivers/mtd/nand/ecc-mxic.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/ecc-mxic.c b/drivers/mtd/nand/ecc-mxic.c
index 8afdca731b87..6b487ffe2f2d 100644
--- a/drivers/mtd/nand/ecc-mxic.c
+++ b/drivers/mtd/nand/ecc-mxic.c
@@ -429,6 +429,7 @@ static int mxic_ecc_data_xfer_wait_for_completion(struct mxic_ecc_engine *mxic)
mxic_ecc_enable_int(mxic);
ret = wait_for_completion_timeout(&mxic->complete,
msecs_to_jiffies(1000));
+ ret = ret ? 0 : -ETIMEDOUT;
mxic_ecc_disable_int(mxic);
} else {
ret = readl_poll_timeout(mxic->regs + INTRPT_STS, val,
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used
2023-02-15 11:08 [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used Christophe JAILLET
@ 2023-02-15 13:09 ` Miquel Raynal
2023-03-07 19:21 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2023-02-15 13:09 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Richard Weinberger, Vignesh Raghavendra, linux-kernel,
kernel-janitors, linux-mtd
Hi Christophe,
christophe.jaillet@wanadoo.fr wrote on Wed, 15 Feb 2023 12:08:45 +0100:
> wait_for_completion_timeout() and readl_poll_timeout() don't handle their
> return value the same way.
>
> wait_for_completion_timeout() returns 0 on time out (and >0 in all other
> cases)
> readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout.
That's a shame, but yeah, excellent catch!
> In order for the error handling path to work in both cases, the logic
> against wait_for_completion_timeout() needs to be inverted.
>
> Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
>
> This is really spurious.
> If I'm right, this means that it never worked!
>
> Can any one with the hardware test?
The design I used for development and testing had no interrupt line
available for that IIRC, so I only tested the polling case ('else'
side) and completely overlooked that difference. I might have mentioned
it in the cover letter, if I didn't, it's an oversight.
> ---
> drivers/mtd/nand/ecc-mxic.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/ecc-mxic.c b/drivers/mtd/nand/ecc-mxic.c
> index 8afdca731b87..6b487ffe2f2d 100644
> --- a/drivers/mtd/nand/ecc-mxic.c
> +++ b/drivers/mtd/nand/ecc-mxic.c
> @@ -429,6 +429,7 @@ static int mxic_ecc_data_xfer_wait_for_completion(struct mxic_ecc_engine *mxic)
> mxic_ecc_enable_int(mxic);
> ret = wait_for_completion_timeout(&mxic->complete,
> msecs_to_jiffies(1000));
> + ret = ret ? 0 : -ETIMEDOUT;
> mxic_ecc_disable_int(mxic);
> } else {
> ret = readl_poll_timeout(mxic->regs + INTRPT_STS, val,
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used
2023-02-15 11:08 [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used Christophe JAILLET
2023-02-15 13:09 ` Miquel Raynal
@ 2023-03-07 19:21 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2023-03-07 19:21 UTC (permalink / raw)
To: Christophe JAILLET, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra
Cc: linux-kernel, kernel-janitors, linux-mtd
On Wed, 2023-02-15 at 11:08:45 UTC, Christophe JAILLET wrote:
> wait_for_completion_timeout() and readl_poll_timeout() don't handle their
> return value the same way.
>
> wait_for_completion_timeout() returns 0 on time out (and >0 in all other
> cases)
> readl_poll_timeout() returns 0 on success and -ETIMEDOUT upon a timeout.
>
> In order for the error handling path to work in both cases, the logic
> against wait_for_completion_timeout() needs to be inverted.
>
> Fixes: 48e6633a9fa2 ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-07 19:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 11:08 [PATCH] mtd: nand: mxic-ecc: Fix mxic_ecc_data_xfer_wait_for_completion() when irq is used Christophe JAILLET
2023-02-15 13:09 ` Miquel Raynal
2023-03-07 19:21 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox