mbox series

[v1,00/10] iommufd: Add VIOMMU infrastructure (Part-2 VIRQ)

Message ID cover.1724777091.git.nicolinc@nvidia.com
Headers show
Series iommufd: Add VIOMMU infrastructure (Part-2 VIRQ) | expand

Message

Nicolin Chen Aug. 27, 2024, 5:02 p.m. UTC
As the part-2 of the VIOMMU infrastructure, this series introduces a VIRQ
object after repurposing the existing FAULT object, which provides a nice
notification pathway to the user space already. So, the first thing to do
is reworking the FAULT object.

Mimicing the HWPT structures, add a common EVENT structure to support its
derivatives: EVENT_IOPF (the prior FAULT object) and EVENT_VIRQ (new one).
IOMMUFD_CMD_VIRQ_ALLOC is introduced to allocate EVENT_VIRQ for a VIOMMU.
One VIOMMU can have multiple VIRQs in different types but can not support
multiple VIRQs with the same types.

Drivers might need the VIOMMU's vdev_id list or the exact vdev_id link of
the passthrough device's to forward IRQs/events via the VIOMMU framework.
Thus, extend the set/unset_vdev_id ioctls down to the driver using VIOMMU
ops. This allows drivers to take the control of a vdev_id's lifecycle.

The forwarding part is fairly simple but might need to replace a physical
device ID with a virtual device ID. So, there comes with some helpers for
drivers to use.

As usual, this series comes with the selftest coverage for this new VIRQ,
and with a real world use case in the ARM SMMUv3 driver.

This must be based on the VIOMMU Part-1 series. It's on Github:
https://github.com/nicolinc/iommufd/commits/iommufd_virq-v1
Paring QEMU branch for testing:
https://github.com/nicolinc/qemu/commits/wip/for_iommufd_virq-v1

Thanks!
Nicolin

Nicolin Chen (10):
  iommufd: Rename IOMMUFD_OBJ_FAULT to IOMMUFD_OBJ_EVENT_IOPF
  iommufd: Rename fault.c to event.c
  iommufd: Add IOMMUFD_OBJ_EVENT_VIRQ and IOMMUFD_CMD_VIRQ_ALLOC
  iommufd/viommu: Allow drivers to control vdev_id lifecycle
  iommufd/viommu: Add iommufd_vdev_id_to_dev helper
  iommufd/viommu: Add iommufd_viommu_report_irq helper
  iommufd/selftest: Implement mock_viommu_set/unset_vdev_id
  iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VIRQ for VIRQ coverage
  iommufd/selftest: Add EVENT_VIRQ test coverage
  iommu/arm-smmu-v3: Report virtual IRQ for device in user space

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 109 +++-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |   2 +
 drivers/iommu/iommufd/Makefile                |   2 +-
 drivers/iommu/iommufd/device.c                |   2 +
 drivers/iommu/iommufd/event.c                 | 613 ++++++++++++++++++
 drivers/iommu/iommufd/fault.c                 | 443 -------------
 drivers/iommu/iommufd/hw_pagetable.c          |  12 +-
 drivers/iommu/iommufd/iommufd_private.h       | 147 ++++-
 drivers/iommu/iommufd/iommufd_test.h          |  10 +
 drivers/iommu/iommufd/main.c                  |  13 +-
 drivers/iommu/iommufd/selftest.c              |  66 ++
 drivers/iommu/iommufd/viommu.c                |  25 +-
 drivers/iommu/iommufd/viommu_api.c            |  54 ++
 include/linux/iommufd.h                       |  28 +
 include/uapi/linux/iommufd.h                  |  46 ++
 tools/testing/selftests/iommu/iommufd.c       |  11 +
 tools/testing/selftests/iommu/iommufd_utils.h |  64 ++
 17 files changed, 1130 insertions(+), 517 deletions(-)
 create mode 100644 drivers/iommu/iommufd/event.c
 delete mode 100644 drivers/iommu/iommufd/fault.c