All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>,
	u-boot@lists.denx.de, Sumit Garg <sumit.garg@kernel.org>,
	u-boot-qcom@groups.io
Cc: "Tom Rini" <trini@konsulko.com>,
	"Quentin Schulz" <quentin.schulz@cherry.de>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Javier Tia" <javier.tia@linaro.org>,
	"Varadarajan Narayanan" <quic_varada@quicinc.com>,
	"Rasmus Villemoes" <ravi@prevas.dk>,
	"Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"João Marcos Costa" <joaomarcos.costa@bootlin.com>,
	"Tien Fong Chee" <tien.fong.chee@altera.com>,
	"Richard Genoud" <richard.genoud@bootlin.com>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"Casey Connolly" <casey.connolly@linaro.org>,
	"Simon Glass" <simon.glass@canonical.com>,
	"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
	"Christian Marangi" <ansuelsmth@gmail.com>,
	"Michael Walle" <mwalle@kernel.org>,
	"Sumit Garg" <sumit.garg@oss.qualcomm.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Aswin Murugan" <aswin.murugan@oss.qualcomm.com>,
	"Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>,
	"Simon Glass" <sjg@chromium.org>,
	"Mattijs Korpershoek" <mkorpershoek@kernel.org>,
	"Jerome Forissier" <jerome.forissier@arm.com>
Subject: Re: [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment
Date: Mon, 20 Apr 2026 17:35:39 -0500	[thread overview]
Message-ID: <af534d93-aefe-4658-984b-ebed80f0cbc0@baylibre.com> (raw)
In-Reply-To: <20260419-type-v3-3-ec49acd6870e@oss.qualcomm.com>

On 4/19/26 5:24 AM, Balaji Selvanathan wrote:
> Add support for locating SCSI environment partition using GPT type
> GUID instead of unique UUID. This enables the saveenv command to
> work with partitions identified by their type rather than unique
> identifiers, providing flexibility for systems where partition
> UUIDs may vary across devices but types remain constant.
> 
> Introduce a Kconfig choice statement to select between three partition
> lookup methods. The choice provides mutually exclusive options:
> ENV_SCSI_PART_USE_UUID (default), ENV_SCSI_PART_USE_TYPE_GUID, and
> ENV_SCSI_PART_USE_HW. The corresponding string configs depend on their
> respective selection method, creating a clear configuration structure.
> 
> Introduce CONFIG_ENV_SCSI_PART_TYPE_GUID configuration option that
> allows specifying a partition type GUID for environment storage.
> When SCSI_ENV_PART_USE_TYPE_GUID is enabled, the environment subsystem
> uses the type GUID based lookup method via
> scsi_get_blk_by_type_guid() to find the first matching partition.
> 
> Refactor env/scsi.c to use compile-time preprocessor conditionals
> instead of runtime string checks. Replace the previous logic that
> checked if CONFIG_ENV_SCSI_PART_UUID was empty with explicit #if/#elif
> branches for each method.

Might be a bit cleaner to split the refactor and adding the new option
into two patches. This is quite a bit going on in one patch.

> 
> Elevate hardware partition selection from an implicit fallback to an
> explicit choice (ENV_SCSI_PART_USE_HW), improving configuration clarity.
> Move ENV_SCSI_HW_PARTITION to depend on this new option.
> 
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v3:
> - Introduce a new choice config: ENV_SCSI_PART_USE_HW for
>   ENV_SCSI_HW_PARTITION
> - Refactor env_scsi_get_part and env_scsi_load functions based
>   on the choice configs
> 
> Changes in v2:
> - Introduce a Kconfig choice config to select between UUID-based
> and type GUID-based partition lookup methods.
> ---
>  env/Kconfig | 51 +++++++++++++++++++++++++++++++++++++++++++--------
>  env/scsi.c  | 45 +++++++++++++++++++++++++++------------------
>  2 files changed, 70 insertions(+), 26 deletions(-)
> 
> diff --git a/env/Kconfig b/env/Kconfig
> index 7abd82ab6f3..d5d956cb4ce 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -780,10 +780,51 @@ config ENV_MMC_USE_DT
>  	  The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND
>  	  are not used as fallback.
>  

We should update the help of `config ENV_IS_IN_SCSI` as well since it
mentions these options below.

> +choice
> +	prompt "SCSI partition selection method"
> +	depends on ENV_IS_IN_SCSI
> +	default ENV_SCSI_PART_USE_UUID
> +	help
> +	  Select the method to identify the SCSI partition for environment storage.
> +

I wish I would have thought of using `choice` in the recent changes I
did. It is much cleaner to explicitly select which one you want. :-)

> +config ENV_SCSI_PART_USE_UUID
> +	bool "Use partition UUID"
> +	help
> +	  Use the partition's unique UUID to identify the SCSI partition
> +	  for environment storage.
> +
> +config ENV_SCSI_PART_USE_TYPE_GUID
> +	bool "Use partition type GUID"
> +	help
> +	  Use the partition type GUID to identify the SCSI partition
> +	  for environment storage. The first partition matching the
> +	  specified type GUID will be used.
> +
> +config ENV_SCSI_PART_USE_HW
> +	bool "Use hardware partition number"
> +	help
> +	  Use the hardware device number to identify the SCSI device
> +	  for environment storage.
> +
> +endchoice
> +
> +config ENV_SCSI_PART_UUID
> +	string "SCSI partition UUID for saving environment"
> +	depends on ENV_SCSI_PART_USE_UUID
> +	help
> +	  UUID of the SCSI partition that you want to store the environment in.
> +
> +config ENV_SCSI_PART_TYPE_GUID
> +	string "SCSI partition type GUID for saving environment"
> +	depends on ENV_SCSI_PART_USE_TYPE_GUID
> +	help
> +	  Type GUID of the SCSI partition to store the environment in.
> +	  Uses the first partition matching this type GUID.
> +
>  config ENV_SCSI_HW_PARTITION
>  	string "SCSI hardware partition number"
> -	depends on ENV_IS_IN_SCSI
> -	default 0
> +	depends on ENV_SCSI_PART_USE_HW
> +	default "0"

Fixing the quotes here is technically an unrelated change, so could be
a patch on it's own as well.

>  	help
>  	  SCSI hardware partition device number on the platform where the
>  	  environment is stored.  Note that this is not related to any software
> @@ -791,12 +832,6 @@ config ENV_SCSI_HW_PARTITION
>  	  partition 0 or the first boot partition, which is 1 or some other defined
>  	  partition.
>  
> -config ENV_SCSI_PART_UUID
> -	string "SCSI partition UUID for saving environment"
> -	depends on ENV_IS_IN_SCSI
> -	help
> -	  UUID of the SCSI partition that you want to store the environment in.
> -
>  config ENV_USE_DEFAULT_ENV_TEXT_FILE
>  	bool "Create default environment from file"
>  	depends on !COMPILE_TEST
> diff --git a/env/scsi.c b/env/scsi.c
> index 91a6c430302..abb8b0a1dfd 100644
> --- a/env/scsi.c
> +++ b/env/scsi.c
> @@ -41,14 +41,19 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>  		is_scsi_scanned = true;
>  	}
>  
> -	if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0') {
> -		if (blk_get_device_part_str("scsi", CONFIG_ENV_SCSI_HW_PARTITION,
> -					    &ep->blk, &ep->part, true))
> -			return NULL;
> -	} else {
> -		if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
> -			return NULL;
> -	}
> +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID)
> +	if (scsi_get_blk_by_type_guid(CONFIG_ENV_SCSI_PART_TYPE_GUID, &ep->blk, &ep->part))
> +		return NULL;
> +
> +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID)
> +	if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
> +		return NULL;
> +
> +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW)
> +	if (blk_get_device_part_str("scsi", CONFIG_ENV_SCSI_HW_PARTITION,
> +				    &ep->blk, &ep->part, true))
> +		return NULL;
> +#endif
>  
>  	ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
>  
> @@ -95,20 +100,24 @@ static int env_scsi_load(void)
>  	int ret;
>  
>  	if (!ep) {
> -		if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
> -			env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found", 0);
> -		else
> -			env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition not found", 0);
> -
> +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID)
> +		env_set_default(CONFIG_ENV_SCSI_PART_TYPE_GUID " partition not found", 0);

It could be a bit more clear to have a different message for
this one. e.g. "partition type " CONFIG_ENV_SCSI_PART_TYPE_GUID " not found".

> +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID)
> +		env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition not found", 0);
> +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW)
> +		env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found", 0);
> +#endif
>  		return -ENOENT;
>  	}
>  
>  	if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
> -		if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
> -			env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed", 0);
> -		else
> -			env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition read failed", 0);
> -
> +#if defined(CONFIG_ENV_SCSI_PART_USE_TYPE_GUID)
> +		env_set_default(CONFIG_ENV_SCSI_PART_TYPE_GUID " partition read failed", 0);

similar as above

> +#elif defined(CONFIG_ENV_SCSI_PART_USE_UUID)
> +		env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition read failed", 0);
> +#elif defined(CONFIG_ENV_SCSI_PART_USE_HW)
> +		env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed", 0);
> +#endif
>  		return -EIO;
>  	}
>  
> 


  parent reply	other threads:[~2026-04-20 22:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 10:24 [PATCH v3 0/5] Add partition type GUID support for environment Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 1/5] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
2026-04-20  1:17   ` Simon Glass
2026-04-19 10:24 ` [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
2026-04-20 22:38   ` David Lechner
2026-04-19 10:24 ` [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
2026-04-20  1:18   ` Simon Glass
2026-04-20 22:35   ` David Lechner [this message]
2026-04-19 10:24 ` [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
2026-04-20  1:18   ` Simon Glass
2026-04-19 10:24 ` [PATCH v3 5/5] test: dm: Add partition type GUID lookup test Balaji Selvanathan
2026-04-20  1:18   ` Simon Glass
2026-04-20 13:37 ` [PATCH v3 0/5] Add partition type GUID support for environment Sumit Garg
2026-04-27 16:49   ` Balaji Selvanathan
2026-05-01  7:56     ` Sumit Garg

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=af534d93-aefe-4658-984b-ebed80f0cbc0@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=ansuelsmth@gmail.com \
    --cc=aswin.murugan@oss.qualcomm.com \
    --cc=balaji.selvanathan@oss.qualcomm.com \
    --cc=casey.connolly@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jan.kiszka@siemens.com \
    --cc=javier.tia@linaro.org \
    --cc=javierm@redhat.com \
    --cc=jerome.forissier@arm.com \
    --cc=joaomarcos.costa@bootlin.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mikhail.kshevetskiy@iopsys.eu \
    --cc=miquel.raynal@bootlin.com \
    --cc=mkorpershoek@kernel.org \
    --cc=mwalle@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quentin.schulz@cherry.de \
    --cc=quic_varada@quicinc.com \
    --cc=ravi@prevas.dk \
    --cc=richard.genoud@bootlin.com \
    --cc=simon.glass@canonical.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@kernel.org \
    --cc=sumit.garg@oss.qualcomm.com \
    --cc=tien.fong.chee@altera.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=varadarajan.narayanan@oss.qualcomm.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 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.