From: Andrew Lunn <andrew@lunn.ch>
To: Alexey Charkov <alchark@flipper.net>
Cc: "Ryan Leung" <untilscour@protonmail.com>,
"Srinivas Kandagatla" <srini@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Rafał Miłecki" <rafal@milecki.pl>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Simon Horman" <horms@kernel.org>,
"Ricardo Pardini" <ricardo@pardini.net>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
Date: Wed, 25 Nov 2026 16:23:20 +0100 [thread overview]
Message-ID: <1defc5c8-ba61-40d2-99f3-6654f1743af1@lunn.ch> (raw)
In-Reply-To: <CAKTNdwG1sSBVKcKpHBj24nFCdc6WVKabV5=K4sJFucWpTLqRQQ@mail.gmail.com>
On Wed, Nov 25, 2026 at 06:41:42PM +0400, Alexey Charkov wrote:
> On Wed, Nov 25, 2026 at 6:21 PM Andrew Lunn <andrew@lunn.ch> 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
I would say this one is different. The cell specifically contains the
MAC address. But its endianness is wrong. Nothing about CPU ID here.
> [2] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/nvmem/imx-ocotp-ele.c#L115-L129
And this seems to be the same.
As i said, i don't like the concept that a function called
rockchip_otp_cpuid_pp() returns something which is not a CPU ID. The
two examples you give ask for a MAC address, and they get a MAC
address.
Does nvmem support aliases? Can you put two different names on the
same cell? If you access the cell via the name cpu-id, it calls a
function _cpu_id_, it gives you the CPU ID. If you access the cell via
the name mac-address, it calls a function called _mac_address_, and it
gives you a MAC address.
That way of_get_mac_address_nvmem() just works, so the MAC driver just
needs to call of_get_mac_address() or of_get_ethdev_address().
Andrew
next prev parent reply other threads:[~2026-11-25 15:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 12:04 [PATCH v4 0/5] nvmem: Derive Rockchip MAC addresses from the OTP " Alexey Charkov
2026-11-24 12:04 ` [PATCH v4 1/5] dt-bindings: nvmem: fixed-cell: Add Rockchip " Alexey Charkov
2026-11-24 12:04 ` [PATCH v4 2/5] net: Accept MAC addresses from longer NVMEM cells Alexey Charkov
2026-11-24 12:04 ` [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID Alexey Charkov
2026-11-25 13:49 ` Ryan Leung
2026-11-25 13:55 ` Alexey Charkov
2026-11-25 14:21 ` Andrew Lunn
2026-11-25 14:41 ` Alexey Charkov
2026-11-25 15:23 ` Andrew Lunn [this message]
2026-11-25 15:58 ` Alexey Charkov
2026-11-25 16:41 ` Andrew Lunn
2026-11-25 18:01 ` Alexey Charkov
2026-11-24 12:04 ` [PATCH v4 4/5] arm64: dts: rockchip: Move RK3576 OTP cells into a fixed layout Alexey Charkov
2026-11-24 12:04 ` [PATCH v4 5/5] arm64: dts: rockchip: Derive GMAC MAC addresses from OTP on RK3576 Alexey Charkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1defc5c8-ba61-40d2-99f3-6654f1743af1@lunn.ch \
--to=andrew@lunn.ch \
--cc=alchark@flipper.net \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=heiko@sntech.de \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rafal@milecki.pl \
--cc=ricardo@pardini.net \
--cc=robh@kernel.org \
--cc=srini@kernel.org \
--cc=untilscour@protonmail.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®