Skip to content

Commit

Permalink
iommu/vt-d: Add attach_deferred() helper
Browse files Browse the repository at this point in the history
Implement a helper function to check whether a device's attach process
is deferred.

Fixes: 1ee0186 ("iommu/vt-d: Refactor find_domain() helper")
Cc: [email protected] # v5.5
Reviewed-by: Jerry Snitselaar <[email protected]>
Acked-by: Lu Baolu <[email protected]>
Signed-off-by: Joerg Roedel <[email protected]>
  • Loading branch information
joergroedel committed Feb 18, 2020
1 parent e7598fa commit 1d46159
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,11 @@ static int iommu_dummy(struct device *dev)
return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
}

static bool attach_deferred(struct device *dev)
{
return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
}

/**
* is_downstream_to_pci_bridge - test if a device belongs to the PCI
* sub-hierarchy of a candidate PCI-PCI bridge
Expand Down Expand Up @@ -2510,8 +2515,7 @@ struct dmar_domain *find_domain(struct device *dev)
{
struct device_domain_info *info;

if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO ||
dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO))
if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
return NULL;

if (dev_is_pci(dev))
Expand All @@ -2527,7 +2531,7 @@ struct dmar_domain *find_domain(struct device *dev)

static struct dmar_domain *deferred_attach_domain(struct device *dev)
{
if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO)) {
if (unlikely(attach_deferred(dev))) {
struct iommu_domain *domain;

dev->archdata.iommu = NULL;
Expand Down Expand Up @@ -6133,7 +6137,7 @@ intel_iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev)
static bool intel_iommu_is_attach_deferred(struct iommu_domain *domain,
struct device *dev)
{
return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
return attach_deferred(dev);
}

static int
Expand Down

0 comments on commit 1d46159

Please sign in to comment.