Update reserved memory for simple framebuffer
Subsystems (2)
cover Update reserved memory for simple framebuffer
Reserved memory for simple frame buffer should be created in a different way:
+ aliases {
+ display0 = &lcdif;
+ };
+
+ reserved-memory {
+ #address-cells = <1>; + #size-cells = <1>; + ranges;
+
+ display_reserved: framebuffer at 86fa2000 {
+ reg = <0x86fa2000 0x80000>;
+ no-map;
+ };
+
+ };
We add a function to change the loaded dts and inject those information. I have added another patch for meson. Right now I'm testing on tinker-s board.
Michael Trimarchi (2):
common: fdt: Add a function for reserving memory without kernel linear
mapping
video: meson: Use reserving memory function without kernel linear
mapping
common/fdt_support.c | 40 +++++++++++++++++++++++++++++++++ drivers/video/meson/meson_vpu.c | 6 ++--- include/fdt_support.h | 11 +++++++++ 3 files changed, 54 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 common: fdt: Add a function for reserving memory without kernel linear mapping
The intent is to reserve memory _and_ prevent it from being included in the kernel's linear map. For thos reason it is also necessary to include the 'no-map' property for this reserved-mem node.
From Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:
no-map (optional) - empty property
- Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region.
---
Changes: RFC->v1
- Add a better commit message
--- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 11 +++++++++++ 2 files changed, 51 insertions(+)
common/fdt_support.c +40 -0
@@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,return p - (char *)buf; } +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]) +{ +int offs, len; +const char *subpath; +const char *path ="/reserved-memory" ; +fdt32_t address_cells =cpu_to_fdt32 (fdt_address_cells (blob,0 )); +fdt32_t size_cells =cpu_to_fdt32 (fdt_size_cells (blob,0 )); +u8 temp[16 ];/* Up to 64-bit address + 64-bit size */ + + offs =fdt_path_offset (blob, path); +if (offs <0 ) { +debug ("Node %s not found\n" , path); + path ="/" ; + subpath ="reserved-memory" ; + offs =fdt_path_offset (blob, path); + offs =fdt_add_subnode (blob, offs, subpath); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + path ="/reserved-memory" ; + offs =fdt_path_offset (blob, path); + +fdt_setprop (blob, offs,"#address-cells" , &address_cells,sizeof (address_cells)); +fdt_setprop (blob, offs,"#size-cells" , &size_cells,sizeof (size_cells)); +fdt_setprop (blob, offs,"ranges" ,NULL ,0 ); + } + + offs =fdt_add_subnode (blob, offs, area ? :"private" ); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + +fdt_setprop (blob, offs,"no-map" ,NULL ,0 ); + len =fdt_pack_reg (blob, temp, start, size,1 ); +fdt_setprop (blob, offs,"reg" , temp, len); +return 0 ; +} +#if CONFIG_NR_DRAM_BANKS >4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else
include/fdt_support.h +11 -0
@@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,*/ int fdt_fixup_memory (void *blob,u64 start,u64 size); +/** +* Setup the memory reserved node in the DT. Creates one if none was existing before. +* +* @param blob FDT blob to update +* @param area Reserved area name +* @param start Begin of DRAM mapping in physical memory +* @param size Size of the single memory bank +* @return 0 if ok, or -1 or -FDT_ERR_... on error +*/ +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]); +/** * Fill the DT memory node with multiple memory banks. * Creates the node if none was existing before.
Signature · 1 line
2.17.1
PATCH 2/2 video: meson: Use reserving memory function without kernel linear mapping
In reply to Michael TrimarchiMemory reserved for the simple framebuffer should not be used and part of memory linear mapping. See
https://patchwork.kernel.org/patch/10486131/ for more detailed background information and discussion.
---
Changes RFC -> v1:
- Fix compilation issue on RFC
- change node name from display_reserved to display-reserved
--- drivers/video/meson/meson_vpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/meson/meson_vpu.c +3 -3
@@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt)* at the end of the RAM and we strip this portion from the kernel * allowed region */ - mem_start = gd->bd->bi_dram[0 ].start; - mem_size = gd->bd->bi_dram[0 ].size - meson_fb.fb_size; - ret =fdt_fixup_memory_banks (fdt, &mem_start, &mem_size,1 ); + mem_start = meson_fb.base; + mem_size = meson_fb.fb_size; + ret =fdt_fixup_reserved_memory (fdt,"display-reserved" , &mem_start, &mem_size);if (ret) {eprintf ("Cannot setup simplefb: Error reserving memory\n" );return ;
Signature · 1 line
2.17.1
PATCH 1/2 common: fdt: Add a function for reserving memory without kernel linear mapping
In reply to Michael TrimarchiHi Michael,
Quoted 35 lines · Michael Trimarchi
The intent is to reserve memory _and_ prevent it from being included in the kernel's linear map. For thos reason it is also necessary to include the 'no-map' property for this reserved-mem node.
From
Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:no-map (optional) - empty property
- Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region.Signed-off-by Michael Trimarchi <[email protected]>---
Changes:RFC->v1
- Add a better commit message--- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 11 +++++++++++ 2 files changed, 51 insertions(+)common/fdt_support.c +5
-0@@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,return p - (char *)buf; } +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]) +{ +int offs, len; +const char *subpath; +const char *path ="/reserved-memory" ;
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 427
Quoted 10 lines
common/fdt_support.c +10
-0+fdt32_t address_cells =cpu_to_fdt32 (fdt_address_cells (blob,0 )); +fdt32_t size_cells =cpu_to_fdt32 (fdt_size_cells (blob,0 )); +u8 temp[16 ];/* Up to 64-bit address + 64-bit size */ + + offs =fdt_path_offset (blob, path); +if (offs <0 ) { +debug ("Node %s not found\n" , path); + path ="/" ; + subpath ="reserved-memory" ; + offs =fdt_path_offset (blob, path);
Error check
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 438
Quoted 11 lines
common/fdt_support.c +11
-0+ offs =fdt_add_subnode (blob, offs, subpath); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + path ="/reserved-memory" ; + offs =fdt_path_offset (blob, path); + +fdt_setprop (blob, offs,"#address-cells" , &address_cells,sizeof (address_cells)); +fdt_setprop (blob, offs,"#size-cells" , &size_cells,sizeof (size_cells)); +fdt_setprop (blob, offs,"ranges" ,NULL ,0 );
Need error-checking on these three
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 441
Quoted 3 lines
common/fdt_support.c +3
-0+ } + + offs =fdt_add_subnode (blob, offs, area ? :"private" );
Is this in a binding file somewhere?
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 431
Quoted 3 lines
common/fdt_support.c +3
-0+if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ;
return offs
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 447
Quoted 3 lines
common/fdt_support.c +3
-0+ } + +fdt_setprop (blob, offs,"no-map" ,NULL ,0 );
and this?
Also needs error check
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 449
Quoted 2 lines
common/fdt_support.c +2
-0+ len =fdt_pack_reg (blob, temp, start, size,1 ); +fdt_setprop (blob, offs,"reg" , temp, len);
blank line before return
Quoted 12 lines
common/fdt_support.c +3
-0+return 0 ; +} +#if CONFIG_NR_DRAM_BANKS >4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else include/fdt_support.h +0
-0@@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,*/
include/fdt_support.h void do_fixup_by_compat_u32(void *fdt, const char *compat, · line 103
Quoted 10 lines
include/fdt_support.h +8
-0int fdt_fixup_memory (void *blob,u64 start,u64 size); +/** +* Setup the memory reserved node in the DT. Creates one if none was existing before. +* +* @param blob FDT blob to update +* @param area Reserved area name +* @param start Begin of DRAM mapping in physical memory +* @param size Size of the single memory bank +* @return 0 if ok, or -1 or -FDT_ERR_... on error
Really we should return an FDT_ERR always. -1 is not a good idea and in fact is an FDT_ERR
Quoted 9 lines
include/fdt_support.h +3
-1+*/ +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]); +/** * Fill the DT memory node with multiple memory banks. * Creates the node if none was existing before. -- 2.17.1
Regards,
Simon
PATCH 2/2 video: meson: Use reserving memory function without kernel linear mapping
In reply to Michael TrimarchiHi Michae,
Quoted 6 lines · Michael Trimarchi
Memory reserved for the simple framebuffer should not be used and part of memory linear mapping. See
https://patchwork.kernel.org/patch/10486131/ for more detailed background information and discussion.
Quoted 8 lines
Signed-off-by Michael Trimarchi <[email protected]>---
Changes RFC -> v1:
- Fix compilation issue on RFC
- change node name fromdisplay_reservedto display-reserved--- drivers/video/meson/meson_vpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Is the binding file for this in U-Boot? If not can you please add it?
Quoted 8 lines
drivers/video/meson/meson_vpu.c +0
-0@@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt)* at the end of the RAM and we strip this portion from the kernel * allowed region
drivers/video/meson/meson_vpu.c static void meson_vpu_setup_simplefb(void *fdt) · line 181
Quoted 10 lines
drivers/video/meson/meson_vpu.c +3
-3*/ - mem_start = gd->bd->bi_dram[0 ].start; - mem_size = gd->bd->bi_dram[0 ].size - meson_fb.fb_size; - ret =fdt_fixup_memory_banks (fdt, &mem_start, &mem_size,1 ); + mem_start = meson_fb.base; + mem_size = meson_fb.fb_size; + ret =fdt_fixup_reserved_memory (fdt,"display-reserved" , &mem_start, &mem_size);if (ret) {eprintf ("Cannot setup simplefb: Error reserving memory\n" );return ;
Needs to return an error code which needs to be checked by caller.
Quoted 3 lines
--
2.17.1
Regards,
Simon
PATCH 1/2 common: fdt: Add a function for reserving memory without kernel linear mapping
In reply to Simon GlassHi
Quoted 44 lines · Simon Glass
Hi Michael,
Quoted 39 lines · Michael Trimarchi
The intent is to reserve memory _and_ prevent it from being included in the kernel's linear map. For thos reason it is also necessary to include the 'no-map' property for this reserved-mem node.
From
Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:no-map (optional) - empty property
- Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region.Signed-off-by Michael Trimarchi <[email protected]>---
Changes:RFC->v1
- Add a better commit message--- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 11 +++++++++++ 2 files changed, 51 insertions(+)common/fdt_support.c +9
-0@@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,return p - (char *)buf; } +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]) +{ +int offs, len; +const char *subpath; +const char *path ="/reserved-memory" ; +fdt32_t address_cells =cpu_to_fdt32 (fdt_address_cells (blob,0 )); +fdt32_t size_cells =cpu_to_fdt32 (fdt_size_cells (blob,0 )); +u8 temp[16 ];/* Up to 64-bit address + 64-bit size */ +
Quoted 9 lines
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 427
Quoted 6 lines
common/fdt_support.c +6
-0+ offs =fdt_path_offset (blob, path); +if (offs <0 ) { +debug ("Node %s not found\n" , path); + path ="/" ; + subpath ="reserved-memory" ; + offs =fdt_path_offset (blob, path);Error check
Ok
Quoted 12 lines
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 438
Quoted 11 lines
common/fdt_support.c +11
-0+ offs =fdt_add_subnode (blob, offs, subpath); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + path ="/reserved-memory" ; + offs =fdt_path_offset (blob, path); + +fdt_setprop (blob, offs,"#address-cells" , &address_cells,sizeof (address_cells)); +fdt_setprop (blob, offs,"#size-cells" , &size_cells,sizeof (size_cells)); +fdt_setprop (blob, offs,"ranges" ,NULL ,0 );
Quoted 2 lines
Need error-checking on these three
ok
Quoted 6 lines
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 441
Quoted 3 lines
common/fdt_support.c +3
-0+ } + + offs =fdt_add_subnode (blob, offs, area ? :"private" );Is this in a binding file somewhere?
The reserved memory is needed to avoid the linux kernel to use it and to get a persistent framebuffer. On some SoC I have implemented the reuse on the memory on their graphics driver. I need to check how this is
documented in Linux. The name of the reserved memory it's not mandatory.
Quoted 6 lines
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 431
Quoted 3 lines
common/fdt_support.c +3
-0+if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ;return offs
ok
Quoted 6 lines
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 447
Quoted 3 lines
common/fdt_support.c +3
-0+ } + +fdt_setprop (blob, offs,"no-map" ,NULL ,0 );and this?
ok
Quoted 7 lines
Also needs error check
common/fdt_support.c static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size, · line 449
Quoted 2 lines
common/fdt_support.c +2
-0+ len =fdt_pack_reg (blob, temp, start, size,1 ); +fdt_setprop (blob, offs,"reg" , temp, len);blank line before return
done
Quoted 14 lines
Quoted 14 lines
common/fdt_support.c +3
-0+return 0 ; +} +#if CONFIG_NR_DRAM_BANKS >4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else include/fdt_support.h +0
-0@@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,*/ int fdt_fixup_memory (void *blob,u64 start,u64 size);
Quoted 12 lines
include/fdt_support.h void do_fixup_by_compat_u32(void *fdt, const char *compat, · line 103
Quoted 8 lines
include/fdt_support.h +8
-0+/** +* Setup the memory reserved node in the DT. Creates one if none was existing before. +* +* @param blob FDT blob to update +* @param area Reserved area name +* @param start Begin of DRAM mapping in physical memory +* @param size Size of the single memory bank +* @return 0 if ok, or -1 or -FDT_ERR_... on error Really we should return an
FDT_ERRalways. -1 is not a good idea and in fact is anFDT_ERR
Now with the change FDT_ERR only is returned.
Quoted 4 lines
Quoted 4 lines
include/fdt_support.h +3
-0+*/ +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]); +/**
Quoted 8 lines
Quoted 5 lines
include/fdt_support.h +0
-1* Fill the DT memory node with multiple memory banks. * Creates the node if none was existing before. -- 2.17.1
Regards,
Simon
I will post a new one
Michael
Re: [PATCH 1/2] common: fdt: Add a function for reserving memory without kernel linear mapping
In reply to Michael TrimarchiHI Tommaso,
Thank you to have time on this
Michael
Quoted 98 lines · Michael Trimarchi
The intent is to reserve memory _and_ prevent it from being included in the kernel's linear map. For thos reason it is also necessary to include the 'no-map' property for this reserved-mem node.
From
Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:no-map (optional) - empty property
- Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region.Signed-off-by Michael Trimarchi <[email protected]>---
Changes:RFC->v1
- Add a better commit message--- common/fdt_support.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 11 +++++++++++ 2 files changed, 51 insertions(+)common/fdt_support.c +40
-0@@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 *address, u64 *size,return p - (char *)buf; } +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]) +{ +int offs, len; +const char *subpath; +const char *path ="/reserved-memory" ; +fdt32_t address_cells =cpu_to_fdt32 (fdt_address_cells (blob,0 )); +fdt32_t size_cells =cpu_to_fdt32 (fdt_size_cells (blob,0 )); +u8 temp[16 ];/* Up to 64-bit address + 64-bit size */ + + offs =fdt_path_offset (blob, path); +if (offs <0 ) { +debug ("Node %s not found\n" , path); + path ="/" ; + subpath ="reserved-memory" ; + offs =fdt_path_offset (blob, path); + offs =fdt_add_subnode (blob, offs, subpath); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + path ="/reserved-memory" ; + offs =fdt_path_offset (blob, path); + +fdt_setprop (blob, offs,"#address-cells" , &address_cells,sizeof (address_cells)); +fdt_setprop (blob, offs,"#size-cells" , &size_cells,sizeof (size_cells)); +fdt_setprop (blob, offs,"ranges" ,NULL ,0 ); + } + + offs =fdt_add_subnode (blob, offs, area ? :"private" ); +if (offs <0 ) { +printf ("Could not create %s%s node.\n" , path, subpath); +return -1 ; + } + +fdt_setprop (blob, offs,"no-map" ,NULL ,0 ); + len =fdt_pack_reg (blob, temp, start, size,1 ); +fdt_setprop (blob, offs,"reg" , temp, len); +return 0 ; +} +#if CONFIG_NR_DRAM_BANKS >4 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS#else include/fdt_support.h +11
-1@@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,*/ int fdt_fixup_memory (void *blob,u64 start,u64 size); +/** +* Setup the memory reserved node in the DT. Creates one if none was existing before. +* +* @param blob FDT blob to update +* @param area Reserved area name +* @param start Begin of DRAM mapping in physical memory +* @param size Size of the single memory bank +* @return 0 if ok, or -1 or -FDT_ERR_... on error +*/ +int fdt_fixup_reserved_memory (void *blob,const char *area,u64 start[],u64 size[]); +/** * Fill the DT memory node with multiple memory banks. * Creates the node if none was existing before. -- 2.17.1
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com