iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 27 Sep 2023 23:47:31 +0000 (20:47 -0300)
committerJoerg Roedel <jroedel@suse.de>
Thu, 26 Oct 2023 14:53:49 +0000 (16:53 +0200)
Following the pattern of identity domains, just assign the BLOCKED domain
global statics to a value in ops. Update the core code to use the global
static directly.

Update powerpc to use the new scheme and remove its empty domain_alloc
callback.

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Sven Peter <sven@svenpeter.dev>
Link: https://lore.kernel.org/r/1-v2-bff223cf6409+282-dart_paging_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
arch/powerpc/kernel/iommu.c
drivers/iommu/iommu.c
include/linux/iommu.h

index bf19932147517bf6cfe0eab7e47f06404abce79c..ed7c97d9128e1c53ddc40709ba94b303bf19c7b5 100644 (file)
@@ -1333,13 +1333,6 @@ static bool spapr_tce_iommu_capable(struct device *dev, enum iommu_cap cap)
        return false;
 }
 
-static struct iommu_domain *spapr_tce_iommu_domain_alloc(unsigned int type)
-{
-       if (type != IOMMU_DOMAIN_BLOCKED)
-               return NULL;
-       return &spapr_tce_blocked_domain;
-}
-
 static struct iommu_device *spapr_tce_iommu_probe_device(struct device *dev)
 {
        struct pci_dev *pdev;
@@ -1374,8 +1367,8 @@ static struct iommu_group *spapr_tce_iommu_device_group(struct device *dev)
 
 static const struct iommu_ops spapr_tce_iommu_ops = {
        .default_domain = &spapr_tce_platform_domain,
+       .blocked_domain = &spapr_tce_blocked_domain,
        .capable = spapr_tce_iommu_capable,
-       .domain_alloc = spapr_tce_iommu_domain_alloc,
        .probe_device = spapr_tce_iommu_probe_device,
        .release_device = spapr_tce_iommu_release_device,
        .device_group = spapr_tce_iommu_device_group,
index f9f315d58a3a1498ee03e1fe24d15741e43903e6..79a0fdb334046fc51074be9abbe120a8a97178f1 100644 (file)
@@ -2086,6 +2086,8 @@ static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
 
        if (alloc_type == IOMMU_DOMAIN_IDENTITY && ops->identity_domain)
                return ops->identity_domain;
+       else if (alloc_type == IOMMU_DOMAIN_BLOCKED && ops->blocked_domain)
+               return ops->blocked_domain;
        else if (type & __IOMMU_DOMAIN_PAGING && ops->domain_alloc_paging)
                domain = ops->domain_alloc_paging(dev);
        else if (ops->domain_alloc)
index c28178f3690a810fdc48eb146be79b8d9a57e190..73daa4fb168bc4553f45eb62bde8b7e0dcc1beec 100644 (file)
@@ -265,6 +265,8 @@ struct iommu_iotlb_gather {
  * @owner: Driver module providing these ops
  * @identity_domain: An always available, always attachable identity
  *                   translation.
+ * @blocked_domain: An always available, always attachable blocking
+ *                  translation.
  * @default_domain: If not NULL this will always be set as the default domain.
  *                  This should be an IDENTITY/BLOCKED/PLATFORM domain.
  *                  Do not use in new drivers.
@@ -303,6 +305,7 @@ struct iommu_ops {
        unsigned long pgsize_bitmap;
        struct module *owner;
        struct iommu_domain *identity_domain;
+       struct iommu_domain *blocked_domain;
        struct iommu_domain *default_domain;
 };