All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] Add partition type GUID support for environment
@ 2026-01-08  6:49 Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 1/4] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-08  6:49 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, balaji.selvanathan, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

This series adds support for locating partitions using GPT partition
type GUID instead of unique partition 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.

Balaji Selvanathan (4):
  disk: Add partition lookup by type GUID functionality
  scsi: Add partition lookup by type GUID for SCSI devices
  env: scsi: Add support for partition type GUID based environment
  configs: Enable partition type GUID for QCM6490 and QCS615 boards

 configs/qcm6490_defconfig     |  4 ++++
 configs/qcom_qcs615_defconfig |  4 ++++
 disk/part.c                   | 39 +++++++++++++++++++++++++++++++++++
 drivers/scsi/scsi-uclass.c    | 28 +++++++++++++++++++++++++
 env/Kconfig                   |  7 +++++++
 env/scsi.c                    | 13 ++++++++++++
 include/part.h                | 21 +++++++++++++++++++
 include/scsi.h                | 11 ++++++++++
 8 files changed, 127 insertions(+)

-- 
2.34.1

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

* [PATCH v1 1/4] disk: Add partition lookup by type GUID functionality
  2026-01-08  6:49 [PATCH v1 0/4] Add partition type GUID support for environment Balaji Selvanathan
@ 2026-01-08  6:49 ` Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-08  6:49 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, balaji.selvanathan, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

Introduce part_get_info_by_type_guid() function to enable partition
lookup using partition type GUID. This complements the existing UUID
lookup functionality and provides more flexible partition discovery
mechanisms.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
 disk/part.c    | 39 +++++++++++++++++++++++++++++++++++++++
 include/part.h | 21 +++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index 49a0fca6b89..2bc21dd66cc 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -731,6 +731,45 @@ int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 	return -ENOENT;
 }
 
+int part_get_info_by_type_guid(struct blk_desc *desc, const char *type_guid,
+			       struct disk_partition *info)
+{
+	struct part_driver *part_drv;
+	int ret;
+	int i;
+
+	if (!IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+		return -ENOENT;
+
+	part_drv = part_driver_lookup_type(desc);
+	if (!part_drv)
+		return -1;
+
+	if (!part_drv->get_info) {
+		log_debug("## Driver %s does not have the get_info() method\n",
+			  part_drv->name);
+		return -ENOSYS;
+	}
+
+	for (i = 1; i < part_drv->max_entries; i++) {
+		ret = part_drv->get_info(desc, i, info);
+		if (ret != 0) {
+			/*
+			 * Partition with this index can't be obtained, but
+			 * further partitions might be, so keep checking.
+			 */
+			continue;
+		}
+
+		if (!strncasecmp(type_guid, disk_partition_type_guid(info), UUID_STR_LEN)) {
+			/* matched */
+			return i;
+		}
+	}
+
+	return -ENOENT;
+}
+
 /**
  * Get partition info from device number and partition name.
  *
diff --git a/include/part.h b/include/part.h
index daebbbc2e68..85457618cdf 100644
--- a/include/part.h
+++ b/include/part.h
@@ -327,6 +327,20 @@ int part_get_info_by_name(struct blk_desc *desc, const char *name,
 int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 			  struct disk_partition *info);
 
+/**
+ * part_get_info_by_type_guid() - Search for a partition by type GUID
+ *                                among all available registered partitions
+ *
+ * @desc:	block device descriptor
+ * @type_guid:	the specified partition type GUID
+ * @info:	the disk partition info
+ *
+ * Return: the partition number on match (starting on 1), -ENOENT on no match,
+ * otherwise error
+ */
+int part_get_info_by_type_guid(struct blk_desc *desc, const char *type_guid,
+			       struct disk_partition *info);
+
 /**
  * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number
  *					    and part name, or dev number and
@@ -404,6 +418,13 @@ static inline int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
 	return -ENOENT;
 }
 
+static inline int part_get_info_by_type_guid(struct blk_desc *desc,
+					     const char *type_guid,
+					     struct disk_partition *info)
+{
+	return -ENOENT;
+}
+
 static inline int
 part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 				     const char *dev_part_str,
-- 
2.34.1


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

* [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices
  2026-01-08  6:49 [PATCH v1 0/4] Add partition type GUID support for environment Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 1/4] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
@ 2026-01-08  6:49 ` Balaji Selvanathan
  2026-01-08  9:37   ` Varadarajan Narayanan
  2026-01-08  6:49 ` [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 4/4] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
  3 siblings, 1 reply; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-08  6:49 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, balaji.selvanathan, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

Introduce scsi_get_blk_by_type_guid() function to enable SCSI
partition discovery using partition type GUID. This function scans
all available SCSI devices and searches for a partition matching the
specified type GUID.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
 drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++++
 include/scsi.h             | 11 +++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index 3eb6069649f..42a6b5233c2 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -53,6 +53,34 @@ int scsi_get_blk_by_uuid(const char *uuid,
 	return -1;
 }
 
+int scsi_get_blk_by_type_guid(const char *type_guid,
+			      struct blk_desc **blk_desc_ptr,
+			      struct disk_partition *part_info_ptr)
+{
+	static int is_scsi_scanned;
+	struct blk_desc *blk;
+	int i, ret;
+
+	if (!is_scsi_scanned) {
+		scsi_scan(false /* no verbose */);
+		is_scsi_scanned = 1;
+	}
+
+	for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
+		ret = blk_get_desc(UCLASS_SCSI, i, &blk);
+		if (ret)
+			continue;
+
+		ret = part_get_info_by_type_guid(blk, type_guid, part_info_ptr);
+		if (ret > 0) {
+			*blk_desc_ptr = blk;
+			return 0;
+		}
+	}
+
+	return -1;
+}
+
 int scsi_bus_reset(struct udevice *dev)
 {
 	struct scsi_ops *ops = scsi_get_ops(dev);
diff --git a/include/scsi.h b/include/scsi.h
index 8d6c5116419..e0b2f869057 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -361,6 +361,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
 int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
 			 struct disk_partition *part_info_ptr);
 
+
+/**
+ * scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID.
+ *
+ * @type_guid:		Type GUID of the partition for fetching its info
+ * @blk_desc_ptr:	Provides the blk descriptor
+ * @part_info_ptr:	Provides partition info
+ */
+int scsi_get_blk_by_type_guid(const char *type_guid, struct blk_desc **blk_desc_ptr,
+			      struct disk_partition *part_info_ptr);
+
 #define SCSI_IDENTIFY					0xC0  /* not used */
 
 /* Hardware errors  */
-- 
2.34.1


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

* [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08  6:49 [PATCH v1 0/4] Add partition type GUID support for environment Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 1/4] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
  2026-01-08  6:49 ` [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
@ 2026-01-08  6:49 ` Balaji Selvanathan
  2026-01-08  9:41   ` Varadarajan Narayanan
  2026-01-08 17:42   ` Simon Glass
  2026-01-08  6:49 ` [PATCH v1 4/4] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
  3 siblings, 2 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-08  6:49 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, balaji.selvanathan, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
allows specifying a partition type GUID for environment storage.
When enabled, the environment subsystem uses the new type GUID
based lookup method via scsi_get_blk_by_type_guid() to find the
first matching partition.

This change maintains backward compatibility with the existing
UUID-based approach.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
 env/Kconfig |  7 +++++++
 env/scsi.c  | 13 +++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index b312f9b5324..97cb3d05daf 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
 	help
 	  UUID of the SCSI partition that you want to store the environment in.
 
+config SCSI_ENV_PART_TYPE_GUID
+	string "SCSI partition type GUID for saving environment"
+	depends on ENV_IS_IN_SCSI
+	help
+	  Type GUID of the SCSI partition to store the environment in.
+	  Uses the first partition matching this type GUID.
+
 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 207717e17b1..6182ae26679 100644
--- a/env/scsi.c
+++ b/env/scsi.c
@@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
 {
 	struct env_scsi_info *ep = &env_part;
 
+#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
+	if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
+		return NULL;
+#else
 	if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
 		return NULL;
+#endif
 
 	ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
 
@@ -83,12 +88,20 @@ static int env_scsi_load(void)
 	int ret;
 
 	if (!ep) {
+#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
+		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0);
+#else
 		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
+#endif
 		return -ENOENT;
 	}
 
 	if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
+#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
+		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0);
+#else
 		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
+#endif
 		return -EIO;
 	}
 
-- 
2.34.1


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

* [PATCH v1 4/4] configs: Enable partition type GUID for QCM6490 and QCS615 boards
  2026-01-08  6:49 [PATCH v1 0/4] Add partition type GUID support for environment Balaji Selvanathan
                   ` (2 preceding siblings ...)
  2026-01-08  6:49 ` [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
@ 2026-01-08  6:49 ` Balaji Selvanathan
  3 siblings, 0 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-08  6:49 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, balaji.selvanathan, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

Enable CONFIG_PARTITION_TYPE_GUID and configure SCSI environment
partition type GUID for QCM6490 and QCS615 board configurations.
This allows these platforms to locate the environment partition
using GPT type GUID instead of unique UUID.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
 configs/qcm6490_defconfig     | 4 ++++
 configs/qcom_qcs615_defconfig | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/configs/qcm6490_defconfig b/configs/qcm6490_defconfig
index 54eb5dedaec..e1296fa268e 100644
--- a/configs/qcm6490_defconfig
+++ b/configs/qcm6490_defconfig
@@ -13,3 +13,7 @@ CONFIG_TEXT_BASE=0x9fc00000
 CONFIG_REMAKE_ELF=y
 
 CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs6490-rb3gen2"
+
+CONFIG_ENV_IS_IN_SCSI=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SCSI_ENV_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
diff --git a/configs/qcom_qcs615_defconfig b/configs/qcom_qcs615_defconfig
index 2468267b955..4a41602be10 100644
--- a/configs/qcom_qcs615_defconfig
+++ b/configs/qcom_qcs615_defconfig
@@ -20,3 +20,7 @@ CONFIG_REMAKE_ELF=y
 
 # Address where U-Boot will be loaded
 CONFIG_TEXT_BASE=0x9fc00000
+
+CONFIG_ENV_IS_IN_SCSI=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SCSI_ENV_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
-- 
2.34.1


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

* Re: [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices
  2026-01-08  6:49 ` [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
@ 2026-01-08  9:37   ` Varadarajan Narayanan
  2026-01-08 17:41     ` Simon Glass
  2026-01-09  7:13     ` Balaji Selvanathan
  0 siblings, 2 replies; 16+ messages in thread
From: Varadarajan Narayanan @ 2026-01-08  9:37 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

On Thu, Jan 08, 2026 at 12:19:45PM +0530, Balaji Selvanathan wrote:
> Introduce scsi_get_blk_by_type_guid() function to enable SCSI
> partition discovery using partition type GUID. This function scans
> all available SCSI devices and searches for a partition matching the
> specified type GUID.
>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
>  drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++++
>  include/scsi.h             | 11 +++++++++++
>  2 files changed, 39 insertions(+)
>
> diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
> index 3eb6069649f..42a6b5233c2 100644
> --- a/drivers/scsi/scsi-uclass.c
> +++ b/drivers/scsi/scsi-uclass.c
> @@ -53,6 +53,34 @@ int scsi_get_blk_by_uuid(const char *uuid,
>  	return -1;
>  }
>
> +int scsi_get_blk_by_type_guid(const char *type_guid,
> +			      struct blk_desc **blk_desc_ptr,
> +			      struct disk_partition *part_info_ptr)
> +{
> +	static int is_scsi_scanned;
> +	struct blk_desc *blk;
> +	int i, ret;
> +
> +	if (!is_scsi_scanned) {
> +		scsi_scan(false /* no verbose */);
> +		is_scsi_scanned = 1;
> +	}
> +
> +	for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {

	max = blk_find_max_devnum(UCLASS_SCSI) + 1;
	for (i = 0; i < max; i++) {

Else, i believe blk_find_max_devnum() will get invoked multiple times.

-Varada

> +		ret = blk_get_desc(UCLASS_SCSI, i, &blk);
> +		if (ret)
> +			continue;
> +
> +		ret = part_get_info_by_type_guid(blk, type_guid, part_info_ptr);
> +		if (ret > 0) {
> +			*blk_desc_ptr = blk;
> +			return 0;
> +		}
> +	}
> +
> +	return -1;
> +}
> +
>  int scsi_bus_reset(struct udevice *dev)
>  {
>  	struct scsi_ops *ops = scsi_get_ops(dev);
> diff --git a/include/scsi.h b/include/scsi.h
> index 8d6c5116419..e0b2f869057 100644
> --- a/include/scsi.h
> +++ b/include/scsi.h
> @@ -361,6 +361,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
>  int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
>  			 struct disk_partition *part_info_ptr);
>
> +
> +/**
> + * scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID.
> + *
> + * @type_guid:		Type GUID of the partition for fetching its info
> + * @blk_desc_ptr:	Provides the blk descriptor
> + * @part_info_ptr:	Provides partition info
> + */
> +int scsi_get_blk_by_type_guid(const char *type_guid, struct blk_desc **blk_desc_ptr,
> +			      struct disk_partition *part_info_ptr);
> +
>  #define SCSI_IDENTIFY					0xC0  /* not used */
>
>  /* Hardware errors  */
> --
> 2.34.1
>

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08  6:49 ` [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
@ 2026-01-08  9:41   ` Varadarajan Narayanan
  2026-01-08 14:32     ` Tom Rini
  2026-01-09  7:15     ` Balaji Selvanathan
  2026-01-08 17:42   ` Simon Glass
  1 sibling, 2 replies; 16+ messages in thread
From: Varadarajan Narayanan @ 2026-01-08  9:41 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

On Thu, Jan 08, 2026 at 12:19:46PM +0530, 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> allows specifying a partition type GUID for environment storage.
> When enabled, the environment subsystem uses the new type GUID
> based lookup method via scsi_get_blk_by_type_guid() to find the
> first matching partition.
>
> This change maintains backward compatibility with the existing
> UUID-based approach.
>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
>  env/Kconfig |  7 +++++++
>  env/scsi.c  | 13 +++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index b312f9b5324..97cb3d05daf 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>  	help
>  	  UUID of the SCSI partition that you want to store the environment in.
>
> +config SCSI_ENV_PART_TYPE_GUID
> +	string "SCSI partition type GUID for saving environment"
> +	depends on ENV_IS_IN_SCSI

Should we add

	depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID

and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to
handle them as mutually exclusive...

-Varada

> +	help
> +	  Type GUID of the SCSI partition to store the environment in.
> +	  Uses the first partition matching this type GUID.
> +
>  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 207717e17b1..6182ae26679 100644
> --- a/env/scsi.c
> +++ b/env/scsi.c
> @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>  {
>  	struct env_scsi_info *ep = &env_part;
>
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +	if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
> +		return NULL;
> +#else
>  	if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
>  		return NULL;
> +#endif
>
>  	ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
>
> @@ -83,12 +88,20 @@ static int env_scsi_load(void)
>  	int ret;
>
>  	if (!ep) {
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0);
> +#else
>  		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
> +#endif
>  		return -ENOENT;
>  	}
>
>  	if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0);
> +#else
>  		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
> +#endif
>  		return -EIO;
>  	}
>
> --
> 2.34.1
>

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08  9:41   ` Varadarajan Narayanan
@ 2026-01-08 14:32     ` Tom Rini
  2026-01-09  7:16       ` Balaji Selvanathan
  2026-01-09  7:15     ` Balaji Selvanathan
  1 sibling, 1 reply; 16+ messages in thread
From: Tom Rini @ 2026-01-08 14:32 UTC (permalink / raw)
  To: Varadarajan Narayanan
  Cc: Balaji Selvanathan, casey.connolly, neil.armstrong, sumit.garg,
	aswin.murugan, joe.hershberger, ilias.apalodimas, quentin.schulz,
	ravi, javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]

On Thu, Jan 08, 2026 at 03:11:37PM +0530, Varadarajan Narayanan wrote:
> On Thu, Jan 08, 2026 at 12:19:46PM +0530, 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> > allows specifying a partition type GUID for environment storage.
> > When enabled, the environment subsystem uses the new type GUID
> > based lookup method via scsi_get_blk_by_type_guid() to find the
> > first matching partition.
> >
> > This change maintains backward compatibility with the existing
> > UUID-based approach.
> >
> > Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> > ---
> >  env/Kconfig |  7 +++++++
> >  env/scsi.c  | 13 +++++++++++++
> >  2 files changed, 20 insertions(+)
> >
> > diff --git a/env/Kconfig b/env/Kconfig
> > index b312f9b5324..97cb3d05daf 100644
> > --- a/env/Kconfig
> > +++ b/env/Kconfig
> > @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
> >  	help
> >  	  UUID of the SCSI partition that you want to store the environment in.
> >
> > +config SCSI_ENV_PART_TYPE_GUID
> > +	string "SCSI partition type GUID for saving environment"
> > +	depends on ENV_IS_IN_SCSI
> 
> Should we add
> 
> 	depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID
> 
> and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to
> handle them as mutually exclusive...

If they're mutually exclusive it needs to be handled in a choice
statement.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices
  2026-01-08  9:37   ` Varadarajan Narayanan
@ 2026-01-08 17:41     ` Simon Glass
  2026-01-09  7:13     ` Balaji Selvanathan
  1 sibling, 0 replies; 16+ messages in thread
From: Simon Glass @ 2026-01-08 17:41 UTC (permalink / raw)
  To: Varadarajan Narayanan
  Cc: Balaji Selvanathan, casey.connolly, neil.armstrong, sumit.garg,
	trini, aswin.murugan, joe.hershberger, ilias.apalodimas,
	quentin.schulz, ravi, javier.tia, quic_varada,
	marek.vasut+renesas, michal.simek, ansuelsmth, mwalle, anshuld,
	jan.kiszka, javierm, u-boot-qcom, u-boot

On Thu, 8 Jan 2026 at 02:38, Varadarajan Narayanan
<varadarajan.narayanan@oss.qualcomm.com> wrote:
>
> On Thu, Jan 08, 2026 at 12:19:45PM +0530, Balaji Selvanathan wrote:
> > Introduce scsi_get_blk_by_type_guid() function to enable SCSI
> > partition discovery using partition type GUID. This function scans
> > all available SCSI devices and searches for a partition matching the
> > specified type GUID.
> >
> > Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> > ---
> >  drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++++
> >  include/scsi.h             | 11 +++++++++++
> >  2 files changed, 39 insertions(+)
> >
> > diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
> > index 3eb6069649f..42a6b5233c2 100644
> > --- a/drivers/scsi/scsi-uclass.c
> > +++ b/drivers/scsi/scsi-uclass.c
> > @@ -53,6 +53,34 @@ int scsi_get_blk_by_uuid(const char *uuid,
> >       return -1;
> >  }
> >
> > +int scsi_get_blk_by_type_guid(const char *type_guid,
> > +                           struct blk_desc **blk_desc_ptr,
> > +                           struct disk_partition *part_info_ptr)
> > +{
> > +     static int is_scsi_scanned;
> > +     struct blk_desc *blk;
> > +     int i, ret;
> > +
> > +     if (!is_scsi_scanned) {
> > +             scsi_scan(false /* no verbose */);
> > +             is_scsi_scanned = 1;
> > +     }
> > +
> > +     for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
>
>         max = blk_find_max_devnum(UCLASS_SCSI) + 1;
>         for (i = 0; i < max; i++) {
>
> Else, i believe blk_find_max_devnum() will get invoked multiple times.
>
> -Varada
>
> > +             ret = blk_get_desc(UCLASS_SCSI, i, &blk);
> > +             if (ret)
> > +                     continue;
> > +
> > +             ret = part_get_info_by_type_guid(blk, type_guid, part_info_ptr);
> > +             if (ret > 0) {
> > +                     *blk_desc_ptr = blk;
> > +                     return 0;
> > +             }
> > +     }
> > +
> > +     return -1;
> > +}
> > +
> >  int scsi_bus_reset(struct udevice *dev)
> >  {
> >       struct scsi_ops *ops = scsi_get_ops(dev);
> > diff --git a/include/scsi.h b/include/scsi.h
> > index 8d6c5116419..e0b2f869057 100644
> > --- a/include/scsi.h
> > +++ b/include/scsi.h
> > @@ -361,6 +361,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
> >  int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
> >                        struct disk_partition *part_info_ptr);
> >
> > +
> > +/**
> > + * scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID.
> > + *
> > + * @type_guid:               Type GUID of the partition for fetching its info
> > + * @blk_desc_ptr:    Provides the blk descriptor
> > + * @part_info_ptr:   Provides partition info
> > + */
> > +int scsi_get_blk_by_type_guid(const char *type_guid, struct blk_desc **blk_desc_ptr,
> > +                           struct disk_partition *part_info_ptr);
> > +
> >  #define SCSI_IDENTIFY                                        0xC0  /* not used */
> >
> >  /* Hardware errors  */
> > --
> > 2.34.1
> >

With the above fixed:

Reviewed-by: Simon Glass <simon.glass@canonical.com>

Regards,
Simon

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08  6:49 ` [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
  2026-01-08  9:41   ` Varadarajan Narayanan
@ 2026-01-08 17:42   ` Simon Glass
  2026-01-09  8:51     ` Balaji Selvanathan
  1 sibling, 1 reply; 16+ messages in thread
From: Simon Glass @ 2026-01-08 17:42 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

Hi Balaji,

On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
<balaji.selvanathan@oss.qualcomm.com> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> allows specifying a partition type GUID for environment storage.
> When enabled, the environment subsystem uses the new type GUID
> based lookup method via scsi_get_blk_by_type_guid() to find the
> first matching partition.
>
> This change maintains backward compatibility with the existing
> UUID-based approach.
>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
>  env/Kconfig |  7 +++++++
>  env/scsi.c  | 13 +++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/env/Kconfig b/env/Kconfig
> index b312f9b5324..97cb3d05daf 100644
> --- a/env/Kconfig
> +++ b/env/Kconfig
> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>         help
>           UUID of the SCSI partition that you want to store the environment in.
>
> +config SCSI_ENV_PART_TYPE_GUID
> +       string "SCSI partition type GUID for saving environment"
> +       depends on ENV_IS_IN_SCSI
> +       help
> +         Type GUID of the SCSI partition to store the environment in.
> +         Uses the first partition matching this type GUID.
> +
>  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 207717e17b1..6182ae26679 100644
> --- a/env/scsi.c
> +++ b/env/scsi.c
> @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>  {
>         struct env_scsi_info *ep = &env_part;
>
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +       if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))

Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)

(we try to avoid #ifdef)

> +               return NULL;
> +#else
>         if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
>                 return NULL;
> +#endif
>
>         ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
>
> @@ -83,12 +88,20 @@ static int env_scsi_load(void)
>         int ret;
>
>         if (!ep) {
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +               env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0);
> +#else
>                 env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
> +#endif
>                 return -ENOENT;
>         }
>
>         if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> +               env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0);
> +#else
>                 env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
> +#endif
>                 return -EIO;
>         }
>
> --
> 2.34.1
>

Regards,
Simon

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

* Re: [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices
  2026-01-08  9:37   ` Varadarajan Narayanan
  2026-01-08 17:41     ` Simon Glass
@ 2026-01-09  7:13     ` Balaji Selvanathan
  1 sibling, 0 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-09  7:13 UTC (permalink / raw)
  To: Varadarajan Narayanan
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

Hi Varada,

On 1/8/2026 3:07 PM, Varadarajan Narayanan wrote:
> On Thu, Jan 08, 2026 at 12:19:45PM +0530, Balaji Selvanathan wrote:
>> Introduce scsi_get_blk_by_type_guid() function to enable SCSI
>> partition discovery using partition type GUID. This function scans
>> all available SCSI devices and searches for a partition matching the
>> specified type GUID.
>>
>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>> ---
>>   drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++++
>>   include/scsi.h             | 11 +++++++++++
>>   2 files changed, 39 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
>> index 3eb6069649f..42a6b5233c2 100644
>> --- a/drivers/scsi/scsi-uclass.c
>> +++ b/drivers/scsi/scsi-uclass.c
>> @@ -53,6 +53,34 @@ int scsi_get_blk_by_uuid(const char *uuid,
>>   	return -1;
>>   }
>>
>> +int scsi_get_blk_by_type_guid(const char *type_guid,
>> +			      struct blk_desc **blk_desc_ptr,
>> +			      struct disk_partition *part_info_ptr)
>> +{
>> +	static int is_scsi_scanned;
>> +	struct blk_desc *blk;
>> +	int i, ret;
>> +
>> +	if (!is_scsi_scanned) {
>> +		scsi_scan(false /* no verbose */);
>> +		is_scsi_scanned = 1;
>> +	}
>> +
>> +	for (i = 0; i < blk_find_max_devnum(UCLASS_SCSI) + 1; i++) {
> 	max = blk_find_max_devnum(UCLASS_SCSI) + 1;
> 	for (i = 0; i < max; i++) {
>
> Else, i believe blk_find_max_devnum() will get invoked multiple times.
>
> -Varada

Thanks for the feedback. Addressed this.

Regards,

Balaji

>
>> +		ret = blk_get_desc(UCLASS_SCSI, i, &blk);
>> +		if (ret)
>> +			continue;
>> +
>> +		ret = part_get_info_by_type_guid(blk, type_guid, part_info_ptr);
>> +		if (ret > 0) {
>> +			*blk_desc_ptr = blk;
>> +			return 0;
>> +		}
>> +	}
>> +
>> +	return -1;
>> +}
>> +
>>   int scsi_bus_reset(struct udevice *dev)
>>   {
>>   	struct scsi_ops *ops = scsi_get_ops(dev);
>> diff --git a/include/scsi.h b/include/scsi.h
>> index 8d6c5116419..e0b2f869057 100644
>> --- a/include/scsi.h
>> +++ b/include/scsi.h
>> @@ -361,6 +361,17 @@ int scsi_scan_dev(struct udevice *dev, bool verbose);
>>   int scsi_get_blk_by_uuid(const char *uuid, struct blk_desc **blk_desc_ptr,
>>   			 struct disk_partition *part_info_ptr);
>>
>> +
>> +/**
>> + * scsi_get_blk_by_type_guid() - Provides SCSI partition information by type GUID.
>> + *
>> + * @type_guid:		Type GUID of the partition for fetching its info
>> + * @blk_desc_ptr:	Provides the blk descriptor
>> + * @part_info_ptr:	Provides partition info
>> + */
>> +int scsi_get_blk_by_type_guid(const char *type_guid, struct blk_desc **blk_desc_ptr,
>> +			      struct disk_partition *part_info_ptr);
>> +
>>   #define SCSI_IDENTIFY					0xC0  /* not used */
>>
>>   /* Hardware errors  */
>> --
>> 2.34.1
>>

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08  9:41   ` Varadarajan Narayanan
  2026-01-08 14:32     ` Tom Rini
@ 2026-01-09  7:15     ` Balaji Selvanathan
  1 sibling, 0 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-09  7:15 UTC (permalink / raw)
  To: Varadarajan Narayanan
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

Hi Varada,

On 1/8/2026 3:11 PM, Varadarajan Narayanan wrote:
> On Thu, Jan 08, 2026 at 12:19:46PM +0530, 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
>> allows specifying a partition type GUID for environment storage.
>> When enabled, the environment subsystem uses the new type GUID
>> based lookup method via scsi_get_blk_by_type_guid() to find the
>> first matching partition.
>>
>> This change maintains backward compatibility with the existing
>> UUID-based approach.
>>
>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>> ---
>>   env/Kconfig |  7 +++++++
>>   env/scsi.c  | 13 +++++++++++++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/env/Kconfig b/env/Kconfig
>> index b312f9b5324..97cb3d05daf 100644
>> --- a/env/Kconfig
>> +++ b/env/Kconfig
>> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>>   	help
>>   	  UUID of the SCSI partition that you want to store the environment in.
>>
>> +config SCSI_ENV_PART_TYPE_GUID
>> +	string "SCSI partition type GUID for saving environment"
>> +	depends on ENV_IS_IN_SCSI
> Should we add
>
> 	depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID
>
> and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to
> handle them as mutually exclusive...
>
> -Varada

Introduced a choice config (in this respin: 
https://lore.kernel.org/u-boot/20260109070912.4106466-4-balaji.selvanathan@oss.qualcomm.com/) 
as suggested by Tom Rini.

Regards,

Balaji

>
>> +	help
>> +	  Type GUID of the SCSI partition to store the environment in.
>> +	  Uses the first partition matching this type GUID.
>> +
>>   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 207717e17b1..6182ae26679 100644
>> --- a/env/scsi.c
>> +++ b/env/scsi.c
>> @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>>   {
>>   	struct env_scsi_info *ep = &env_part;
>>
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +	if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
>> +		return NULL;
>> +#else
>>   	if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
>>   		return NULL;
>> +#endif
>>
>>   	ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
>>
>> @@ -83,12 +88,20 @@ static int env_scsi_load(void)
>>   	int ret;
>>
>>   	if (!ep) {
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0);
>> +#else
>>   		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
>> +#endif
>>   		return -ENOENT;
>>   	}
>>
>>   	if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +		env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0);
>> +#else
>>   		env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
>> +#endif
>>   		return -EIO;
>>   	}
>>
>> --
>> 2.34.1
>>

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08 14:32     ` Tom Rini
@ 2026-01-09  7:16       ` Balaji Selvanathan
  0 siblings, 0 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-09  7:16 UTC (permalink / raw)
  To: Tom Rini, Varadarajan Narayanan
  Cc: casey.connolly, neil.armstrong, sumit.garg, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

Hi Tom,

On 1/8/2026 8:02 PM, Tom Rini wrote:
> On Thu, Jan 08, 2026 at 03:11:37PM +0530, Varadarajan Narayanan wrote:
>> On Thu, Jan 08, 2026 at 12:19:46PM +0530, 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
>>> allows specifying a partition type GUID for environment storage.
>>> When enabled, the environment subsystem uses the new type GUID
>>> based lookup method via scsi_get_blk_by_type_guid() to find the
>>> first matching partition.
>>>
>>> This change maintains backward compatibility with the existing
>>> UUID-based approach.
>>>
>>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>>> ---
>>>   env/Kconfig |  7 +++++++
>>>   env/scsi.c  | 13 +++++++++++++
>>>   2 files changed, 20 insertions(+)
>>>
>>> diff --git a/env/Kconfig b/env/Kconfig
>>> index b312f9b5324..97cb3d05daf 100644
>>> --- a/env/Kconfig
>>> +++ b/env/Kconfig
>>> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>>>   	help
>>>   	  UUID of the SCSI partition that you want to store the environment in.
>>>
>>> +config SCSI_ENV_PART_TYPE_GUID
>>> +	string "SCSI partition type GUID for saving environment"
>>> +	depends on ENV_IS_IN_SCSI
>> Should we add
>>
>> 	depends on ENV_IS_IN_SCSI && !SCSI_ENV_PART_UUID
>>
>> and similarly vice versa in SCSI_ENV_PART_UUID since the code seems to
>> handle them as mutually exclusive...
> If they're mutually exclusive it needs to be handled in a choice
> statement.

Thanks for the feedback. Introduced a choice config as suggested in this 
respin: 
https://lore.kernel.org/u-boot/20260109070912.4106466-4-balaji.selvanathan@oss.qualcomm.com/.

Regards,

Balaji

>

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-08 17:42   ` Simon Glass
@ 2026-01-09  8:51     ` Balaji Selvanathan
  2026-01-09 11:55       ` Rasmus Villemoes
  2026-01-09 14:48       ` Tom Rini
  0 siblings, 2 replies; 16+ messages in thread
From: Balaji Selvanathan @ 2026-01-09  8:51 UTC (permalink / raw)
  To: Simon Glass
  Cc: casey.connolly, neil.armstrong, sumit.garg, trini, aswin.murugan,
	joe.hershberger, ilias.apalodimas, quentin.schulz, ravi,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

Hi Simon,

On 1/8/2026 11:12 PM, Simon Glass wrote:
> Hi Balaji,
>
> On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
> <balaji.selvanathan@oss.qualcomm.com> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
>> allows specifying a partition type GUID for environment storage.
>> When enabled, the environment subsystem uses the new type GUID
>> based lookup method via scsi_get_blk_by_type_guid() to find the
>> first matching partition.
>>
>> This change maintains backward compatibility with the existing
>> UUID-based approach.
>>
>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>> ---
>>   env/Kconfig |  7 +++++++
>>   env/scsi.c  | 13 +++++++++++++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/env/Kconfig b/env/Kconfig
>> index b312f9b5324..97cb3d05daf 100644
>> --- a/env/Kconfig
>> +++ b/env/Kconfig
>> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>>          help
>>            UUID of the SCSI partition that you want to store the environment in.
>>
>> +config SCSI_ENV_PART_TYPE_GUID
>> +       string "SCSI partition type GUID for saving environment"
>> +       depends on ENV_IS_IN_SCSI
>> +       help
>> +         Type GUID of the SCSI partition to store the environment in.
>> +         Uses the first partition matching this type GUID.
>> +
>>   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 207717e17b1..6182ae26679 100644
>> --- a/env/scsi.c
>> +++ b/env/scsi.c
>> @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>>   {
>>          struct env_scsi_info *ep = &env_part;
>>
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +       if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
> Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
>
> (we try to avoid #ifdef)
Thanks for the feedback.

In this respin 
https://lore.kernel.org/u-boot/20260109070912.4106466-4-balaji.selvanathan@oss.qualcomm.com/, 
I've introduced a choice statement in env/Kconfig to ensure mutual 
exclusivity between CONFIG_SCSI_ENV_PART_UUID and 
CONFIG_SCSI_ENV_PART_TYPE_GUID.

Due to this choice-based configuration, only one of these string configs 
is defined at compile time. When I attempted to use `if 
(IS_ENABLED(...))` for the string concatenation cases, I encountered 
compilation errors because the compiler tries to evaluate both branches, 
but the undefined config macro causes an "undeclared identifier" error.

For example:

if (IS_ENABLED(CONFIG_SCSI_ENV_PART_USE_TYPE_GUID))
     env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not 
found", 0);
else
     env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 
0);  // Error: CONFIG_SCSI_ENV_PART_UUID undeclared

Given this constraint with mutually exclusive string configs, I've kept 
the #ifdef approach for these specific cases. I understand the 
preference for IS_ENABLED() for its compile-time checking benefits, but 
in this scenario with string concatenation, the preprocessor conditional 
appears to be necessary.

Would this approach be acceptable, or would you prefer an alternative 
solution?

Best regards,
Balaji
>
>> +               return NULL;
>> +#else
>>          if (scsi_get_blk_by_uuid(CONFIG_SCSI_ENV_PART_UUID, &ep->blk, &ep->part))
>>                  return NULL;
>> +#endif
>>
>>          ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
>>
>> @@ -83,12 +88,20 @@ static int env_scsi_load(void)
>>          int ret;
>>
>>          if (!ep) {
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +               env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found", 0);
>> +#else
>>                  env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0);
>> +#endif
>>                  return -ENOENT;
>>          }
>>
>>          if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>> +               env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition read failed", 0);
>> +#else
>>                  env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition read failed", 0);
>> +#endif
>>                  return -EIO;
>>          }
>>
>> --
>> 2.34.1
>>
> Regards,
> Simon

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-09  8:51     ` Balaji Selvanathan
@ 2026-01-09 11:55       ` Rasmus Villemoes
  2026-01-09 14:48       ` Tom Rini
  1 sibling, 0 replies; 16+ messages in thread
From: Rasmus Villemoes @ 2026-01-09 11:55 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: Simon Glass, casey.connolly, neil.armstrong, sumit.garg, trini,
	aswin.murugan, joe.hershberger, ilias.apalodimas, quentin.schulz,
	javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

On Fri, Jan 09 2026, Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com> wrote:

> Hi Simon,
>
> On 1/8/2026 11:12 PM, Simon Glass wrote:
>> Hi Balaji,
>>
>> On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
>> <balaji.selvanathan@oss.qualcomm.com> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
>>> allows specifying a partition type GUID for environment storage.
>>> When enabled, the environment subsystem uses the new type GUID
>>> based lookup method via scsi_get_blk_by_type_guid() to find the
>>> first matching partition.
>>>
>>> This change maintains backward compatibility with the existing
>>> UUID-based approach.
>>>
>>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>>> ---
>>>   env/Kconfig |  7 +++++++
>>>   env/scsi.c  | 13 +++++++++++++
>>>   2 files changed, 20 insertions(+)
>>>
>>> diff --git a/env/Kconfig b/env/Kconfig
>>> index b312f9b5324..97cb3d05daf 100644
>>> --- a/env/Kconfig
>>> +++ b/env/Kconfig
>>> @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
>>>          help
>>>            UUID of the SCSI partition that you want to store the environment in.
>>>
>>> +config SCSI_ENV_PART_TYPE_GUID
>>> +       string "SCSI partition type GUID for saving environment"
>>> +       depends on ENV_IS_IN_SCSI
>>> +       help
>>> +         Type GUID of the SCSI partition to store the environment in.
>>> +         Uses the first partition matching this type GUID.
>>> +
>>>   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 207717e17b1..6182ae26679 100644
>>> --- a/env/scsi.c
>>> +++ b/env/scsi.c
>>> @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
>>>   {
>>>          struct env_scsi_info *ep = &env_part;
>>>
>>> +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
>>> +       if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
>> Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
>>
>> (we try to avoid #ifdef)
> Thanks for the feedback.
>
> In this respin
> https://lore.kernel.org/u-boot/20260109070912.4106466-4-balaji.selvanathan@oss.qualcomm.com/,
> I've introduced a choice statement in env/Kconfig to ensure mutual
> exclusivity between CONFIG_SCSI_ENV_PART_UUID and
> CONFIG_SCSI_ENV_PART_TYPE_GUID.
>
> Due to this choice-based configuration, only one of these string
> configs is defined at compile time. When I attempted to use `if
> (IS_ENABLED(...))` for the string concatenation cases, I encountered
> compilation errors because the compiler tries to evaluate both
> branches, but the undefined config macro causes an "undeclared
> identifier" error.
>

I think you could do

config SCSI_ENV_PART_TYPE_GUID
	string "SCSI partition type GUID for saving environment" if SCSI_ENV_PART_USE_TYPE_GUID
	help
	  Type GUID of the SCSI partition to store the environment in.
	  Uses the first partition matching this type GUID.

instead of

config SCSI_ENV_PART_TYPE_GUID
	string "SCSI partition type GUID for saving environment"
	depends on SCSI_ENV_PART_USE_TYPE_GUID
	help
	  Type GUID of the SCSI partition to store the environment in.
	  Uses the first partition matching this type GUID.


Then the config symbol always exists, but is only visible/changable when
relevant.

Also, I suggest adding

  default "3de21764-95bd-54bd-a5c3-4abe786f38a8"

There's really no reason everybody should come up with their own, and we
already have exactly that type guid defined to mean "partition
containing a u-boot environment".

Rasmus

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

* Re: [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment
  2026-01-09  8:51     ` Balaji Selvanathan
  2026-01-09 11:55       ` Rasmus Villemoes
@ 2026-01-09 14:48       ` Tom Rini
  1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2026-01-09 14:48 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: Simon Glass, casey.connolly, neil.armstrong, sumit.garg,
	aswin.murugan, joe.hershberger, ilias.apalodimas, quentin.schulz,
	ravi, javier.tia, quic_varada, marek.vasut+renesas, michal.simek,
	ansuelsmth, mwalle, anshuld, jan.kiszka, javierm, u-boot-qcom,
	u-boot

[-- Attachment #1: Type: text/plain, Size: 4150 bytes --]

On Fri, Jan 09, 2026 at 02:21:28PM +0530, Balaji Selvanathan wrote:
> Hi Simon,
> 
> On 1/8/2026 11:12 PM, Simon Glass wrote:
> > Hi Balaji,
> > 
> > On Wed, 7 Jan 2026 at 23:50, Balaji Selvanathan
> > <balaji.selvanathan@oss.qualcomm.com> 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 CONFIG_SCSI_ENV_PART_TYPE_GUID configuration option that
> > > allows specifying a partition type GUID for environment storage.
> > > When enabled, the environment subsystem uses the new type GUID
> > > based lookup method via scsi_get_blk_by_type_guid() to find the
> > > first matching partition.
> > > 
> > > This change maintains backward compatibility with the existing
> > > UUID-based approach.
> > > 
> > > Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> > > ---
> > >   env/Kconfig |  7 +++++++
> > >   env/scsi.c  | 13 +++++++++++++
> > >   2 files changed, 20 insertions(+)
> > > 
> > > diff --git a/env/Kconfig b/env/Kconfig
> > > index b312f9b5324..97cb3d05daf 100644
> > > --- a/env/Kconfig
> > > +++ b/env/Kconfig
> > > @@ -768,6 +768,13 @@ config SCSI_ENV_PART_UUID
> > >          help
> > >            UUID of the SCSI partition that you want to store the environment in.
> > > 
> > > +config SCSI_ENV_PART_TYPE_GUID
> > > +       string "SCSI partition type GUID for saving environment"
> > > +       depends on ENV_IS_IN_SCSI
> > > +       help
> > > +         Type GUID of the SCSI partition to store the environment in.
> > > +         Uses the first partition matching this type GUID.
> > > +
> > >   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 207717e17b1..6182ae26679 100644
> > > --- a/env/scsi.c
> > > +++ b/env/scsi.c
> > > @@ -35,8 +35,13 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
> > >   {
> > >          struct env_scsi_info *ep = &env_part;
> > > 
> > > +#ifdef CONFIG_SCSI_ENV_PART_TYPE_GUID
> > > +       if (scsi_get_blk_by_type_guid(CONFIG_SCSI_ENV_PART_TYPE_GUID, &ep->blk, &ep->part))
> > Can you use if IS_ENABLED(CONFIG_SCSI_ENV_PART_TYPE_GUID)
> > 
> > (we try to avoid #ifdef)
> Thanks for the feedback.
> 
> In this respin https://lore.kernel.org/u-boot/20260109070912.4106466-4-balaji.selvanathan@oss.qualcomm.com/,
> I've introduced a choice statement in env/Kconfig to ensure mutual
> exclusivity between CONFIG_SCSI_ENV_PART_UUID and
> CONFIG_SCSI_ENV_PART_TYPE_GUID.
> 
> Due to this choice-based configuration, only one of these string configs is
> defined at compile time. When I attempted to use `if (IS_ENABLED(...))` for
> the string concatenation cases, I encountered compilation errors because the
> compiler tries to evaluate both branches, but the undefined config macro
> causes an "undeclared identifier" error.
> 
> For example:
> 
> if (IS_ENABLED(CONFIG_SCSI_ENV_PART_USE_TYPE_GUID))
>     env_set_default(CONFIG_SCSI_ENV_PART_TYPE_GUID " partition not found",
> 0);
> else
>     env_set_default(CONFIG_SCSI_ENV_PART_UUID " partition not found", 0); 
> // Error: CONFIG_SCSI_ENV_PART_UUID undeclared
> 
> Given this constraint with mutually exclusive string configs, I've kept the
> #ifdef approach for these specific cases. I understand the preference for
> IS_ENABLED() for its compile-time checking benefits, but in this scenario
> with string concatenation, the preprocessor conditional appears to be
> necessary.
> 
> Would this approach be acceptable, or would you prefer an alternative
> solution?

The way to solve this would be to wrap CONFIG_SCSI_ENV_PART_*UID with
CONFIG_VAL(...), but at that point we've also lost the readability
argument of avoiding #ifdef.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2026-01-09 14:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08  6:49 [PATCH v1 0/4] Add partition type GUID support for environment Balaji Selvanathan
2026-01-08  6:49 ` [PATCH v1 1/4] disk: Add partition lookup by type GUID functionality Balaji Selvanathan
2026-01-08  6:49 ` [PATCH v1 2/4] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
2026-01-08  9:37   ` Varadarajan Narayanan
2026-01-08 17:41     ` Simon Glass
2026-01-09  7:13     ` Balaji Selvanathan
2026-01-08  6:49 ` [PATCH v1 3/4] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
2026-01-08  9:41   ` Varadarajan Narayanan
2026-01-08 14:32     ` Tom Rini
2026-01-09  7:16       ` Balaji Selvanathan
2026-01-09  7:15     ` Balaji Selvanathan
2026-01-08 17:42   ` Simon Glass
2026-01-09  8:51     ` Balaji Selvanathan
2026-01-09 11:55       ` Rasmus Villemoes
2026-01-09 14:48       ` Tom Rini
2026-01-08  6:49 ` [PATCH v1 4/4] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan

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.