Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-30 Thread Ohad Ben-Cohen
Hi Marek,

On Mon, Jan 30, 2012 at 9:43 AM, Marek Szyprowski
m.szyprow...@samsung.com wrote:
 Did you managed to fix this issue?

Yes -- the recent increase in the vmalloc region triggered a bigger
truncation in the system RAM than we had before, and therefore
conflicted with the previous hardcoded region we were using.

Long term, our plan is to get rid of those hardcoded values, but for
the moment our remote RTOS still needs to know the physical address in
advance.

 Right, thanks for spotting it, I will squash it to the next release.

Thanks. With that hunk squashed in, feel free to add my Tested-by tag
to the patches.

Thanks!
Ohad.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-29 Thread Marek Szyprowski
Hello,

On Saturday, January 28, 2012 7:57 PM Ohad Ben-Cohen wrote:

 On Fri, Jan 27, 2012 at 5:17 PM, Marek Szyprowski
 m.szyprow...@samsung.com wrote:
  There have been some vmalloc layout changes merged to v3.3-rc1.
 
 That was dead-on, thanks a lot!

Did you managed to fix this issue?

 
 I did then bump into a different allocation failure which happened
 because dma_alloc_from_contiguous() computes 'mask' before capping the
 'align' argument.
 
 The early 'mask' computation was added in v18 (and therefore exists in
 v19 too) and I was actually testing v17 previously, so I didn't notice
 it before.

Right, thanks for spotting it, I will squash it to the next release.

 You may want to squash something like this:
 
 diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
 index f41e699..8455cb7 100644
 --- a/drivers/base/dma-contiguous.c
 +++ b/drivers/base/dma-contiguous.c
 @@ -319,8 +319,7 @@ struct page *dma_alloc_from_contiguous(struct device 
 *dev, i
unsigned int align)
  {
 struct cma *cma = dev_get_cma_area(dev);
 -   unsigned long pfn, pageno, start = 0;
 -   unsigned long mask = (1  align) - 1;
 +   unsigned long mask, pfn, pageno, start = 0;
 int ret;
 
 if (!cma || !cma-count)
 @@ -329,6 +328,8 @@ struct page *dma_alloc_from_contiguous(struct device 
 *dev, i
 if (align  CONFIG_CMA_ALIGNMENT)
 align = CONFIG_CMA_ALIGNMENT;
 
 +   mask = (1  align) - 1;
 +
 pr_debug(%s(cma %p, count %d, align %d)\n, __func__, (void *)cma,
  count, align);
 

Best regards
-- 
Marek Szyprowski
Samsung Poland RD Center


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-28 Thread Ohad Ben-Cohen
Hi Marek,

On Fri, Jan 27, 2012 at 5:17 PM, Marek Szyprowski
m.szyprow...@samsung.com wrote:
 There have been some vmalloc layout changes merged to v3.3-rc1.

That was dead-on, thanks a lot!

I did then bump into a different allocation failure which happened
because dma_alloc_from_contiguous() computes 'mask' before capping the
'align' argument.

The early 'mask' computation was added in v18 (and therefore exists in
v19 too) and I was actually testing v17 previously, so I didn't notice
it before.

You may want to squash something like this:

diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index f41e699..8455cb7 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -319,8 +319,7 @@ struct page *dma_alloc_from_contiguous(struct device *dev, i
   unsigned int align)
 {
struct cma *cma = dev_get_cma_area(dev);
-   unsigned long pfn, pageno, start = 0;
-   unsigned long mask = (1  align) - 1;
+   unsigned long mask, pfn, pageno, start = 0;
int ret;

if (!cma || !cma-count)
@@ -329,6 +328,8 @@ struct page *dma_alloc_from_contiguous(struct device *dev, i
if (align  CONFIG_CMA_ALIGNMENT)
align = CONFIG_CMA_ALIGNMENT;

+   mask = (1  align) - 1;
+
pr_debug(%s(cma %p, count %d, align %d)\n, __func__, (void *)cma,
 count, align);

Thanks,
Ohad.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Ohad Ben-Cohen
Hi Marek,

With v19, I can't seem to allocate big regions anymore (e.g. 101MiB).
In particular, this seems to fail:

On Thu, Jan 26, 2012 at 11:00 AM, Marek Szyprowski
m.szyprow...@samsung.com wrote:
 +static int cma_activate_area(unsigned long base_pfn, unsigned long count)
 +{
 +       unsigned long pfn = base_pfn;
 +       unsigned i = count  pageblock_order;
 +       struct zone *zone;
 +
 +       WARN_ON_ONCE(!pfn_valid(pfn));
 +       zone = page_zone(pfn_to_page(pfn));
 +
 +       do {
 +               unsigned j;
 +               base_pfn = pfn;
 +               for (j = pageblock_nr_pages; j; --j, pfn++) {
 +                       WARN_ON_ONCE(!pfn_valid(pfn));
 +                       if (page_zone(pfn_to_page(pfn)) != zone)
 +                               return -EINVAL;

The above WARN_ON_ONCE is triggered, and then the conditional is
asserted (page_zone() retuns a Movable zone, whereas zone is
Normal) and the function fails.

This happens to me on OMAP4 with your 3.3-rc1-cma-v19 branch (and a
bunch of remoteproc/rpmsg patches).

Do big allocations work for you ?

Thanks,
Ohad.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Marek Szyprowski
Hi Ohad,

On Friday, January 27, 2012 10:44 AM Ohad Ben-Cohen wrote:

 With v19, I can't seem to allocate big regions anymore (e.g. 101MiB).
 In particular, this seems to fail:
 
 On Thu, Jan 26, 2012 at 11:00 AM, Marek Szyprowski
 m.szyprow...@samsung.com wrote:
  +static int cma_activate_area(unsigned long base_pfn, unsigned long count)
  +{
  +       unsigned long pfn = base_pfn;
  +       unsigned i = count  pageblock_order;
  +       struct zone *zone;
  +
  +       WARN_ON_ONCE(!pfn_valid(pfn));
  +       zone = page_zone(pfn_to_page(pfn));
  +
  +       do {
  +               unsigned j;
  +               base_pfn = pfn;
  +               for (j = pageblock_nr_pages; j; --j, pfn++) {
  +                       WARN_ON_ONCE(!pfn_valid(pfn));
  +                       if (page_zone(pfn_to_page(pfn)) != zone)
  +                               return -EINVAL;
 
 The above WARN_ON_ONCE is triggered, and then the conditional is
 asserted (page_zone() retuns a Movable zone, whereas zone is
 Normal) and the function fails.
 
 This happens to me on OMAP4 with your 3.3-rc1-cma-v19 branch (and a
 bunch of remoteproc/rpmsg patches).
 
 Do big allocations work for you ?

I've tested it with 256MiB on Exynos4 platform. Could you check if the
problem also appears on 3.2-cma-v19 branch (I've uploaded it a few hours
ago) and 3.2-cma-v18? Both are available on our public repo:
git://git.infradead.org/users/kmpark/linux-samsung/

The above code has not been changed since v16, so I'm really surprised 
that it causes problems. Maybe the memory configuration or layout has 
been changed in 3.3-rc1 for OMAP4?

Best regards
-- 
Marek Szyprowski
Samsung Poland RD Center



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Clark, Rob
2012/1/27 Marek Szyprowski m.szyprow...@samsung.com:
 Hi Ohad,

 On Friday, January 27, 2012 10:44 AM Ohad Ben-Cohen wrote:

 With v19, I can't seem to allocate big regions anymore (e.g. 101MiB).
 In particular, this seems to fail:

 On Thu, Jan 26, 2012 at 11:00 AM, Marek Szyprowski
 m.szyprow...@samsung.com wrote:
  +static int cma_activate_area(unsigned long base_pfn, unsigned long count)
  +{
  +       unsigned long pfn = base_pfn;
  +       unsigned i = count  pageblock_order;
  +       struct zone *zone;
  +
  +       WARN_ON_ONCE(!pfn_valid(pfn));
  +       zone = page_zone(pfn_to_page(pfn));
  +
  +       do {
  +               unsigned j;
  +               base_pfn = pfn;
  +               for (j = pageblock_nr_pages; j; --j, pfn++) {
  +                       WARN_ON_ONCE(!pfn_valid(pfn));
  +                       if (page_zone(pfn_to_page(pfn)) != zone)
  +                               return -EINVAL;

 The above WARN_ON_ONCE is triggered, and then the conditional is
 asserted (page_zone() retuns a Movable zone, whereas zone is
 Normal) and the function fails.

 This happens to me on OMAP4 with your 3.3-rc1-cma-v19 branch (and a
 bunch of remoteproc/rpmsg patches).

 Do big allocations work for you ?

 I've tested it with 256MiB on Exynos4 platform. Could you check if the
 problem also appears on 3.2-cma-v19 branch (I've uploaded it a few hours
 ago) and 3.2-cma-v18? Both are available on our public repo:
 git://git.infradead.org/users/kmpark/linux-samsung/

 The above code has not been changed since v16, so I'm really surprised
 that it causes problems. Maybe the memory configuration or layout has
 been changed in 3.3-rc1 for OMAP4?

is highmem still an issue?  I remember hitting this WARN_ON_ONCE() but
went away after I switched to a 2g/2g vm split (which avoids highmem)

BR,
-R

 Best regards
 --
 Marek Szyprowski
 Samsung Poland RD Center




 ___
 Linaro-mm-sig mailing list
 linaro-mm-...@lists.linaro.org
 http://lists.linaro.org/mailman/listinfo/linaro-mm-sig
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Marek Szyprowski
Hello,

On Friday, January 27, 2012 3:28 PM Clark, Rob wrote:

 2012/1/27 Marek Szyprowski m.szyprow...@samsung.com:
  Hi Ohad,
 
  On Friday, January 27, 2012 10:44 AM Ohad Ben-Cohen wrote:
 
  With v19, I can't seem to allocate big regions anymore (e.g. 101MiB).
  In particular, this seems to fail:
 
  On Thu, Jan 26, 2012 at 11:00 AM, Marek Szyprowski
  m.szyprow...@samsung.com wrote:
   +static int cma_activate_area(unsigned long base_pfn, unsigned long 
   count)
   +{
   +       unsigned long pfn = base_pfn;
   +       unsigned i = count  pageblock_order;
   +       struct zone *zone;
   +
   +       WARN_ON_ONCE(!pfn_valid(pfn));
   +       zone = page_zone(pfn_to_page(pfn));
   +
   +       do {
   +               unsigned j;
   +               base_pfn = pfn;
   +               for (j = pageblock_nr_pages; j; --j, pfn++) {
   +                       WARN_ON_ONCE(!pfn_valid(pfn));
   +                       if (page_zone(pfn_to_page(pfn)) != zone)
   +                               return -EINVAL;
 
  The above WARN_ON_ONCE is triggered, and then the conditional is
  asserted (page_zone() retuns a Movable zone, whereas zone is
  Normal) and the function fails.
 
  This happens to me on OMAP4 with your 3.3-rc1-cma-v19 branch (and a
  bunch of remoteproc/rpmsg patches).
 
  Do big allocations work for you ?
 
  I've tested it with 256MiB on Exynos4 platform. Could you check if the
  problem also appears on 3.2-cma-v19 branch (I've uploaded it a few hours
  ago) and 3.2-cma-v18? Both are available on our public repo:
  git://git.infradead.org/users/kmpark/linux-samsung/
 
  The above code has not been changed since v16, so I'm really surprised
  that it causes problems. Maybe the memory configuration or layout has
  been changed in 3.3-rc1 for OMAP4?
 
 is highmem still an issue?  I remember hitting this WARN_ON_ONCE() but
 went away after I switched to a 2g/2g vm split (which avoids highmem)

No, it shouldn't be an issue. I've tested CMA v19 on a system with 1GiB of
the memory and general purpose (global) cma region was allocated correctly
at the end of low memory. For device private regions you should take care 
of correct placement by yourself, so maybe this is an issue in this case?

Ohad, could you tell a bit more about your issue? Does this 'large region'
is a device private region (declared with dma_declare_contiguous()) or is it
a global one (defined in Kconfig or cma= kernel boot parameter)? 

Best regards
-- 
Marek Szyprowski
Samsung Poland RD Center


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Ohad Ben-Cohen
2012/1/27 Marek Szyprowski m.szyprow...@samsung.com:
 I've tested it with 256MiB on Exynos4 platform. Could you check if the
 problem also appears on 3.2-cma-v19 branch (I've uploaded it a few hours
 ago)

Exactly what I needed, thanks :)

Both v18 and v19 seem to work fine with 3.2.

 The above code has not been changed since v16, so I'm really surprised
 that it causes problems. Maybe the memory configuration or layout has
 been changed in 3.3-rc1 for OMAP4?

Not sure what the culprit is, but it is only triggered with 3.3-rc1.

I'll tell you if I find anything.

Thanks!
Ohad.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Ohad Ben-Cohen
2012/1/27 Marek Szyprowski m.szyprow...@samsung.com:
 Ohad, could you tell a bit more about your issue?

Sure, feel free to ask.

 Does this 'large region'
 is a device private region (declared with dma_declare_contiguous())

Yes, it is.

See omap_rproc_reserve_cma() in:

http://git.kernel.org/?p=linux/kernel/git/ohad/remoteproc.git;a=commitdiff;h=dab6a2584550a629746fa1dea2be8ffbe1910277

Thanks,
Ohad.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [Linaro-mm-sig] [PATCH 12/15] drivers: add Contiguous Memory Allocator

2012-01-27 Thread Marek Szyprowski
Hello,

On Friday, January 27, 2012 3:59 PM Ohad Ben-Cohen wrote:

 2012/1/27 Marek Szyprowski m.szyprow...@samsung.com:
  Ohad, could you tell a bit more about your issue?
 
 Sure, feel free to ask.
 
  Does this 'large region'
  is a device private region (declared with dma_declare_contiguous())
 
 Yes, it is.
 
 See omap_rproc_reserve_cma() in:
 
 http://git.kernel.org/?p=linux/kernel/git/ohad/remoteproc.git;a=commitdiff;h=dab6a2584550a6297
 46fa1dea2be8ffbe1910277

There have been some vmalloc layout changes merged to v3.3-rc1. Please check
if the hardcoded OMAP_RPROC_CMA_BASE+CONFIG_OMAP_DUCATI_CMA_SIZE fits into 
kernel
low-memory. Some hints you can find after the Virtual kernel memory layout: 
message during boot and using cat /proc/iomem.

Best regards
-- 
Marek Szyprowski
Samsung Poland RD Center



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html