Skip to content

Simplify vfio_iommu_type1 attach/detach routine

Nicolin Chen asahi kvm linux-arm-kernel linux-arm-msm linux-iommu linux-s390 linux-tegra lkml virtualization 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest5 patches 22 repliesIn review
  2. v55 patches 8 repliesSuperseded
  3. v45 patches 5 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v35 patches17 repliesSuperseded
v25 patches24 repliesSuperseded
v15 patches20 repliesSuperseded

Changes in v6 from the cover letter · 27 lines

* Rebased on top of v6.0-rc1
* Added "Reviewed-by" from Jason
* Added "Cc" to Joerg/Will/Robin for the IOMMU patch
v5: https://lore.kernel.org/kvm/[email protected]/
* Rebased on top of Robin's "Simplify bus_type determination".
* Fixed a wrong change returning -EMEDIUMTYPE in arm-smmu driver.
* Added Baolu's "Reviewed-by".
v4: https://lore.kernel.org/kvm/[email protected]/
* Dropped -EMEDIUMTYPE change in mtk_v1 driver per Robin's input
* Added Baolu's and Kevin's Reviewed-by lines
v3: https://lore.kernel.org/kvm/[email protected]/
* Dropped all dev_err since -EMEDIUMTYPE clearly indicates what error.
* Updated commit message of enforce_cache_coherency removing patch.
* Updated commit message of domain->ops removing patch.
* Replaced "goto out_unlock" with simply mutex_unlock() and return.
* Added a line of comments for -EMEDIUMTYPE return check.
* Moved iommu_get_msi_cookie() into alloc_attach_domain() as a cookie should be logically tied to the lifetime of a domain itself.
* Added Kevin's "Reviewed-by".
v2: https://lore.kernel.org/kvm/[email protected]/
* Added -EMEDIUMTYPE to more IOMMU drivers that fit the category.
* Changed dev_err to dev_dbg for -EMEDIUMTYPE to avoid kernel log spam.
* Dropped iommu_ops patch, and removed domain->ops in VFIO directly, since there's no mixed-driver use case that would fail the sanity.
* Updated commit log of the patch removing enforce_cache_coherency.
* Fixed a misplace of "num_non_pinned_groups--" in detach_group patch.
* Moved "num_non_pinned_groups++" in PATCH-5 to the common path between domain-reusing and new-domain pathways, like the code previously did.
* Fixed a typo in EMEDIUMTYPE patch.
v1: https://lore.kernel.org/kvm/[email protected]/

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5iommu: Return -EMEDIUMTYPE for incompatible domain and device/groupdrivers/iommu/amd/iommu.c drivers/iommu/apple-dart.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +10 more+47 -4622 replies
2/5vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherencydrivers/vfio/vfio_iommu_type1.c+1 -30 replies
3/5vfio/iommu_type1: Remove the domain->ops comparisondrivers/vfio/vfio_iommu_type1.c+11 -210 replies
4/5vfio/iommu_type1: Clean up update_dirty_scope in detach_group()drivers/vfio/vfio_iommu_type1.c+12 -150 replies
5/5vfio/iommu_type1: Simplify group attachmentdrivers/vfio/vfio_iommu_type1.c+180 -1540 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchKevin TianLu BaoluJason Gunthorpe
1/5R-b R-b R-b
2/5R-b R-b
3/5R-b R-b
4/5R-b R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH v6 0/5] Simplify vfio_iommu_type1 attach/detach routine

This is a preparatory series for IOMMUFD v2 patches. It enforces error code -EMEDIUMTYPE in iommu_attach_device() and iommu_attach_group() when an IOMMU domain and a device/group are incompatible. It also drops the useless domain->ops check since it won't fail in current environment.

These allow VFIO iommu code to simplify its group attachment routine, by avoiding the extra IOMMU domain allocations and attach/detach sequences of the old code.

Worths mentioning the exact match for enforce_cache_coherency is removed with this series, since there's very less value in doing that as KVM will not be able to take advantage of it -- this just wastes domain memory. Instead, we rely on Intel IOMMU driver taking care of that internally.

This is on github:
https://github.com/nicolinc/iommufd/commits/vfio_iommu_attach-v6

Changelog
v6:
* Rebased on top of v6.0-rc1
* Added "Reviewed-by" from Jason
* Added "Cc" to Joerg/Will/Robin for the IOMMU patch
v5: https://lore.kernel.org/kvm/[email protected]/
* Rebased on top of Robin's "Simplify bus_type determination".
* Fixed a wrong change returning -EMEDIUMTYPE in arm-smmu driver.
* Added Baolu's "Reviewed-by".
v4: https://lore.kernel.org/kvm/[email protected]/
* Dropped -EMEDIUMTYPE change in mtk_v1 driver per Robin's input
* Added Baolu's and Kevin's Reviewed-by lines
v3: https://lore.kernel.org/kvm/[email protected]/
* Dropped all dev_err since -EMEDIUMTYPE clearly indicates what error.
* Updated commit message of enforce_cache_coherency removing patch.
* Updated commit message of domain->ops removing patch.
* Replaced "goto out_unlock" with simply mutex_unlock() and return.
* Added a line of comments for -EMEDIUMTYPE return check.
* Moved iommu_get_msi_cookie() into alloc_attach_domain() as a cookie should be logically tied to the lifetime of a domain itself.
* Added Kevin's "Reviewed-by".
v2: https://lore.kernel.org/kvm/[email protected]/
* Added -EMEDIUMTYPE to more IOMMU drivers that fit the category.
* Changed dev_err to dev_dbg for -EMEDIUMTYPE to avoid kernel log spam.
* Dropped iommu_ops patch, and removed domain->ops in VFIO directly, since there's no mixed-driver use case that would fail the sanity.
* Updated commit log of the patch removing enforce_cache_coherency.
* Fixed a misplace of "num_non_pinned_groups--" in detach_group patch.
* Moved "num_non_pinned_groups++" in PATCH-5 to the common path between domain-reusing and new-domain pathways, like the code previously did.
* Fixed a typo in EMEDIUMTYPE patch.
v1: https://lore.kernel.org/kvm/[email protected]/

Jason Gunthorpe (1):
vfio/iommu_type1: Prefer to reuse domains vs match enforced cache
coherency

Nicolin Chen (4):
iommu: Return -EMEDIUMTYPE for incompatible domain and device/group vfio/iommu_type1: Remove the domain->ops comparison vfio/iommu_type1: Clean up update_dirty_scope in detach_group() vfio/iommu_type1: Simplify group attachment

 drivers/iommu/amd/iommu.c                   |   2 +-
 drivers/iommu/apple-dart.c                  |   4 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c |  15 +-
 drivers/iommu/arm/arm-smmu/arm-smmu.c       |   5 +-
 drivers/iommu/arm/arm-smmu/qcom_iommu.c     |   9 +-
 drivers/iommu/intel/iommu.c                 |  10 +-
 drivers/iommu/iommu.c                       |  28 ++
 drivers/iommu/ipmmu-vmsa.c                  |   4 +-
 drivers/iommu/omap-iommu.c                  |   3 +-
 drivers/iommu/s390-iommu.c                  |   2 +-
 drivers/iommu/sprd-iommu.c                  |   6 +-
 drivers/iommu/tegra-gart.c                  |   2 +-
 drivers/iommu/virtio-iommu.c                |   3 +-
 drivers/vfio/vfio_iommu_type1.c             | 353 ++++++++++----------
 14 files changed, 229 insertions(+), 217 deletions(-)
Signature · 1 line
2.17.1