Archive-only list for patches
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Will Deacon <will@kernel.org>
Cc: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
	Joerg Roedel <jroedel@suse.de>, Kevin Tian <kevin.tian@intel.com>,
	patches@lists.linux.dev, Vasant Hegde <vasant.hegde@amd.com>
Subject: [PATCH 2/7] iommu/amd: Remove domain_alloc()
Date: Thu,  5 Dec 2024 20:23:37 -0400	[thread overview]
Message-ID: <2-v1-cf88773f22d1+39bd-amd_paging_flags_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-cf88773f22d1+39bd-amd_paging_flags_jgg@nvidia.com>

IOMMU drivers should not be sensitive to the domain type, a paging domain
should be created based only on the flags passed in, the same for all
callers.

AMD was using the domain_alloc() path to force VFIO into a v1 domain type,
because v1 gives higher performance. However now that
IOMMU_HWPT_ALLOC_PASID is present, and a NULL device is not possible,
domain_alloc_paging_flags() will do the right thing for VFIO.

When invoked from VFIO flags will be 0 and the amd_iommu_pgtable type of
domain will be selected. This is v1 by default unless the kernel command
line has overridden it to v2.

If the admin is forcing v2 assume they know what they are doing so force
it everywhere, including for VFIO.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/amd/iommu.c | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 7e7246c49006ad..96d87406f89467 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2386,25 +2386,6 @@ static struct iommu_domain *do_iommu_domain_alloc(unsigned int type,
 	return &domain->domain;
 }
 
-static struct iommu_domain *amd_iommu_domain_alloc(unsigned int type)
-{
-	struct iommu_domain *domain;
-	int pgtable = amd_iommu_pgtable;
-
-	/*
-	 * Force IOMMU v1 page table when allocating
-	 * domain for pass-through devices.
-	 */
-	if (type == IOMMU_DOMAIN_UNMANAGED)
-		pgtable = AMD_IOMMU_V1;
-
-	domain = do_iommu_domain_alloc(type, NULL, 0, pgtable);
-	if (IS_ERR(domain))
-		return NULL;
-
-	return domain;
-}
-
 static struct iommu_domain *
 amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
 				    const struct iommu_user_data *user_data)
@@ -2881,7 +2862,6 @@ const struct iommu_ops amd_iommu_ops = {
 	.blocked_domain = &blocked_domain,
 	.release_domain = &release_domain,
 	.identity_domain = &identity_domain.domain,
-	.domain_alloc = amd_iommu_domain_alloc,
 	.domain_alloc_paging_flags = amd_iommu_domain_alloc_paging_flags,
 	.domain_alloc_sva = amd_iommu_domain_alloc_sva,
 	.probe_device = amd_iommu_probe_device,
-- 
2.43.0


  parent reply	other threads:[~2024-12-06  0:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06  0:23 [PATCH 0/7] iommu/amd: Cleanup some of the domain_alloc_paging path Jason Gunthorpe
2024-12-06  0:23 ` [PATCH 1/7] iommu/amd: Remove unused amd_iommu_domain_update() Jason Gunthorpe
2025-01-06 11:09   ` Vasant Hegde
2024-12-06  0:23 ` Jason Gunthorpe [this message]
2025-01-06 14:04   ` [PATCH 2/7] iommu/amd: Remove domain_alloc() Vasant Hegde
2024-12-06  0:23 ` [PATCH 3/7] iommu/amd: Remove dev == NULL checks Jason Gunthorpe
2025-01-06 14:33   ` Vasant Hegde
2024-12-06  0:23 ` [PATCH 4/7] iommu/amd: Remove type argument from do_iommu_domain_alloc() and related Jason Gunthorpe
2025-01-06 14:54   ` Vasant Hegde
2024-12-06  0:23 ` [PATCH 5/7] iommu/amd: Change amd_iommu_pgtable to use enum protection_domain_mode Jason Gunthorpe
2025-01-07  9:39   ` Vasant Hegde
2024-12-06  0:23 ` [PATCH 6/7] iommu/amd: Move the nid to pdom_setup_pgtable() Jason Gunthorpe
2025-01-07  9:43   ` Vasant Hegde
2024-12-06  0:23 ` [PATCH 7/7] iommu/amd: Fully decode all combinations of alloc_paging_flags Jason Gunthorpe
2025-01-07 10:47   ` Vasant Hegde
2025-01-09 17:17     ` Jason Gunthorpe
2025-01-07 10:51 ` [PATCH 0/7] iommu/amd: Cleanup some of the domain_alloc_paging path Vasant Hegde
2025-01-09 17:18   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2-v1-cf88773f22d1+39bd-amd_paging_flags_jgg@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alejandro.j.jimenez@oracle.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=kevin.tian@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox