* [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall
@ 2016-02-16 14:14 Marek Szyprowski
2016-02-16 19:05 ` Robin Murphy
0 siblings, 1 reply; 4+ messages in thread
From: Marek Szyprowski @ 2016-02-16 14:14 UTC (permalink / raw)
To: linux-arm-kernel
This patch ensures that devices, which got registered before arch_initcall
will be handled correctly by IOMMU-based DMA-mapping code.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
arch/arm64/mm/dma-mapping.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 573b1e6..ce6019f 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -928,6 +928,10 @@ static int __init __iommu_dma_init(void)
ret = register_iommu_dma_ops_notifier(&platform_bus_type);
if (!ret)
ret = register_iommu_dma_ops_notifier(&amba_bustype);
+
+ /* handle devices queued before this arch_initcall */
+ if (!ret)
+ __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
return ret;
}
arch_initcall(__iommu_dma_init);
--
1.9.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall
2016-02-16 14:14 [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall Marek Szyprowski
@ 2016-02-16 19:05 ` Robin Murphy
2016-02-17 7:06 ` Marek Szyprowski
0 siblings, 1 reply; 4+ messages in thread
From: Robin Murphy @ 2016-02-16 19:05 UTC (permalink / raw)
To: linux-arm-kernel
On 16/02/16 14:14, Marek Szyprowski wrote:
> This patch ensures that devices, which got registered before arch_initcall
> will be handled correctly by IOMMU-based DMA-mapping code.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> arch/arm64/mm/dma-mapping.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index 573b1e6..ce6019f 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -928,6 +928,10 @@ static int __init __iommu_dma_init(void)
> ret = register_iommu_dma_ops_notifier(&platform_bus_type);
> if (!ret)
> ret = register_iommu_dma_ops_notifier(&amba_bustype);
> +
> + /* handle devices queued before this arch_initcall */
> + if (!ret)
> + __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
Hmm, surely unless *all* the devices on the relevant buses are created
before arch_initcall level, then the next one is going to kick off the
notifier to walk the whole list anyway. Have you seen this being a
problem in practice?
Robin.
> return ret;
> }
> arch_initcall(__iommu_dma_init);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall
2016-02-16 19:05 ` Robin Murphy
@ 2016-02-17 7:06 ` Marek Szyprowski
2016-02-17 10:19 ` Robin Murphy
0 siblings, 1 reply; 4+ messages in thread
From: Marek Szyprowski @ 2016-02-17 7:06 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
On 2016-02-16 20:05, Robin Murphy wrote:
> On 16/02/16 14:14, Marek Szyprowski wrote:
>> This patch ensures that devices, which got registered before
>> arch_initcall
>> will be handled correctly by IOMMU-based DMA-mapping code.
>>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>> arch/arm64/mm/dma-mapping.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
>> index 573b1e6..ce6019f 100644
>> --- a/arch/arm64/mm/dma-mapping.c
>> +++ b/arch/arm64/mm/dma-mapping.c
>> @@ -928,6 +928,10 @@ static int __init __iommu_dma_init(void)
>> ret = register_iommu_dma_ops_notifier(&platform_bus_type);
>> if (!ret)
>> ret = register_iommu_dma_ops_notifier(&amba_bustype);
>> +
>> + /* handle devices queued before this arch_initcall */
>> + if (!ret)
>> + __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
>
> Hmm, surely unless *all* the devices on the relevant buses are created
> before arch_initcall level, then the next one is going to kick off the
> notifier to walk the whole list anyway. Have you seen this being a
> problem in practice?
Yes, I've observed such situation, that's why I've posted this patch. I was
really surprised that this code doesn't handle all cases.
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall
2016-02-17 7:06 ` Marek Szyprowski
@ 2016-02-17 10:19 ` Robin Murphy
0 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2016-02-17 10:19 UTC (permalink / raw)
To: linux-arm-kernel
On 17/02/16 07:06, Marek Szyprowski wrote:
> Hello,
>
> On 2016-02-16 20:05, Robin Murphy wrote:
>> On 16/02/16 14:14, Marek Szyprowski wrote:
>>> This patch ensures that devices, which got registered before
>>> arch_initcall
>>> will be handled correctly by IOMMU-based DMA-mapping code.
>>>
>>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>>> ---
>>> arch/arm64/mm/dma-mapping.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
>>> index 573b1e6..ce6019f 100644
>>> --- a/arch/arm64/mm/dma-mapping.c
>>> +++ b/arch/arm64/mm/dma-mapping.c
>>> @@ -928,6 +928,10 @@ static int __init __iommu_dma_init(void)
>>> ret = register_iommu_dma_ops_notifier(&platform_bus_type);
>>> if (!ret)
>>> ret = register_iommu_dma_ops_notifier(&amba_bustype);
>>> +
>>> + /* handle devices queued before this arch_initcall */
>>> + if (!ret)
>>> + __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
>>
>> Hmm, surely unless *all* the devices on the relevant buses are created
>> before arch_initcall level, then the next one is going to kick off the
>> notifier to walk the whole list anyway. Have you seen this being a
>> problem in practice?
>
> Yes, I've observed such situation, that's why I've posted this patch. I was
> really surprised that this code doesn't handle all cases.
Ok, fair enough - I guess I just didn't consider that being a likely
possibility. Since I am a fan of correctness:
Acked-by: Robin Murphy <robin.murphy@arm.com>
Thanks,
Robin.
>
> Best regards
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-17 10:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16 14:14 [PATCH] ARM64: dma-mapping: fix handling of devices registered before arch_initcall Marek Szyprowski
2016-02-16 19:05 ` Robin Murphy
2016-02-17 7:06 ` Marek Szyprowski
2016-02-17 10:19 ` Robin Murphy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.