diff mbox series

arm64: Properly clean up iommu-dma remnants

Message ID d4cc20cbb0c45175e98dd76bf187e2ad6421296d.1714472573.git.robin.murphy@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: Properly clean up iommu-dma remnants | expand

Commit Message

Robin Murphy April 30, 2024, 10:22 a.m. UTC
Thanks to the somewhat asymmetrical nature, while removing
iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
forget that arm64's teardown path was also specific to iommu-dma. Clean
that up to match, otherwise probe deferral will lead to the arch code
erroneously removing DMA ops set elsewhere.

Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 arch/arm64/Kconfig          | 1 -
 arch/arm64/mm/dma-mapping.c | 8 --------
 2 files changed, 9 deletions(-)

Comments

Dmitry Baryshkov April 30, 2024, 10:32 a.m. UTC | #1
On Tue, 30 Apr 2024 at 13:23, Robin Murphy <robin.murphy@arm.com> wrote:
>
> Thanks to the somewhat asymmetrical nature, while removing
> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> forget that arm64's teardown path was also specific to iommu-dma. Clean
> that up to match, otherwise probe deferral will lead to the arch code
> erroneously removing DMA ops set elsewhere.
>
> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  arch/arm64/Kconfig          | 1 -
>  arch/arm64/mm/dma-mapping.c | 8 --------
>  2 files changed, 9 deletions(-)


Thanks!

Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Robin Murphy April 30, 2024, 11 a.m. UTC | #2
On 2024-04-30 11:32 am, Dmitry Baryshkov wrote:
> On Tue, 30 Apr 2024 at 13:23, Robin Murphy <robin.murphy@arm.com> wrote:
>>
>> Thanks to the somewhat asymmetrical nature, while removing
>> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
>> forget that arm64's teardown path was also specific to iommu-dma. Clean
>> that up to match, otherwise probe deferral will lead to the arch code
>> erroneously removing DMA ops set elsewhere.
>>
>> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
>> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>> ---
>>   arch/arm64/Kconfig          | 1 -
>>   arch/arm64/mm/dma-mapping.c | 8 --------
>>   2 files changed, 9 deletions(-)
> 
> 
> Thanks!
> 
> Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Great! Always nice when the issue is one of simply not deleting *enough* 
code :)

Cheers,
Robin.
Catalin Marinas April 30, 2024, 11:22 a.m. UTC | #3
On Tue, Apr 30, 2024 at 11:22:53AM +0100, Robin Murphy wrote:
> Thanks to the somewhat asymmetrical nature, while removing
> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> forget that arm64's teardown path was also specific to iommu-dma. Clean
> that up to match, otherwise probe deferral will lead to the arch code
> erroneously removing DMA ops set elsewhere.
> 
> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Konrad Dybcio April 30, 2024, 12:51 p.m. UTC | #4
On 30.04.2024 12:22 PM, Robin Murphy wrote:
> Thanks to the somewhat asymmetrical nature, while removing
> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> forget that arm64's teardown path was also specific to iommu-dma. Clean
> that up to match, otherwise probe deferral will lead to the arch code
> erroneously removing DMA ops set elsewhere.
> 
> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---

Tested-by: Konrad Dybcio <konrad.dybcio@linaro.org> # QC SM8550 QRD
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
Dmitry Baryshkov May 4, 2024, 2:21 p.m. UTC | #5
On Tue, 30 Apr 2024 at 13:23, Robin Murphy <robin.murphy@arm.com> wrote:
>
> Thanks to the somewhat asymmetrical nature, while removing
> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> forget that arm64's teardown path was also specific to iommu-dma. Clean
> that up to match, otherwise probe deferral will lead to the arch code
> erroneously removing DMA ops set elsewhere.
>
> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  arch/arm64/Kconfig          | 1 -
>  arch/arm64/mm/dma-mapping.c | 8 --------
>  2 files changed, 9 deletions(-)


Just wanted to ping regarding the patch. It's still not a part of
linux-net, Is it going to be picked up for 6.10?
Will Deacon May 7, 2024, 9:50 a.m. UTC | #6
On Sat, May 04, 2024 at 05:21:12PM +0300, Dmitry Baryshkov wrote:
> On Tue, 30 Apr 2024 at 13:23, Robin Murphy <robin.murphy@arm.com> wrote:
> >
> > Thanks to the somewhat asymmetrical nature, while removing
> > iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> > forget that arm64's teardown path was also specific to iommu-dma. Clean
> > that up to match, otherwise probe deferral will lead to the arch code
> > erroneously removing DMA ops set elsewhere.
> >
> > Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> > Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> > Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> > ---
> >  arch/arm64/Kconfig          | 1 -
> >  arch/arm64/mm/dma-mapping.c | 8 --------
> >  2 files changed, 9 deletions(-)
> 
> 
> Just wanted to ping regarding the patch. It's still not a part of
> linux-next, Is it going to be picked up for 6.10?

Oops, thanks Dmitry!

Joerg -- please can you pick this one up for iommu next? It fixes a
commit you already have there, so I think it's best to keep everything
together.

FWIW:

Acked-by: Will Deacon <will@kernel.org>

Will
Nicolin Chen May 9, 2024, 9:04 a.m. UTC | #7
On Tue, Apr 30, 2024 at 11:22:53AM +0100, Robin Murphy wrote:
> Thanks to the somewhat asymmetrical nature, while removing
> iommu_setup_dma_ops() from the arch_setup_dma_ops() flow, I managed to
> forget that arm64's teardown path was also specific to iommu-dma. Clean
> that up to match, otherwise probe deferral will lead to the arch code
> erroneously removing DMA ops set elsewhere.
> 
> Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Link: https://lore.kernel.org/linux-iommu/Zi_LV28TR-P-PzXi@eriador.lumag.spb.ru/
> Fixes: b67483b3c44e ("iommu/dma: Centralise iommu_setup_dma_ops()")
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

This fixes the breakage occurring to my system too. Thanks!

Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Joerg Roedel May 10, 2024, 7:04 a.m. UTC | #8
On Tue, Apr 30, 2024 at 11:22:53AM +0100, Robin Murphy wrote:
>  arch/arm64/Kconfig          | 1 -
>  arch/arm64/mm/dma-mapping.c | 8 --------
>  2 files changed, 9 deletions(-)

Applied, thanks.
diff mbox series

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7b11c98b3e84..8fe59fb9cb35 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -46,7 +46,6 @@  config ARM64
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
 	select ARCH_HAS_SYSCALL_WRAPPER
-	select ARCH_HAS_TEARDOWN_DMA_OPS if IOMMU_SUPPORT
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_ZONE_DMA_SET if EXPERT
 	select ARCH_HAVE_ELF_PROT
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 0b320a25a471..b2b5792b2caa 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -7,7 +7,6 @@ 
 #include <linux/gfp.h>
 #include <linux/cache.h>
 #include <linux/dma-map-ops.h>
-#include <linux/iommu.h>
 #include <xen/xen.h>
 
 #include <asm/cacheflush.h>
@@ -39,13 +38,6 @@  void arch_dma_prep_coherent(struct page *page, size_t size)
 	dcache_clean_poc(start, start + size);
 }
 
-#ifdef CONFIG_IOMMU_DMA
-void arch_teardown_dma_ops(struct device *dev)
-{
-	dev->dma_ops = NULL;
-}
-#endif
-
 void arch_setup_dma_ops(struct device *dev, bool coherent)
 {
 	int cls = cache_line_size_of_cpu();