cee25393d8
- Fix P15-8-init-cycle-detection.patch: replace visiting+error with seen+silent-skip to eliminate 11 false-positive 'dependency cycle detected' errors on shared deps - Fix P0-daemon-fix-init-notify-unwrap.patch: remove eprintln! for missing INIT_NOTIFY (expected for oneshot_async services, ~7 daemons affected) - Fix driver-manager hotplug loop: add PERMANENTLY_SKIPPED static set shared between hotplug handler and DriverConfig::probe() to stop infinite re-probing of Fatal/NotSupported/deferred-exhausted device+driver pairs (e.g. ided) - Fix driver-manager log_timeline: suppress repeated EPIPE/ENOENT errors with AtomicI32 dedup and AtomicBool one-shot guards for boot timeline JSON - Add driver-manager SIGTERM handler, ACPI bus registration, --status mode, driver reap loop, graceful shutdown, and reduced deferred retries (30→3)
213 lines
7.4 KiB
Diff
213 lines
7.4 KiB
Diff
--- a/drivers/acpid/src/aml_physmem.rs
|
|
+++ b/drivers/acpid/src/aml_physmem.rs
|
|
@@ -143,7 +143,7 @@
|
|
#[derive(Clone)]
|
|
pub struct AmlPhysMemHandler {
|
|
page_cache: Arc<Mutex<AmlPageCache>>,
|
|
- pci_fd: Arc<Option<libredox::Fd>>,
|
|
+ pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>,
|
|
aml_mutexes: Arc<Mutex<FxHashMap<u32, Arc<AmlMutex>>>>,
|
|
next_mutex_handle: Arc<AtomicU32>,
|
|
}
|
|
@@ -163,16 +163,10 @@
|
|
/// Read from a physical address.
|
|
/// Generic parameter must be u8, u16, u32 or u64.
|
|
impl AmlPhysMemHandler {
|
|
- pub fn new(pci_fd_opt: Option<&libredox::Fd>, page_cache: Arc<Mutex<AmlPageCache>>) -> Self {
|
|
- let pci_fd = if let Some(pci_fd) = pci_fd_opt {
|
|
- Some(libredox::Fd::new(pci_fd.raw()))
|
|
- } else {
|
|
- log::error!("pci_fd is not registered");
|
|
- None
|
|
- };
|
|
+ pub fn new(pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>, page_cache: Arc<Mutex<AmlPageCache>>) -> Self {
|
|
Self {
|
|
page_cache,
|
|
- pci_fd: Arc::new(pci_fd),
|
|
+ pci_fd,
|
|
aml_mutexes: Arc::new(Mutex::new(FxHashMap::default())),
|
|
next_mutex_handle: Arc::new(AtomicU32::new(1)),
|
|
}
|
|
@@ -218,7 +212,8 @@
|
|
|
|
fn read_pci(&self, addr: PciAddress, off: u16, value: &mut [u8]) {
|
|
let metadata = Self::pci_call_metadata(1, addr, off);
|
|
- match &*self.pci_fd {
|
|
+ let guard = self.pci_fd.read();
|
|
+ match guard.as_ref() {
|
|
Some(pci_fd) => match pci_fd.call_ro(value, syscall::CallFlags::empty(), &metadata) {
|
|
Ok(_) => {}
|
|
Err(err) => {
|
|
@@ -236,7 +231,8 @@
|
|
|
|
fn write_pci(&self, addr: PciAddress, off: u16, value: &[u8]) {
|
|
let metadata = Self::pci_call_metadata(2, addr, off);
|
|
- match &*self.pci_fd {
|
|
+ let guard = self.pci_fd.read();
|
|
+ match guard.as_ref() {
|
|
Some(pci_fd) => match pci_fd.call_wo(value, syscall::CallFlags::empty(), &metadata) {
|
|
Ok(_) => {}
|
|
Err(err) => {
|
|
--- a/drivers/acpid/src/acpi.rs
|
|
+++ b/drivers/acpid/src/acpi.rs
|
|
@@ -245,24 +245,26 @@
|
|
symbol_cache: FxHashMap<String, String>,
|
|
page_cache: Arc<Mutex<AmlPageCache>>,
|
|
aml_region_handlers: Vec<(RegionSpace, Box<dyn RegionHandler>)>,
|
|
+ pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>,
|
|
}
|
|
|
|
impl AmlSymbols {
|
|
- pub fn new(aml_region_handlers: Vec<(RegionSpace, Box<dyn RegionHandler>)>) -> Self {
|
|
+ pub fn new(aml_region_handlers: Vec<(RegionSpace, Box<dyn RegionHandler>)>, pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>) -> Self {
|
|
Self {
|
|
aml_context: None,
|
|
symbol_cache: FxHashMap::default(),
|
|
page_cache: Arc::new(Mutex::new(AmlPageCache::default())),
|
|
aml_region_handlers,
|
|
+ pci_fd,
|
|
}
|
|
}
|
|
|
|
- pub fn init(&mut self, pci_fd: Option<&libredox::Fd>) -> Result<(), Box<dyn Error>> {
|
|
+ pub fn init(&mut self) -> Result<(), Box<dyn Error>> {
|
|
if self.aml_context.is_some() {
|
|
return Err("AML interpreter already initialized".into());
|
|
}
|
|
let format_err = |err| format!("{:?}", err);
|
|
- let handler = AmlPhysMemHandler::new(pci_fd, Arc::clone(&self.page_cache));
|
|
+ let handler = AmlPhysMemHandler::new(Arc::clone(&self.pci_fd), Arc::clone(&self.page_cache));
|
|
//TODO: use these parsed tables for the rest of acpid
|
|
let rsdp_address = usize::from_str_radix(&std::env::var("RSDP_ADDR")?, 16)?;
|
|
let tables =
|
|
@@ -278,10 +280,9 @@
|
|
|
|
pub fn aml_context_mut(
|
|
&mut self,
|
|
- pci_fd: Option<&libredox::Fd>,
|
|
) -> Result<&mut Interpreter<AmlPhysMemHandler>, AmlEvalError> {
|
|
if self.aml_context.is_none() {
|
|
- match self.init(pci_fd) {
|
|
+ match self.init() {
|
|
Ok(()) => (),
|
|
Err(err) => {
|
|
log::error!("failed to initialize AML context: {}", err);
|
|
@@ -305,8 +306,8 @@
|
|
None
|
|
}
|
|
|
|
- pub fn build_cache(&mut self, pci_fd: Option<&libredox::Fd>) {
|
|
- let Ok(aml_context) = self.aml_context_mut(pci_fd) else {
|
|
+ pub fn build_cache(&mut self) {
|
|
+ let Ok(aml_context) = self.aml_context_mut() else {
|
|
return;
|
|
};
|
|
|
|
@@ -382,6 +383,8 @@
|
|
|
|
aml_symbols: RwLock<AmlSymbols>,
|
|
|
|
+ pub pci_fd: Arc<parking_lot::RwLock<Option<libredox::Fd>>>,
|
|
+
|
|
// TODO: The kernel ACPI code seemed to use load_table quite ubiquitously, however ACPI 5.1
|
|
// states that DDBHandles can only be obtained when loading XSDT-pointed tables. So, we'll
|
|
// generate an index only for those.
|
|
@@ -397,7 +400,7 @@
|
|
args: Vec<AmlSerdeValue>,
|
|
) -> Result<AmlSerdeValue, AmlEvalError> {
|
|
let mut symbols = self.aml_symbols.write();
|
|
- let interpreter = symbols.aml_context_mut(None)?;
|
|
+ let interpreter = symbols.aml_context_mut()?;
|
|
interpreter.acquire_global_lock(16)?;
|
|
|
|
let args = args
|
|
@@ -440,13 +443,17 @@
|
|
})
|
|
.collect::<Vec<Sdt>>();
|
|
|
|
+ let pci_fd = Arc::new(parking_lot::RwLock::new(None));
|
|
+
|
|
let mut this = Self {
|
|
tables,
|
|
dsdt: None,
|
|
fadt: None,
|
|
|
|
// Temporary values
|
|
- aml_symbols: RwLock::new(AmlSymbols::new(ec)),
|
|
+ aml_symbols: RwLock::new(AmlSymbols::new(ec, Arc::clone(&pci_fd))),
|
|
+
|
|
+ pci_fd,
|
|
|
|
next_ctx: RwLock::new(0),
|
|
|
|
@@ -526,7 +533,7 @@
|
|
}
|
|
|
|
pub fn aml_lookup(&self, symbol: &str) -> Option<String> {
|
|
- if let Ok(aml_symbols) = self.aml_symbols(None) {
|
|
+ if let Ok(aml_symbols) = self.aml_symbols() {
|
|
aml_symbols.lookup(symbol)
|
|
} else {
|
|
None
|
|
@@ -535,7 +542,6 @@
|
|
|
|
pub fn aml_symbols(
|
|
&self,
|
|
- pci_fd: Option<&libredox::Fd>,
|
|
) -> Result<RwLockReadGuard<'_, AmlSymbols>, AmlError> {
|
|
// return the cached value if it exists
|
|
let symbols = self.aml_symbols.read();
|
|
@@ -550,7 +556,7 @@
|
|
|
|
let mut aml_symbols = self.aml_symbols.write();
|
|
|
|
- aml_symbols.build_cache(pci_fd);
|
|
+ aml_symbols.build_cache();
|
|
|
|
// return the cached value
|
|
Ok(RwLockWriteGuard::downgrade(aml_symbols))
|
|
--- a/drivers/acpid/src/scheme.rs
|
|
+++ b/drivers/acpid/src/scheme.rs
|
|
@@ -26,7 +26,6 @@
|
|
pub struct AcpiScheme<'acpi, 'sock> {
|
|
ctx: &'acpi AcpiContext,
|
|
handles: HandleMap<Handle<'acpi>>,
|
|
- pci_fd: Option<Fd>,
|
|
socket: &'sock Socket,
|
|
}
|
|
|
|
@@ -77,7 +76,6 @@
|
|
Self {
|
|
ctx,
|
|
handles: HandleMap::new(),
|
|
- pci_fd: None,
|
|
socket,
|
|
}
|
|
}
|
|
@@ -204,7 +202,7 @@
|
|
}
|
|
|
|
["symbols"] => {
|
|
- if let Ok(aml_symbols) = self.ctx.aml_symbols(self.pci_fd.as_ref()) {
|
|
+ if let Ok(aml_symbols) = self.ctx.aml_symbols() {
|
|
HandleKind::Symbols(aml_symbols)
|
|
} else {
|
|
return Err(Error::new(EIO));
|
|
@@ -470,10 +468,12 @@
|
|
}
|
|
let new_fd = libredox::Fd::new(new_fd);
|
|
|
|
- if self.pci_fd.is_some() {
|
|
- return Err(Error::new(EINVAL));
|
|
- } else {
|
|
- self.pci_fd = Some(new_fd);
|
|
+ {
|
|
+ let mut pci_fd = self.ctx.pci_fd.write();
|
|
+ if pci_fd.is_some() {
|
|
+ return Err(Error::new(EINVAL));
|
|
+ }
|
|
+ *pci_fd = Some(new_fd);
|
|
}
|
|
|
|
Ok(num_fds)
|