linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing
@ 2024-08-28  9:51 ` Baruch Siach
  2024-08-28 10:19   ` Marek Szyprowski
  2024-08-29  4:16   ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Baruch Siach @ 2024-08-28  9:51 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
	Catalin Marinas, Will Deacon
  Cc: iommu, linux-arm-kernel, Petr Tesařík, Ramon Fried,
	Elad Nachman, Baruch Siach

Some platforms, like Rockchip RK3568 based Odroid M1, do not provide DMA
limits information in device-tree dma-ranges property. Still some device
drivers set DMA limit that relies on DMA zone at low 4GB memory area.
Until commit ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by
zone_dma_limit"), zone_sizes_init() restricted DMA zone to low 32-bit.

Restore DMA zone 32-bit limit when the platform provides no DMA bus
limit information.

Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/53d988b1-bdce-422a-ae4e-158f305ad703@samsung.com
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
This should go via the dma-mapping tree that contains the fixed commit.

Marek, can you test on Odroid M1? Thanks.

v2:

  * Directly check whether platform provides DMA bus limit (Robin)

  * Add Link tag
---
 arch/arm64/mm/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index bfb10969cbf0..5710129b8033 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -116,6 +116,9 @@ static void __init arch_reserve_crashkernel(void)
 
 static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)
 {
+	if (zone_limit == PHYS_ADDR_MAX)
+		zone_limit = U32_MAX;
+
 	return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
 }
 
-- 
2.45.2



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

* Re: [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing
  2024-08-28  9:51 ` [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing Baruch Siach
@ 2024-08-28 10:19   ` Marek Szyprowski
  2024-08-29  4:16   ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Szyprowski @ 2024-08-28 10:19 UTC (permalink / raw)
  To: Baruch Siach, Christoph Hellwig, Robin Murphy, Catalin Marinas,
	Will Deacon
  Cc: iommu, linux-arm-kernel, Petr Tesařík, Ramon Fried,
	Elad Nachman

On 28.08.2024 11:51, Baruch Siach wrote:
> Some platforms, like Rockchip RK3568 based Odroid M1, do not provide DMA
> limits information in device-tree dma-ranges property. Still some device
> drivers set DMA limit that relies on DMA zone at low 4GB memory area.
> Until commit ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by
> zone_dma_limit"), zone_sizes_init() restricted DMA zone to low 32-bit.
>
> Restore DMA zone 32-bit limit when the platform provides no DMA bus
> limit information.
>
> Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Link: https://lore.kernel.org/r/53d988b1-bdce-422a-ae4e-158f305ad703@samsung.com
> Suggested-by: Robin Murphy <robin.murphy@arm.com>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> This should go via the dma-mapping tree that contains the fixed commit.
>
> Marek, can you test on Odroid M1? Thanks.


Works fine!

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>


> v2:
>
>    * Directly check whether platform provides DMA bus limit (Robin)
>
>    * Add Link tag
> ---
>   arch/arm64/mm/init.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index bfb10969cbf0..5710129b8033 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -116,6 +116,9 @@ static void __init arch_reserve_crashkernel(void)
>   
>   static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)
>   {
> +	if (zone_limit == PHYS_ADDR_MAX)
> +		zone_limit = U32_MAX;
> +
>   	return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
>   }
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



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

* Re: [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing
  2024-08-28  9:51 ` [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing Baruch Siach
  2024-08-28 10:19   ` Marek Szyprowski
@ 2024-08-29  4:16   ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-08-29  4:16 UTC (permalink / raw)
  To: Baruch Siach
  Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
	Catalin Marinas, Will Deacon, iommu, linux-arm-kernel,
	Petr Tesařík, Ramon Fried, Elad Nachman

Thanks, applied.



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

end of thread, other threads:[~2024-08-29  4:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240828095158eucas1p1e4c0cbd7d74b3e56c067382a229a5ec1@eucas1p1.samsung.com>
2024-08-28  9:51 ` [PATCH v2] arm64: mm: fix DMA zone when dma-ranges is missing Baruch Siach
2024-08-28 10:19   ` Marek Szyprowski
2024-08-29  4:16   ` Christoph Hellwig

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