From: Joerg Roedel <[email protected]>
Implement a helper function to check whether a device's attach process
is deferred.
Signed-off-by: Joerg Roedel <[email protected]>
---
drivers/iommu/intel-iommu.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 9dc37672bf89..80f2332a5466 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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
@@ -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))
@@ -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;
@@ -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
--
2.17.1
On Mon Feb 17 20, Joerg Roedel wrote:
>From: Joerg Roedel <[email protected]>
>
>Implement a helper function to check whether a device's attach process
>is deferred.
>
>Signed-off-by: Joerg Roedel <[email protected]>
Reviewed-by: Jerry Snitselaar <[email protected]>
> +static bool attach_deferred(struct device *dev)
> +{
> + return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
> +}
This is not a very useful helper.
> +
> /**
> * is_downstream_to_pci_bridge - test if a device belongs to the PCI
> * sub-hierarchy of a candidate PCI-PCI bridge
> @@ -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;
I'd rather kill the iommu_dummy helper as well. And IIRC I have an
outstanding series somewhere that does just that..
On Tue, Feb 18, 2020 at 09:14:54AM -0800, Christoph Hellwig wrote:
> > +static bool attach_deferred(struct device *dev)
> > +{
> > + return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
> > +}
>
> This is not a very useful helper.
Depends on what one considers useful. I think such helpers make the code
better readable, which is pretty useful to me.
Regards,
Joerg