[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <scmsm6wsgspieamsjqftjfdswfmfh5cemiebb6k66qzetdovy5@oa677gskzst4>
Date: Thu, 20 Feb 2025 17:50:39 +0200
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Mark Brown <broonie@...nel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Akhil P Oommen <quic_akhilpo@...cinc.com>,
linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/5] nvmem: core: verify cell's raw_len
On Thu, Feb 20, 2025 at 02:18:06PM +0000, Mark Brown wrote:
> On Wed, Feb 19, 2025 at 05:14:43PM +0200, Dmitry Baryshkov wrote:
> > On Wed, 19 Feb 2025 at 16:51, Mark Brown <broonie@...nel.org> wrote:
> > > On Thu, Jan 09, 2025 at 06:35:46AM +0200, Dmitry Baryshkov wrote:
>
> > > > Check that the NVMEM cell's raw_len is a aligned to word_size. Otherwise
> > > > Otherwise drivers might face incomplete read while accessing the last
> > > > part of the NVMEM cell.
>
> > > I'm seeing a bunch of failures on i.MX platforms in -next which bisect
> > > to this patch. For example on the i.MX6q based UDOOq various things
> > > including the ethernet fail to come up due to the efuse not appearing:
>
> > > [ 1.735264] nvmem imx-ocotp0: cell mac-addr raw len 6 unaligned to nvmem word size 4
> > > [ 1.735289] imx_ocotp 21bc000.efuse: probe with driver imx_ocotp failed with error -22
>
> > This looks like an error on the i.MX platforms. The raw_len must be
> > aligned to word size. I think the easiest fix is to implement the
> > .fixup_dt_cell_info() callback like I did for the qfprom driver.
>
> That sounds pluasible, but as things stand we've got a regression on
> these platforms - taking out ethernet breaks NFS boot apart from
> anything else. I'd also be a bit concerned that there might be other
> users with issues, does this need an audit of users before trying to
> enforce this requirement?
A quick grep shows that there are enough drivers using word size greater
than 1. Would you mind checking if the following patch fixes an issue
for you? (Note, compile-tested only.)
>From 2bde6ec5c9e74771f29170cfa11623208266880b Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
Date: Thu, 20 Feb 2025 17:43:54 +0200
Subject: [PATCH] nvmem: make the misaligned raw_len non-fatal
The commit 11ccaa312111 ("nvmem: core: verify cell's raw_len") enforced
the raw read len being aligned to the NVMEM's word_size. However this
change broke some of the platforms, because those used misaligned
reads. Make this error non-fatal for the drivers that didn't specify
raw_len directly and just increase the raw_len making it aligned.
Fixes: 11ccaa312111 ("nvmem: core: verify cell's raw_len")
Reported-by: Mark Brown <broonie@...nel.org>
Closes: https://lore.kernel.org/linux-arm-msm/Z7Xv9lNc6ckJVtKc@finisterre.sirena.org.uk/
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
---
drivers/nvmem/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b6f8544fd966..e206efc29a00 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -612,7 +612,11 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
"cell %s raw len %zd unaligned to nvmem word size %d\n",
cell->name ?: "<unknown>", cell->raw_len,
nvmem->word_size);
- return -EINVAL;
+
+ if (info->raw_len)
+ return -EINVAL;
+
+ cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size);
}
return 0;
--
2.39.5
--
With best wishes
Dmitry
Powered by blists - more mailing lists