Re: [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
From: Alexey Charkov
Date: Wed Nov 25 2026 - 09:42:10 EST
On Wed, Nov 25, 2026 at 6:21 PM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> > > +static int rockchip_otp_cpuid_pp(void *priv, const char *id, int index,
> > > + unsigned int offset, void *buf, size_t bytes)
> > > +{
> > > + char cpuid[ROCKCHIP_CPUID_LEN * 2];
> > > + u8 digest[SHA256_DIGEST_SIZE];
> > > + u8 *mac = buf;
> > > +
> > > + if (!id || strcmp(id, "mac-address"))
> > > + return 0;
>
> I don't know OTP drivers. But to me, a function called
> rockchip_otp_cpuid_pp() which does not actually return the CPU ID is
> architecturally wrong.
There is precedent for this at least in IMX [1], [2]. To me the
interpretation is "Rockchip CPU ID used as a MAC address base with
offset X", which is exactly what the derivation does. IMO, this is
less clunky than the alternatives (e.g., a custom NVMEM layout which I
used in v1-v2; a "virtual" NVMEM driver referencing the real cell and
returning the processed one, which Ryan proposed in v2 discussion, or
caller-side processing).
[1] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/nvmem/imx-ocotp.c#L224-L238
[2] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/nvmem/imx-ocotp-ele.c#L115-L129
> I would probably not mangle the CPU ID in the OTP driver, but in the
> MAC driver. The MAC driver should ask for the CPU ID and then hash it.
This would then tie the address derivation logic to a specific MAC
driver, rather than to the platform, and it won't work for boards
using other MACs (such as PCIe connected ones).
Best regards,
Alexey