public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: YueHaibing <yuehaibing@huawei.com>,
	Yanfei Xu <yanfei.xu@intel.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 10/13] iommu/vt-d: Remove rmrr check in domain attaching device path
Date: Wed,  9 Aug 2023 20:48:03 +0800	[thread overview]
Message-ID: <20230809124806.45516-11-baolu.lu@linux.intel.com> (raw)
In-Reply-To: <20230809124806.45516-1-baolu.lu@linux.intel.com>

The core code now prevents devices with RMRR regions from being assigned
to user space. There is no need to check for this condition in individual
drivers. Remove it to avoid duplicate code.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20230724060352.113458-3-baolu.lu@linux.intel.com
---
 drivers/iommu/intel/iommu.c | 58 -------------------------------------
 1 file changed, 58 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index f939fc2aa66c..1f89714ca462 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2487,30 +2487,6 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
 	return 0;
 }
 
-static bool device_has_rmrr(struct device *dev)
-{
-	struct dmar_rmrr_unit *rmrr;
-	struct device *tmp;
-	int i;
-
-	rcu_read_lock();
-	for_each_rmrr_units(rmrr) {
-		/*
-		 * Return TRUE if this RMRR contains the device that
-		 * is passed in.
-		 */
-		for_each_active_dev_scope(rmrr->devices,
-					  rmrr->devices_cnt, i, tmp)
-			if (tmp == dev ||
-			    is_downstream_to_pci_bridge(dev, tmp)) {
-				rcu_read_unlock();
-				return true;
-			}
-	}
-	rcu_read_unlock();
-	return false;
-}
-
 /**
  * device_rmrr_is_relaxable - Test whether the RMRR of this device
  * is relaxable (ie. is allowed to be not enforced under some conditions)
@@ -2540,34 +2516,6 @@ static bool device_rmrr_is_relaxable(struct device *dev)
 		return false;
 }
 
-/*
- * There are a couple cases where we need to restrict the functionality of
- * devices associated with RMRRs.  The first is when evaluating a device for
- * identity mapping because problems exist when devices are moved in and out
- * of domains and their respective RMRR information is lost.  This means that
- * a device with associated RMRRs will never be in a "passthrough" domain.
- * The second is use of the device through the IOMMU API.  This interface
- * expects to have full control of the IOVA space for the device.  We cannot
- * satisfy both the requirement that RMRR access is maintained and have an
- * unencumbered IOVA space.  We also have no ability to quiesce the device's
- * use of the RMRR space or even inform the IOMMU API user of the restriction.
- * We therefore prevent devices associated with an RMRR from participating in
- * the IOMMU API, which eliminates them from device assignment.
- *
- * In both cases, devices which have relaxable RMRRs are not concerned by this
- * restriction. See device_rmrr_is_relaxable comment.
- */
-static bool device_is_rmrr_locked(struct device *dev)
-{
-	if (!device_has_rmrr(dev))
-		return false;
-
-	if (device_rmrr_is_relaxable(dev))
-		return false;
-
-	return true;
-}
-
 /*
  * Return the required default domain type for a specific device.
  *
@@ -4173,12 +4121,6 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
 	struct device_domain_info *info = dev_iommu_priv_get(dev);
 	int ret;
 
-	if (domain->type == IOMMU_DOMAIN_UNMANAGED &&
-	    device_is_rmrr_locked(dev)) {
-		dev_warn(dev, "Device is ineligible for IOMMU domain attach due to platform RMRR requirement.  Contact your platform vendor.\n");
-		return -EPERM;
-	}
-
 	if (info->domain)
 		device_block_translation(dev);
 
-- 
2.34.1


  parent reply	other threads:[~2023-08-09 12:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 12:47 [PATCH 00/13] [PULL REQUEST] Intel IOMMU updates for Linux v6.6 Lu Baolu
2023-08-09 12:47 ` [PATCH 01/13] iommu: Generalize PASID 0 for normal DMA w/o PASID Lu Baolu
2023-08-09 12:47 ` [PATCH 02/13] iommu: Move global PASID allocation from SVA to core Lu Baolu
2023-08-09 12:47 ` [PATCH 03/13] iommu/vt-d: Add domain_flush_pasid_iotlb() Lu Baolu
2023-08-09 12:47 ` [PATCH 04/13] iommu/vt-d: Remove pasid_mutex Lu Baolu
2023-08-09 12:47 ` [PATCH 05/13] iommu/vt-d: Make prq draining code generic Lu Baolu
2023-08-09 12:47 ` [PATCH 06/13] iommu/vt-d: Prepare for set_dev_pasid callback Lu Baolu
2023-08-09 12:48 ` [PATCH 07/13] iommu/vt-d: Add set_dev_pasid callback for dma domain Lu Baolu
2023-08-09 12:48 ` [PATCH 08/13] dmaengine/idxd: Re-enable kernel workqueue under DMA API Lu Baolu
2023-08-09 12:48 ` [PATCH 09/13] iommu: Prevent RESV_DIRECT devices from blocking domains Lu Baolu
2023-08-09 12:48 ` Lu Baolu [this message]
2023-08-09 12:48 ` [PATCH 11/13] iommu/vt-d: Fix to flush cache of PASID directory table Lu Baolu
2023-08-09 12:48 ` [PATCH 12/13] iommu/vt-d: Fix to convert mm pfn to dma pfn Lu Baolu
2023-08-09 12:48 ` [PATCH 13/13] iommu/vt-d: Remove unused extern declaration dmar_parse_dev_scope() Lu Baolu
2023-08-09 15:47 ` [PATCH 00/13] [PULL REQUEST] Intel IOMMU updates for Linux v6.6 Joerg Roedel

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=20230809124806.45516-11-baolu.lu@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yanfei.xu@intel.com \
    --cc=yuehaibing@huawei.com \
    /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