All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set
@ 2019-11-29 15:40 Heiko Stuebner
  2019-11-29 15:40 ` [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten Heiko Stuebner
  2019-12-01 13:47 ` [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Kever Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Heiko Stuebner @ 2019-11-29 15:40 UTC (permalink / raw)
  To: u-boot

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

rockchip_setup_macaddr() runs from an initcall, so returning an error
code will make that initcall fail thus breaking the boot process.

And if an ethernet address is already set this is definitly not a
cause for that, so just return success in that case.

Fixes: 04825384999f ("rockchip: rk3399: derive ethaddr from cpuid");
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
 arch/arm/mach-rockchip/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
index bed4317f7e..d0fb3d07a7 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -29,7 +29,7 @@ int rockchip_setup_macaddr(void)
 
 	/* Only generate a MAC address, if none is set in the environment */
 	if (env_get("ethaddr"))
-		return -1;
+		return 0;
 
 	if (!cpuid) {
 		debug("%s: could not retrieve 'cpuid#'\n", __func__);
-- 
2.24.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten
  2019-11-29 15:40 [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Heiko Stuebner
@ 2019-11-29 15:40 ` Heiko Stuebner
  2019-12-01 13:47   ` Kever Yang
  2019-12-01 13:47 ` [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Kever Yang
  1 sibling, 1 reply; 4+ messages in thread
From: Heiko Stuebner @ 2019-11-29 15:40 UTC (permalink / raw)
  To: u-boot

From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

serial# is one of the vendor properties and thus protected from being
overwritten if already set. If env_set is called anyway this result in
some nasty warnings, so check for presence before trying that.

In the same direction check for the presence of cpuid# and compare it
to the actual hardware and emit a warning if they don't match.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
 arch/arm/mach-rockchip/misc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
index d0fb3d07a7..545b98baad 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -91,6 +91,7 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
 	char cpuid_str[cpuid_length * 2 + 1];
 	u64 serialno;
 	char serialno_str[17];
+	const char *oldid;
 	int i;
 
 	memset(cpuid_str, 0, sizeof(cpuid_str));
@@ -112,8 +113,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
 	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
 	snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno);
 
+	oldid = env_get("cpuid#");
+	if (oldid && strcmp(oldid, cpuid_str) != 0)
+		printf("cpuid: value %s present in env does not match hardware %s\n",
+		       oldid, cpuid_str);
+
 	env_set("cpuid#", cpuid_str);
-	env_set("serial#", serialno_str);
+
+	/* Only generate serial# when none is set yet */
+	if (!env_get("serial#"))
+		env_set("serial#", serialno_str);
 
 	return 0;
 }
-- 
2.24.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set
  2019-11-29 15:40 [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Heiko Stuebner
  2019-11-29 15:40 ` [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten Heiko Stuebner
@ 2019-12-01 13:47 ` Kever Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Kever Yang @ 2019-12-01 13:47 UTC (permalink / raw)
  To: u-boot


On 2019/11/29 下午11:40, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
>
> rockchip_setup_macaddr() runs from an initcall, so returning an error
> code will make that initcall fail thus breaking the boot process.
>
> And if an ethernet address is already set this is definitly not a
> cause for that, so just return success in that case.
>
> Fixes: 04825384999f ("rockchip: rk3399: derive ethaddr from cpuid");
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/mach-rockchip/misc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
> index bed4317f7e..d0fb3d07a7 100644
> --- a/arch/arm/mach-rockchip/misc.c
> +++ b/arch/arm/mach-rockchip/misc.c
> @@ -29,7 +29,7 @@ int rockchip_setup_macaddr(void)
>   
>   	/* Only generate a MAC address, if none is set in the environment */
>   	if (env_get("ethaddr"))
> -		return -1;
> +		return 0;
>   
>   	if (!cpuid) {
>   		debug("%s: could not retrieve 'cpuid#'\n", __func__);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten
  2019-11-29 15:40 ` [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten Heiko Stuebner
@ 2019-12-01 13:47   ` Kever Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Kever Yang @ 2019-12-01 13:47 UTC (permalink / raw)
  To: u-boot


On 2019/11/29 下午11:40, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
>
> serial# is one of the vendor properties and thus protected from being
> overwritten if already set. If env_set is called anyway this result in
> some nasty warnings, so check for presence before trying that.
>
> In the same direction check for the presence of cpuid# and compare it
> to the actual hardware and emit a warning if they don't match.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/mach-rockchip/misc.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
> index d0fb3d07a7..545b98baad 100644
> --- a/arch/arm/mach-rockchip/misc.c
> +++ b/arch/arm/mach-rockchip/misc.c
> @@ -91,6 +91,7 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
>   	char cpuid_str[cpuid_length * 2 + 1];
>   	u64 serialno;
>   	char serialno_str[17];
> +	const char *oldid;
>   	int i;
>   
>   	memset(cpuid_str, 0, sizeof(cpuid_str));
> @@ -112,8 +113,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
>   	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
>   	snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno);
>   
> +	oldid = env_get("cpuid#");
> +	if (oldid && strcmp(oldid, cpuid_str) != 0)
> +		printf("cpuid: value %s present in env does not match hardware %s\n",
> +		       oldid, cpuid_str);
> +
>   	env_set("cpuid#", cpuid_str);
> -	env_set("serial#", serialno_str);
> +
> +	/* Only generate serial# when none is set yet */
> +	if (!env_get("serial#"))
> +		env_set("serial#", serialno_str);
>   
>   	return 0;
>   }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-01 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 15:40 [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Heiko Stuebner
2019-11-29 15:40 ` [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten Heiko Stuebner
2019-12-01 13:47   ` Kever Yang
2019-12-01 13:47 ` [U-Boot] [PATCH 1/2] rockchip: misc: don't fail if eth_addr already set Kever Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.