maint: fix irq priority addition for aarch64/x86_64
This commit is contained in:
@@ -5,7 +5,7 @@ use device_api::{
|
||||
device::Device,
|
||||
interrupt::{
|
||||
ExternalInterruptController, InterruptAffinity, InterruptHandler, Irq, IrqOptions,
|
||||
MessageInterruptController, MsiInfo,
|
||||
IrqPriority, MessageInterruptController, MsiInfo,
|
||||
},
|
||||
};
|
||||
use libk::device::external_interrupt_controller;
|
||||
@@ -215,9 +215,10 @@ impl PciDeviceInfo {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_interrupt(
|
||||
pub fn map_interrupt_with_priority(
|
||||
&self,
|
||||
affinity: InterruptAffinity,
|
||||
priority: IrqPriority,
|
||||
handler: Arc<dyn InterruptHandler>,
|
||||
) -> Result<Option<MsiInfo>, Error> {
|
||||
let mut irq = self.interrupt_config.get().write();
|
||||
@@ -238,17 +239,25 @@ impl PciDeviceInfo {
|
||||
Ok(Some(info[0]))
|
||||
}
|
||||
ConfiguredInterruptMode::LegacyPin(intc, pin) => {
|
||||
self.try_map_legacy(intc.as_ref(), *pin, handler)?;
|
||||
self.try_map_legacy(intc.as_ref(), *pin, priority, handler)?;
|
||||
Ok(None)
|
||||
}
|
||||
ConfiguredInterruptMode::LegacyLine(intc, irq) => {
|
||||
self.try_map_legacy_line(intc.as_ref(), *irq, handler)?;
|
||||
self.try_map_legacy_line(intc.as_ref(), *irq, priority, handler)?;
|
||||
Ok(None)
|
||||
}
|
||||
ConfiguredInterruptMode::None => Err(Error::InvalidOperation),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_interrupt(
|
||||
&self,
|
||||
affinity: InterruptAffinity,
|
||||
handler: Arc<dyn InterruptHandler>,
|
||||
) -> Result<Option<MsiInfo>, Error> {
|
||||
self.map_interrupt_with_priority(affinity, IrqPriority::Normal, handler)
|
||||
}
|
||||
|
||||
pub fn map_interrupt_multiple(
|
||||
&self,
|
||||
vector_range: Range<usize>,
|
||||
@@ -271,6 +280,7 @@ impl PciDeviceInfo {
|
||||
&self,
|
||||
intc: &dyn ExternalInterruptController,
|
||||
pin: PciInterruptPin,
|
||||
priority: IrqPriority,
|
||||
handler: Arc<dyn InterruptHandler>,
|
||||
) -> Result<(), Error> {
|
||||
let src = PciInterrupt {
|
||||
@@ -280,7 +290,7 @@ impl PciDeviceInfo {
|
||||
let route = self
|
||||
.segment
|
||||
.irq_translation_map
|
||||
.map_interrupt(&src)
|
||||
.map_interrupt(&src, priority)
|
||||
.inspect_err(|e| log::warn!("Could not map PCI IRQ {pin:?}: {e:?}"))?;
|
||||
|
||||
log::debug!(
|
||||
@@ -299,12 +309,20 @@ impl PciDeviceInfo {
|
||||
&self,
|
||||
intc: &dyn ExternalInterruptController,
|
||||
line: u8,
|
||||
priority: IrqPriority,
|
||||
handler: Arc<dyn InterruptHandler>,
|
||||
) -> Result<(), Error> {
|
||||
log::debug!("PCI {} -> IRQ#{}", self.address, line);
|
||||
|
||||
let irq = Irq::External(line as u32);
|
||||
intc.register_irq(irq, Default::default(), handler)?;
|
||||
intc.register_irq(
|
||||
irq,
|
||||
IrqOptions {
|
||||
priority,
|
||||
..Default::default()
|
||||
},
|
||||
handler,
|
||||
)?;
|
||||
intc.enable_irq(irq)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use core::fmt;
|
||||
|
||||
use alloc::{collections::btree_map::BTreeMap, sync::Arc, vec::Vec};
|
||||
use device_api::interrupt::MessageInterruptController;
|
||||
use device_api::interrupt::{IrqPriority, MessageInterruptController};
|
||||
use libk::error::Error;
|
||||
|
||||
use crate::{
|
||||
@@ -36,7 +36,11 @@ pub enum PciMsiMap {
|
||||
}
|
||||
|
||||
impl PciInterruptMap {
|
||||
pub fn map_interrupt(&self, interrupt: &PciInterrupt) -> Result<PciInterruptRoute, Error> {
|
||||
pub fn map_interrupt(
|
||||
&self,
|
||||
interrupt: &PciInterrupt,
|
||||
priority: IrqPriority,
|
||||
) -> Result<PciInterruptRoute, Error> {
|
||||
match self {
|
||||
Self::Fixed(map) => map.get(interrupt).cloned().ok_or(Error::DoesNotExist),
|
||||
#[cfg(any(target_arch = "x86_64", rust_analyzer))]
|
||||
@@ -77,7 +81,11 @@ impl PciInterruptMap {
|
||||
};
|
||||
|
||||
Ok(PciInterruptRoute {
|
||||
options: IrqOptions { trigger, level },
|
||||
options: IrqOptions {
|
||||
trigger,
|
||||
level,
|
||||
priority,
|
||||
},
|
||||
number: aml_route.irq,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use device_api::{
|
||||
device::{Device, DeviceInitContext},
|
||||
interrupt::{
|
||||
ExternalInterruptController, InterruptAffinity, InterruptHandler, Irq, IrqLevel,
|
||||
IrqOptions, IrqTrigger, IrqVector, MessageInterruptController, MsiInfo,
|
||||
IrqOptions, IrqPriority, IrqTrigger, IrqVector, MessageInterruptController, MsiInfo,
|
||||
},
|
||||
};
|
||||
use device_tree::driver::{Node, ProbeContext, device_tree_driver};
|
||||
@@ -129,6 +129,7 @@ impl Device for Gicv2m {
|
||||
IrqOptions {
|
||||
trigger: IrqTrigger::Edge,
|
||||
level: IrqLevel::ActiveHigh,
|
||||
priority: IrqPriority::Normal,
|
||||
},
|
||||
self.clone(),
|
||||
)?;
|
||||
|
||||
@@ -198,7 +198,11 @@ impl DeviceTreeInterruptController for Gic {
|
||||
|
||||
Some(IrqHandle {
|
||||
irq,
|
||||
options: IrqOptions { trigger, level },
|
||||
options: IrqOptions {
|
||||
trigger,
|
||||
level,
|
||||
priority: Default::default(),
|
||||
},
|
||||
intc: self.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user