2022-04-28 15:20:26

by Robin Murphy

[permalink] [raw]
Subject: [PATCH v2 09/14] iommu/ipmmu-vmsa: Clean up bus_set_iommu()

Stop calling bus_set_iommu() since it's now unnecessary. This also
leaves the custom initcall effectively doing nothing but register
the driver, which no longer needs to happen early either, so convert
it to builtin_platform_driver().

Signed-off-by: Robin Murphy <[email protected]>
---
drivers/iommu/ipmmu-vmsa.c | 35 +----------------------------------
1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 8fdb84b3642b..2549d32f0ddd 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1090,11 +1090,6 @@ static int ipmmu_probe(struct platform_device *pdev)
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
if (ret)
return ret;
-
-#if defined(CONFIG_IOMMU_DMA)
- if (!iommu_present(&platform_bus_type))
- bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-#endif
}

/*
@@ -1168,32 +1163,4 @@ static struct platform_driver ipmmu_driver = {
.probe = ipmmu_probe,
.remove = ipmmu_remove,
};
-
-static int __init ipmmu_init(void)
-{
- struct device_node *np;
- static bool setup_done;
- int ret;
-
- if (setup_done)
- return 0;
-
- np = of_find_matching_node(NULL, ipmmu_of_ids);
- if (!np)
- return 0;
-
- of_node_put(np);
-
- ret = platform_driver_register(&ipmmu_driver);
- if (ret < 0)
- return ret;
-
-#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
- if (!iommu_present(&platform_bus_type))
- bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-#endif
-
- setup_done = true;
- return 0;
-}
-subsys_initcall(ipmmu_init);
+builtin_platform_driver(ipmmu_driver);
--
2.35.3.dirty


2022-07-06 09:03:08

by Alexey Kardashevskiy

[permalink] [raw]
Subject: Re: [PATCH v2 09/14] iommu/ipmmu-vmsa: Clean up bus_set_iommu()



On 28/04/2022 23:18, Robin Murphy wrote:
> Stop calling bus_set_iommu() since it's now unnecessary. This also
> leaves the custom initcall effectively doing nothing but register
> the driver, which no longer needs to happen early either, so convert
> it to builtin_platform_driver().
>
> Signed-off-by: Robin Murphy <[email protected]>
> ---
> drivers/iommu/ipmmu-vmsa.c | 35 +----------------------------------
> 1 file changed, 1 insertion(+), 34 deletions(-)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 8fdb84b3642b..2549d32f0ddd 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1090,11 +1090,6 @@ static int ipmmu_probe(struct platform_device *pdev)
> ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
> if (ret)
> return ret;
> -
> -#if defined(CONFIG_IOMMU_DMA)
> - if (!iommu_present(&platform_bus_type))
> - bus_set_iommu(&platform_bus_type, &ipmmu_ops);
> -#endif
> }
>
> /*

The comment which starts here did not make it to the patch but it should
have as it mentions bus_set_iommu() which is gone by the end of the series.


More general question/request - could you please include the exact sha1
the patchset is based on? It did not apply to any current trees and
while it was trivial, it was slightly annoying to resolve the conflicts
:) Thanks,


> @@ -1168,32 +1163,4 @@ static struct platform_driver ipmmu_driver = {
> .probe = ipmmu_probe,
> .remove = ipmmu_remove,
> };
> -
> -static int __init ipmmu_init(void)
> -{
> - struct device_node *np;
> - static bool setup_done;
> - int ret;
> -
> - if (setup_done)
> - return 0;
> -
> - np = of_find_matching_node(NULL, ipmmu_of_ids);
> - if (!np)
> - return 0;
> -
> - of_node_put(np);
> -
> - ret = platform_driver_register(&ipmmu_driver);
> - if (ret < 0)
> - return ret;
> -
> -#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
> - if (!iommu_present(&platform_bus_type))
> - bus_set_iommu(&platform_bus_type, &ipmmu_ops);
> -#endif
> -
> - setup_done = true;
> - return 0;
> -}
> -subsys_initcall(ipmmu_init);
> +builtin_platform_driver(ipmmu_driver);

--
Alexey

2022-07-06 11:12:06

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH v2 09/14] iommu/ipmmu-vmsa: Clean up bus_set_iommu()

On 2022-07-06 09:38, Alexey Kardashevskiy wrote:
>
>
> On 28/04/2022 23:18, Robin Murphy wrote:
>> Stop calling bus_set_iommu() since it's now unnecessary. This also
>> leaves the custom initcall effectively doing nothing but register
>> the driver, which no longer needs to happen early either, so convert
>> it to builtin_platform_driver().
>>
>> Signed-off-by: Robin Murphy <[email protected]>
>> ---
>>   drivers/iommu/ipmmu-vmsa.c | 35 +----------------------------------
>>   1 file changed, 1 insertion(+), 34 deletions(-)
>>
>> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
>> index 8fdb84b3642b..2549d32f0ddd 100644
>> --- a/drivers/iommu/ipmmu-vmsa.c
>> +++ b/drivers/iommu/ipmmu-vmsa.c
>> @@ -1090,11 +1090,6 @@ static int ipmmu_probe(struct platform_device
>> *pdev)
>>           ret = iommu_device_register(&mmu->iommu, &ipmmu_ops,
>> &pdev->dev);
>>           if (ret)
>>               return ret;
>> -
>> -#if defined(CONFIG_IOMMU_DMA)
>> -        if (!iommu_present(&platform_bus_type))
>> -            bus_set_iommu(&platform_bus_type, &ipmmu_ops);
>> -#endif
>>       }
>>       /*
>
> The comment which starts here did not make it to the patch but it should
> have as it mentions bus_set_iommu() which is gone by the end of the series.

Heh, busted! In fact I think the whole point of that comment stops being
true, but I couldn't be bothered to reason about it since one of the
next steps after this is to start ripping all the arm_iommu_* stuff out
anyway.

> More general question/request - could you please include the exact sha1
> the patchset is based on? It did not apply to any current trees and
> while it was trivial, it was slightly annoying to resolve the conflicts
> :)  Thanks,

v3 is based directly on 5.19-rc3:

https://lore.kernel.org/lkml/[email protected]/

And if it helps I have it on a branch here as well:

https://gitlab.arm.com/linux-arm/linux-rm/-/tree/bus-set-iommu-v3

Robin.