From: Danilo Krummrich <[email protected]> VFIO manages DMA ownership through the userspace IOMMU interface. Its PCI variant drivers must opt out of the driver's default DMA domain.
Add Driver::DRIVER_MANAGED_DMA and pass it to the PCI core. Existing Rust PCI drivers keep the default setting. Signed-off-by: Danilo Krummrich <[email protected]> Signed-off-by: Zhi Wang <[email protected]> --- rust/kernel/pci.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 10864ffda4ea..a156927e23d5 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -108,6 +108,7 @@ unsafe fn register( (*pdrv.get()).probe = Some(Self::probe_callback); (*pdrv.get()).remove = Some(Self::remove_callback); (*pdrv.get()).id_table = T::ID_TABLE.as_ptr(); + (*pdrv.get()).driver_managed_dma = T::DRIVER_MANAGED_DMA; #[cfg(CONFIG_PCI_IOV)] if T::HAS_SRIOV_ENABLE { (*pdrv.get()).sriov_configure = Some(Self::sriov_configure_callback); @@ -345,6 +346,9 @@ pub trait Driver { /// The table of device ids supported by the driver. const ID_TABLE: IdTable<Self::IdInfo>; + /// Whether the driver manages DMA ownership instead of using the default DMA domain. + const DRIVER_MANAGED_DMA: bool = false; + /// PCI driver probe. /// /// Called when a new pci device is added or discovered. Implementers should -- 2.53.0
