From: Dan Holmes-Mitra <dholmesm@google.com>
To: u-boot@lists.u-boot-project.org
Cc: "Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Tom Rini" <trini@konsulko.com>,
"Vincent Stehlé" <vincent.stehle@arm.com>
Subject: [PATCH 2/2] efi_loader: Emit ACPI/PCI device path nodes for PCI DM devices
Date: Thu, 03 Dec 2026 02:21:20 GMT [thread overview]
Message-ID: <20261203022028.05-02-dholmesm@google.com> (raw)
In-Reply-To: <20261203022028.05-00-dholmesm@google.com>
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
prev parent reply other threads:[~2026-12-03 5:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203022028.05-02-dholmesm@google.com \
--to=dholmesm@google.com \
--cc=ilias.apalodimas@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=vincent.stehle@arm.com \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox