Re: [PATCH v3 06/20] iommu/mtk: Remove detach_dev callback

From: Baolu Lu
Date: Tue Nov 29 2022 - 06:59:04 EST


On 2022/11/29 19:45, Robin Murphy wrote:
On 2022-11-29 02:07, Baolu Lu wrote:
On 11/28/22 9:59 PM, Robin Murphy wrote:
On 2022-11-28 13:49, Jason Gunthorpe wrote:
On Mon, Nov 28, 2022 at 02:46:34PM +0800, Lu Baolu wrote:
The IOMMU driver supports default domain, so the detach_dev op will never
be called. Remove it to avoid dead code.

Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
---
  drivers/iommu/mtk_iommu.c | 9 ---------
  1 file changed, 9 deletions(-)

I listed this driver as not supporting default domains:

https://lore.kernel.org/linux-iommu/20220516135741.GV1343366@xxxxxxxxxx/

?

Has something changed? Did I get it wrong?

static struct iommu_domain *mtk_iommu_domain_alloc(unsigned type)
{
     struct mtk_iommu_domain *dom;

     if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED)
         return NULL;
...


This one runs on arm64, so has always supported default domains for iommu-dma to work.

This, together with several other ones, only support IOMMU_DOMAIN_DMA
type of default domain. The iommu core handle this by falling back to
IOMMU_DOMAIN_DMA if other types fail.

         dom = __iommu_domain_alloc(bus, type);
         if (!dom && type != IOMMU_DOMAIN_DMA) {
                 dom = __iommu_domain_alloc(bus, IOMMU_DOMAIN_DMA);
                 if (dom)
                         pr_warn("Failed to allocate default IOMMU domain of type %u for group %s - Falling back to IOMMU_DOMAIN_DMA",
                                 type, group->name);
         }

I have another cleanup series:

https://github.com/LuBaolu/intel-iommu/commits/iommu-use-def_default_type-wip

which adds IOMMU_DOMAIN_DMA default domain type requirement in the
def_domain_type callback. I planed to bring that to discussion after
this one.

Per the discussion over on the s390 thread, I think that would be a step in the wrong direction. I'd prefer to keep .def_domain_type for device-specific requirements and express general driver domain support a different way. If the IOMMU_DOMAIN_DMA fallback is worth removing then the one for IOMMU_DOMAIN_BLOCKED is as well - no point doing half the job ;)

Get you. Thanks for pointing this out. Sure, let's keep the code.

Best regards,
baolu