linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/34] iommu: Move iommu_group setup to IOMMU core code
@ 2020-04-07 18:37 Joerg Roedel
  2020-04-07 18:37 ` [RFC PATCH 01/34] iommu: Move default domain allocation to separate function Joerg Roedel
                   ` (33 more replies)
  0 siblings, 34 replies; 51+ messages in thread
From: Joerg Roedel @ 2020-04-07 18:37 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Robin Murphy, Marek Szyprowski,
	Kukjin Kim, Krzysztof Kozlowski, David Woodhouse, Lu Baolu,
	Andy Gross, Bjorn Andersson, Matthias Brugger, Rob Clark,
	Heiko Stuebner, Gerald Schaefer, Thierry Reding, Jonathan Hunter,
	Jean-Philippe Brucker
  Cc: iommu, linux-kernel, linux-samsung-soc, linux-arm-msm,
	linux-mediatek, linux-rockchip, linux-s390, linux-tegra,
	virtualization

Hi,

here is a patch-set to remove all calls of iommu_group_get_for_dev() from
the IOMMU drivers and move the per-device group setup and default domain
allocation into the IOMMU core code.

This eliminates some ugly back and forth between IOMMU core code and the
IOMMU drivers, where the driver called iommu_group_get_for_dev() which itself
called back into the driver.

The patch-set started as a "quick" Friday afternoon project to split the
IOMMU group creation and the allocation of the default domain, so that the
default domain is not allocated before all devices are added to the group.
In the end it took 1.5 weeks to get this in a reasonable shape, but now the
code (during bus probing) first adds all devices to their respective IOMMU
group before it determines the default domain type and then allocates it for
the group.

It turned out that this required to remove the calls of
iommu_group_get_for_dev() from the IOMMU drivers. While at it, the calls to
iommu_device_link()/unlink() where also moved out of the drivers, which
required a different interface than add_device()/remove_device(). The result
is the new probe_device()/release_device() interface, where the driver just
does its own setup and then returns the iommu_device which belongs to the
device being probed.

There is certainly more room for cleanups, but I think this is a good start
to simplify the code flow during IOMMU device probing.  It is also a more
robust base for the pending patch-sets which implement per-group default
domain types and the removal of the private domains from the Intel VT-d
driver.

With regards to testing, I verified this code works on three IOMMUs:

	- AMD-Vi
	- Intel VT-d (but there might be breakages on some hardware, the
	  patches to remove the private domain handling from the VT-d driver
	  should be rebased to these patches)
	- ARM-SMMU-v3 (as emulated by QEMU)

Most driver conversions to the probe_device()/release_device() interface
were trivial, but there were also some hard nuts, which I am not sure still
work. The more difficult drivers were:

	- ARM-SMMU-v2
	- OMAP
	- Renesas
	- Mediatek IOMMU v1
	- Exynos

It would be great if the changes could be tested (and possibly fixed) on
those IOMMUs, as I can't do testing on them.

The patches are based on the current iommu/next branch, I will rebase them
to v5.7-rc1 when it comes out. A branch with these patches applied can be
found here:

	https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/log/?h=iommu-probe-device

Please review and test these changes and let me know what breaks.

Thanks,

	Joerg

Joerg Roedel (33):
  iommu: Move default domain allocation to separate function
  iommu/amd: Implement iommu_ops->def_domain_type call-back
  iommu/vt-d: Wire up iommu_ops->def_domain_type
  iommu/amd: Remove dma_mask check from check_device()
  iommu/amd: Return -ENODEV in add_device when device is not handled by
    IOMMU
  iommu: Add probe_device() and remove_device() call-backs
  iommu: Move default domain allocation to iommu_probe_device()
  iommu: Keep a list of allocated groups in __iommu_probe_device()
  iommu: Move new probe_device path to separate function
  iommu: Split off default domain allocation from group assignment
  iommu: Move iommu_group_create_direct_mappings() out of
    iommu_group_add_device()
  iommu: Export bus_iommu_probe() and make is safe for re-probing
  iommu/amd: Remove dev_data->passthrough
  iommu/amd: Convert to probe/release_device() call-backs
  iommu/vt-d: Convert to probe/release_device() call-backs
  iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr
  iommu/arm-smmu: Convert to probe/release_device() call-backs
  iommu/pamu: Convert to probe/release_device() call-backs
  iommu/s390: Convert to probe/release_device() call-backs
  iommu/virtio: Convert to probe/release_device() call-backs
  iommu/msm: Convert to probe/release_device() call-backs
  iommu/mediatek: Convert to probe/release_device() call-backs
  iommu/mediatek-v1 Convert to probe/release_device() call-backs
  iommu/qcom: Convert to probe/release_device() call-backs
  iommu/rockchip: Convert to probe/release_device() call-backs
  iommu/tegra: Convert to probe/release_device() call-backs
  iommu/renesas: Convert to probe/release_device() call-backs
  iommu/omap: Remove orphan_dev tracking
  iommu/omap: Convert to probe/release_device() call-backs
  iommu/exynos: Create iommu_device in struct exynos_iommu_owner
  iommu/exynos: Convert to probe/release_device() call-backs
  iommu: Remove add_device()/remove_device() code-paths
  iommu: Unexport iommu_group_get_for_dev()

Sai Praneeth Prakhya (1):
  iommu: Add def_domain_type() callback in iommu_ops

 drivers/iommu/amd_iommu.c       |  97 ++++----
 drivers/iommu/amd_iommu_types.h |   1 -
 drivers/iommu/arm-smmu-v3.c     |  42 +---
 drivers/iommu/arm-smmu.c        |  44 ++--
 drivers/iommu/exynos-iommu.c    | 113 ++++++---
 drivers/iommu/fsl_pamu_domain.c |  22 +-
 drivers/iommu/intel-iommu.c     |  68 +-----
 drivers/iommu/iommu.c           | 391 +++++++++++++++++++++++++-------
 drivers/iommu/ipmmu-vmsa.c      |  60 ++---
 drivers/iommu/msm_iommu.c       |  34 +--
 drivers/iommu/mtk_iommu.c       |  24 +-
 drivers/iommu/mtk_iommu_v1.c    |  50 ++--
 drivers/iommu/omap-iommu.c      |  99 ++------
 drivers/iommu/qcom_iommu.c      |  24 +-
 drivers/iommu/rockchip-iommu.c  |  26 +--
 drivers/iommu/s390-iommu.c      |  22 +-
 drivers/iommu/tegra-gart.c      |  24 +-
 drivers/iommu/tegra-smmu.c      |  31 +--
 drivers/iommu/virtio-iommu.c    |  41 +---
 include/linux/iommu.h           |  21 +-
 20 files changed, 600 insertions(+), 634 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2020-04-14 15:28 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 18:37 [RFC PATCH 00/34] iommu: Move iommu_group setup to IOMMU core code Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 01/34] iommu: Move default domain allocation to separate function Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 02/34] iommu: Add def_domain_type() callback in iommu_ops Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 03/34] iommu/amd: Implement iommu_ops->def_domain_type call-back Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 04/34] iommu/vt-d: Wire up iommu_ops->def_domain_type Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 05/34] iommu/amd: Remove dma_mask check from check_device() Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 06/34] iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 07/34] iommu: Add probe_device() and remove_device() call-backs Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 08/34] iommu: Move default domain allocation to iommu_probe_device() Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 09/34] iommu: Keep a list of allocated groups in __iommu_probe_device() Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 10/34] iommu: Move new probe_device path to separate function Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 11/34] iommu: Split off default domain allocation from group assignment Joerg Roedel
2020-04-13 22:10   ` Derrick, Jonathan
2020-04-14 15:27     ` joro
2020-04-07 18:37 ` [RFC PATCH 12/34] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device() Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 13/34] iommu: Export bus_iommu_probe() and make is safe for re-probing Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 14/34] iommu/amd: Remove dev_data->passthrough Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 15/34] iommu/amd: Convert to probe/release_device() call-backs Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 16/34] iommu/vt-d: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr Joerg Roedel
2020-04-08 12:09   ` Robin Murphy
2020-04-08 14:37     ` Joerg Roedel
2020-04-08 15:07       ` Robin Murphy
2020-04-08 19:11         ` Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 18/34] iommu/arm-smmu: Convert to probe/release_device() call-backs Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 19/34] iommu/pamu: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 20/34] iommu/s390: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 21/34] iommu/virtio: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 22/34] iommu/msm: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 23/34] iommu/mediatek: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 24/34] iommu/mediatek-v1 " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 25/34] iommu/qcom: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 26/34] iommu/rockchip: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 27/34] iommu/tegra: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 28/34] iommu/renesas: " Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 29/34] iommu/omap: Remove orphan_dev tracking Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 30/34] iommu/omap: Convert to probe/release_device() call-backs Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 31/34] iommu/exynos: Create iommu_device in struct exynos_iommu_owner Joerg Roedel
2020-04-08 12:23   ` Marek Szyprowski
2020-04-08 14:23     ` Marek Szyprowski
2020-04-08 15:00       ` Joerg Roedel
2020-04-09 11:46       ` [PATCH] iommu/exynos: Get rid of 'struct exynos_iommu_owner' exynos_iommu_owner Joerg Roedel
2020-04-09 13:58         ` Marek Szyprowski
     [not found]           ` <CGME20200409140939eucas1p190daac74c0d5dda4627314c49c1a5b50@eucas1p1.samsung.com>
2020-04-09 14:09             ` [PATCH] iommu/exynos: Rework intialization Marek Szyprowski
2020-04-09 14:30           ` [PATCH] iommu/exynos: Get rid of 'struct exynos_iommu_owner' exynos_iommu_owner Joerg Roedel
2020-04-14 13:20           ` Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 32/34] iommu/exynos: Convert to probe/release_device() call-backs Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 33/34] iommu: Remove add_device()/remove_device() code-paths Joerg Roedel
2020-04-10 10:39   ` Marek Szyprowski
2020-04-14 13:17     ` Joerg Roedel
2020-04-07 18:37 ` [RFC PATCH 34/34] iommu: Unexport iommu_group_get_for_dev() Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).