From: Michal Nazarewicz <mina86@mina86.com>
To: Vitaly Andrianov <vitalya@ti.com>,
m.szyprowski@samsung.com, kyungmin.park@samsung.com,
arnd@arndb.de, linux-kernel@vger.kernel.org,
linux-keystone@list.ti.com
Cc: Vitaly Andrianov <vitalya@ti.com>, Cyril Chemparathy <cyril@ti.com>
Subject: Re: [PATCH v2] drivers: cma: fix addressing on PAE machines
Date: Mon, 03 Dec 2012 19:19:55 +0100 [thread overview]
Message-ID: <xa1ty5hfroac.fsf@mina86.com> (raw)
In-Reply-To: <1354549570-21445-1-git-send-email-vitalya@ti.com>
[-- Attachment #1: Type: text/plain, Size: 4872 bytes --]
On Mon, Dec 03 2012, Vitaly Andrianov <vitalya@ti.com> wrote:
> This patch fixes a couple of bugs that otherwise impair CMA functionality on
> PAE machines:
>
> - alignment must be a 64-bit type when running on systems with 64-bit
> physical addresses. If this is not the case, the limit calculation thunks
> allocations down to an address range < 4G.
>
> - The allocated range check is removed. On 32bit ARM kernel with LPAE
> enabled the base may be allocated outside the fist 4GB of physical
> memory (keystone SoC for example).
>
> Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
> Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
> index 9a14694..097dd44 100644
> --- a/drivers/base/dma-contiguous.c
> +++ b/drivers/base/dma-contiguous.c
> @@ -60,8 +60,8 @@ struct cma *dma_contiguous_default_area;
> * Users, who want to set the size of global CMA area for their system
> * should use cma= kernel parameter.
> */
> -static const unsigned long size_bytes = CMA_SIZE_MBYTES * SZ_1M;
> -static long size_cmdline = -1;
> +static const phys_addr_t size_bytes = CMA_SIZE_MBYTES * SZ_1M;
> +static phys_addr_t size_cmdline = -1;
>
> static int __init early_cma(char *p)
> {
> @@ -73,7 +73,7 @@ early_param("cma", early_cma);
>
> #ifdef CONFIG_CMA_SIZE_PERCENTAGE
>
> -static unsigned long __init __maybe_unused cma_early_percent_memory(void)
> +static phys_addr_t __init __maybe_unused cma_early_percent_memory(void)
> {
> struct memblock_region *reg;
> unsigned long total_pages = 0;
> @@ -91,7 +91,7 @@ static unsigned long __init __maybe_unused cma_early_percent_memory(void)
>
> #else
>
> -static inline __maybe_unused unsigned long cma_early_percent_memory(void)
> +static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
> {
> return 0;
> }
> @@ -109,7 +109,7 @@ static inline __maybe_unused unsigned long cma_early_percent_memory(void)
> */
> void __init dma_contiguous_reserve(phys_addr_t limit)
> {
> - unsigned long selected_size = 0;
> + phys_addr_t selected_size = 0;
>
> pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit);
>
> @@ -129,7 +129,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
>
> if (selected_size) {
> pr_debug("%s: reserving %ld MiB for global area\n", __func__,
> - selected_size / SZ_1M);
> + (unsigned long)selected_size / SZ_1M);
>
> dma_declare_contiguous(NULL, selected_size, 0, limit);
> }
> @@ -230,11 +230,11 @@ core_initcall(cma_init_reserved_areas);
> * called by board specific code when early allocator (memblock or bootmem)
> * is still activate.
> */
> -int __init dma_declare_contiguous(struct device *dev, unsigned long size,
> +int __init dma_declare_contiguous(struct device *dev, phys_addr_t size,
> phys_addr_t base, phys_addr_t limit)
> {
> struct cma_reserved *r = &cma_reserved[cma_reserved_count];
> - unsigned long alignment;
> + phys_addr_t alignment;
>
> pr_debug("%s(size %lx, base %08lx, limit %08lx)\n", __func__,
> (unsigned long)size, (unsigned long)base,
> @@ -271,10 +271,6 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size,
> if (!addr) {
> base = -ENOMEM;
> goto err;
> - } else if (addr + size > ~(unsigned long)0) {
> - memblock_free(addr, size);
> - base = -EINVAL;
> - goto err;
> } else {
> base = addr;
> }
> diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
> index 2f303e4..01b5c84 100644
> --- a/include/linux/dma-contiguous.h
> +++ b/include/linux/dma-contiguous.h
> @@ -68,7 +68,7 @@ struct device;
> extern struct cma *dma_contiguous_default_area;
>
> void dma_contiguous_reserve(phys_addr_t addr_limit);
> -int dma_declare_contiguous(struct device *dev, unsigned long size,
> +int dma_declare_contiguous(struct device *dev, phys_addr_t size,
> phys_addr_t base, phys_addr_t limit);
>
> struct page *dma_alloc_from_contiguous(struct device *dev, int count,
> @@ -83,7 +83,7 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
> static inline void dma_contiguous_reserve(phys_addr_t limit) { }
>
> static inline
> -int dma_declare_contiguous(struct device *dev, unsigned long size,
> +int dma_declare_contiguous(struct device *dev, phys_addr_t size,
> phys_addr_t base, phys_addr_t limit)
> {
> return -ENOSYS;
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--
[-- Attachment #2.1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2.2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2012-12-03 18:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 15:46 [PATCH v2] drivers: cma: fix addressing on PAE machines Vitaly Andrianov
2012-12-03 18:19 ` Michal Nazarewicz [this message]
2012-12-04 6:46 ` [linux-keystone] " Santosh Shilimkar
2012-12-04 13:07 ` Michal Nazarewicz
2012-12-04 15:00 ` Santosh Shilimkar
2012-12-04 19:04 ` Michal Nazarewicz
2012-12-04 21:03 ` Andrianov, Vitaly
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=xa1ty5hfroac.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=arnd@arndb.de \
--cc=cyril@ti.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-keystone@list.ti.com \
--cc=m.szyprowski@samsung.com \
--cc=vitalya@ti.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox