Skip to content

Commit e01d191

Browse files
Baoquan Hejoergroedel
authored andcommitted
iommu: Add is_attach_deferred call-back to iommu-ops
This new call-back will be used to check if the domain attach need be deferred for now. If yes, the domain attach/detach will return directly. Signed-off-by: Baoquan He <bhe@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 53019a9 commit e01d191

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/iommu/iommu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,10 @@ static int __iommu_attach_device(struct iommu_domain *domain,
12831283
struct device *dev)
12841284
{
12851285
int ret;
1286+
if ((domain->ops->is_attach_deferred != NULL) &&
1287+
domain->ops->is_attach_deferred(domain, dev))
1288+
return 0;
1289+
12861290
if (unlikely(domain->ops->attach_dev == NULL))
12871291
return -ENODEV;
12881292

@@ -1324,6 +1328,10 @@ EXPORT_SYMBOL_GPL(iommu_attach_device);
13241328
static void __iommu_detach_device(struct iommu_domain *domain,
13251329
struct device *dev)
13261330
{
1331+
if ((domain->ops->is_attach_deferred != NULL) &&
1332+
domain->ops->is_attach_deferred(domain, dev))
1333+
return;
1334+
13271335
if (unlikely(domain->ops->detach_dev == NULL))
13281336
return;
13291337

include/linux/iommu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ struct iommu_ops {
225225
u32 (*domain_get_windows)(struct iommu_domain *domain);
226226

227227
int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
228+
bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);
228229

229230
unsigned long pgsize_bitmap;
230231
};

0 commit comments

Comments
 (0)