Regenerate P2 patches against current upstream (463f76b9 + redox.patch)

Both P2 patches were stale — generated against an older upstream HEAD whose
context lines shifted after redox.patch modified the same files. Regenerated
from scratch against the current upstream commit so they apply cleanly.

P2-boot-runtime-fixes: hwd I2C candidate logging, pcid-spawner initfs detach,
pcid sendfd PCI fd handoff (319 lines)
P2-acpi-i2c-resources: new acpi-resource shared decoder crate (688 lines),
acpid /scheme/acpi/resources/ endpoint, resources.rs re-export shim,
sleep.rs restore (1265 lines)
This commit is contained in:
2026-04-22 23:09:41 +01:00
parent 3054adc5d5
commit 89247e0d77
2 changed files with 1013 additions and 1124 deletions
File diff suppressed because it is too large Load Diff
+88 -102
View File
@@ -1,5 +1,5 @@
diff --git a/drivers/hwd/src/backend/acpi.rs b/drivers/hwd/src/backend/acpi.rs diff --git a/drivers/hwd/src/backend/acpi.rs b/drivers/hwd/src/backend/acpi.rs
index 3da41d63..5d1a9466 100644 index c24dfc4b..12d26261 100644
--- a/drivers/hwd/src/backend/acpi.rs --- a/drivers/hwd/src/backend/acpi.rs
+++ b/drivers/hwd/src/backend/acpi.rs +++ b/drivers/hwd/src/backend/acpi.rs
@@ -1,27 +1,36 @@ @@ -1,27 +1,36 @@
@@ -21,7 +21,7 @@ index 3da41d63..5d1a9466 100644
- // Spawn acpid - // Spawn acpid
- //TODO: pass rxsdt data to acpid? - //TODO: pass rxsdt data to acpid?
- #[allow(deprecated, reason = "we can't yet move this to init")] - #[allow(deprecated, reason = "we can't yet move this to init")]
- daemon::Daemon::spawn(Command::new("acpid")); - let _ = daemon::Daemon::spawn(Command::new("acpid"));
- -
- Ok(Self { rxsdt }) - Ok(Self { rxsdt })
+ Ok(Self { _rxsdt: rxsdt }) + Ok(Self { _rxsdt: rxsdt })
@@ -48,7 +48,7 @@ index 3da41d63..5d1a9466 100644
// TODO: Reimplement with getdents? // TODO: Reimplement with getdents?
let symbols_fd = libredox::Fd::open( let symbols_fd = libredox::Fd::open(
"/scheme/acpi/symbols", "/scheme/acpi/symbols",
@@ -100,12 +109,102 @@ impl Backend for AcpiBackend { @@ -100,12 +109,103 @@ impl Backend for AcpiBackend {
"PNP0C0F" => "PCI interrupt link", "PNP0C0F" => "PCI interrupt link",
"PNP0C50" => "I2C HID", "PNP0C50" => "I2C HID",
"PNP0F13" => "PS/2 port for PS/2-style mouse", "PNP0F13" => "PS/2 port for PS/2-style mouse",
@@ -62,9 +62,7 @@ index 3da41d63..5d1a9466 100644
+ "Intel THC companion (QuickI2C/QuickSPI path)" + "Intel THC companion (QuickI2C/QuickSPI path)"
+ } + }
+ _ if is_elan_touchpad_id(&id) => "ELAN touchpad (I2C/SMBus path)", + _ if is_elan_touchpad_id(&id) => "ELAN touchpad (I2C/SMBus path)",
+ _ if is_cypress_touchpad_id(&id) => { + _ if is_cypress_touchpad_id(&id) => "Cypress/Trackpad (non-HID I2C path)",
+ "Cypress/Trackpad (non-HID I2C path)"
+ }
+ _ if is_synaptics_rmi_id(&id) => "Synaptics RMI touchpad (I2C/SMBus path)", + _ if is_synaptics_rmi_id(&id) => "Synaptics RMI touchpad (I2C/SMBus path)",
_ => "?", _ => "?",
}; };
@@ -133,7 +131,10 @@ index 3da41d63..5d1a9466 100644
+} +}
+ +
+fn is_thc_companion(id: &str) -> bool { +fn is_thc_companion(id: &str) -> bool {
+ matches!(id, "INTC1050" | "INTC1051" | "INTC1080" | "INTC1081" | "INTC1082") + matches!(
+ id,
+ "INTC1050" | "INTC1051" | "INTC1080" | "INTC1081" | "INTC1082"
+ )
+} +}
+ +
+fn is_elan_touchpad_id(id: &str) -> bool { +fn is_elan_touchpad_id(id: &str) -> bool {
@@ -152,16 +153,17 @@ index 3da41d63..5d1a9466 100644
+ is_elan_touchpad_id(id) || is_cypress_touchpad_id(id) || is_synaptics_rmi_id(id) + is_elan_touchpad_id(id) || is_cypress_touchpad_id(id) || is_synaptics_rmi_id(id)
+} +}
diff --git a/drivers/pcid-spawner/src/main.rs b/drivers/pcid-spawner/src/main.rs diff --git a/drivers/pcid-spawner/src/main.rs b/drivers/pcid-spawner/src/main.rs
index a968f4d4..4f0aa7f7 100644 index e41caee0..31a4af5a 100644
--- a/drivers/pcid-spawner/src/main.rs --- a/drivers/pcid-spawner/src/main.rs
+++ b/drivers/pcid-spawner/src/main.rs +++ b/drivers/pcid-spawner/src/main.rs
@@ -1,4 +1,5 @@ @@ -1,11 +1,40 @@
use std::fs;
+use std::env; +use std::env;
use std::fs;
use std::process::Command; use std::process::Command;
+use std::thread;
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
@@ -6,6 +7,38 @@ use anyhow::{anyhow, Context, Result};
use pcid_interface::config::Config; use pcid_interface::config::Config;
use pcid_interface::PciFunctionHandle; use pcid_interface::PciFunctionHandle;
@@ -181,15 +183,10 @@ index a968f4d4..4f0aa7f7 100644
+ return false; + return false;
+ } + }
+ +
+ // Keep storage controller drivers synchronous in initfs so rootfs discovery stays
+ // deterministic. Everything else is non-blocking to avoid wedging boot on optional
+ // hardware paths (GPU, HID companions, etc).
+ if class == 0x01 { + if class == 0x01 {
+ return false; + return false;
+ } + }
+ +
+ // When explicitly requested, keep USB host controller startup synchronous
+ // for rootfs-on-USB scenarios.
+ if strict_usb_boot && class == 0x0C && subclass == 0x03 { + if strict_usb_boot && class == 0x0C && subclass == 0x03 {
+ return false; + return false;
+ } + }
@@ -200,7 +197,7 @@ index a968f4d4..4f0aa7f7 100644
fn main() -> Result<()> { fn main() -> Result<()> {
let mut args = pico_args::Arguments::from_env(); let mut args = pico_args::Arguments::from_env();
let initfs = args.contains("--initfs"); let initfs = args.contains("--initfs");
@@ -30,6 +63,7 @@ fn main() -> Result<()> { @@ -30,6 +59,7 @@ fn main() -> Result<()> {
} }
let config: Config = toml::from_str(&config_data)?; let config: Config = toml::from_str(&config_data)?;
@@ -208,104 +205,93 @@ index a968f4d4..4f0aa7f7 100644
for entry in fs::read_dir("/scheme/pci")? { for entry in fs::read_dir("/scheme/pci")? {
let entry = entry.context("failed to get entry")?; let entry = entry.context("failed to get entry")?;
@@ -55,10 +89,11 @@ fn main() -> Result<()> { @@ -107,24 +137,61 @@ fn main() -> Result<()> {
};
let full_device_id = handle.config().func.full_device_id; log::info!("pcid-spawner: spawn {:?}", command);
+ let device_addr = handle.config().func.addr;
log::debug!(
"pcid-spawner enumerated: PCI {} {}",
- handle.config().func.addr,
+ device_addr,
full_device_id.display()
);
@@ -67,7 +102,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", device_addr);
continue;
};
@@ -85,16 +120,61 @@ fn main() -> Result<()> {
let mut command = Command::new(program);
command.args(args);
- log::info!("pcid-spawner: spawn {:?}", command);
-
- handle.enable_device();
+ log::info!(
+ "pcid-spawner: matched {} to driver {:?}",
+ device_addr,
+ driver.command
+ );
+ log::info!("pcid-spawner: enabling {} before spawn", device_addr);
+
+ if let Err(err) = handle.try_enable_device() {
+ log::error!(
+ "pcid-spawner: failed to enable {} before spawn: {}",
+ device_addr,
+ err
+ );
+ continue;
+ }
let channel_fd = handle.into_inner_fd();
command.env("PCID_CLIENT_CHANNEL", channel_fd.to_string());
+ log::info!("pcid-spawner: spawn {:?}", command);
#[allow(deprecated, reason = "we can't yet move this to init")] #[allow(deprecated, reason = "we can't yet move this to init")]
- daemon::Daemon::spawn(command); - if let Err(err) = daemon::Daemon::spawn(command) {
- syscall::close(channel_fd as usize).unwrap(); - log::error!(
+ let spawn_result = - "pcid-spawner: spawn/readiness failed for {}: {}",
+ if should_detach_in_initfs( - device_addr,
+ initfs, - err
+ full_device_id.class, - );
+ full_device_id.subclass, - log::error!(
+ strict_usb_boot, - "pcid-spawner: {} remains enabled without a confirmed ready driver",
+ ) { + if should_detach_in_initfs(
+ log::warn!( + initfs,
+ "pcid-spawner: detached initfs spawn for {} to avoid blocking early boot", + full_device_id.class,
+ full_device_id.subclass,
+ strict_usb_boot,
+ ) {
+ log::warn!(
+ "pcid-spawner: detached initfs spawn for {} to avoid blocking early boot",
device_addr
);
- }
- if let Err(err) = syscall::close(channel_fd as usize) {
- log::error!(
- "pcid-spawner: failed to close channel fd {} for {}: {}",
- channel_fd,
- device_addr,
- err
- );
+
+ let device_addr = device_addr.to_string();
+ thread::spawn(move || {
+ #[allow(deprecated, reason = "we can't yet move this to init")]
+ if let Err(err) = daemon::Daemon::spawn(command) {
+ log::error!(
+ "pcid-spawner: spawn/readiness failed for {}: {}",
+ device_addr,
+ err
+ );
+ log::error!(
+ "pcid-spawner: {} remains enabled without a confirmed ready driver",
+ device_addr
+ );
+ }
+ if let Err(err) = syscall::close(channel_fd as usize) {
+ log::error!(
+ "pcid-spawner: failed to close channel fd {} for {}: {}",
+ channel_fd,
+ device_addr,
+ err
+ );
+ }
+ });
+ } else {
+ #[allow(deprecated, reason = "we can't yet move this to init")]
+ if let Err(err) = daemon::Daemon::spawn(command) {
+ log::error!(
+ "pcid-spawner: spawn/readiness failed for {}: {}",
+ device_addr,
+ err
+ );
+ log::error!(
+ "pcid-spawner: {} remains enabled without a confirmed ready driver",
+ device_addr + device_addr
+ ); + );
+ daemon::Daemon::spawn_detached(command) + }
+ } else { + if let Err(err) = syscall::close(channel_fd as usize) {
+ daemon::Daemon::spawn(command) + log::error!(
+ }; + "pcid-spawner: failed to close channel fd {} for {}: {}",
+ if let Err(err) = spawn_result { + channel_fd,
+ log::error!( + device_addr,
+ "pcid-spawner: spawn/readiness failed for {}: {}", + err
+ device_addr, + );
+ err + }
+ ); }
+ log::error!(
+ "pcid-spawner: {} remains enabled without a confirmed ready driver",
+ device_addr
+ );
+ }
+ if let Err(err) = syscall::close(channel_fd as usize) {
+ log::error!(
+ "pcid-spawner: failed to close channel fd {} for {}: {}",
+ channel_fd,
+ device_addr,
+ err
+ );
+ }
} }
Ok(())
diff --git a/drivers/pcid/src/main.rs b/drivers/pcid/src/main.rs diff --git a/drivers/pcid/src/main.rs b/drivers/pcid/src/main.rs
index 61cd9a78..a15e5f38 100644 index 61cd9a78..6da034ef 100644
--- a/drivers/pcid/src/main.rs --- a/drivers/pcid/src/main.rs
+++ b/drivers/pcid/src/main.rs +++ b/drivers/pcid/src/main.rs
@@ -12,6 +12,7 @@ use pci_types::{ @@ -12,6 +12,7 @@ use pci_types::{
}; };
use redox_scheme::scheme::register_sync_scheme; use redox_scheme::scheme::register_sync_scheme;
use scheme_utils::Blocking; use scheme_utils::Blocking;
+use syscall::{SendFdFlags, sendfd}; +use syscall::{sendfd, SendFdFlags};
use crate::cfg_access::Pcie; use crate::cfg_access::Pcie;
use pcid_interface::{FullDeviceId, LegacyInterruptLine, PciBar, PciFunction, PciRom}; use pcid_interface::{FullDeviceId, LegacyInterruptLine, PciBar, PciFunction, PciRom};