public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset
Date: Wed, 4 Dec 2019 12:09:35 +0100	[thread overview]
Message-ID: <20191204110935.GA251845@aptenodytes> (raw)
In-Reply-To: <2570e8cd-e81e-a2a8-340b-ae8bffe630dd@theobroma-systems.com>

Hi Heiko,

On Tue 03 Dec 19, 20:50, Heiko Stuebner wrote:
> Hi Paul,
> 
> On 03.12.19 16:46, Paul Kocialkowski wrote:
> > The serial# environment variable is a read-only special variable, that
> > can only be set once. As a result, if the environment was saved to a
> > persistent storage location, attempting to set it again in
> > rockchip_cpuid_set will fail and halt the boot with the following error:
> > 
> > Solve this by checking whether the variable is already set before.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> 
> it looks like we're fixing the same problems a lot. Yesterday I
> also got a patch from Miquel about the px30 iommu clocks ;-) .
> 
> Here it's the same as "rockchip: misc: protect serial# from getting
> overwritten"
> from november 29 ;-)

Hehe good catch! We'll try to keep better track of the list before sending
fixes next time ;)

Cheers,

Paul

> Heiko
> 
> > ---
> >   arch/arm/mach-rockchip/misc.c | 14 +++++++++-----
> >   1 file changed, 9 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
> > index bed4317f7ece..a0c6a1c0b266 100644
> > --- a/arch/arm/mach-rockchip/misc.c
> > +++ b/arch/arm/mach-rockchip/misc.c
> > @@ -108,12 +108,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
> >   		high[i] = cpuid[i << 1];
> >   	}
> > -	serialno = crc32_no_comp(0, low, 8);
> > -	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
> > -	snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno);
> > -
> >   	env_set("cpuid#", cpuid_str);
> > -	env_set("serial#", serialno_str);
> > +
> > +	if (!env_get("serial#")) {
> > +		serialno = crc32_no_comp(0, low, 8);
> > +		serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
> > +		snprintf(serialno_str, sizeof(serialno_str), "%016llx",
> > +			 serialno);
> > +
> > +		env_set("serial#", serialno_str);
> > +	}
> >   	return 0;
> >   }
> 
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191204/fa334960/attachment.sig>

      reply	other threads:[~2019-12-04 11:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 15:46 [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Paul Kocialkowski
2019-12-03 15:46 ` [PATCH 2/2] rockchip: misc: Don't fail if ethaddr is already set Paul Kocialkowski
2019-12-03 19:47   ` Heiko Stuebner
2019-12-03 19:50 ` [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Heiko Stuebner
2019-12-04 11:09   ` Paul Kocialkowski [this message]

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=20191204110935.GA251845@aptenodytes \
    --to=paul.kocialkowski@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /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