arm64: Kconfig: select ZONE_DMA
PATCH 1/1 arm64: Kconfig: select ZONE_DMA
From: Peng Fan <[email protected]>
ZONE_DMA should not be disabled, otherwise arm64_dma_phys_limit is left uninitialized and cause swiotlb have IO TLB above 4GB which might crash some platforms
---
Not sure whether need to address code to initialize the variables or force select ZONE_DMA
arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
@@ -206,6 +206,7 @@ config ARM64 select SWIOTLB select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK + select ZONE_DMA help ARM 64-bit (AArch64) Linux support.
Signature · 1 line
2.28.0
Hi Peng,
sorry for the inconvenience, this is most probably related to these changes:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Quoted 11 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
ZONE_DMAshould not be disabled, otherwisearm64_dma_phys_limitis left uninitialized and cause swiotlb have IO TLB above 4GB which might crash some platformsSigned-off-by Peng Fan <[email protected]>---
Not sure whether need to address code to initialize the variables or force select
ZONE_DMA
What is the cause for the swiotlb related crashes? I assume it's DMA into an address too high for the bus, but it might be something else.
I figure you have a setup with ZONE_DMA32, ZONE_NORMAL and !ZONE_DMA.
First of all, I'd suggest you try arm64's defaults (all zones enabled), the series I mention above should fix most of the issues we've had with ZONE_DMA/ZONE_DMA32 in the past. We now parse DT/ACPI and only create two distinct DMA zones if really needed. Otherwise ZONE_DMA spans the whole 32 bit address space.
That said, IMO we're not doing the right thing in the !ZONE_DMA && ZONE_DMA32 case, and this should fix it (I didn't test it):
- #define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)
+ #define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit ? : arm64_dma32_phys_limit)
Regards,
Nicolas
Catalin Marinas
maintainerQuoted 6 lines · Nicolas Saenz Julienne
Quoted 5 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
ZONE_DMAshould not be disabled, otherwisearm64_dma_phys_limitis left uninitialized and cause swiotlb have IO TLB above 4GB which might crash some platforms
Actually, arm64_dma_phys_limit would be zero-initialised. The ARCH_LOW_ADDRESS_LIMIT becomes ~0UL, hence it covers the whole address space.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Peng Fan <[email protected]>---
Not sure whether need to address code to initialize the variables or force select
ZONE_DMAWhat is the cause for the swiotlb related crashes? I assume it's DMA into an address too high for the bus, but it might be something else.
I think that's the case, swiotlb is not within the low 32-bit of the address space.
Quoted 8 lines
I figure you have a setup with
ZONE_DMA32,ZONE_NORMALand !ZONE_DMA.First of all, I'd suggest you try arm64's defaults (all zones enabled), the series I mention above should fix most of the issues we've had with ZONE_DMA/ZONE_DMA32 in the past. We now parse DT/ACPI and only create two distinct DMA zones if really needed. Otherwise
ZONE_DMAspans the whole 32 bit address space.
Quoted 5 lines
That said, IMO we're not doing the right thing in the !ZONE_DMA &&
ZONE_DMA32case, and this should fix it (I didn't test it):- #define
ARCH_LOW_ADDRESS_LIMIT(arm64_dma_phys_limit- 1)
+ #defineARCH_LOW_ADDRESS_LIMIT(arm64_dma_phys_limit? :arm64_dma32_phys_limit)
Does this limit need to be inclusive?
Signature · 1 line
Catalin
Quoted 32 lines · Catalin Marinas
Quoted 6 lines · Nicolas Saenz Julienne
Quoted 5 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
ZONE_DMAshould not be disabled, otherwisearm64_dma_phys_limitis left uninitialized and cause swiotlb have IO TLB above 4GB which might crash some platformsActually,
arm64_dma_phys_limitwould be zero-initialised. TheARCH_LOW_ADDRESS_LIMITbecomes ~0UL, hence it covers the whole address space.Quoted 8 lines
Quoted 5 lines
Signed-off-by Peng Fan <[email protected]>---
Not sure whether need to address code to initialize the variables or force select
ZONE_DMAWhat is the cause for the swiotlb related crashes? I assume it's DMA into an address too high for the bus, but it might be something else.
I think that's the case, swiotlb is not within the low 32-bit of the address space.
Quoted 8 lines
I figure you have a setup with
ZONE_DMA32,ZONE_NORMALand !ZONE_DMA.First of all, I'd suggest you try arm64's defaults (all zones enabled), the series I mention above should fix most of the issues we've had with ZONE_DMA/ZONE_DMA32 in the past. We now parse DT/ACPI and only create two distinct DMA zones if really needed. Otherwise
ZONE_DMAspans the whole 32 bit address space.
Quoted 7 lines
Quoted 5 lines
That said, IMO we're not doing the right thing in the !ZONE_DMA &&
ZONE_DMA32case, and this should fix it (I didn't test it):- #define
ARCH_LOW_ADDRESS_LIMIT(arm64_dma_phys_limit- 1)
+ #defineARCH_LOW_ADDRESS_LIMIT(arm64_dma_phys_limit? :arm64_dma32_phys_limit)Does this limit need to be inclusive?
Yes, I'm missing a '- 1'.
I'll send a fix if there is no further push back/comments.
Regards,
Nicolas