Re: [RFC PATCH] mtd: spinand: core: Properly fill the OOB area.

From: Miquel Raynal
Date: Mon Aug 16 2021 - 03:42:31 EST


Hi Daniel,

Daniel Palmer <daniel@xxxxxxxx> wrote on Wed, 11 Aug 2021 16:37:55
+0900:

> Hi Miquel,
>
> On Sat, 7 Aug 2021 at 05:02, Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote:
> > This change looks fine, I'll use spinand->oobbuf instead of databuf +
> > offset (will update when applying).
>
> Thanks for looking at this for me. One thing I was worried about is
> why the SPI NAND subsystem worked before this change with winbond etc
> parts.

I didn't look closely to the history but it is possible that during the
ECC engine framework introduction and the split of the on-die ECC code
the behavior changed (which, in this case, is a regression).

> You probably don't remember now but I sent a patch to include support
> for the longsys foresee parts that have the weird quirk of having no
> ECC
> data in the OOB so it's all usable by the user except for the bad
> block marker and the ECC status bits being next to useless.
> I found this issue while trying to validate ubi + my ECC status
> decoding worked. [0]

Yes I remember now!

> The SPI NAND subsystem in u-boot worked fine as it could create the
> ubi formatting on the flash and that would survive reboots but any
> blocks written by Linux would be bad on reboot.
> When Linux created the ubi format it would work until a reboot as the
> correct data was cached in memory then u-boot would complain because
> all of the blocks were marked bad.
>
> But winbond parts mounted on the same board, same code etc worked just fine.
> I guess the OOB is getting fixed somewhere else for other parts.

I think the reason is that most ECC codes do not cover the OOB part,
hence writing garbage there is not an issue (while with your part, the
OOB area was actually fully protected). But it is certainly best to keep
this area tidy anyway.

> Maybe
> it only happens on the longsys parts because there is no ECC in OOB?
>
> Anyhow I was worried my fix hid some other issue/broke other parts.

I think this patch is legit, I will keep it.

>
> Cheers,
>
> Daniel
>
> 0 - https://lore.kernel.org/lkml/20210408174922.55c1149f@xps13/

Thanks,
Miquèl