mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
hw/pci: Introduce pci_device_[set|unset]_iommu_device()
pci_device_[set|unset]_iommu_device() call pci_device_get_iommu_bus_devfn() to get iommu_bus->iommu_ops and call [set|unset]_iommu_device callback to set/unset HostIOMMUDevice for a given PCI device. Signed-off-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
6c8ed5fea1
commit
b025ea6886
2 changed files with 64 additions and 1 deletions
27
hw/pci/pci.c
27
hw/pci/pci.c
|
@ -2742,6 +2742,33 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
|
|||
return &address_space_memory;
|
||||
}
|
||||
|
||||
bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
|
||||
Error **errp)
|
||||
{
|
||||
PCIBus *iommu_bus;
|
||||
|
||||
/* set_iommu_device requires device's direct BDF instead of aliased BDF */
|
||||
pci_device_get_iommu_bus_devfn(dev, &iommu_bus, NULL, NULL);
|
||||
if (iommu_bus && iommu_bus->iommu_ops->set_iommu_device) {
|
||||
return iommu_bus->iommu_ops->set_iommu_device(pci_get_bus(dev),
|
||||
iommu_bus->iommu_opaque,
|
||||
dev->devfn, hiod, errp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void pci_device_unset_iommu_device(PCIDevice *dev)
|
||||
{
|
||||
PCIBus *iommu_bus;
|
||||
|
||||
pci_device_get_iommu_bus_devfn(dev, &iommu_bus, NULL, NULL);
|
||||
if (iommu_bus && iommu_bus->iommu_ops->unset_iommu_device) {
|
||||
return iommu_bus->iommu_ops->unset_iommu_device(pci_get_bus(dev),
|
||||
iommu_bus->iommu_opaque,
|
||||
dev->devfn);
|
||||
}
|
||||
}
|
||||
|
||||
void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque)
|
||||
{
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue