linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Kconfig: select ZONE_DMA
@ 2020-12-17  8:08 Peng Fan (OSS)
  2020-12-17  8:44 ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Fan (OSS) @ 2020-12-17  8:08 UTC (permalink / raw)
  To: catalin.marinas, will, nsaenzjulienne
  Cc: linux-arm-kernel, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

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(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 33446269f692..377b391a41d6 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -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.
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Kconfig: select ZONE_DMA
  2020-12-17  8:08 [PATCH] arm64: Kconfig: select ZONE_DMA Peng Fan (OSS)
@ 2020-12-17  8:44 ` Nicolas Saenz Julienne
  2020-12-17 12:43   ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2020-12-17  8:44 UTC (permalink / raw)
  To: Peng Fan (OSS), catalin.marinas, will
  Cc: linux-arm-kernel, linux-kernel, Peng Fan

[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]

Hi Peng,
sorry for the inconvenience, this is most probably related to these changes:
https://lore.kernel.org/linux-arm-kernel/20201119175400.9995-1-nsaenzjulienne@suse.de/

On Thu, 2020-12-17 at 16:08 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 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
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> 
> 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





[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Kconfig: select ZONE_DMA
  2020-12-17  8:44 ` Nicolas Saenz Julienne
@ 2020-12-17 12:43   ` Catalin Marinas
  2020-12-17 14:53     ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2020-12-17 12:43 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Peng Fan (OSS), will, linux-arm-kernel, linux-kernel, Peng Fan

On Thu, Dec 17, 2020 at 09:44:31AM +0100, Nicolas Saenz Julienne wrote:
> On Thu, 2020-12-17 at 16:08 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> > 
> > 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

Actually, arm64_dma_phys_limit would be zero-initialised. The
ARCH_LOW_ADDRESS_LIMIT becomes ~0UL, hence it covers the whole address
space.

> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> > 
> > 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 think that's the case, swiotlb is not within the low 32-bit of the
address space.

> 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)

Does this limit need to be inclusive?

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: Kconfig: select ZONE_DMA
  2020-12-17 12:43   ` Catalin Marinas
@ 2020-12-17 14:53     ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2020-12-17 14:53 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Peng Fan (OSS), will, linux-arm-kernel, linux-kernel, Peng Fan

[-- Attachment #1: Type: text/plain, Size: 1888 bytes --]

On Thu, 2020-12-17 at 12:43 +0000, Catalin Marinas wrote:
> On Thu, Dec 17, 2020 at 09:44:31AM +0100, Nicolas Saenz Julienne wrote:
> > On Thu, 2020-12-17 at 16:08 +0800, Peng Fan (OSS) wrote:
> > > From: Peng Fan <peng.fan@nxp.com>
> > > 
> > > 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
> 
> Actually, arm64_dma_phys_limit would be zero-initialised. The
> ARCH_LOW_ADDRESS_LIMIT becomes ~0UL, hence it covers the whole address
> space.
> 
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > > 
> > > 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 think that's the case, swiotlb is not within the low 32-bit of the
> address space.
> 
> > 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)
> 
> 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


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-17 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17  8:08 [PATCH] arm64: Kconfig: select ZONE_DMA Peng Fan (OSS)
2020-12-17  8:44 ` Nicolas Saenz Julienne
2020-12-17 12:43   ` Catalin Marinas
2020-12-17 14:53     ` Nicolas Saenz Julienne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).