Re: [PATCH v2] mtd: limit OTP NVMEM Cell parse to non Nand devices

From: Miquel Raynal
Date: Thu Mar 21 2024 - 09:19:55 EST


Hi,

ansuelsmth@xxxxxxxxx wrote on Thu, 21 Mar 2024 11:34:16 +0100:

> On Thu, Mar 21, 2024 at 11:32:56AM +0100, Miquel Raynal wrote:
> > Hi Christian,
> >
> > ansuelsmth@xxxxxxxxx wrote on Thu, 21 Mar 2024 10:55:13 +0100:
> >
> > > MTD OTP logic is very fragile and can be problematic with some specific
> > > kind of devices.
> > >
> > > NVMEM across the years had various iteration on how Cells could be
> > > declared in DT and MTD OTP probably was left behind and
> > > add_legacy_fixed_of_cells was enabled without thinking of the consequences.
> > >
> > > That option enables NVMEM to scan the provided of_node and treat each
> > > child as a NVMEM Cell, this was to support legacy NVMEM implementation
> > > and don't cause regression.
> > >
> > > This is problematic if we have devices like Nand where the OTP is
> > > triggered by setting a special mode in the flash. In this context real
> > > partitions declared in the Nand node are registered as OTP Cells and
> > > this cause probe fail with -EINVAL error.
> > >
> > > This was never notice due to the fact that till now, no Nand supported
> > > the OTP feature. With commit e87161321a40 ("mtd: rawnand: macronix: OTP
> > > access for MX30LFxG18AC") this changed and coincidentally this Nand is
> > > used on an FritzBox 7530 supported on OpenWrt.
> > >
> > > Alternative and more robust way to declare OTP Cells are already
> > > prossible by using the fixed-layout node or by declaring a child node
> > > with the compatible set to "otp-user" or "otp-factory".
> > >
> > > To fix this and limit any regression with other MTD that makes use of
> > > declaring OTP as direct child of the dev node, disable
> > > add_legacy_fixed_of_cells if we have a node called nand since it's the
> > > standard property name to identify Nand devices attached to a Nand
> > > Controller.
> >
> > You forgot to update the commit log :-)
> >
>
> Ugh... sorry. Ok to resend or I need to wait 24h similar to the rules on
> net-next?
>

You can go ahead, but I'll only queue it after -rc1 is out.

Thanks,
Miquèl