From nobody Sat Feb 7 21:05:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 466CB3101C5 for ; Fri, 14 Nov 2025 11:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118423; cv=none; b=eP8+B584LPQ29twuoRLzh7Ux5wZ8uwpsyiJR1T9J9R4XnAx+U5XXX8bD/4Q/Lxsu7mm7APsqDpVf5aX9ZzbEFtOVTcghSTvpkukl6PvkNDBnF/D+0RbcfFCPKhSBr3ufz9Vk7rNLrTowQAvUVSQfUuBDYPLyY+Ts2P2k661FDp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118423; c=relaxed/simple; bh=3zn898ph6csNAD4s2vNo4jJ+Nl98+U50PrFRSjm0sHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BDgXtuaHKrYebalEJbmdURmYTUFlhGQIGdt6gclzP+wWkrx7nmbtUmxEOkxlPXF9c/xPa2OfGCrufxcS1ZEEwJLP91dEsxr7jded00ElNVQq2B4wJ4fHsxed2u/PEWKbQ4VsoCRb/xmOiBBMzNUuMGvMtHXhO3ObVg/pnHqsoxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AcE/r09A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AcE/r09A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8BAEC4CEFB; Fri, 14 Nov 2025 11:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763118421; bh=3zn898ph6csNAD4s2vNo4jJ+Nl98+U50PrFRSjm0sHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AcE/r09A5m7AkYjwqkDMVdbQncZidngct7tup++ud8CE1x7zCoIWZZ/gCuaBXhWgc 4I5w3BmgPV6KNs9ogHGCcza8OkZq/URYBWmMQbW1Yi1HtRidW6HLUnohw7+ece2x+8 2G4RkbwUQU3A4ftXZzhj9BsEm3pcVbc4MrNlBOlcnpZrY0vgG86XUfNTy8A455zJm0 RkT9Rae360XT91cgE44Qo78uTTSDze3g93VDa2ga393aXgatvU+8GtD4AkEK0xOZ9W mRjhjwLLE6tqtiKmAwfYdGVqSM/FZEvje66bFR8XoilHQ8DaDY5vFzGmzhaZ/AMo/E 7DVe/lcAdJYtQ== From: srini@kernel.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Jascha Sundaresan , "Rob Herring (Arm)" , Srinivas Kandagatla Subject: [PATCH 4/8] nvmem: layouts: u-boot-env: add optional "env-size" property Date: Fri, 14 Nov 2025 11:06:32 +0000 Message-ID: <20251114110636.143268-5-srini@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251114110636.143268-1-srini@kernel.org> References: <20251114110636.143268-1-srini@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jascha Sundaresan Some devices reserve a larger NVMEM region for the U-Boot environment than the actual environment data length used by U-Boot itself. The CRC32 in the U-Boot header is calculated over the smaller data length, causing CRC validation to fail when Linux reads the full partition. Allow an optional device tree property "env-size" to specify the environment data size to use for CRC computation. v2: add missing $ref line to DT binding Signed-off-by: Jascha Sundaresan Reviewed-by: Rob Herring (Arm) Signed-off-by: Srinivas Kandagatla --- .../devicetree/bindings/nvmem/layouts/u-boot,env.yaml | 7 +++++++ drivers/nvmem/layouts/u-boot-env.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yam= l b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml index 56a8f55d4a09..e9e75c38bd11 100644 --- a/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml +++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml @@ -46,6 +46,12 @@ properties: type: object description: Command to use for automatic booting =20 + env-size: + description: + Size in bytes of the environment data used by U-Boot for CRC + calculation. If omitted, the full NVMEM region size is used. + $ref: /schemas/types.yaml#/definitions/uint32 + ethaddr: type: object description: Ethernet interfaces base MAC address. @@ -104,6 +110,7 @@ examples: =20 partition-u-boot-env { compatible =3D "brcm,env"; + env-size =3D <0x20000>; =20 ethaddr { }; diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-b= oot-env.c index a27eeb08146f..ab32bf1291af 100644 --- a/drivers/nvmem/layouts/u-boot-env.c +++ b/drivers/nvmem/layouts/u-boot-env.c @@ -99,10 +99,12 @@ int u_boot_env_parse(struct device *dev, struct nvmem_d= evice *nvmem, uint32_t crc32; uint32_t calc; uint8_t *buf; + u32 env_size; int bytes; int err; =20 - dev_size =3D nvmem_dev_size(nvmem); + dev_size =3D device_property_read_u32(dev, "env-size", &env_size) ? + nvmem_dev_size(nvmem) : (size_t)env_size; =20 buf =3D kzalloc(dev_size, GFP_KERNEL); if (!buf) { --=20 2.51.0