From: Catalin Marinas <catalin.marinas@arm.com>
To: Elad Nachman <enachman@marvell.com>
Cc: will@kernel.org, thunder.leizhen@huawei.com, bhe@redhat.com,
akpm@linux-foundation.org, yajun.deng@linux.dev,
chris.zjh@huawei.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: mm: Fix SOCs with DDR starting above zero
Date: Fri, 5 Jan 2024 19:21:45 +0000 [thread overview]
Message-ID: <ZZhWya4EK45lLbds@arm.com> (raw)
In-Reply-To: <20240103170002.1793197-1-enachman@marvell.com>
On Wed, Jan 03, 2024 at 07:00:02PM +0200, Elad Nachman wrote:
> From: Elad Nachman <enachman@marvell.com>
>
> Some SOCs, like the Marvell AC5/X/IM, have a combination
> of DDR starting at 0x2_0000_0000 coupled with DMA controllers
> limited to 31 and 32 bit of addressing.
> This requires to properly arrange ZONE_DMA and ZONE_DMA32 for
> these SOCs, so swiotlb and coherent DMA allocation would work
> properly.
> Change initialization so device tree dma zone bits are taken as
> function of offset from DRAM start, and when calculating the
> maximal zone physical RAM address for physical DDR starting above
> 32-bit, combine the physical address start plus the zone mask
> passed as parameter.
> This creates the proper zone splitting for these SOCs:
> 0..2GB for ZONE_DMA
> 2GB..4GB for ZONE_DMA32
> 4GB..8GB for ZONE_NORMAL
Please see this discussion:
https://lore.kernel.org/all/ZU0QEL9ByWNYVki1@arm.com/
and follow-up patches from Baruch, though I haven't reviewed them yet:
https://lore.kernel.org/all/fae5b1180161a7d8cd626a96f5df80b0a0796b8b.1703683642.git.baruch@tkos.co.il/
The problem is that the core code pretty much assumes that DRAM starts
from 0. No matter how you massage the zones in the arm64 kernel for your
case, memblock_start_of_DRAM() + (2 << zone_dma_bits) won't be a power
of two and therefore zone_dma_bits in the core code cannot describe what
you need.
I can see Baruch added a zone_dma_off assuming it's the same for all
DMA-capable devices on that SoC (well, those with a coherent mask
smaller than 64-bit). I need to think a bit more about this.
Anyway, we first need to address the mask/bits comparisons in the core
code, maybe changing bits to a physical limit instead and take the
device DMA offset into account. After that we can look at how to
correctly set up the DMA zones on arm64.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Elad Nachman <enachman@marvell.com>
Cc: will@kernel.org, thunder.leizhen@huawei.com, bhe@redhat.com,
akpm@linux-foundation.org, yajun.deng@linux.dev,
chris.zjh@huawei.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: mm: Fix SOCs with DDR starting above zero
Date: Fri, 5 Jan 2024 19:21:45 +0000 [thread overview]
Message-ID: <ZZhWya4EK45lLbds@arm.com> (raw)
In-Reply-To: <20240103170002.1793197-1-enachman@marvell.com>
On Wed, Jan 03, 2024 at 07:00:02PM +0200, Elad Nachman wrote:
> From: Elad Nachman <enachman@marvell.com>
>
> Some SOCs, like the Marvell AC5/X/IM, have a combination
> of DDR starting at 0x2_0000_0000 coupled with DMA controllers
> limited to 31 and 32 bit of addressing.
> This requires to properly arrange ZONE_DMA and ZONE_DMA32 for
> these SOCs, so swiotlb and coherent DMA allocation would work
> properly.
> Change initialization so device tree dma zone bits are taken as
> function of offset from DRAM start, and when calculating the
> maximal zone physical RAM address for physical DDR starting above
> 32-bit, combine the physical address start plus the zone mask
> passed as parameter.
> This creates the proper zone splitting for these SOCs:
> 0..2GB for ZONE_DMA
> 2GB..4GB for ZONE_DMA32
> 4GB..8GB for ZONE_NORMAL
Please see this discussion:
https://lore.kernel.org/all/ZU0QEL9ByWNYVki1@arm.com/
and follow-up patches from Baruch, though I haven't reviewed them yet:
https://lore.kernel.org/all/fae5b1180161a7d8cd626a96f5df80b0a0796b8b.1703683642.git.baruch@tkos.co.il/
The problem is that the core code pretty much assumes that DRAM starts
from 0. No matter how you massage the zones in the arm64 kernel for your
case, memblock_start_of_DRAM() + (2 << zone_dma_bits) won't be a power
of two and therefore zone_dma_bits in the core code cannot describe what
you need.
I can see Baruch added a zone_dma_off assuming it's the same for all
DMA-capable devices on that SoC (well, those with a coherent mask
smaller than 64-bit). I need to think a bit more about this.
Anyway, we first need to address the mask/bits comparisons in the core
code, maybe changing bits to a physical limit instead and take the
device DMA offset into account. After that we can look at how to
correctly set up the DMA zones on arm64.
--
Catalin
next prev parent reply other threads:[~2024-01-05 19:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 17:00 [PATCH] arm64: mm: Fix SOCs with DDR starting above zero Elad Nachman
2024-01-03 17:45 ` Will Deacon
2024-01-03 17:45 ` Will Deacon
2024-01-03 18:32 ` Florian Fainelli
2024-01-03 18:32 ` Florian Fainelli
2024-01-04 12:38 ` [EXT] " Elad Nachman
2024-01-04 12:38 ` Elad Nachman
2024-01-04 18:28 ` Florian Fainelli
2024-01-04 18:28 ` Florian Fainelli
2024-01-04 18:34 ` Elad Nachman
2024-01-04 18:34 ` Elad Nachman
2024-01-04 18:37 ` Florian Fainelli
2024-01-04 18:37 ` Florian Fainelli
2024-01-03 18:47 ` Baruch Siach
2024-01-03 18:47 ` Baruch Siach
2024-01-05 19:21 ` Catalin Marinas [this message]
2024-01-05 19:21 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZZhWya4EK45lLbds@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=chris.zjh@huawei.com \
--cc=enachman@marvell.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=will@kernel.org \
--cc=yajun.deng@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.