mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
pci: Add a pci-level initialization function for IOMMU notifiers
This is meant to be used by ATS-capable devices. Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com> Message-Id: <20250520071823.764266-10-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
7e94e45296
commit
a849ff5d6f
2 changed files with 50 additions and 0 deletions
17
hw/pci/pci.c
17
hw/pci/pci.c
|
@ -2939,6 +2939,23 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
|
||||||
return &address_space_memory;
|
return &address_space_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pci_iommu_init_iotlb_notifier(PCIDevice *dev, IOMMUNotifier *n,
|
||||||
|
IOMMUNotify fn, void *opaque)
|
||||||
|
{
|
||||||
|
PCIBus *bus;
|
||||||
|
PCIBus *iommu_bus;
|
||||||
|
int devfn;
|
||||||
|
|
||||||
|
pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn);
|
||||||
|
if (iommu_bus && iommu_bus->iommu_ops->init_iotlb_notifier) {
|
||||||
|
iommu_bus->iommu_ops->init_iotlb_notifier(bus, iommu_bus->iommu_opaque,
|
||||||
|
devfn, n, fn, opaque);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
|
bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -442,6 +442,26 @@ typedef struct PCIIOMMUOps {
|
||||||
*/
|
*/
|
||||||
void (*get_iotlb_info)(void *opaque, uint8_t *addr_width,
|
void (*get_iotlb_info)(void *opaque, uint8_t *addr_width,
|
||||||
uint32_t *min_page_size);
|
uint32_t *min_page_size);
|
||||||
|
/**
|
||||||
|
* @init_iotlb_notifier: initialize an IOMMU notifier.
|
||||||
|
*
|
||||||
|
* Optional callback.
|
||||||
|
*
|
||||||
|
* @bus: the #PCIBus of the PCI device.
|
||||||
|
*
|
||||||
|
* @opaque: the data passed to pci_setup_iommu().
|
||||||
|
*
|
||||||
|
* @devfn: device and function number of the PCI device.
|
||||||
|
*
|
||||||
|
* @n: the notifier to be initialized.
|
||||||
|
*
|
||||||
|
* @fn: the callback to be installed.
|
||||||
|
*
|
||||||
|
* @user_opaque: a user pointer that can be used to track a state.
|
||||||
|
*/
|
||||||
|
void (*init_iotlb_notifier)(PCIBus *bus, void *opaque, int devfn,
|
||||||
|
IOMMUNotifier *n, IOMMUNotify fn,
|
||||||
|
void *user_opaque);
|
||||||
} PCIIOMMUOps;
|
} PCIIOMMUOps;
|
||||||
|
|
||||||
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
|
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
|
||||||
|
@ -462,6 +482,19 @@ void pci_device_unset_iommu_device(PCIDevice *dev);
|
||||||
int pci_iommu_get_iotlb_info(PCIDevice *dev, uint8_t *addr_width,
|
int pci_iommu_get_iotlb_info(PCIDevice *dev, uint8_t *addr_width,
|
||||||
uint32_t *min_page_size);
|
uint32_t *min_page_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_iommu_init_iotlb_notifier: initialize an IOMMU notifier.
|
||||||
|
*
|
||||||
|
* This function is used by devices before registering an IOTLB notifier.
|
||||||
|
*
|
||||||
|
* @dev: the device.
|
||||||
|
* @n: the notifier to be initialized.
|
||||||
|
* @fn: the callback to be installed.
|
||||||
|
* @opaque: a user pointer that can be used to track a state.
|
||||||
|
*/
|
||||||
|
int pci_iommu_init_iotlb_notifier(PCIDevice *dev, IOMMUNotifier *n,
|
||||||
|
IOMMUNotify fn, void *opaque);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus
|
* pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue