Skip to content

RFC Add Tegra241 (Grace) CMDQV Support (part 2/2)

Nicolin Chen linux-arm-kernel linux-iommu linux-tegra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest14 patches 103 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14iommufd: Move iommufd_object to public iommufd headerdrivers/iommu/iommufd/iommufd_private.h include/linux/iommufd.h+24 -233 replies
2/14iommufd: Swap _iommufd_object_alloc and __iommufd_object_allocdrivers/iommu/iommufd/hw_pagetable.c drivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c+11 -114 replies
3/14iommufd: Prepare for viommu structures and functionsdrivers/iommu/iommufd/Makefile drivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c +1 more+44 -72 replies
4/14iommufd: Add struct iommufd_viommu and iommufd_viommu_opsdrivers/iommu/iommufd/viommu.c include/linux/iommu.h include/linux/iommufd.h+55 -013 replies
5/14iommufd: Add IOMMUFD_OBJ_VIOMMU and IOMMUFD_CMD_VIOMMU_ALLOCdrivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c drivers/iommu/iommufd/viommu.c +2 more+123 -07 replies
6/14iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coveragedrivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_utils.h+67 -00 replies
7/14iommufd: Add viommu set/unset_dev_id opsinclude/linux/iommufd.h+4 -021 replies
8/14iommufd: Add IOMMU_VIOMMU_SET_DEV_ID ioctldrivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c +3 more+103 -036 replies
9/14iommufd/selftest: Add IOMMU_VIOMMU_SET_DEV_ID test coveragedrivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_utils.h+85 -00 replies
10/14iommufd/selftest: Add IOMMU_TEST_OP_MV_CHECK_DEV_IDdrivers/iommu/iommufd/iommufd_test.h drivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c +1 more+68 -00 replies
11/14iommufd: Add struct iommufd_vqueue and its related viommu opsdrivers/iommu/iommufd/viommu.c include/linux/iommu.h include/linux/iommufd.h+29 -00 replies
12/14iommufd: Add IOMMUFD_OBJ_VQUEUE and IOMMUFD_CMD_VQUEUE_ALLOCdrivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c drivers/iommu/iommufd/viommu.c +2 more+129 -08 replies
13/14iommufd: Add mmap infrastructuredrivers/iommu/iommufd/main.c include/linux/iommufd.h+44 -02 replies
14/14iommu/tegra241-cmdqv: Add user-space use supportdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c+317 -50 replies

Reviews trailers per patch

2 of 14 patches have a Reviewed-by or Acked-by.

PatchJason Gunthorpe
1/14R-b
2/14
3/14
4/14
5/14
6/14
7/14R-b
8/14
9/14
10/14
11/14
12/14
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH RFCv1 00/14] Add Tegra241 (Grace) CMDQV Support (part 2/2)

This is an experimental RFC series for VIOMMU infrastructure, using NVIDIA Tegra241 (Grace) CMDQV as a test instance.

VIOMMU obj is used to represent a virtual interface (iommu) backed by an underlying IOMMU's HW-accelerated feature for virtualizaion: for example, NVIDIA's VINTF (v-interface for CMDQV) and AMD"s vIOMMU.

VQUEUE obj is used to represent a virtual command queue (buffer) backed by an underlying IOMMU command queue to passthrough for VMs to use directly:
for example, NVIDIA's Virtual Command Queue and AMD's Command Buffer.

NVIDIA's CMDQV requires a pair of physical and virtual device Stream IDs to process ATC invalidation commands by ARM SMMU. So, set/unset_dev_id ops and ioctls are introduced to VIOMMU.

Also, a passthrough queue has a pair of start and tail pointers/indexes in the real HW registers, which should be mmaped to user space for hypervisor to map to VM's mmio region directly. Thus, iommufd needs an mmap op too.

Some todos/opens:
1. Add selftest coverages for new ioctls
2. The mmap needs a way to get viommu_id. Currently it's getting from vma->vm_pgoff, which might not be ideal.
3. This series is only verified with a single passthrough device that's hehind a physical ARM SMMU. So, devices behind two+ IOMMUs might need some additional support (and verifications).
4. Requires for comments from AMD folks to support AMD's vIOMMU feature.

This series is on Github (for review and reference only):
https://github.com/nicolinc/iommufd/commits/vcmdq_user_space-rfc-v1

Real HW tests wre conducted with this QEMU branch:
https://github.com/nicolinc/qemu/commits/wip/iommufd_vcmdq/

Thanks

Nicolin Chen (14):
iommufd: Move iommufd_object to public iommufd header
iommufd: Swap _iommufd_object_alloc and __iommufd_object_alloc
iommufd: Prepare for viommu structures and functions
iommufd: Add struct iommufd_viommu and iommufd_viommu_ops
iommufd: Add IOMMUFD_OBJ_VIOMMU and IOMMUFD_CMD_VIOMMU_ALLOC iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage
iommufd: Add viommu set/unset_dev_id ops
iommufd: Add IOMMU_VIOMMU_SET_DEV_ID ioctl iommufd/selftest: Add IOMMU_VIOMMU_SET_DEV_ID test coverage iommufd/selftest: Add IOMMU_TEST_OP_MV_CHECK_DEV_ID
iommufd: Add struct iommufd_vqueue and its related viommu ops
iommufd: Add IOMMUFD_OBJ_VQUEUE and IOMMUFD_CMD_VQUEUE_ALLOC
iommufd: Add mmap infrastructure iommu/tegra241-cmdqv: Add user-space use support

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   |  19 ++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  19 ++
 .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c    | 284 +++++++++++++++++-
 drivers/iommu/iommufd/Makefile                |   3 +-
 drivers/iommu/iommufd/device.c                |  11 +
 drivers/iommu/iommufd/hw_pagetable.c          |   4 +-
 drivers/iommu/iommufd/iommufd_private.h       |  71 +++--
 drivers/iommu/iommufd/iommufd_test.h          |   5 +
 drivers/iommu/iommufd/main.c                  |  69 ++++-
 drivers/iommu/iommufd/selftest.c              | 100 ++++++
 drivers/iommu/iommufd/viommu.c                | 235 +++++++++++++++
 include/linux/iommu.h                         |  16 +
 include/linux/iommufd.h                       | 100 ++++++
 include/uapi/linux/iommufd.h                  |  98 ++++++
 tools/testing/selftests/iommu/iommufd.c       |  44 +++
 tools/testing/selftests/iommu/iommufd_utils.h |  71 +++++
 16 files changed, 1103 insertions(+), 46 deletions(-)
 create mode 100644 drivers/iommu/iommufd/viommu.c
Signature · 1 line
2.43.0