Skip to content

Convert the intel iommu driver to the dma-iommu api

Tom Murphy dri-devel intel-gfx kvm linux-arm-kernel linux-arm-msm linux-iommu linux-mediatek linux-rockchip linux-s390 linux-samsung-soc linux-tegra lkml oe-kbuild-all virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 31 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8iommu/vt-d: clean up 32bit si_domain assignmentdrivers/iommu/intel-iommu.c+31 -572 replies
1/8iommu/vt-d: clean up 32bit si_domain assignmentdrivers/iommu/intel-iommu.c+31 -570 replies
2/8iommu/vt-d: Use default dma_direct_* mapping functions for direct mapped devicesdrivers/iommu/intel-iommu.c+6 -460 replies
2/8iommu/vt-d: Use default dma_direct_* mapping functions for direct mapped devicesdrivers/iommu/intel-iommu.c+6 -460 replies
3/8iommu/vt-d: Remove IOVA handling code from non-dma_ops pathdrivers/iommu/intel-iommu.c+33 -562 replies
3/8iommu/vt-d: Remove IOVA handling code from non-dma_ops pathdrivers/iommu/intel-iommu.c+33 -560 replies
4/8iommu: Handle freelists when using deferred flushing in iommu driversdrivers/iommu/amd_iommu.c drivers/iommu/arm-smmu-v3.c drivers/iommu/arm-smmu.c +17 more+151 -570 replies
4/8iommu: Handle freelists when using deferred flushing in iommu driversdrivers/iommu/amd_iommu.c drivers/iommu/arm-smmu-v3.c drivers/iommu/arm-smmu.c +17 more+151 -570 replies
5/8iommu: Add iommu_dma_free_cpu_cached_iovas functiondrivers/iommu/dma-iommu.c include/linux/dma-iommu.h+12 -00 replies
5/8iommu: Add iommu_dma_free_cpu_cached_iovas functiondrivers/iommu/dma-iommu.c include/linux/dma-iommu.h+12 -00 replies
6/8iommu: allow the dma-iommu api to use bounce buffersdrivers/iommu/dma-iommu.c drivers/iommu/iommu.c include/linux/iommu.h+95 -170 replies
6/8iommu: allow the dma-iommu api to use bounce buffersdrivers/iommu/dma-iommu.c drivers/iommu/iommu.c include/linux/iommu.h+95 -170 replies
7/8iommu/vt-d: Convert intel iommu driver to the iommu opsdrivers/iommu/Kconfig drivers/iommu/intel-iommu.c include/linux/intel-iommu.h+55 -6890 replies
7/8iommu/vt-d: Convert intel iommu driver to the iommu opsdrivers/iommu/Kconfig drivers/iommu/intel-iommu.c include/linux/intel-iommu.h+55 -6890 replies
8/8DO NOT MERGE: iommu: disable list appending in dma-iommudrivers/iommu/dma-iommu.c+7 -310 replies
8/8DO NOT MERGE: iommu: disable list appending in dma-iommudrivers/iommu/dma-iommu.c+7 -310 replies

Reviews trailers per patch

None of the 16 patches has a Reviewed-by or Acked-by.

PatchLogan Gunthorpe
SeriesT-b
1/8
1/8
2/8
2/8
3/8
3/8
4/8
4/8
5/8
5/8
6/8
6/8
7/8
7/8
8/8
8/8

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 0/8] Convert the intel iommu driver to the dma-iommu api

This patchset converts the intel iommu driver to the dma-iommu api.

While converting the driver I exposed a bug in the intel i915 driver which causes a huge amount of artifacts on the screen of my laptop. You can see a picture of it here:
https://github.com/pippy360/kernelPatches/blob/master/IMG_20191219_225922.jpg

This issue is most likely in the i915 driver and is most likely caused by the driver not respecting the return value of the dma_map_ops::map_sg function. You can see the driver ignoring the return value here:
https://github.com/torvalds/linux/blob/7e0165b2f1a912a06e381e91f0f4e495f4ac3736/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c#L51

Previously this didn’t cause issues because the intel map_sg always returned the same number of elements as the input scatter gather list but with the change to this dma-iommu api this is no longer the case. I wasn’t able to track the bug down to a specific line of code unfortunately.

Could someone from the intel team look at this?

I have been testing on a lenovo x1 carbon 5th generation. Let me know if there’s any more information you need.

To allow my patch set to be tested I have added a patch (patch 8/8) in this series to disable combining sg segments in the dma-iommu api which fixes the bug but it doesn't fix the actual problem.

As part of this patch series I copied the intel bounce buffer code to the dma-iommu path. The addition of the bounce buffer code took me by surprise. I did most of my development on this patch series before the bounce buffer code was added and my reimplementation in the dma-iommu path is very rushed and not properly tested but I’m running out of time to work on this patch set.

On top of that I also didn’t port over the intel tracing code from this commit:
https://github.com/torvalds/linux/commit/3b53034c268d550d9e8522e613a14ab53b8840d8#diff-6b3e7c4993f05e76331e463ab1fc87e1
So all the work in that commit is now wasted. The code will need to be removed and reimplemented in the dma-iommu path. I would like to take the time to do this but I really don’t have the time at the moment and I want to get these changes out before the iommu code changes any more.

Tom Murphy (8):
iommu/vt-d: clean up 32bit si_domain assignment iommu/vt-d: Use default dma_direct_* mapping functions for direct
mapped devices
iommu/vt-d: Remove IOVA handling code from non-dma_ops path
iommu: Handle freelists when using deferred flushing in iommu drivers
iommu: Add iommu_dma_free_cpu_cached_iovas function
iommu: allow the dma-iommu api to use bounce buffers iommu/vt-d: Convert intel iommu driver to the iommu ops
DO NOT MERGE: iommu: disable list appending in dma-iommu

 drivers/iommu/Kconfig           |   1 +
 drivers/iommu/amd_iommu.c       |  14 +-
 drivers/iommu/arm-smmu-v3.c     |   3 +-
 drivers/iommu/arm-smmu.c        |   3 +-
 drivers/iommu/dma-iommu.c       | 183 +++++--
 drivers/iommu/exynos-iommu.c    |   3 +-
 drivers/iommu/intel-iommu.c     | 936 ++++----------------------------
 drivers/iommu/iommu.c           |  39 +-
 drivers/iommu/ipmmu-vmsa.c      |   3 +-
 drivers/iommu/msm_iommu.c       |   3 +-
 drivers/iommu/mtk_iommu.c       |   3 +-
 drivers/iommu/mtk_iommu_v1.c    |   3 +-
 drivers/iommu/omap-iommu.c      |   3 +-
 drivers/iommu/qcom_iommu.c      |   3 +-
 drivers/iommu/rockchip-iommu.c  |   3 +-
 drivers/iommu/s390-iommu.c      |   3 +-
 drivers/iommu/tegra-gart.c      |   3 +-
 drivers/iommu/tegra-smmu.c      |   3 +-
 drivers/iommu/virtio-iommu.c    |   3 +-
 drivers/vfio/vfio_iommu_type1.c |   2 +-
 include/linux/dma-iommu.h       |   3 +
 include/linux/intel-iommu.h     |   1 -
 include/linux/iommu.h           |  32 +-
 23 files changed, 345 insertions(+), 908 deletions(-)
Signature · 1 line
2.20.1