Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions alioth/src/vfio/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ use crate::pci::config::{
};
use crate::pci::{self, Pci, PciBar};
use crate::sys::vfio::{
VfioIrqSet, VfioIrqSetData, VfioIrqSetFlag, VfioPciIrq, VfioPciRegion, VfioRegionInfo,
VfioRegionInfoFlag,
VfioDeviceInfoFlag, VfioIrqSet, VfioIrqSetData, VfioIrqSetFlag, VfioPciIrq, VfioPciRegion,
VfioRegionInfo, VfioRegionInfoFlag,
};
use crate::vfio::device::Device;
use crate::vfio::{Result, error};
Expand Down Expand Up @@ -205,6 +205,19 @@ where
struct VfioDev<D> {
name: Arc<str>,
dev: D,
flags: VfioDeviceInfoFlag,
}

impl<D> VfioDev<D>
where
D: Device,
{
fn reset(&self) -> Result<()> {
if self.flags.contains(VfioDeviceInfoFlag::RESET) {
self.dev.reset()?;
}
Ok(())
}
}

#[derive(Debug)]
Expand Down Expand Up @@ -365,7 +378,9 @@ where
D: Device,
{
pub fn new(name: Arc<str>, dev: D, msi_sender: M) -> Result<VfioPciDev<M, D>> {
let cdev = Arc::new(VfioDev { dev, name });
let flags = dev.get_info()?.flags;

let cdev = Arc::new(VfioDev { dev, name, flags });

let msi_sender = Arc::new(msi_sender);

Expand Down Expand Up @@ -500,7 +515,7 @@ where

let config_header = ConfigHeader::Device(dev_header);

cdev.dev.reset()?;
cdev.reset()?;

let msix_count = match &msix_cap {
Some(cap) => cap.control.table_len() + 1,
Expand Down Expand Up @@ -578,7 +593,7 @@ where
}

self.msix_table.reset();
self.config.dev.dev.reset()
self.config.dev.reset()
}
}

Expand Down