[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220826121141.50743-8-baolu.lu@linux.intel.com>
Date: Fri, 26 Aug 2022 20:11:31 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Joerg Roedel <joro@...tes.org>, Jason Gunthorpe <jgg@...dia.com>,
Christoph Hellwig <hch@...radead.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Kevin Tian <kevin.tian@...el.com>,
Ashok Raj <ashok.raj@...el.com>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Jean-Philippe Brucker <jean-philippe@...aro.com>,
Dave Jiang <dave.jiang@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Vinod Koul <vkoul@...nel.org>
Cc: Eric Auger <eric.auger@...hat.com>, Liu Yi L <yi.l.liu@...el.com>,
Jacob jun Pan <jacob.jun.pan@...el.com>,
Zhangfei Gao <zhangfei.gao@...aro.org>,
Zhu Tony <tony.zhu@...el.com>, iommu@...ts.linux.dev,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Lu Baolu <baolu.lu@...ux.intel.com>
Subject: [PATCH v12 07/17] iommu: Try to allocate blocking domain when probing device
Allocate the blocking domain when probing devices if the driver supports
blocking domain allocation. Otherwise, revert to the previous behavior,
that is, use UNMANAGED domain instead when the blocking domain is needed.
Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
Tested-by: Zhangfei Gao <zhangfei.gao@...aro.org>
Tested-by: Tony Zhu <tony.zhu@...el.com>
---
drivers/iommu/iommu.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 2c9488d966ab..e985f4d5895f 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -318,6 +318,10 @@ int iommu_probe_device(struct device *dev)
mutex_lock(&group->mutex);
iommu_alloc_default_domain(group, dev);
+ /* Try to allocate a blocking domain */
+ group->blocking_domain = __iommu_domain_alloc(dev->bus,
+ IOMMU_DOMAIN_BLOCKED);
+
/*
* If device joined an existing group which has been claimed, don't
* attach the default domain.
@@ -1778,6 +1782,10 @@ int bus_iommu_probe(struct bus_type *bus)
/* Try to allocate default domain */
probe_alloc_default_domain(bus, group);
+ /* Try to allocate blocking domain */
+ group->blocking_domain =
+ __iommu_domain_alloc(bus, IOMMU_DOMAIN_BLOCKED);
+
if (!group->default_domain) {
mutex_unlock(&group->mutex);
continue;
@@ -3165,18 +3173,15 @@ static int __iommu_group_alloc_blocking_domain(struct iommu_group *group)
if (group->blocking_domain)
return 0;
- group->blocking_domain =
- __iommu_domain_alloc(dev->dev->bus, IOMMU_DOMAIN_BLOCKED);
- if (!group->blocking_domain) {
- /*
- * For drivers that do not yet understand IOMMU_DOMAIN_BLOCKED
- * create an empty domain instead.
- */
- group->blocking_domain = __iommu_domain_alloc(
- dev->dev->bus, IOMMU_DOMAIN_UNMANAGED);
- if (!group->blocking_domain)
- return -EINVAL;
- }
+ /*
+ * For drivers that do not yet understand IOMMU_DOMAIN_BLOCKED
+ * create an empty domain instead.
+ */
+ group->blocking_domain = __iommu_domain_alloc(dev->dev->bus,
+ IOMMU_DOMAIN_UNMANAGED);
+ if (!group->blocking_domain)
+ return -EINVAL;
+
return 0;
}
--
2.25.1
Powered by blists - more mailing lists