* [PATCH v3 1/5] disk: Add partition lookup by type GUID functionality
2026-04-19 10:24 [PATCH v3 0/5] Add partition type GUID support for environment Balaji Selvanathan
@ 2026-04-19 10:24 ` Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Balaji Selvanathan @ 2026-04-19 10:24 UTC (permalink / raw)
To: u-boot, Sumit Garg, u-boot-qcom
Cc: Tom Rini, Quentin Schulz, Ilias Apalodimas, Javier Tia,
Varadarajan Narayanan, Rasmus Villemoes, Mikhail Kshevetskiy,
Javier Martinez Canillas, Miquel Raynal, João Marcos Costa,
Tien Fong Chee, Richard Genoud, Jan Kiszka, David Lechner,
Casey Connolly, Simon Glass, Marek Vasut, Christian Marangi,
Michael Walle, Sumit Garg, Neil Armstrong, Aswin Murugan,
Varadarajan Narayanan, Simon Glass, Mattijs Korpershoek,
Jerome Forissier, Balaji Selvanathan
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>
---
Changes in v3:
- Addressed minor corrections in part_get_info_by_type_guid function
Changes in v2:
- No changes
---
disk/part.c | 37 +++++++++++++++++++++++++++++++++++++
include/part.h | 21 +++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/disk/part.c b/disk/part.c
index 4923dc44593..4cb3204ac6e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -731,6 +731,43 @@ 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 (!CONFIG_IS_ENABLED(PARTITION_TYPE_GUID))
+ return -ENOENT;
+
+ part_drv = part_driver_lookup_type(desc);
+ if (!part_drv)
+ return -ENOENT;
+
+ for (i = 1; i <= part_drv->max_entries; i++) {
+ ret = part_driver_get_info(part_drv, desc, i, info);
+ if (ret) {
+ /* -ENOSYS means no ->get_info method. */
+ if (ret == -ENOSYS)
+ return ret;
+ /*
+ * 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 15daacd7faa..32614bd085b 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] 6+ messages in thread* [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices
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-19 10:24 ` Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Balaji Selvanathan @ 2026-04-19 10:24 UTC (permalink / raw)
To: u-boot, Sumit Garg, u-boot-qcom
Cc: Tom Rini, Quentin Schulz, Ilias Apalodimas, Javier Tia,
Varadarajan Narayanan, Rasmus Villemoes, Mikhail Kshevetskiy,
Javier Martinez Canillas, Miquel Raynal, João Marcos Costa,
Tien Fong Chee, Richard Genoud, Jan Kiszka, David Lechner,
Casey Connolly, Simon Glass, Marek Vasut, Christian Marangi,
Michael Walle, Sumit Garg, Neil Armstrong, Aswin Murugan,
Varadarajan Narayanan, Simon Glass, Mattijs Korpershoek,
Jerome Forissier, Balaji Selvanathan
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.
Reviewed-by: Simon Glass <simon.glass@canonical.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v3:
- No changes
Changes in v2:
- Compute blk_find_max_devnum(UCLASS_SCSI) only once in scsi_get_blk_by_type_guid()
---
drivers/scsi/scsi-uclass.c | 28 ++++++++++++++++++++++++++--
include/scsi.h | 11 +++++++++++
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi-uclass.c b/drivers/scsi/scsi-uclass.c
index 39b4c7476d4..031dc01b9de 100644
--- a/drivers/scsi/scsi-uclass.c
+++ b/drivers/scsi/scsi-uclass.c
@@ -30,9 +30,10 @@ int scsi_get_blk_by_uuid(const char *uuid,
struct disk_partition *part_info_ptr)
{
struct blk_desc *blk;
- int i, ret;
+ int i, ret, max;
- 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++) {
ret = blk_get_desc(UCLASS_SCSI, i, &blk);
if (ret)
continue;
@@ -47,6 +48,29 @@ int scsi_get_blk_by_uuid(const char *uuid,
return -ENODEV;
}
+int scsi_get_blk_by_type_guid(const char *type_guid,
+ struct blk_desc **blk_desc_ptr,
+ struct disk_partition *part_info_ptr)
+{
+ struct blk_desc *blk;
+ int i, ret, max;
+
+ max = blk_find_max_devnum(UCLASS_SCSI) + 1;
+ for (i = 0; i < max; 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 -ENODEV;
+}
+
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 2520a8b8fe6..83aaf0a70f6 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -366,6 +366,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
+ * Return: 0 if OK, -ve on error
+ */
+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] 6+ messages in thread* [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment
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-19 10:24 ` [PATCH v3 2/5] scsi: Add partition lookup by type GUID for SCSI devices Balaji Selvanathan
@ 2026-04-19 10:24 ` Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 5/5] test: dm: Add partition type GUID lookup test Balaji Selvanathan
4 siblings, 0 replies; 6+ messages in thread
From: Balaji Selvanathan @ 2026-04-19 10:24 UTC (permalink / raw)
To: u-boot, Sumit Garg, u-boot-qcom
Cc: Tom Rini, Quentin Schulz, Ilias Apalodimas, Javier Tia,
Varadarajan Narayanan, Rasmus Villemoes, Mikhail Kshevetskiy,
Javier Martinez Canillas, Miquel Raynal, João Marcos Costa,
Tien Fong Chee, Richard Genoud, Jan Kiszka, David Lechner,
Casey Connolly, Simon Glass, Marek Vasut, Christian Marangi,
Michael Walle, Sumit Garg, Neil Armstrong, Aswin Murugan,
Varadarajan Narayanan, Simon Glass, Mattijs Korpershoek,
Jerome Forissier, Balaji Selvanathan
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.
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.
+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.
+
+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"
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);
+#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);
+#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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards
2026-04-19 10:24 [PATCH v3 0/5] Add partition type GUID support for environment Balaji Selvanathan
` (2 preceding siblings ...)
2026-04-19 10:24 ` [PATCH v3 3/5] env: scsi: Add support for partition type GUID based environment Balaji Selvanathan
@ 2026-04-19 10:24 ` Balaji Selvanathan
2026-04-19 10:24 ` [PATCH v3 5/5] test: dm: Add partition type GUID lookup test Balaji Selvanathan
4 siblings, 0 replies; 6+ messages in thread
From: Balaji Selvanathan @ 2026-04-19 10:24 UTC (permalink / raw)
To: u-boot, Sumit Garg, u-boot-qcom
Cc: Tom Rini, Quentin Schulz, Ilias Apalodimas, Javier Tia,
Varadarajan Narayanan, Rasmus Villemoes, Mikhail Kshevetskiy,
Javier Martinez Canillas, Miquel Raynal, João Marcos Costa,
Tien Fong Chee, Richard Genoud, Jan Kiszka, David Lechner,
Casey Connolly, Simon Glass, Marek Vasut, Christian Marangi,
Michael Walle, Sumit Garg, Neil Armstrong, Aswin Murugan,
Varadarajan Narayanan, Simon Glass, Mattijs Korpershoek,
Jerome Forissier, Balaji Selvanathan
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>
---
Changes in v3:
- No changes
Changes in v2:
- Enable above new config in qcom_qcs615_defconfig and qcm6490_defconfig
---
configs/qcm6490_defconfig | 5 +++++
configs/qcom_qcs615_defconfig | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/configs/qcm6490_defconfig b/configs/qcm6490_defconfig
index 618098c8860..f2bd5e4515f 100644
--- a/configs/qcm6490_defconfig
+++ b/configs/qcm6490_defconfig
@@ -15,3 +15,8 @@ CONFIG_REMAKE_ELF=y
CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs6490-rb3gen2"
CONFIG_FASTBOOT_BUF_ADDR=0xd8800000
+
+CONFIG_ENV_IS_IN_SCSI=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y
+CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
diff --git a/configs/qcom_qcs615_defconfig b/configs/qcom_qcs615_defconfig
index 27666a8129d..88f692b2bca 100644
--- a/configs/qcom_qcs615_defconfig
+++ b/configs/qcom_qcs615_defconfig
@@ -22,3 +22,8 @@ CONFIG_REMAKE_ELF=y
CONFIG_TEXT_BASE=0x9fc00000
CONFIG_FASTBOOT_BUF_ADDR=0xa1600000
+
+CONFIG_ENV_IS_IN_SCSI=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_ENV_SCSI_PART_USE_TYPE_GUID=y
+CONFIG_ENV_SCSI_PART_TYPE_GUID="bc0330eb-3410-4951-a617-03898dbe3372"
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 5/5] test: dm: Add partition type GUID lookup test
2026-04-19 10:24 [PATCH v3 0/5] Add partition type GUID support for environment Balaji Selvanathan
` (3 preceding siblings ...)
2026-04-19 10:24 ` [PATCH v3 4/5] configs: Enable partition type GUID for QCM6490 and QCS615 boards Balaji Selvanathan
@ 2026-04-19 10:24 ` Balaji Selvanathan
4 siblings, 0 replies; 6+ messages in thread
From: Balaji Selvanathan @ 2026-04-19 10:24 UTC (permalink / raw)
To: u-boot, Sumit Garg, u-boot-qcom
Cc: Tom Rini, Quentin Schulz, Ilias Apalodimas, Javier Tia,
Varadarajan Narayanan, Rasmus Villemoes, Mikhail Kshevetskiy,
Javier Martinez Canillas, Miquel Raynal, João Marcos Costa,
Tien Fong Chee, Richard Genoud, Jan Kiszka, David Lechner,
Casey Connolly, Simon Glass, Marek Vasut, Christian Marangi,
Michael Walle, Sumit Garg, Neil Armstrong, Aswin Murugan,
Varadarajan Narayanan, Simon Glass, Mattijs Korpershoek,
Jerome Forissier, Balaji Selvanathan
Add a unit test for the partition type GUID lookup functionality. The
test verifies that partitions can be correctly identified by their type
GUID, specifically testing the ChromeOS kernel partition lookup.
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v3:
- Add unit test for the partition type GUID lookup functionality
---
test/dm/part.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/test/dm/part.c b/test/dm/part.c
index caae23bd4aa..41fb6efe5e4 100644
--- a/test/dm/part.c
+++ b/test/dm/part.c
@@ -8,9 +8,13 @@
#include <mmc.h>
#include <part.h>
#include <part_efi.h>
+#include <asm/global_data.h>
+#include <dm/lists.h>
#include <dm/test.h>
#include <test/ut.h>
+DECLARE_GLOBAL_DATA_PTR;
+
static int do_test(struct unit_test_state *uts, int expected,
const char *part_str, bool whole)
{
@@ -195,3 +199,47 @@ static int dm_test_part_get_info_by_type(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_part_get_info_by_type, UTF_SCAN_PDATA | UTF_SCAN_FDT);
+
+static int dm_test_part_get_info_by_type_guid(struct unit_test_state *uts)
+{
+ struct udevice *dev, *blk_dev;
+ struct blk_desc *desc;
+ struct disk_partition info;
+ ofnode root, node;
+ int partnum;
+
+ if (!IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+ return -EOPNOTSUPP;
+
+ /* Bind the mmc5 node (ChromeOS image with type GUIDs) */
+ root = oftree_root(oftree_default());
+ node = ofnode_find_subnode(root, "mmc5");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
+
+ /* Get the MMC device (probes it), then walk MMC -> BLK parent link */
+ ut_assertok(uclass_get_device_by_seq(UCLASS_MMC, 5, &dev));
+ ut_assertok(blk_get_from_parent(dev, &blk_dev));
+ desc = dev_get_uclass_plat(blk_dev);
+ ut_assert(desc);
+
+ /*
+ * Test: look up the first ChromeOS kernel partition by type GUID.
+ * In the ChromeOS image KERN_A is the first partition carrying the
+ * ChromeOS kernel type GUID (fe3a2a5d-...).
+ */
+ partnum = part_get_info_by_type_guid(desc,
+ "FE3A2A5D-4F32-41A7-B725-ACCC3285A309",
+ &info);
+ ut_assert(partnum > 0);
+
+ /* Test: non-existent GUID must return -ENOENT */
+ ut_asserteq(-ENOENT,
+ part_get_info_by_type_guid(desc,
+ "00000000-0000-0000-0000-000000000000",
+ &info));
+
+ return 0;
+}
+
+DM_TEST(dm_test_part_get_info_by_type_guid, UTF_SCAN_PDATA | UTF_SCAN_FDT);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread