* [PATCH] drivers: cma: fix addressing on PAE machines
@ 2012-11-30 12:58 Vitaly Andrianov
2012-11-30 15:00 ` Michal Nazarewicz
0 siblings, 1 reply; 4+ messages in thread
From: Vitaly Andrianov @ 2012-11-30 12:58 UTC (permalink / raw)
To: mina86, m.szyprowski, kyungmin.park, arnd, linux-kernel,
linux-keystone
Cc: Vitaly Andrianov, Cyril Chemparathy
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>
---
drivers/base/dma-contiguous.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 9a14694..7936b2e 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -234,7 +234,7 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long 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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: cma: fix addressing on PAE machines
2012-11-30 12:58 [PATCH] drivers: cma: fix addressing on PAE machines Vitaly Andrianov
@ 2012-11-30 15:00 ` Michal Nazarewicz
2012-11-30 20:33 ` Andrianov, Vitaly
0 siblings, 1 reply; 4+ messages in thread
From: Michal Nazarewicz @ 2012-11-30 15:00 UTC (permalink / raw)
To: Vitaly Andrianov, m.szyprowski, kyungmin.park, arnd, linux-kernel,
linux-keystone
Cc: Vitaly Andrianov, Cyril Chemparathy
[-- Attachment #1: Type: text/plain, Size: 2280 bytes --]
On Fri, Nov 30 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>
To be consistent, you should also change the type in:
static long size_cmdline = -1;
static const unsigned long size_bytes = CMA_SIZE_MBYTES * SZ_1M;
static unsigned long __init __maybe_unused cma_early_percent_memory(void)
and in
void __init dma_contiguous_reserve(phys_addr_t limit)
> ---
> drivers/base/dma-contiguous.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
> index 9a14694..7936b2e 100644
> --- a/drivers/base/dma-contiguous.c
> +++ b/drivers/base/dma-contiguous.c
> @@ -234,7 +234,7 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long 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;
> }
> --
> 1.7.9.5
>
--
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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drivers: cma: fix addressing on PAE machines
2012-11-30 15:00 ` Michal Nazarewicz
@ 2012-11-30 20:33 ` Andrianov, Vitaly
2012-11-30 20:47 ` Michal Nazarewicz
0 siblings, 1 reply; 4+ messages in thread
From: Andrianov, Vitaly @ 2012-11-30 20:33 UTC (permalink / raw)
To: Michal Nazarewicz, m.szyprowski@samsung.com,
kyungmin.park@samsung.com, arnd@arndb.de,
linux-kernel@vger.kernel.org,
linux-keystone@list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers)
Cc: Chemparathy, Cyril
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3086 bytes --]
> -----Original Message-----
> From: Michal Nazarewicz [mailto:mpn@google.com] On Behalf Of Michal
> Nazarewicz
> Sent: Friday, November 30, 2012 10:01 AM
> To: Andrianov, Vitaly; m.szyprowski@samsung.com;
> kyungmin.park@samsung.com; arnd@arndb.de; linux-kernel@vger.kernel.org;
> linux-keystone@list.ti.com - Linux developers for Keystone family of
> devices (May contain non-TIers)
> Cc: Andrianov, Vitaly; Chemparathy, Cyril
> Subject: Re: [PATCH] drivers: cma: fix addressing on PAE machines
>
>
> On Fri, Nov 30 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>
>
> To be consistent, you should also change the type in:
>
> static long size_cmdline = -1;
> static const unsigned long size_bytes = CMA_SIZE_MBYTES * SZ_1M; static
> unsigned long __init __maybe_unused cma_early_percent_memory(void)
>
> and in
>
> void __init dma_contiguous_reserve(phys_addr_t limit)
>
Can you elaborate why we need to change type for size?
> > ---
> > drivers/base/dma-contiguous.c | 6 +-----
> > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/base/dma-contiguous.c
> > b/drivers/base/dma-contiguous.c index 9a14694..7936b2e 100644
> > --- a/drivers/base/dma-contiguous.c
> > +++ b/drivers/base/dma-contiguous.c
> > @@ -234,7 +234,7 @@ int __init dma_declare_contiguous(struct device
> *dev, unsigned long 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;
> > }
> > --
> > 1.7.9.5
> >
>
> --
> 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--
Thanks,
Vitaly
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] drivers: cma: fix addressing on PAE machines
2012-11-30 20:33 ` Andrianov, Vitaly
@ 2012-11-30 20:47 ` Michal Nazarewicz
0 siblings, 0 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2012-11-30 20:47 UTC (permalink / raw)
To: Andrianov, Vitaly, m.szyprowski@samsung.com,
kyungmin.park@samsung.com, arnd@arndb.de,
linux-kernel@vger.kernel.org,
linux-keystone@list.ti.com - Linux developers for Keystone family of devices (May contain non-TIers)
Cc: Chemparathy, Cyril
[-- Attachment #1: Type: text/plain, Size: 2849 bytes --]
>> On Fri, Nov 30 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>
>>
>> To be consistent, you should also change the type in:
>>
>> static long size_cmdline = -1;
>> static const unsigned long size_bytes = CMA_SIZE_MBYTES * SZ_1M; static
>> unsigned long __init __maybe_unused cma_early_percent_memory(void)
>>
>> and in
>>
>> void __init dma_contiguous_reserve(phys_addr_t limit)
On Fri, Nov 30 2012, Andrianov, Vitaly wrote:
> Can you elaborate why we need to change type for size?
Like I've wrote, for consistency. The size should use the same type as
alignment. This most likely won't affect the way you use the code, but
it's the right thing to do. It should be done that way from the start,
so it's really my mistake, but since you are touching the code, it'd
best to have the changes contained in a single commit. Alternatively
I can just send my own patch with all those fixes (including yours).
>> > diff --git a/drivers/base/dma-contiguous.c
>> > b/drivers/base/dma-contiguous.c index 9a14694..7936b2e 100644
>> > --- a/drivers/base/dma-contiguous.c
>> > +++ b/drivers/base/dma-contiguous.c
>> > @@ -234,7 +234,7 @@ int __init dma_declare_contiguous(struct device
>> *dev, unsigned long 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;
>> > }
--
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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-30 20:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-30 12:58 [PATCH] drivers: cma: fix addressing on PAE machines Vitaly Andrianov
2012-11-30 15:00 ` Michal Nazarewicz
2012-11-30 20:33 ` Andrianov, Vitaly
2012-11-30 20:47 ` Michal Nazarewicz
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.