All of lore.kernel.org
 help / color / mirror / Atom feed
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: make CONFIG_ZONE_DMA user settable
Date: Mon, 23 Jun 2014 12:09:38 +0100	[thread overview]
Message-ID: <20140623110937.GB15907@arm.com> (raw)
In-Reply-To: <1403499924-11214-1-git-send-email-msalter@redhat.com>

On Mon, Jun 23, 2014 at 06:05:24AM +0100, Mark Salter wrote:
> Commit 19e7640d1f (arm64: Replace ZONE_DMA32 with ZONE_DMA)
> moves support for 32-bit DMA addressing into ZONE_DMA and renames
> CONFIG_ZONE_DMA32 to CONFIG_ZONE_DMA.
> 
> Commit 2d5a5612bc (arm64: Limit the CMA buffer to 32-bit if ZONE_DMA)
> forces the CMA buffer to be 32-bit addressable if CONFIG_ZONE_DMA is
> defined.
> 
> These two patches pose a problem for platforms which have no 32-bit
> addressable DRAM.

It's actually the bus/dma address that needs to be 32-bit rather than
the DRAM as seen by the CPU (which can be beyond 32-bit like the
Keystone platform).

> If CONFIG_ZONE_DMA is turned on for such platforms,
> CMA is unable to reserve a buffer for allocations. CONFIG_ZONE_DMA is
> not user settable however, so there is no way to turn it off without
> editing arch/arm64/Kconfig. Even if one edits Kconfig to turn off
> CONFIG_ZONE_DMA, the kernel fails to build with such a config:
> 
>   arch/arm64/mm/init.c: In function ?zone_sizes_init?:
>   arch/arm64/mm/init.c:76:13: error: ?ZONE_DMA? undeclared (first use in this function)
>      zone_size[ZONE_DMA] = max_dma - min;
>                ^
> 
> This patch makes CONFIG_ZONE_DMA user settable and fixes the kernel
> build when it is turned off.

The reason I left CONFIG_ZONE_DMA not user settable is because on arm64
we aim for single Image by default. So ZONE_DMA would most likely be
needed on at least one platform. Even with ZONE_DMA it's just a guess
without proper system topology description. dma_to_phys() just takes a
NULL argument for device when trying to guess the physical address for a
32-bit DMA mask (and 32-bit devices may have some physical offset wired
already).

With the CMA fix, does the kernel work properly with a zero sized DMA
zone? Any GFP_DMA allocations will fail, including the swiotlb bounce
buffer. It may be fine if no devices require 32-bit DMA memory but I
wonder whether on such platforms it would be better to simply add
all the memory to ZONE_DMA.

Which gets us back to finding a way for describing such system topology
in hardware. We may be able to find a way with DT but unlikely for ACPI.

My proposal (in the absence of any kind of description) is to still
create a ZONE_DMA if we have DMA memory below 32-bit, otherwise just add
everything (>32-bit) to ZONE_DMA. Basically an extension from your CMA
patch, make dma_phys_limit static in that file and set it to
memblock_end_of_DRAM() if no 32-bit DMA. Re-use it in the
zone_sizes_init() function for ZONE_DMA (maybe with a pr_info for no
32-bit only DMA zone).

-- 
Catalin

WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Mark Salter <msalter@redhat.com>
Cc: Will Deacon <Will.Deacon@arm.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] arm64: make CONFIG_ZONE_DMA user settable
Date: Mon, 23 Jun 2014 12:09:38 +0100	[thread overview]
Message-ID: <20140623110937.GB15907@arm.com> (raw)
In-Reply-To: <1403499924-11214-1-git-send-email-msalter@redhat.com>

On Mon, Jun 23, 2014 at 06:05:24AM +0100, Mark Salter wrote:
> Commit 19e7640d1f (arm64: Replace ZONE_DMA32 with ZONE_DMA)
> moves support for 32-bit DMA addressing into ZONE_DMA and renames
> CONFIG_ZONE_DMA32 to CONFIG_ZONE_DMA.
> 
> Commit 2d5a5612bc (arm64: Limit the CMA buffer to 32-bit if ZONE_DMA)
> forces the CMA buffer to be 32-bit addressable if CONFIG_ZONE_DMA is
> defined.
> 
> These two patches pose a problem for platforms which have no 32-bit
> addressable DRAM.

It's actually the bus/dma address that needs to be 32-bit rather than
the DRAM as seen by the CPU (which can be beyond 32-bit like the
Keystone platform).

> If CONFIG_ZONE_DMA is turned on for such platforms,
> CMA is unable to reserve a buffer for allocations. CONFIG_ZONE_DMA is
> not user settable however, so there is no way to turn it off without
> editing arch/arm64/Kconfig. Even if one edits Kconfig to turn off
> CONFIG_ZONE_DMA, the kernel fails to build with such a config:
> 
>   arch/arm64/mm/init.c: In function ‘zone_sizes_init’:
>   arch/arm64/mm/init.c:76:13: error: ‘ZONE_DMA’ undeclared (first use in this function)
>      zone_size[ZONE_DMA] = max_dma - min;
>                ^
> 
> This patch makes CONFIG_ZONE_DMA user settable and fixes the kernel
> build when it is turned off.

The reason I left CONFIG_ZONE_DMA not user settable is because on arm64
we aim for single Image by default. So ZONE_DMA would most likely be
needed on at least one platform. Even with ZONE_DMA it's just a guess
without proper system topology description. dma_to_phys() just takes a
NULL argument for device when trying to guess the physical address for a
32-bit DMA mask (and 32-bit devices may have some physical offset wired
already).

With the CMA fix, does the kernel work properly with a zero sized DMA
zone? Any GFP_DMA allocations will fail, including the swiotlb bounce
buffer. It may be fine if no devices require 32-bit DMA memory but I
wonder whether on such platforms it would be better to simply add
all the memory to ZONE_DMA.

Which gets us back to finding a way for describing such system topology
in hardware. We may be able to find a way with DT but unlikely for ACPI.

My proposal (in the absence of any kind of description) is to still
create a ZONE_DMA if we have DMA memory below 32-bit, otherwise just add
everything (>32-bit) to ZONE_DMA. Basically an extension from your CMA
patch, make dma_phys_limit static in that file and set it to
memblock_end_of_DRAM() if no 32-bit DMA. Re-use it in the
zone_sizes_init() function for ZONE_DMA (maybe with a pr_info for no
32-bit only DMA zone).

-- 
Catalin

  parent reply	other threads:[~2014-06-23 11:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  5:05 [PATCH] arm64: make CONFIG_ZONE_DMA user settable Mark Salter
2014-06-23  5:05 ` Mark Salter
2014-06-23  9:01 ` Russell King - ARM Linux
2014-06-23  9:01   ` Russell King - ARM Linux
2014-06-23 11:09 ` Catalin Marinas [this message]
2014-06-23 11:09   ` Catalin Marinas
2014-06-23 13:17   ` Mark Salter
2014-06-23 13:17     ` Mark Salter
2014-06-24 14:14     ` Catalin Marinas
2014-06-24 14:14       ` Catalin Marinas
2014-06-24 14:38       ` Mark Salter
2014-06-24 14:38         ` Mark Salter
2014-07-18 11:07         ` Catalin Marinas
2014-07-18 11:07           ` Catalin Marinas
2014-07-18 11:58           ` Anup Patel
2014-07-18 11:58             ` Anup Patel
2014-07-18 14:59             ` Catalin Marinas
2014-07-18 14:59               ` Catalin Marinas
2014-07-21 21:56           ` Mark Salter
2014-07-21 21:56             ` Mark Salter

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=20140623110937.GB15907@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.