From: Jie Liu <[email protected]>
V2:
Add a new PCI driver flag, RTE_PCI_DRV_NEED_IOVA_AS_PA, that allows a
driver to tell the PCI bus layer it cannot work with IOVA as VA and
must use IOVA as PA.
The existing RTE_PCI_DRV_NEED_IOVA_AS_VA flag already provides the
opposite requirement. Some PCI devices, however, are managed by a
kernel driver that uses an identity-mapped IOMMU domain (e.g. when the
kernel is booted with iommu=pt). The user-space PMD for such
devices
must use IOVA as PA, because the DMA addresses programmed by DPDK must
match the identity mapping programmed by the kernel driver.
Without this flag, a PCI driver bound to a non-VFIO/UIO kernel driver
has no way to force IOVA as PA. pci_device_iova_mode() returns
RTE_IOVA_DC for those devices, and rte_eal_init() then sees an enabled
IOMMU and selects RTE_IOVA_VA, which breaks identity-domain PMDs and
forces users to pass --iova-mode=pa on the command line.
When RTE_PCI_DRV_NEED_IOVA_AS_PA is set, pci_device_iova_mode()
returns RTE_IOVA_PA for the device. The requirement is propagated
through rte_pci_get_iommu_class() to rte_bus_get_iommu_class(), so
rte_eal_init() selects IOVA as PA automatically.
If a driver sets both RTE_PCI_DRV_NEED_IOVA_AS_VA and
RTE_PCI_DRV_NEED_IOVA_AS_PA at the same time, a warning is emitted
and the conflicting requirement is ignored (RTE_IOVA_DC), because
the two flags are mutually exclusive.
This is a generic mechanism: any PCI driver whose underlying kernel
driver uses an identity IOMMU domain can set the flag.
liufeng1 (1):
bus/pci: add RTE_PCI_DRV_NEED_IOVA_AS_PA flag
drivers/bus/pci/bus_pci_driver.h | 2 ++
drivers/bus/pci/linux/pci.c | 13 +++++++++++++
drivers/bus/pci/pci_common.c | 3 +--
3 files changed, 16 insertions(+), 2 deletions(-)
--
2.52.0