From: Tomi Valkeinen <hidden> Date: 2013-12-30 13:19:08
Hi,
This is a bit refined version from the patch sent by Ivaylo.
So Ivaylo asked for an exclusive memory area for omapfb, so that the
allocations would not fail, and Vaibhav asked for reserving the fb at a
specified physical address, so that the bootloader can pass the fb to the
kernel. Those are a bit linked issues, and these patches try to accomplish
both.
This series is somewhat experimental, as I'm not so familiar with the dma api,
but, well, this seemed to work for the tests I did.
Tomi
Tomi Valkeinen (2):
ARM: omapfb: add coherent dma memory support
omapfb: add support to reserve fb at specified phys address
arch/arm/mach-omap2/common.c | 1 +
arch/arm/mach-omap2/common.h | 2 +
arch/arm/mach-omap2/fb.c | 77 +++++++++++++++++++++++++++++++-
drivers/video/omap2/omapfb/omapfb-main.c | 36 +++++++++++----
drivers/video/omap2/omapfb/omapfb.h | 1 +
5 files changed, 107 insertions(+), 10 deletions(-)
--
1.8.3.2
From: Tomi Valkeinen <hidden> Date: 2013-12-30 13:19:09
The omapfb driver uses dma_alloc to reserve memory for the framebuffers.
However, on some use cases, even when CMA is in use, it's quite probable
that omapfb fails to allocate the fb, either due to not enough free dma
memory, fragmented dma memory, or CMA failing to make enough contiguous
space.
This patch adds a kernel cmdline parameter 'omapfb_vram' which can be
used to give the size of a memory area reserved exclusively for omapfb,
and optionally a physical address where the memory area is reserved.
The memory area is reserved with memblock, and assigned to omapfb with
dma_declare_coherent_memory. The dma_alloc function will first try to
allocate the fb from the coherent memory area, and if that fails, it'll
use the normal method of allocation.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Ivaylo Dimitrov <redacted>
---
arch/arm/mach-omap2/common.c | 1 +
arch/arm/mach-omap2/common.h | 2 ++
arch/arm/mach-omap2/fb.c | 77 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 79 insertions(+), 1 deletion(-)
From: Tomi Valkeinen <hidden> Date: 2013-12-30 13:19:10
The previous patch added support to reserve an exclusive coherent area
for omapfb. This patch adds support to allocate a fb from a specified
physical address inside that coherent area.
This can be used to "pass" a framebuffer from the bootloader to the
kernel: the bootloader sets up the DSS hardware to display a piece of
memory, and gives the address and size of the used piece of memory to
the kernel via omapfb_vram and omapfb.vram cmdline parameters.
Note that the DSS driver itself does not yet support this, and the DSS
hardware is reset at kernel init. This means that the display will be
off until later omapfb is started, which will set up the DSS again.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Vaibhav Hiremath <redacted>
---
drivers/video/omap2/omapfb/omapfb-main.c | 36 ++++++++++++++++++++++++--------
drivers/video/omap2/omapfb/omapfb.h | 1 +
2 files changed, 28 insertions(+), 9 deletions(-)
@@ -1383,18 +1383,36 @@ static int omapfb_alloc_fbmem(struct fb_info *fbi, unsigned long size,rg->type=0;rg->alloc=false;rg->map=false;+rg->noclear=0;size=PAGE_ALIGN(size);-dma_set_attr(DMA_ATTR_WRITE_COMBINE,&attrs);+if(paddr){+DBG("reserving %#lx bytes at %#lx\n",size,paddr);-if(ofbi->rotation_type=OMAP_DSS_ROT_VRFB)-dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING,&attrs);+token=dma_mark_declared_memory_occupied(fbdev->dev,+paddr,size);++if(IS_ERR(token)){+dev_err(fbdev->dev,+"dma_mark_declared_memory_occupied failed: %ld\n",+PTR_ERR(token));+returnPTR_ERR(token);+}++dma_handle=paddr;+rg->noclear=1;+}else{+dma_set_attr(DMA_ATTR_WRITE_COMBINE,&attrs);-DBG("allocating %lu bytes for fb %d\n",size,ofbi->id);+if(ofbi->rotation_type=OMAP_DSS_ROT_VRFB)+dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING,&attrs);-token=dma_alloc_attrs(fbdev->dev,size,&dma_handle,-GFP_KERNEL,&attrs);+DBG("allocating %lu bytes for fb %d\n",size,ofbi->id);++token=dma_alloc_attrs(fbdev->dev,size,&dma_handle,+GFP_KERNEL,&attrs);+}if(token=NULL){dev_err(fbdev->dev,"failed to allocate framebuffer\n");
@@ -1513,9 +1531,6 @@ static int omapfb_parse_vram_param(const char *param, int max_entries,}-WARN_ONCE(paddr,-"reserving memory at predefined address not supported\n");-paddrs[fbnum]=paddr;sizes[fbnum]=size;
@@ -1950,6 +1965,9 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev)if(ofbi->region->size=0)continue;+if(ofbi->region->noclear)+continue;+omapfb_clear_fb(fbi);}
The omapfb driver uses dma_alloc to reserve memory for the framebuffers.
However, on some use cases, even when CMA is in use, it's quite probable
that omapfb fails to allocate the fb, either due to not enough free dma
memory, fragmented dma memory, or CMA failing to make enough contiguous
space.
This patch adds a kernel cmdline parameter 'omapfb_vram' which can be
used to give the size of a memory area reserved exclusively for omapfb,
and optionally a physical address where the memory area is reserved.
The memory area is reserved with memblock, and assigned to omapfb with
dma_declare_coherent_memory. The dma_alloc function will first try to
allocate the fb from the coherent memory area, and if that fails, it'll
use the normal method of allocation.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Ivaylo Dimitrov <redacted>
---
arch/arm/mach-omap2/common.c | 1 +
arch/arm/mach-omap2/common.h | 2 ++
arch/arm/mach-omap2/fb.c | 77 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 79 insertions(+), 1 deletion(-)
Tested on Nokia N900 with Maemo5 and linux 3.13-rc6
The omapfb driver uses dma_alloc to reserve memory for the framebuffers.
However, on some use cases, even when CMA is in use, it's quite probable
that omapfb fails to allocate the fb, either due to not enough free dma
memory, fragmented dma memory, or CMA failing to make enough contiguous
space.
This patch adds a kernel cmdline parameter 'omapfb_vram' which can be
used to give the size of a memory area reserved exclusively for omapfb,
and optionally a physical address where the memory area is reserved.
The memory area is reserved with memblock, and assigned to omapfb with
dma_declare_coherent_memory. The dma_alloc function will first try to
allocate the fb from the coherent memory area, and if that fails, it'll
use the normal method of allocation.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Ivaylo Dimitrov <redacted>
Feel free to queue this along with the DSS patches:
Acked-by: Tony Lindgren <tony@atomide.com>
From: Tomi Valkeinen <hidden> Date: 2014-01-08 14:13:39
On 2014-01-08 01:59, Tony Lindgren wrote:
* Tomi Valkeinen [off-list ref] [131230 05:21]:
quoted
The omapfb driver uses dma_alloc to reserve memory for the framebuffers.
However, on some use cases, even when CMA is in use, it's quite probable
that omapfb fails to allocate the fb, either due to not enough free dma
memory, fragmented dma memory, or CMA failing to make enough contiguous
space.
This patch adds a kernel cmdline parameter 'omapfb_vram' which can be
used to give the size of a memory area reserved exclusively for omapfb,
and optionally a physical address where the memory area is reserved.
The memory area is reserved with memblock, and assigned to omapfb with
dma_declare_coherent_memory. The dma_alloc function will first try to
allocate the fb from the coherent memory area, and if that fails, it'll
use the normal method of allocation.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Ivaylo Dimitrov <redacted>
Feel free to queue this along with the DSS patches:
Acked-by: Tony Lindgren <tony@atomide.com>
Thanks.
This introduces new kernel boot parameter, and I haven't really had time
to test and think about this. If Ivaylo doesn't insist on this to be
merged for 3.14, I'd rather leave this for 3.15 as adding new parameter
that we need to support "forever" should be thought a bit more.
Tomi
-----Original Message-----
From: Valkeinen, Tomi
Sent: Wednesday, January 08, 2014 7:44 PM
To: Tony Lindgren; Ivaylo Dimitrov
Cc: Hiremath, Vaibhav; linux-omap@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
On 2014-01-08 01:59, Tony Lindgren wrote:
quoted
* Tomi Valkeinen [off-list ref] [131230 05:21]:
quoted
The omapfb driver uses dma_alloc to reserve memory for the framebuffers.
However, on some use cases, even when CMA is in use, it's quite
probable that omapfb fails to allocate the fb, either due to not
enough free dma memory, fragmented dma memory, or CMA failing to make
enough contiguous space.
This patch adds a kernel cmdline parameter 'omapfb_vram' which can be
used to give the size of a memory area reserved exclusively for
omapfb, and optionally a physical address where the memory area is
reserved.
quoted
quoted
The memory area is reserved with memblock, and assigned to omapfb
with dma_declare_coherent_memory. The dma_alloc function will first
try to allocate the fb from the coherent memory area, and if that
fails, it'll use the normal method of allocation.
Signed-off-by: Tomi Valkeinen <redacted>
Cc: Ivaylo Dimitrov <redacted>
Feel free to queue this along with the DSS patches:
Acked-by: Tony Lindgren <tony@atomide.com>
Thanks.
This introduces new kernel boot parameter, and I haven't really had time to test
and think about this. If Ivaylo doesn't insist on this to be merged for 3.14, I'd
rather leave this for 3.15 as adding new parameter that we need to support
"forever" should be thought a bit more.
Tomi,
I am seeing underflow issue on AM43x device if I use omapfb_vram argument.
Did you see this on OMAP?
I am using "omapfb_vramM@0xA0000000", and I believe it is correct way of usage.
Thanks,
Vaibhav
Tomi,
I am seeing underflow issue on AM43x device if I use omapfb_vram argument.
Did you see this on OMAP?
I am using "omapfb_vramM@0xA0000000", and I believe it is correct way of usage.
Thanks,
Vaibhav
AFAIK underflow interrupts could come from badly calculated DSS core
clock or bad HW resizer setup and should be unrelated to the memory
allocation. It might be something similar to the problem I have on N900
- see https://lkml.org/lkml/2014/1/6/173
Is it possible to upload the video you have problems with, so me to test
it on N900? So far I didn't see any underflow issues on it (N900 is
OMAP3, in case you're not aware), no matter the resolution of the videos
I played(up to 720p), however I didn't test the part that allocates the
memory on a pre-defined address. Though I don't think that should matter.
Ivo
-----Original Message-----
From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
owner@vger.kernel.org] On Behalf Of Ivaylo Dimitrov
Sent: Thursday, January 09, 2014 1:05 PM
To: Hiremath, Vaibhav; Valkeinen, Tomi; Tony Lindgren; Ivaylo Dimitrov
Cc: linux-omap@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
fbdev@vger.kernel.org
Subject: Re: RE: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
On 09.01.2014 07:06, Hiremath, Vaibhav wrote:
quoted
Tomi,
I am seeing underflow issue on AM43x device if I use omapfb_vram argument.
Did you see this on OMAP?
I am using "omapfb_vramM@0xA0000000", and I believe it is correct way
of usage.
quoted
Thanks,
Vaibhav
AFAIK underflow interrupts could come from badly calculated DSS core clock or
bad HW resizer setup and should be unrelated to the memory allocation. It
might be something similar to the problem I have on N900
- see https://lkml.org/lkml/2014/1/6/173
I can see the difference when I really "omapfb_vram" command line argument.
Without omapfb_vram in bootargs
-------------------------------------------
bootargs=console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait mem8M
consoleblank=0 clocksource=gp_timer consoleblank=0 earlyprintk omapfb.debug=y omapdss.debug=y
I do not get UNDERFLOW during boot.
With omapfb_vram in the bootargs
---------------------------------------------
bootargs=console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait mem8M
consoleblank=0 clocksource=gp_timer consoleblank=0 earlyprintk omapfb_vramM@0xA0000000
omapfb.debug=y omapdss.debug=y
I always get UNDERFLOW during boot itself.
Is it possible to upload the video you have problems with, so me to test it on
N900? So far I didn't see any underflow issues on it (N900 is OMAP3, in case
you're not aware), no matter the resolution of the videos I played(up to 720p),
however I didn't test the part that allocates the memory on a pre-defined
address. Though I don't think that should matter.
From: Tomi Valkeinen <hidden> Date: 2014-01-09 08:21:46
On 2014-01-09 07:06, Hiremath, Vaibhav wrote:
I am seeing underflow issue on AM43x device if I use omapfb_vram argument.
Did you see this on OMAP?
I am using "omapfb_vram=10M@0xA0000000", and I believe it is correct way of usage.
Hmm ok... The AM4x seems to have issues anyway, as we're seeing
underflows easily in other situations also.
Well, there's a small difference in the allocation. The normal dma alloc
uses dma_alloc_attrs() and passes DMA_ATTR_WRITE_COMBINE as a flag,
whereas allocating from the absolute address just uses the piece of
memory. I couldn't find how to set write-combine for the abs memory area.
Then again, that's for CPU caching, so I don't see why it would affect
DSS as such (but that's still something we should measure, cpu
read/write perf for normal and abs allocation).
The only thought I have is that somehow the reserved memory area is
missing some configuration that is done for the rest of the memory. But
that's purely a guess, this is totally out of my area of expertise...
Vaibhav, just to be sure, can you run both with normal dma_alloc and
with the reserve, and verify that the dispc register dumps are the same?
I don't see how they could be different, but just to be sure.
Tomi
From: Tomi Valkeinen <hidden> Date: 2014-01-09 08:27:27
On 2014-01-09 10:08, Hiremath, Vaibhav wrote:
No, that's what is causing issue to me. Can you try predefined address flow?
Just to highlight, I get UNDERFLOW during boot itself, immediately when it gets mapped to userspace.
Boot LOG:
[ 4.822549] Freeing unused kernel memory: 440K (c0919000 - c0987000)
[ 5.276615] OMAPFB: pan_display(0)
[ 5.276625] OMAPFB: setcmap
[ 5.276635] OMAPFB: setcmap
[ 5.293518] OMAPFB: user mmap region start a0000000, len 1536000, off 0
[ 5.300171] omapdss APPLY error: FIFO UNDERFLOW on gfx, disabling the overlay
Hmm that's interesting... So you have some tool that's ran early, which
draws something on the screen? Or maybe that's X starting?
Ah... I think I understand now. As I mentioned, AM4x has issues already.
I think the CPU/others can block DSS when accessing memory. So, if we
have bad caching for the mapped framebuffer, the CPU will use more
bandwidth when reading/writing to it, and that will cause DSS to underflow.
Tomi
-----Original Message-----
From: Valkeinen, Tomi
Sent: Thursday, January 09, 2014 1:52 PM
To: Hiremath, Vaibhav; Ivaylo Dimitrov
Cc: Tony Lindgren; linux-omap@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
On 2014-01-09 07:06, Hiremath, Vaibhav wrote:
quoted
I am seeing underflow issue on AM43x device if I use omapfb_vram argument.
Did you see this on OMAP?
I am using "omapfb_vramM@0xA0000000", and I believe it is correct way
of usage.
Hmm ok... The AM4x seems to have issues anyway, as we're seeing underflows
easily in other situations also.
Well, there's a small difference in the allocation. The normal dma alloc uses
dma_alloc_attrs() and passes DMA_ATTR_WRITE_COMBINE as a flag, whereas
allocating from the absolute address just uses the piece of memory. I couldn't
find how to set write-combine for the abs memory area.
Then again, that's for CPU caching, so I don't see why it would affect DSS as
such (but that's still something we should measure, cpu read/write perf for
normal and abs allocation).
The only thought I have is that somehow the reserved memory area is missing
some configuration that is done for the rest of the memory. But that's purely a
guess, this is totally out of my area of expertise...
Vaibhav, just to be sure, can you run both with normal dma_alloc and with the
reserve, and verify that the dispc register dumps are the same?
I don't see how they could be different, but just to be sure.
Will check and update you shortly.
Thanks,
Vaibhav
-----Original Message-----
From: Valkeinen, Tomi
Sent: Thursday, January 09, 2014 1:57 PM
To: Hiremath, Vaibhav; Ivaylo Dimitrov; Ivaylo Dimitrov
Cc: Tony Lindgren; linux-omap@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
On 2014-01-09 10:08, Hiremath, Vaibhav wrote:
quoted
No, that's what is causing issue to me. Can you try predefined address flow?
Just to highlight, I get UNDERFLOW during boot itself, immediately when it
gets mapped to userspace.
quoted
Boot LOG:
quoted
[ 4.822549] Freeing unused kernel memory: 440K (c0919000 - c0987000)
[ 5.276615] OMAPFB: pan_display(0)
[ 5.276625] OMAPFB: setcmap
[ 5.276635] OMAPFB: setcmap
[ 5.293518] OMAPFB: user mmap region start a0000000, len 1536000, off 0
[ 5.300171] omapdss APPLY error: FIFO UNDERFLOW on gfx, disabling the
overlay
Hmm that's interesting... So you have some tool that's ran early, which draws
something on the screen? Or maybe that's X starting?
It's initial demo, not sure whether you heard of MATRIX demo. I am running Matrix demo
As part of init script.
Ah... I think I understand now. As I mentioned, AM4x has issues already.
I think the CPU/others can block DSS when accessing memory. So, if we have
bad caching for the mapped framebuffer, the CPU will use more bandwidth
when reading/writing to it, and that will cause DSS to underflow.
Yeah, AM4x already has some issues but I am comparing normal dma_alloc and reserved
Memory and I see different behavior and it could be due to bad caching for the mapped buffers.
Thanks,
Vaibhav
-----Original Message-----
From: Hiremath, Vaibhav
Sent: Thursday, January 09, 2014 2:01 PM
To: Valkeinen, Tomi; Ivaylo Dimitrov
Cc: Tony Lindgren; linux-omap@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-fbdev@vger.kernel.org
Subject: RE: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
quoted
-----Original Message-----
From: Valkeinen, Tomi
Sent: Thursday, January 09, 2014 1:52 PM
To: Hiremath, Vaibhav; Ivaylo Dimitrov
Cc: Tony Lindgren; linux-omap@vger.kernel.org; linux-arm-
kernel@lists.infradead.org; linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 1/2] ARM: omapfb: add coherent dma memory support
On 2014-01-09 07:06, Hiremath, Vaibhav wrote:
quoted
I am seeing underflow issue on AM43x device if I use omapfb_vram
argument.
quoted
quoted
Did you see this on OMAP?
I am using "omapfb_vramM@0xA0000000", and I believe it is correct
way
of usage.
Hmm ok... The AM4x seems to have issues anyway, as we're seeing
underflows easily in other situations also.
Well, there's a small difference in the allocation. The normal dma
alloc uses
dma_alloc_attrs() and passes DMA_ATTR_WRITE_COMBINE as a flag, whereas
allocating from the absolute address just uses the piece of memory. I
couldn't find how to set write-combine for the abs memory area.
Then again, that's for CPU caching, so I don't see why it would affect
DSS as such (but that's still something we should measure, cpu
read/write perf for normal and abs allocation).
The only thought I have is that somehow the reserved memory area is
missing some configuration that is done for the rest of the memory.
But that's purely a guess, this is totally out of my area of expertise...
Vaibhav, just to be sure, can you run both with normal dma_alloc and
with the reserve, and verify that the dispc register dumps are the same?
I don't see how they could be different, but just to be sure.
No, that's what is causing issue to me. Can you try predefined address flow?
Thanks,
Vaibhav
Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpu
Linux version 3.13.0-rc7+ (maemo@maemo-desktop) (gcc version 4.7.2
20120701 (prerelease) (Linaro GCC 4.7-2012.07) ) #24 PREEMPT Sat Jan 11
17:06:39 EET 2014
CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), crc53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: Nokia RX-51 board
omapfb: reserved 0x00800000 bytes at 0x8f100000
Memory policy: Data cache writeback
On node 0 totalpages: 61696
free_area_init_node: node 0, pgdat c05b73b4, node_mem_map c061b000
Normal zone: 512 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 61696 pages, LIFO batch:15
CPU: All CPU(s) started in SVC mode.
OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp )
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 61184
Kernel command line: init=/sbin/preinit ubi.mtd=rootfs root=ubi0:rootfs
rootfstype=ubifs rootflags=bulk_read,no_chk_data_crc rw
mtdoops.mtddev=log console=tty0 console=ttyO2 omapfb_vram=8M@0x8F100000
omapfb.mode=lcd:848x480-16
There are no (UNDERFLOW) errors on OMAP3 when predefined address is
used, I am still able to play every video I try.
Ivo
I don't know, it wasn't immediately clear to me if the reserved memory
was handled with CMA or not.
Also, we have this funniness that omapfb is not present in DT data, so
we can't give reserved memory to omapfb directly like that.
Tomi