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

Message ID 20221128064648.1934720-7-baolu.lu@linux.intel.com
State New
Headers
Series iommu: Retire detach_dev callback |

Commit Message

Baolu Lu Nov. 28, 2022, 6:46 a.m. UTC
  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@linux.intel.com>
---
 drivers/iommu/mtk_iommu.c | 9 ---------
 1 file changed, 9 deletions(-)
  

Comments

Jason Gunthorpe Nov. 28, 2022, 1:49 p.m. UTC | #1
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@linux.intel.com>
> ---
>  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@nvidia.com/

?

Has something changed? Did I get it wrong?

Jason
  
Robin Murphy Nov. 28, 2022, 1:59 p.m. UTC | #2
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@linux.intel.com>
>> ---
>>   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@nvidia.com/
> 
> ?
> 
> 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.

Cheers,
Robin.
  
Baolu Lu Nov. 29, 2022, 2:07 a.m. UTC | #3
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@linux.intel.com>
>>> ---
>>>   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@nvidia.com/
>>
>> ?
>>
>> 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.

Best regards,
baolu
  
Robin Murphy Nov. 29, 2022, 11:45 a.m. UTC | #4
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@linux.intel.com>
>>>> ---
>>>>   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@nvidia.com/
>>>
>>> ?
>>>
>>> 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 ;)

Thanks,
Robin.
  
Baolu Lu Nov. 29, 2022, 11:58 a.m. UTC | #5
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@linux.intel.com>
>>>>> ---
>>>>>   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@nvidia.com/
>>>>
>>>> ?
>>>>
>>>> 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
  

Patch

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 5dc1009a19ed..2022f47529c1 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -713,14 +713,6 @@  static int mtk_iommu_attach_device(struct iommu_domain *domain,
 	return ret;
 }
 
-static void mtk_iommu_detach_device(struct iommu_domain *domain,
-				    struct device *dev)
-{
-	struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
-
-	mtk_iommu_config(data, dev, false, 0);
-}
-
 static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova,
 			 phys_addr_t paddr, size_t pgsize, size_t pgcount,
 			 int prot, gfp_t gfp, size_t *mapped)
@@ -949,7 +941,6 @@  static const struct iommu_ops mtk_iommu_ops = {
 	.owner		= THIS_MODULE,
 	.default_domain_ops = &(const struct iommu_domain_ops) {
 		.attach_dev	= mtk_iommu_attach_device,
-		.detach_dev	= mtk_iommu_detach_device,
 		.map_pages	= mtk_iommu_map,
 		.unmap_pages	= mtk_iommu_unmap,
 		.flush_iotlb_all = mtk_iommu_flush_iotlb_all,