ARM64: dma-mapping: fix handling of devices registered before arch_initcall
PATCH 1/1 ARM64: dma-mapping: fix handling of devices registered before arch_initcall
This patch ensures that devices, which got registered before arch_initcall will be handled correctly by IOMMU-based DMA-mapping code.
--- arch/arm64/mm/dma-mapping.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/mm/dma-mapping.c +4 -0
@@ -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);
Signature · 1 line
1.9.2
PATCH 1/1 ARM64: dma-mapping: fix handling of devices registered before arch_initcall
Quoted 13 lines · Marek Szyprowski
This patch ensures that devices, which got registered before
arch_initcallwill be handled correctly by IOMMU-based DMA-mapping code.Signed-off-by Marek Szyprowski <[email protected]>--- arch/arm64/mm/dma-mapping.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/mm/dma-mapping.c +0
-0
arch/arm64/mm/dma-mapping.c static int __init __iommu_dma_init(void) · line 934
Quoted 7 lines
arch/arm64/mm/dma-mapping.c +4
-0@@ -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.
Quoted 4 lines
arch/arm64/mm/dma-mapping.c +0
-0return ret; }arch_initcall (__iommu_dma_init);
PATCH 1/1 ARM64: dma-mapping: fix handling of devices registered before arch_initcall
Hello,
Quoted 19 lines · Robin Murphy
Quoted 18 lines · Marek Szyprowski
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 <[email protected]>--- arch/arm64/mm/dma-mapping.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/mm/dma-mapping.c +1
-0@@ -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); +
Quoted 8 lines
arch/arm64/mm/dma-mapping.c static int __init __iommu_dma_init(void) · line 934
Quoted 3 lines
arch/arm64/mm/dma-mapping.c +3
-0+/* 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_initcalllevel, 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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
PATCH 1/1 ARM64: dma-mapping: fix handling of devices registered before arch_initcall
Quoted 31 lines · Marek Szyprowski
Hello,
Quoted 19 lines · Robin Murphy
Quoted 18 lines · Marek Szyprowski
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 <[email protected]>--- arch/arm64/mm/dma-mapping.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm64/mm/dma-mapping.c +1
-0@@ -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); +Quoted 8 lines
arch/arm64/mm/dma-mapping.c static int __init __iommu_dma_init(void) · line 934
Quoted 3 lines
arch/arm64/mm/dma-mapping.c +3
-0+/* 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_initcalllevel, 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?
Quoted 2 lines
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:
Thanks,
Robin.
Quoted 2 lines
Best regards