All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] efi_loader: Emit standard ACPI/PCI device paths for PCI DM devices
@ 2026-12-03  2:21 Dan Holmes-Mitra
  2026-12-03  2:21 ` [PATCH 1/2] efi_loader: Add PCI hardware device path node and text conversion Dan Holmes-Mitra
  2026-12-03  2:21 ` [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices Dan Holmes-Mitra
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03  2:21 UTC (permalink / raw)
  To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini,
	Vincent Stehlé

UEFI device paths built from Driver Model PCI devices currently fall back
to U-Boot-specific VenHw() nodes instead of standard
Acpi(PNP0A03,uid)/Pci(dev,func) hardware paths.

1. Define DEVICE_PATH_SUB_TYPE_PCI and struct efi_device_path_pci per
   UEFI Specification Section 10.3.1.1, format PCI nodes in
   EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, and add selftest coverage in
   lib/efi_selftest/efi_selftest_devicepath.c.
2. Teach dp_size() and dp_fill() to emit Acpi(PNP0A03,uid) for PCI root
   bridges (preferring DT linux,pci-domain with fallback to dev_seq(dev)
   so multi-domain FDTs keep matching segment IDs) and Pci(dev,func)
   nodes for devices residing on a PCI bus (including PCI bridges,
   PCI-attached NICs and MMC controllers, and default PCI controllers).

Tested:
- sandbox_defconfig: bootefi selftest 'device path' passed (0 failures),
  including the new Pci(0x1a,0x2) conversion check.
- Live QEMU arm64 (qemu_arm64_defconfig + -device e1000): `efidebug dh`
  reports `/Acpi(PNP0A03,0)/Pci(0x1,0x0)/MAC(525400123456,1)`.
- qemu_arm64_defconfig with CONFIG_PCI=n: efi_device_path.o compiles cleanly.
- Checked with scripts/checkpatch.pl --strict --u-boot (0 errors, 0 warnings).

Dan Holmes-Mitra (2):
  efi_loader: Add PCI hardware device path node and text conversion
  efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices

 include/efi_api.h                          |  7 +++
 lib/efi_loader/efi_device_path.c           | 62 ++++++++++++++++++++--
 lib/efi_loader/efi_device_path_to_text.c   |  6 +++
 lib/efi_selftest/efi_selftest_devicepath.c | 33 ++++++++++++
 4 files changed, 105 insertions(+), 3 deletions(-)


base-commit: d1caced3a435607435cb7969e34499051a4ac1e6
-- 
2.56.1.911.g883d8bcb20-goog


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

* [PATCH 1/2] efi_loader: Add PCI hardware device path node and text conversion
  2026-12-03  2:21 [PATCH 0/2] efi_loader: Emit standard ACPI/PCI device paths for PCI DM devices Dan Holmes-Mitra
@ 2026-12-03  2:21 ` Dan Holmes-Mitra
  2026-12-03  2:21 ` [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices Dan Holmes-Mitra
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03  2:21 UTC (permalink / raw)
  To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini,
	Vincent Stehlé

Define DEVICE_PATH_SUB_TYPE_PCI and struct efi_device_path_pci per
UEFI Specification Section 10.3.1.1, format PCI hardware nodes as
Pci(0x<device>,0x<function>) in EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, and
add unit test coverage in efi_selftest_devicepath.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 include/efi_api.h                          |  7 +++++
 lib/efi_loader/efi_device_path_to_text.c   |  6 ++++
 lib/efi_selftest/efi_selftest_devicepath.c | 33 ++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 646581150b..6b199ab8dc 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -646,10 +646,17 @@ struct efi_mac_addr {
 } __packed;
 
 #define DEVICE_PATH_TYPE_HARDWARE_DEVICE	0x01
+#  define DEVICE_PATH_SUB_TYPE_PCI		0x01
 #  define DEVICE_PATH_SUB_TYPE_MEMORY		0x03
 #  define DEVICE_PATH_SUB_TYPE_VENDOR		0x04
 #  define DEVICE_PATH_SUB_TYPE_CONTROLLER	0x05
 
+struct efi_device_path_pci {
+	struct efi_device_path dp;
+	u8 function;
+	u8 device;
+} __packed;
+
 struct efi_device_path_memory {
 	struct efi_device_path dp;
 	u32 memory_type;
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 452ec1b2e8..01e0b4a6e2 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -53,6 +53,12 @@ static char *dp_unknown(char *s, struct efi_device_path *dp)
 static char *dp_hardware(char *s, struct efi_device_path *dp)
 {
 	switch (dp->sub_type) {
+	case DEVICE_PATH_SUB_TYPE_PCI: {
+		struct efi_device_path_pci *pdp =
+			(struct efi_device_path_pci *)dp;
+		s += sprintf(s, "Pci(0x%x,0x%x)", pdp->device, pdp->function);
+		break;
+	}
 	case DEVICE_PATH_SUB_TYPE_MEMORY: {
 		struct efi_device_path_memory *mdp =
 			(struct efi_device_path_memory *)dp;
diff --git a/lib/efi_selftest/efi_selftest_devicepath.c b/lib/efi_selftest/efi_selftest_devicepath.c
index 8a22a5d4d9..09f2de2bb3 100644
--- a/lib/efi_selftest/efi_selftest_devicepath.c
+++ b/lib/efi_selftest/efi_selftest_devicepath.c
@@ -405,6 +405,39 @@ static int execute(void)
 		return EFI_ST_FAILURE;
 	}
 
+	/* Test PCI hardware device node conversion */
+	{
+		struct efi_device_path_pci pci_node = {
+			.dp = {
+				.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE,
+				.sub_type = DEVICE_PATH_SUB_TYPE_PCI,
+				.length = sizeof(struct efi_device_path_pci),
+			},
+			.function = 2,
+			.device = 0x1a,
+		};
+
+		struct efi_device_path *dp =
+			(struct efi_device_path *)&pci_node;
+
+		string = device_path_to_text->convert_device_node_to_text(dp,
+								  true, false);
+		if (!string) {
+			efi_st_error("ConvertDeviceNodeToText (PCI) failed\n");
+			return EFI_ST_FAILURE;
+		}
+		if (efi_st_strcmp_16_8(string, "Pci(0x1a,0x2)")) {
+			efi_st_printf("pci_node: %ps\n", string);
+			efi_st_error("Incorrect PCI device node text\n");
+			return EFI_ST_FAILURE;
+		}
+		ret = boottime->free_pool(string);
+		if (ret != EFI_SUCCESS) {
+			efi_st_error("FreePool failed\n");
+			return EFI_ST_FAILURE;
+		}
+	}
+
 	/* Test ConvertDeviceNodeToText */
 	string = device_path_to_text->convert_device_node_to_text(
 			(struct efi_device_path *)&dp_node, true, false);
-- 
2.56.1.911.g883d8bcb20-goog


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

* [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices
  2026-12-03  2:21 [PATCH 0/2] efi_loader: Emit standard ACPI/PCI device paths for PCI DM devices Dan Holmes-Mitra
  2026-12-03  2:21 ` [PATCH 1/2] efi_loader: Add PCI hardware device path node and text conversion Dan Holmes-Mitra
@ 2026-12-03  2:21 ` Dan Holmes-Mitra
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Holmes-Mitra @ 2026-12-03  2:21 UTC (permalink / raw)
  To: u-boot; +Cc: Heinrich Schuchardt, Ilias Apalodimas, Tom Rini,
	Vincent Stehlé

Construct standard Acpi(PNP0A03,uid)/Pci(dev,func) UEFI device paths in
dp_size() and dp_fill() for PCI root bridges and devices on PCI buses
instead of falling back to U-Boot-specific VenHw() nodes.

Prefer the devicetree linux,pci-domain property for the root bridge
ACPI UID (falling back to dev_seq(dev)) so multi-domain platforms whose
FDT declares PCI hosts out of numeric order keep matching segment IDs.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 lib/efi_loader/efi_device_path.c | 62 ++++++++++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 0389af2390..38ffdfe207 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -17,6 +17,7 @@
 #include <usb.h>
 #include <mmc.h>
 #include <nvme.h>
+#include <pci.h>
 #include <efi_loader.h>
 #include <part.h>
 #include <u-boot/uuid.h>
@@ -379,8 +380,19 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
 	case UCLASS_ROOT:
 		/* stop traversing parents at this point: */
 		return sizeof(struct efi_device_path_udevice);
+	case UCLASS_PCI:
+		if (IS_ENABLED(CONFIG_PCI)) {
+			if (!device_is_on_pci_bus(dev))
+				return sizeof(struct efi_device_path_acpi_path);
+			return dp_size(dev->parent) +
+				sizeof(struct efi_device_path_pci);
+		}
+		return dp_size(dev->parent) +
+			sizeof(struct efi_device_path_udevice);
 	case UCLASS_ETH:
 		return dp_size(dev->parent) +
+			(IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev) ?
+			 sizeof(struct efi_device_path_pci) : 0) +
 			sizeof(struct efi_device_path_mac_addr);
 	case UCLASS_BLK:
 		switch (dev->parent->uclass->uc_drv->id) {
@@ -422,6 +434,8 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
 #if defined(CONFIG_MMC)
 	case UCLASS_MMC:
 		return dp_size(dev->parent) +
+			(IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev) ?
+			 sizeof(struct efi_device_path_pci) : 0) +
 			sizeof(struct efi_device_path_sd_mmc_path);
 #endif
 	case UCLASS_MASS_STORAGE:
@@ -429,11 +443,27 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
 		return dp_size(dev->parent) +
 			sizeof(struct efi_device_path_usb);
 	default:
+		if (IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev))
+			return dp_size(dev->parent) +
+				sizeof(struct efi_device_path_pci);
 		return dp_size(dev->parent) +
 			sizeof(struct efi_device_path_udevice);
 	}
 }
 
+__maybe_unused static void *dp_fill_pci(void *buf, struct udevice *dev)
+{
+	struct efi_device_path_pci *pdp = buf;
+	struct pci_child_plat *pplat = dev_get_parent_plat(dev);
+
+	pdp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
+	pdp->dp.sub_type = DEVICE_PATH_SUB_TYPE_PCI;
+	pdp->dp.length = sizeof(*pdp);
+	pdp->function = PCI_FUNC(pplat->devfn);
+	pdp->device = PCI_DEV(pplat->devfn);
+	return &pdp[1];
+}
+
 /*
  * Recursively build a device path.
  *
@@ -449,15 +479,33 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 		return buf;
 
 	uclass_id = device_get_uclass_id(dev);
+	if (IS_ENABLED(CONFIG_PCI) && uclass_id == UCLASS_PCI &&
+	    !device_is_on_pci_bus(dev)) {
+		struct efi_device_path_acpi_path *adp = buf;
+		u32 uid = dev_seq(dev) >= 0 ? dev_seq(dev) : 0;
+
+		dev_read_u32(dev, "linux,pci-domain", &uid);
+		adp->dp.type = DEVICE_PATH_TYPE_ACPI_DEVICE;
+		adp->dp.sub_type = DEVICE_PATH_SUB_TYPE_ACPI_DEVICE;
+		adp->dp.length = sizeof(*adp);
+		adp->hid = EISA_PNP_ID(0x0a03);
+		adp->uid = uid;
+		return &adp[1];
+	}
+
 	if (uclass_id != UCLASS_ROOT)
 		buf = dp_fill(buf, dev->parent);
 
 	switch (uclass_id) {
 #ifdef CONFIG_NETDEVICES
 	case UCLASS_ETH: {
-		struct efi_device_path_mac_addr *dp = buf;
+		struct efi_device_path_mac_addr *dp;
 		struct eth_pdata *pdata = dev_get_plat(dev);
 
+		if (IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev))
+			buf = dp_fill_pci(buf, dev);
+
+		dp = buf;
 		dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
 		dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR;
 		dp->dp.length = sizeof(*dp);
@@ -573,10 +621,14 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 	}
 #if defined(CONFIG_MMC)
 	case UCLASS_MMC: {
-		struct efi_device_path_sd_mmc_path *sddp = buf;
+		struct efi_device_path_sd_mmc_path *sddp;
 		struct mmc *mmc = mmc_get_mmc_dev(dev);
 		struct blk_desc *desc = mmc_get_blk_desc(mmc);
 
+		if (IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev))
+			buf = dp_fill_pci(buf, dev);
+
+		sddp = buf;
 		sddp->dp.type     = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
 		sddp->dp.sub_type = is_sd(desc) ?
 			DEVICE_PATH_SUB_TYPE_MSG_SD :
@@ -609,8 +661,12 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 		return &udp[1];
 	}
 	default: {
-		struct efi_device_path_udevice *vdp = buf;
+		struct efi_device_path_udevice *vdp;
+
+		if (IS_ENABLED(CONFIG_PCI) && device_is_on_pci_bus(dev))
+			return dp_fill_pci(buf, dev);
 
+		vdp = buf;
 		vdp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
 		vdp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
 		vdp->dp.length = sizeof(*vdp);
-- 
2.56.1.911.g883d8bcb20-goog


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

end of thread, other threads:[~2026-12-03  5:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  2:21 [PATCH 0/2] efi_loader: Emit standard ACPI/PCI device paths for PCI DM devices Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 1/2] efi_loader: Add PCI hardware device path node and text conversion Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices Dan Holmes-Mitra

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.