atmel nand controller regression

alucero at os3sl.com alucero at os3sl.com
Sun Jan 26 04:26:26 PST 2025


Hi all,

A Micron 512MB NAND working fine in a 5.4 kernel was not usable in a 
5.15 one. I have not tested with kernels between those two versions, but 
the same problem still appears in a 6.6.51 from the 
https://github.com/linux4microchip/linux.git repo. I do not think this 
is due to being a non vanilla kernel but something which could still be 
happening in current vanilla kernel. In fact, the same function 
apparently being the problem is the same in a 6.13.0 rc5 (which I have 
been working with for other reasons).

The function is atmel_hsmc_nand_waitrdy and the problem being the call 
to atmel_nand_waitrdy if the rb type not being ATMEL_NAND_NATIVE_RB. 
This is used for at least the nand function for reading the params 
following ONFI standard, and being part of that operation is the call to 
this function for waiting the command/transfer to be completed. That 
implies to read from the NFC SRAM for the status, something I do not 
understand since I would expect the status obtained from the proper NFC 
register, HSMC_SR. I do not completely understand this SMC/NFC 
controller, so assuming that is correct, it is affecting the following 
read from the SRAM containing the params, leading to the nand detection 
failure since the crc check fails. In the tests I have done, that is 
only one byte read, but enough for displacing the full params buffer for 
getting wrong data and the crc failing.

The fix which seems to work for me, but not sure it is the proper one, 
in a 6.6 kernel is this one:

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c 
b/drivers/mtd/nand/raw/atmel/nand-controller.c
index 3f494f7c7ecb..a64ecde52e45 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -531,8 +531,10 @@ static int atmel_hsmc_nand_waitrdy(struct 
atmel_nand *nand,
         struct atmel_hsmc_nand_controller *nc;
         u32 status, mask;

+#if 0
         if (nand->activecs->rb.type != ATMEL_NAND_NATIVE_RB)
                 return atmel_nand_waitrdy(nand, timeout_ms);
+#endif

         nc = to_hsmc_nand_controller(nand->base.controller);
         mask = ATMEL_HSMC_NFC_SR_RBEDGE(nand->activecs->rb.id);

what implies the ATMEL_HSMC_NFC_SR polling in that function.

Maybe this is only impacting the ONFI detection when reading the params 
page, but in any case, I hope this report can help for fixing the 
problem properly.

I offer myself for testing the patch to fix this.

Thank you




More information about the linux-mtd mailing list