mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Bastian Krause <bst@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 3/5] common: machine_id: deprecate machine_id_set_hashable
Date: Mon, 28 Jun 2021 11:50:34 +0200	[thread overview]
Message-ID: <bea1987e-8336-6593-0666-e263f4078c58@pengutronix.de> (raw)
In-Reply-To: <20210628064036.25991-3-a.fatoum@pengutronix.de>

On 6/28/21 8:40 AM, Ahmad Fatoum wrote:
> The Kconfig symbol already warns users that barebox updates
> that add new instances of machine_id_set_hashable may cause the machine
> ID to change making the future less useful. Recent changes allow the
> board DT to identify a specific nvmem cell to use for supplying a machine
> ID, making the old way of drivers providing machine IDs and possibly
> overriding each other no longer necessary or recommended.

I cannot parse the first sentence of the commit message.

Regards,
Bastian

> 
> Make this explicit by allowing the old code to be disabled. As we only
> have a single user now and won't accept any new ones, we can remove the
> warning about it possibly changing after update.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/Kconfig        | 18 +++++++++++-------
>  common/machine_id.c   | 11 ++++++++---
>  drivers/nvmem/Kconfig |  1 +
>  drivers/nvmem/ocotp.c |  7 ++++++-
>  include/machine_id.h  | 16 ----------------
>  5 files changed, 26 insertions(+), 27 deletions(-)
>  delete mode 100644 include/machine_id.h
> 
> diff --git a/common/Kconfig b/common/Kconfig
> index a4a109f04f08..a2aa0b2568de 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -1069,13 +1069,11 @@ config MACHINE_ID
>  	select NVMEM
>  	help
>  	  Compute a persistent machine-specific id and store it to $global.machine_id.
> -	  The id is a hash of device-specific information added either via
> -	  machine_id_set_hashable() or by hashing the nvmem cell referenced by the
> -	  /chosen/barebox,machine-id device tree property.
> -
> -	  With machine_id_set_hashable(), the last call prior to the late initcall
> -	  set_machine_id() willl be used to generate the machine id. This means
> -	  updating barebox may change the machine id!
> +	  The id is a hash of device-specific information. This information
> +	  comes from the nvmem cell device tree node path described by the
> +	  /chosen/barebox,machine-id-path property. As a special case, the i.MX6 OCOTP
> +	  driver supplies the SoC UID as hashable for when /chosen/barebox,machine-id-path
> +	  is not specified.
>  
>  	  global.bootm.provide_machine_id may be used to automatically set
>  	  the linux.bootargs.machine_id global variable with a value of
> @@ -1084,6 +1082,12 @@ config MACHINE_ID
>  	  Note: if no hashable information is available no machine id will be passed
>  	  to the kernel.
>  
> +config MACHINE_ID_LEGACY
> +	bool
> +	help
> +	  Selected by i.MX OCOTP driver, so it can set the SoC UID as hashable.
> +	  New platforms should use /chosen/barebox,machine-id-path instead.
> +
>  config SYSTEMD_OF_WATCHDOG
>  	bool "inform devicetree-enabled kernel of used watchdog"
>  	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
> diff --git a/common/machine_id.c b/common/machine_id.c
> index fd2f0888a6cd..8303c0b7aa87 100644
> --- a/common/machine_id.c
> +++ b/common/machine_id.c
> @@ -9,23 +9,24 @@
>  #include <globalvar.h>
>  #include <magicvar.h>
>  #include <crypto/sha.h>
> -#include <machine_id.h>
>  #include <linux/err.h>
>  #include <linux/nvmem-consumer.h>
>  #include <of.h>
>  
>  #define MACHINE_ID_LENGTH 32
>  
> +#ifdef CONFIG_MACHINE_ID_LEGACY
>  static void *__machine_id_hashable;
>  static size_t __machine_id_hashable_length;
>  
> -
> +/* Shouldn't be called from new code */
> +void machine_id_set_hashable(const void *hashable, size_t len);
>  void machine_id_set_hashable(const void *hashable, size_t len)
>  {
> -
>  	__machine_id_hashable = xmemdup(hashable, len);
>  	__machine_id_hashable_length = len;
>  }
> +#endif
>  
>  static const void *machine_id_get_hashable(size_t *len)
>  {
> @@ -52,8 +53,12 @@ static const void *machine_id_get_hashable(size_t *len)
>  	return ret;
>  
>  no_cell:
> +#ifdef CONFIG_MACHINE_ID_LEGACY
>  	*len = __machine_id_hashable_length;
>  	return __machine_id_hashable;
> +#else
> +	return NULL;
> +#endif
>  }
>  
>  static int machine_id_set_globalvar(void)
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 3781f7a839fc..08a5765573a8 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -25,6 +25,7 @@ config NVMEM_SNVS_LPGPR
>  config IMX_OCOTP
>  	tristate "i.MX6 On Chip OTP controller"
>  	depends on ARCH_IMX6 || ARCH_VF610 || ARCH_IMX8M || ARCH_IMX7
> +	select MACHINE_ID_LEGACY
>  	depends on OFDEVICE
>  	help
>  	  This adds support for the i.MX6 On-Chip OTP controller. Currently the
> diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c
> index b2fad3c68770..0b10e52a86ba 100644
> --- a/drivers/nvmem/ocotp.c
> +++ b/drivers/nvmem/ocotp.c
> @@ -29,7 +29,6 @@
>  #include <regmap.h>
>  #include <linux/clk.h>
>  #include <mach/ocotp.h>
> -#include <machine_id.h>
>  #include <mach/ocotp-fusemap.h>
>  #include <linux/nvmem-provider.h>
>  
> @@ -689,6 +688,7 @@ static int imx_ocotp_read(void *ctx, unsigned offset, void *val, size_t bytes)
>  
>  static void imx_ocotp_set_unique_machine_id(void)
>  {
> +	extern void machine_id_set_hashable(const void *hashable, size_t len);
>  	uint32_t unique_id_parts[UNIQUE_ID_NUM];
>  	int i;
>  
> @@ -785,6 +785,11 @@ static int imx_ocotp_probe(struct device_d *dev)
>  				  ethaddr->value, ethaddr);
>  	}
>  
> +	/* Special case: new machine id providers should provide a nvmem cell
> +	 * and reference its path via /chosen/barebox,machine-id-path.
> +	 * For i.MX, we support the legacy way of the driver supplying the
> +	 * hash instead
> +	 */
>  	if (IS_ENABLED(CONFIG_MACHINE_ID))
>  		imx_ocotp_set_unique_machine_id();
>  
> diff --git a/include/machine_id.h b/include/machine_id.h
> deleted file mode 100644
> index 31d5e0bb2851..000000000000
> --- a/include/machine_id.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -#ifndef __MACHINE_ID_H__
> -#define __MACHINE_ID_H__
> -
> -#if IS_ENABLED(CONFIG_MACHINE_ID)
> -
> -void machine_id_set_hashable(const void *hashable, size_t len);
> -
> -#else
> -
> -static inline void machine_id_set_hashable(const void *hashable, size_t len)
> -{
> -}
> -
> -#endif /* CONFIG_MACHINE_ID */
> -
> -#endif  /* __MACHINE_ID_H__ */
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-06-28  9:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28  6:40 [PATCH 1/5] common: machine_id: support /chosen/barebox, machine-id-path override Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 2/5] ARM: stm32mp: migrate to barebox,machine-id-path Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 3/5] common: machine_id: deprecate machine_id_set_hashable Ahmad Fatoum
2021-06-28  9:50   ` Bastian Krause [this message]
2021-06-28 10:12     ` Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 4/5] sandbox: dts: populate $global.machine_id Ahmad Fatoum
2021-06-28  6:40 ` [PATCH 5/5] ARM: dts: stm32mp: retire barebox, provide-mac-address in favor of NVMEM Ahmad Fatoum
2021-06-28  9:28 ` [PATCH 1/5] common: machine_id: support /chosen/barebox,machine-id-path override Ahmad Fatoum
2021-06-28  9:35 ` [PATCH 1/5] common: machine_id: support /chosen/barebox, machine-id-path override Bastian Krause
2021-06-28 10:11   ` Ahmad Fatoum
2021-06-28 20:20 ` Sascha Hauer
     [not found] ` <CAMHeXxOT__KBUKG6GkNAEkqz4tMBBzuZ7OgnKa0_OX5hz-JEig@mail.gmail.com>
2021-06-30 10:27   ` Ahmad Fatoum
2021-06-30 20:13     ` Trent Piepho
2021-09-15 10:55       ` Ahmad Fatoum

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=bea1987e-8336-6593-0666-e263f4078c58@pengutronix.de \
    --to=bst@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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