Message ID | 20221014170426.1.Ifa806ff30d7c669ba9a3df9c6b64698a2dcc073a@changeid (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] nvmem: stm32: add warning when upper OTPs are updated | expand |
Hi, On 10/14/22 17:04, Patrick Delaunay wrote: > As the upper OTPs are ECC protected, they support only one 32 bits word > programming. > For a second modification of this word, these ECC become invalid and > this OTP will be no more accessible, the shadowed value is invalid. > > This patch adds a warning to indicate an upper OTP update, because this > operation is dangerous as OTP is not locked by the driver after the first > update to avoid a second update. > > Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> > --- > > drivers/nvmem/stm32-romem.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c > index 354be526897f..e3c3c333b5d1 100644 > --- a/drivers/nvmem/stm32-romem.c > +++ b/drivers/nvmem/stm32-romem.c > @@ -133,6 +133,9 @@ static int stm32_bsec_write(void *context, unsigned int offset, void *buf, > } > } > > + if (offset + bytes >= priv->lower * 4) Here I miss a dependency for "priv->lower" with a other preliminary patch for STM32MP13x support. > + dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n"); > + > return 0; > } > Sorry, I will sent a V2 soon Patrick
diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c index 354be526897f..e3c3c333b5d1 100644 --- a/drivers/nvmem/stm32-romem.c +++ b/drivers/nvmem/stm32-romem.c @@ -133,6 +133,9 @@ static int stm32_bsec_write(void *context, unsigned int offset, void *buf, } } + if (offset + bytes >= priv->lower * 4) + dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n"); + return 0; }
As the upper OTPs are ECC protected, they support only one 32 bits word programming. For a second modification of this word, these ECC become invalid and this OTP will be no more accessible, the shadowed value is invalid. This patch adds a warning to indicate an upper OTP update, because this operation is dangerous as OTP is not locked by the driver after the first update to avoid a second update. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> --- drivers/nvmem/stm32-romem.c | 3 +++ 1 file changed, 3 insertions(+)