From bb78be5240c71b9cbb0cb02daec84802c5fcac0a Mon Sep 17 00:00:00 2001 From: Vasilito Date: Thu, 7 May 2026 20:51:56 +0100 Subject: [PATCH] fix: expose pcid handoff to spawned drivers Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../base/P4-pcid-public-client-channel.patch | 8 ++++ .../P4-pcid-spawner-pci-coordinate-env.patch | 37 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 local/patches/base/P4-pcid-public-client-channel.patch create mode 100644 local/patches/base/P4-pcid-spawner-pci-coordinate-env.patch diff --git a/local/patches/base/P4-pcid-public-client-channel.patch b/local/patches/base/P4-pcid-public-client-channel.patch new file mode 100644 index 000000000..58df7e7ac --- /dev/null +++ b/local/patches/base/P4-pcid-public-client-channel.patch @@ -0,0 +1,8 @@ +--- a/drivers/pcid/src/driver_interface/mod.rs ++++ b/drivers/pcid/src/driver_interface/mod.rs +@@ -310,4 +310,4 @@ impl PciFunctionHandle { +- fn connect_default() -> Self { ++ pub fn connect_default() -> Self { + let channel_fd = match env::var("PCID_CLIENT_CHANNEL") { + Ok(channel_fd) => channel_fd, + Err(err) => { diff --git a/local/patches/base/P4-pcid-spawner-pci-coordinate-env.patch b/local/patches/base/P4-pcid-spawner-pci-coordinate-env.patch new file mode 100644 index 000000000..9b7e9e455 --- /dev/null +++ b/local/patches/base/P4-pcid-spawner-pci-coordinate-env.patch @@ -0,0 +1,37 @@ +--- a/drivers/pcid-spawner/src/main.rs ++++ b/drivers/pcid-spawner/src/main.rs +@@ -54,11 +54,12 @@ fn main() -> Result<()> { + } + }; + +- let full_device_id = handle.config().func.full_device_id; ++ let func = handle.config().func; ++ let full_device_id = func.full_device_id; + + log::debug!( + "pcid-spawner enumerated: PCI {} {}", +- handle.config().func.addr, ++ func.addr, + full_device_id.display() + ); + +@@ -67,7 +68,7 @@ fn main() -> Result<()> { + .iter() + .find(|driver| driver.match_function(&full_device_id)) + else { +- log::debug!("no driver for {}, continuing", handle.config().func.addr); ++ log::debug!("no driver for {}, continuing", func.addr); + continue; + }; + +@@ -91,6 +92,10 @@ fn main() -> Result<()> { + + let channel_fd = handle.into_inner_fd(); + command.env("PCID_CLIENT_CHANNEL", channel_fd.to_string()); ++ command.env("PCID_SEGMENT", format!("{:04x}", func.addr.segment())); ++ command.env("PCID_BUS", format!("{:02x}", func.addr.bus())); ++ command.env("PCID_DEVICE", format!("{:02x}", func.addr.device())); ++ command.env("PCID_FUNCTION", format!("{}", func.addr.function())); + + #[allow(deprecated, reason = "we can't yet move this to init")] + daemon::Daemon::spawn(command);