Ignore MSI-X PBA in all drivers
It isn't used in any driver and even on Linux no driver seems to use it at all. The only times it seems to be useful are if you were to mask an interrupt and want to check if the interrupt fired without unmasking or if you want to make the device itself trigger an interrupt.
This commit is contained in:
@@ -109,22 +109,13 @@ fn get_int_method(
|
||||
}
|
||||
let table_bar_base: *mut u8 =
|
||||
bar_base(allocated_bars, function, capability_struct.table_bir())?.as_ptr();
|
||||
let pba_bar_base: *mut u8 =
|
||||
bar_base(allocated_bars, function, capability_struct.pba_bir())?.as_ptr();
|
||||
let table_base =
|
||||
unsafe { table_bar_base.offset(capability_struct.table_offset() as isize) };
|
||||
let pba_base = unsafe { pba_bar_base.offset(capability_struct.pba_offset() as isize) };
|
||||
|
||||
let vector_count = capability_struct.table_size();
|
||||
let table_entries: &'static mut [MsixTableEntry] = unsafe {
|
||||
slice::from_raw_parts_mut(table_base as *mut MsixTableEntry, vector_count as usize)
|
||||
};
|
||||
let pba_entries: &'static mut [Mmio<u64>] = unsafe {
|
||||
slice::from_raw_parts_mut(
|
||||
table_base as *mut Mmio<u64>,
|
||||
(vector_count as usize + 63) / 64,
|
||||
)
|
||||
};
|
||||
|
||||
// Mask all interrupts in case some earlier driver/os already unmasked them (according to
|
||||
// the PCI Local Bus spec 3.0, they are masked after system reset).
|
||||
@@ -162,7 +153,6 @@ fn get_int_method(
|
||||
let interrupt_method = InterruptMethod::MsiX(MsixCfg {
|
||||
cap: capability_struct,
|
||||
table: table_entries,
|
||||
pba: pba_entries,
|
||||
});
|
||||
let interrupt_sources =
|
||||
InterruptSources::MsiX(std::iter::once((msix_vector_number, irq_handle)).collect());
|
||||
|
||||
@@ -122,7 +122,6 @@ impl InterruptMethod {
|
||||
pub struct MsixCfg {
|
||||
pub cap: MsixCapability,
|
||||
pub table: &'static mut [MsixTableEntry],
|
||||
pub pba: &'static mut [Mmio<u64>],
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
|
||||
@@ -81,7 +81,6 @@ where
|
||||
|
||||
pub struct MsixInfo {
|
||||
pub virt_table_base: NonNull<MsixTableEntry>,
|
||||
pub virt_pba_base: NonNull<u64>,
|
||||
pub capability: MsixCapability,
|
||||
}
|
||||
|
||||
@@ -93,18 +92,6 @@ impl MsixInfo {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.table_entry_pointer_unchecked(k) }
|
||||
}
|
||||
pub unsafe fn pba_pointer_unchecked(&mut self, k: usize) -> &mut u64 {
|
||||
&mut *self.virt_pba_base.as_ptr().offset(k as isize)
|
||||
}
|
||||
pub fn pba_pointer(&mut self, k: usize) -> &mut u64 {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.pba_pointer_unchecked(k) }
|
||||
}
|
||||
pub fn pba(&mut self, k: usize) -> bool {
|
||||
let byte = k / 64;
|
||||
let bit = k % 64;
|
||||
*self.pba_pointer(byte) & (1 << bit) != 0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -163,16 +150,13 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
|
||||
};
|
||||
capability.validate(pci_config.func.bars);
|
||||
|
||||
assert_eq!(capability.table_bir(), capability.pba_bir());
|
||||
let bar = &pci_config.func.bars[capability.table_bir() as usize];
|
||||
let bar_address = unsafe { bar.physmap_mem("rtl8139d") } as usize;
|
||||
|
||||
let virt_table_base = (bar_address + capability.table_offset() as usize) as *mut MsixTableEntry;
|
||||
let virt_pba_base = (bar_address + capability.pba_offset() as usize) as *mut u64;
|
||||
|
||||
let mut info = MsixInfo {
|
||||
virt_table_base: NonNull::new(virt_table_base).unwrap(),
|
||||
virt_pba_base: NonNull::new(virt_pba_base).unwrap(),
|
||||
capability,
|
||||
};
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ where
|
||||
|
||||
pub struct MsixInfo {
|
||||
pub virt_table_base: NonNull<MsixTableEntry>,
|
||||
pub virt_pba_base: NonNull<u64>,
|
||||
pub capability: MsixCapability,
|
||||
}
|
||||
|
||||
@@ -91,18 +90,6 @@ impl MsixInfo {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.table_entry_pointer_unchecked(k) }
|
||||
}
|
||||
pub unsafe fn pba_pointer_unchecked(&mut self, k: usize) -> &mut u64 {
|
||||
&mut *self.virt_pba_base.as_ptr().offset(k as isize)
|
||||
}
|
||||
pub fn pba_pointer(&mut self, k: usize) -> &mut u64 {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.pba_pointer_unchecked(k) }
|
||||
}
|
||||
pub fn pba(&mut self, k: usize) -> bool {
|
||||
let byte = k / 64;
|
||||
let bit = k % 64;
|
||||
*self.pba_pointer(byte) & (1 << bit) != 0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -161,16 +148,13 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
|
||||
};
|
||||
capability.validate(pci_config.func.bars);
|
||||
|
||||
assert_eq!(capability.table_bir(), capability.pba_bir());
|
||||
let bar = &pci_config.func.bars[capability.table_bir() as usize];
|
||||
let bar_address = unsafe { bar.physmap_mem("rtl8168d") } as usize;
|
||||
|
||||
let virt_table_base = (bar_address + capability.table_offset() as usize) as *mut MsixTableEntry;
|
||||
let virt_pba_base = (bar_address + capability.pba_offset() as usize) as *mut u64;
|
||||
|
||||
let mut info = MsixInfo {
|
||||
virt_table_base: NonNull::new(virt_table_base).unwrap(),
|
||||
virt_pba_base: NonNull::new(virt_pba_base).unwrap(),
|
||||
capability,
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ pub fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
|
||||
};
|
||||
capability.validate(pci_config.func.bars);
|
||||
|
||||
assert_eq!(capability.table_bir(), capability.pba_bir());
|
||||
let bar = &pci_config.func.bars[capability.table_bir() as usize];
|
||||
let bar_address = unsafe { bar.physmap_mem("virtio-core") } as usize;
|
||||
let virt_table_base = (bar_address + capability.table_offset() as usize) as *mut MsixTableEntry;
|
||||
|
||||
@@ -138,13 +138,10 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle, bar0_address: usize) -> (O
|
||||
capability.validate(pci_config.func.bars);
|
||||
|
||||
assert_eq!(capability.table_bir(), 0);
|
||||
assert_eq!(capability.pba_bir(), 0);
|
||||
let virt_table_base = (bar0_address + capability.table_offset() as usize) as *mut MsixTableEntry;
|
||||
let virt_pba_base = (bar0_address + capability.pba_offset() as usize) as *mut u64;
|
||||
|
||||
let mut info = xhci::MsixInfo {
|
||||
virt_table_base: NonNull::new(virt_table_base).unwrap(),
|
||||
virt_pba_base: NonNull::new(virt_pba_base).unwrap(),
|
||||
capability,
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ pub enum InterruptMethod {
|
||||
|
||||
pub struct MsixInfo {
|
||||
pub virt_table_base: NonNull<MsixTableEntry>,
|
||||
pub virt_pba_base: NonNull<u64>,
|
||||
pub capability: MsixCapability,
|
||||
}
|
||||
impl MsixInfo {
|
||||
@@ -81,18 +80,6 @@ impl MsixInfo {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.table_entry_pointer_unchecked(k) }
|
||||
}
|
||||
pub unsafe fn pba_pointer_unchecked(&mut self, k: usize) -> &mut u64 {
|
||||
&mut *self.virt_pba_base.as_ptr().offset(k as isize)
|
||||
}
|
||||
pub fn pba_pointer(&mut self, k: usize) -> &mut u64 {
|
||||
assert!(k < self.capability.table_size() as usize);
|
||||
unsafe { self.pba_pointer_unchecked(k) }
|
||||
}
|
||||
pub fn pba(&mut self, k: usize) -> bool {
|
||||
let byte = k / 64;
|
||||
let bit = k % 64;
|
||||
*self.pba_pointer(byte) & (1 << bit) != 0
|
||||
}
|
||||
}
|
||||
|
||||
impl Xhci {
|
||||
|
||||
Reference in New Issue
Block a user