Enable caches for the RPi2
Subsystems (5)
v2 cover Enable caches for the RPi2
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
v1 -> v2:
- Move to KConfig
- Adapt to new config name "CONFIG_ARMV7_LPAE"
Alexander Graf (5):
arm64: Add 32bit arm compatible dcache definitions
arm: Add support for HYP mode and LPAE page tables
lcd: Fix compile warning in 64bit mode
RPi: Enable caches for rpi2
bcm2835 video: Map fb as cached
arch/arm/cpu/armv7/Kconfig | 8 ++++ arch/arm/include/asm/system.h | 105 +++++++++++++++++++++++++++++++++++++++--- arch/arm/lib/cache-cp15.c | 66 +++++++++++++++++++++++--- arch/arm/mach-bcm283x/Kconfig | 1 + arch/arm/mach-bcm283x/init.c | 7 +++ common/lcd.c | 4 +- drivers/video/bcm2835.c | 6 +++ include/configs/rpi_2.h | 1 - 8 files changed, 182 insertions(+), 16 deletions(-)
Signature · 1 line
1.8.5.6
PATCH v2 1/5 arm64: Add 32bit arm compatible dcache definitions
We want to be able to reuse device drivers from 32bit code, so let's add definitions for all the dcache options that 32bit code has.
While at it, fix up the DCACHE_OFF configuration. That was setting the bits to declare a PTE a PTE and left the MAIR index bit at 0. Drop the useless bits and make the index explicit.
--- arch/arm/include/asm/system.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/include/asm/system.h +5 -1
@@ -26,8 +26,12 @@ u64 get_page_table_size(void);#define MMU_SECTION_SHIFT 21#define MMU_SECTION_SIZE (1 << MMU_SECTION_SHIFT) +/* These constants need to be synced to the MT_ types in asm/armv8/mmu.h */ enum dcache_option { -DCACHE_OFF =0x3 , +DCACHE_OFF =0 <<2 , +DCACHE_WRITETHROUGH =3 <<2 , +DCACHE_WRITEBACK =4 <<2 , +DCACHE_WRITEALLOC =4 <<2 , };#define isb () \
Signature · 1 line
1.8.5.6
PATCH v2 1/5 arm64: Add 32bit arm compatible dcache definitions
Quoted 8 lines · Alexander Graf
We want to be able to reuse device drivers from 32bit code, so let's add definitions for all the dcache options that 32bit code has.
While at it, fix up the
DCACHE_OFFconfiguration. That was setting the bits to declare a PTE a PTE and left the MAIR index bit at 0. Drop the useless bits and make the index explicit.Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/635b4e77/attachment.sig>
PATCH v2 2/5 arm: Add support for HYP mode and LPAE page tables
In reply to Alexander GrafWe currently always modify the SVC versions of registers and only support the short descriptor PTE format.
Some boards however (like the RPi2) run in HYP mode. There, we need to modify the HYP version of system registers and HYP mode only supports the long descriptor PTE format.
So this patch introduces support for both long descriptor PTEs and HYP mode registers.
---
v1 -> v2:
- Switch to KConfig
- Rename config define to CONFIG_ARMV7_LPAE
--- arch/arm/cpu/armv7/Kconfig | 8 ++++ arch/arm/include/asm/system.h | 99 ++++++++++++++++++++++++++++++++++++++++--- arch/arm/lib/cache-cp15.c | 66 ++++++++++++++++++++++++++--- 3 files changed, 161 insertions(+), 12 deletions(-)
arch/arm/cpu/armv7/Kconfig +8 -0
@@ -31,4 +31,12 @@ config ARMV7_VIRT ---help--- Say Y here to boot in hypervisor (HYP) mode when booting non-secure. +config ARMV7_LPAE + boolean "Use LPAE page table format" if EXPERT + depends on CPU_V7 + default n + ---help--- + Say Y here to use the long descriptor page table format. This is + required if U-Boot runs in HYP mode. + endif
arch/arm/include/asm/system.h +93 -6
142 lines not on this page · raw message
arch/arm/lib/cache-cp15.c +60 -6
93 lines not on this page · raw message
Signature · 1 line
1.8.5.6
PATCH v2 2/5 arm: Add support for HYP mode and LPAE page tables
Quoted 11 lines · Alexander Graf
We currently always modify the SVC versions of registers and only support the short descriptor PTE format.
Some boards however (like the RPi2) run in HYP mode. There, we need to modify the HYP version of system registers and HYP mode only supports the long descriptor PTE format.
So this patch introduces support for both long descriptor PTEs and HYP mode registers.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/fb1b8172/attachment.sig>
PATCH v2 3/5 lcd: Fix compile warning in 64bit mode
In reply to Alexander GrafWhen compiling the code for 64bit, the lcd code emits warnings because it tries to cast pointers to 32bit values. Fix it by casting them to longs instead, actually properly aligning with the function prototype.
--- common/lcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/lcd.c +2 -2
@@ -66,8 +66,8 @@ void lcd_sync(void)int line_length;if (lcd_flush_dcache) -flush_dcache_range ((u32 )lcd_base, - (u32)(lcd_base +lcd_get_size (&line_length))); +flush_dcache_range ((ulong )lcd_base, + (ulong)(lcd_base +lcd_get_size (&line_length)));#endif }
Signature · 1 line
1.8.5.6
PATCH v2 3/5 lcd: Fix compile warning in 64bit mode
Quoted 5 lines · Alexander Graf
When compiling the code for 64bit, the lcd code emits warnings because it tries to cast pointers to 32bit values. Fix it by casting them to longs instead, actually properly aligning with the function prototype.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/16fec502/attachment.sig>
PATCH v2 4/5 RPi: Enable caches for rpi2
In reply to Alexander GrafNow that we have support for running with caches enabled in HYP mode, opt in to that on the Raspberry Pi 2. This brings a significant performance boost.
---
v1 -> v2:
- Move to KConfig
- Adapt to new define name
--- arch/arm/mach-bcm283x/Kconfig | 1 + arch/arm/mach-bcm283x/init.c | 7 +++++++ include/configs/rpi_2.h | 1 - 3 files changed, 8 insertions(+), 1 deletion(-)
arch/arm/mach-bcm283x/Kconfig +1 -0
@@ -12,6 +12,7 @@ config TARGET_RPI config TARGET_RPI_2 bool "Raspberry Pi 2" select CPU_V7 + select ARMV7_LPAE endchoice
arch/arm/mach-bcm283x/init.c +7 -0
@@ -15,3 +15,10 @@ int arch_cpu_init(void)return 0 ; } + +#ifdef CONFIG_ARMV7_LPAE +void enable_caches (void ) +{ +dcache_enable (); +} +#endif
include/configs/rpi_2.h +0 -1
@@ -10,7 +10,6 @@#define CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_BCM2836 #define CONFIG_SYS_CACHELINE_SIZE 64 -#define CONFIG_SYS_DCACHE_OFF #include "rpi-common.h"
Signature · 1 line
1.8.5.6
PATCH v2 4/5 RPi: Enable caches for rpi2
Quoted 5 lines · Alexander Graf
Now that we have support for running with caches enabled in HYP mode, opt in to that on the Raspberry Pi 2. This brings a significant performance boost.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/00e9fb1d/attachment.sig>
PATCH v2 5/5 bcm2835 video: Map fb as cached
In reply to Alexander GrafThe bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
--- drivers/video/bcm2835.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/video/bcm2835.c +6 -0
@@ -106,6 +106,12 @@ void lcd_ctrl_init(void *lcdbase) gd->fb_base =bus_to_phys ( msg_setup->allocate_buffer.body.resp.fb_address); + +/* Enable dcache for the frame buffer */ +mmu_set_region_dcache_behaviour (gd->fb_base, +ALIGN (PAGE_SIZE , msg_setup->allocate_buffer.body.resp.fb_size), +DCACHE_WRITEBACK ); +lcd_set_flush_dcache (1 ); }void lcd_enable (void )
Signature · 1 line
1.8.5.6
PATCH v3 5/5 bcm2835 video: Map fb as cached
The bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
---
v2 -> v3:
- Fix align parameters
- Fix whitespace
--- drivers/video/bcm2835.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/video/bcm2835.c +6 -0
@@ -106,6 +106,12 @@ void lcd_ctrl_init(void *lcdbase) gd->fb_base =bus_to_phys ( msg_setup->allocate_buffer.body.resp.fb_address); + +/* Enable dcache for the frame buffer */ +mmu_set_region_dcache_behaviour (gd->fb_base, +ALIGN (msg_setup->allocate_buffer.body.resp.fb_size,PAGE_SIZE ), +DCACHE_WRITEBACK ); +lcd_set_flush_dcache (1 ); }void lcd_enable (void )
Signature · 1 line
1.8.5.6
PATCH v4 5/5 bcm2835 video: Map fb as cached
In reply to Alexander GrafThe bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
---
v2 -> v3:
- Fix align parameters
- Fix whitespace
v3 -> v4:
- Align start of fb as well to align with segments
- Align fb size on segment size, not page size
--- drivers/video/bcm2835.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/video/bcm2835.c +9 -0
@@ -44,6 +44,7 @@ void lcd_ctrl_init(void *lcdbase) ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);int ret;u32 w, h; +u32 fb_start, fb_end;debug ("bcm2835: Query resolution...\n" );
@@ -106,6 +107,14 @@ void lcd_ctrl_init(void *lcdbase) gd->fb_base =bus_to_phys ( msg_setup->allocate_buffer.body.resp.fb_address); + +/* Enable dcache for the frame buffer */ + fb_start =ALIGN (gd->fb_base,1 <<MMU_SECTION_SHIFT ); + fb_end = gd->fb_base + msg_setup->allocate_buffer.body.resp.fb_size; + fb_end =ALIGN (fb_end,1 <<MMU_SECTION_SHIFT ); +mmu_set_region_dcache_behaviour (fb_start, fb_end - fb_start, +DCACHE_WRITEBACK ); +lcd_set_flush_dcache (1 ); }void lcd_enable (void )
Signature · 1 line
1.8.5.6
PATCH v4 5/5 bcm2835 video: Map fb as cached
Quoted 2 lines · Alexander Graf
The bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
drivers/video/bcm2835.c void lcd_ctrl_init(void *lcdbase) · line 50
Quoted 10 lines
drivers/video/bcm2835.c +6
-0@@ -44,6 +44,7 @@ void lcd_ctrl_init(void *lcdbase) +/* Enable dcache for the frame buffer */ + fb_start =ALIGN (gd->fb_base,1 <<MMU_SECTION_SHIFT ); + fb_end = gd->fb_base + msg_setup->allocate_buffer.body.resp.fb_size; + fb_end =ALIGN (fb_end,1 <<MMU_SECTION_SHIFT ); +mmu_set_region_dcache_behaviour (fb_start, fb_end - fb_start, +DCACHE_WRITEBACK );
Shouldn't the start be rounded down and the end be rounded up to cover the entire FB RAM? Normally it might be problematic to push the boundaries outside the relevant data block since it would affect adjacent memory that might not then be aware of the cache setup. However, since the entire FB is in the VC portion of RAM and U-Boot is touching nothing else there, it should be fine in this case. (And even if it wasn't, the two ALIGNs would still want to move in opposite directions; start up and end down).
PATCH v4 5/5 bcm2835 video: Map fb as cached
Quoted 14 lines
Am 24.03.2016 um 03:05 schrieb Stephen Warren <[email protected]>:
Quoted 3 lines · Alexander Graf
The bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
Tested-by Stephen Warren <[email protected]>Quoted 3 lines
drivers/video/bcm2835.c +0
-0@@ -44,6 +44,7 @@ void lcd_ctrl_init(void *lcdbase)
Quoted 8 lines
drivers/video/bcm2835.c void lcd_ctrl_init(void *lcdbase) · line 116
Quoted 6 lines
drivers/video/bcm2835.c +6
-0+/* Enable dcache for the frame buffer */ + fb_start =ALIGN (gd->fb_base,1 <<MMU_SECTION_SHIFT ); + fb_end = gd->fb_base + msg_setup->allocate_buffer.body.resp.fb_size; + fb_end =ALIGN (fb_end,1 <<MMU_SECTION_SHIFT ); +mmu_set_region_dcache_behaviour (fb_start, fb_end - fb_start, +DCACHE_WRITEBACK );Shouldn't the start be rounded down and the end be rounded up to cover the entire FB RAM? Normally it might be problematic to push the boundaries outside the relevant data block since it would affect adjacent memory that might not then be aware of the cache setup. However, since the entire FB is in the VC portion of RAM and U-Boot is touching nothing else there, it should be fine in this case. (And even if it wasn't, the two ALIGNs would still want to move in opposite directions; start up and end down).
Yes, my bad. I'll send another version.
Alex
PATCH v5 5/5 bcm2835 video: Map fb as cached
In reply to Alexander GrafThe bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
---
v2 -> v3:
- Fix align parameters
- Fix whitespace
v3 -> v4:
- Align start of fb as well to align with segments
- Align fb size on segment size, not page size
v4 -> v5:
- Align fb start down, not up
--- drivers/video/bcm2835.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/video/bcm2835.c +9 -0
@@ -44,6 +44,7 @@ void lcd_ctrl_init(void *lcdbase) ALLOC_CACHE_ALIGN_BUFFER(struct msg_setup, msg_setup, 1);int ret;u32 w, h; +u32 fb_start, fb_end;debug ("bcm2835: Query resolution...\n" );
@@ -106,6 +107,14 @@ void lcd_ctrl_init(void *lcdbase) gd->fb_base =bus_to_phys ( msg_setup->allocate_buffer.body.resp.fb_address); + +/* Enable dcache for the frame buffer */ + fb_start = gd->fb_base & ~(MMU_SECTION_SIZE -1 ); + fb_end = gd->fb_base + msg_setup->allocate_buffer.body.resp.fb_size; + fb_end =ALIGN (fb_end,1 <<MMU_SECTION_SHIFT ); +mmu_set_region_dcache_behaviour (fb_start, fb_end - fb_start, +DCACHE_WRITEBACK ); +lcd_set_flush_dcache (1 ); }void lcd_enable (void )
Signature · 1 line
1.8.5.6
PATCH v5 5/5 bcm2835 video: Map fb as cached
Quoted 2 lines · Alexander Graf
The bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
PATCH v5 5/5 bcm2835 video: Map fb as cached
In reply to Alexander GrafQuoted 6 lines · Alexander Graf
The bcm2835 frame buffer is in RAM, so we can easily map it as cached and gain all the glorious performance boost that brings with it.
Signed-off-by Alexander Graf <[email protected]>Tested-by Stephen Warren <[email protected]>Acked-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160327/1dfe89b8/attachment.sig>
v2 cover Enable caches for the RPi2
In reply to Alexander GrafQuoted 10 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
This series mostly works OK. I found the following results, with my rpi_dev branch on github if you want to test the exact same commits:
RPi B+ (running rpi_1 build):
- Very minor transient corruption when running "ls mmc 0:2 /etc"
RPi 2 (running rpi_2 build):
RPi 3 (booting in 32-bit mode and running rpi_2 build):
RPi 3 (booting in 32-bit mode and running rpi_3_32b build):
- Obvious transient corruption when running "ls mmc 0:2 /etc"
RPi 3 (booting in 64-bit mode and running rpi_3 build):
- No issues
I suspect the transient corruptions that I saw were missing cache flush operations; during the large "memcpy" while scrolling the LCD, I would see corruption in the copied data. This would soon disappear; presumably as new data is written to the bottom lines of the frame-buffer flushes out old cache lines while doing a write-allocate?
Still, I'm not 100% sure this is an issue with these patches since the RPi B+ has a similar (although much less obvious) issue. Perhaps U-Boot is using the wrong VC/GPU cache alias (top 2 bits of 32-bit physical address) for the frame-buffer, i.e. the issue is in the GPU cache, not in the ARM cache?
As far as I can tell, USB worked fine in all cases (at least, the on-board hub/Ethernet device seemed to be enumerated without issue according to "usb tree" and "usb info".)
As such, I'm tempted to just ack the patches, but it'd be nice if you could take a look and see if something obvious is wrong.
v2 cover Enable caches for the RPi2
Quoted 35 lines
Am 17.03.2016 um 05:26 schrieb Stephen Warren <[email protected]>:
Quoted 11 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
This series mostly works OK. I found the following results, with my
rpi_devbranch on github if you want to test the exact same commits:RPi B+ (running
rpi_1build):
- Very minor transient corruption when running "ls mmc 0:2 /etc"RPi 2 (running
rpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_3_32bbuild):
- Obvious transient corruption when running "ls mmc 0:2 /etc"RPi 3 (booting in 64-bit mode and running
rpi_3build):
- No issues
Quoted 7 lines
I suspect the transient corruptions that I saw were missing cache flush operations; during the large "memcpy" while scrolling the LCD, I would see corruption in the copied data. This would soon disappear; presumably as new data is written to the bottom lines of the frame-buffer flushes out old cache lines while doing a write-allocate?
Still, I'm not 100% sure this is an issue with these patches since the RPi B+ has a similar (although much less obvious) issue. Perhaps U-Boot is using the wrong VC/GPU cache alias (top 2 bits of 32-bit physical address) for the frame-buffer, i.e. the issue is in the GPU cache, not in the ARM cache?
As far as I can tell, USB worked fine in all cases (at least, the on-board hub/Ethernet device seemed to be enumerated without issue according to "usb tree" and "usb info".)
As such, I'm tempted to just ack the patches, but it'd be nice if you could take a look and see if something obvious is wrong.
Could you please take all patches except for the one that actually sets the dcache policy in the video driver? That way we already get the non-fb speedups for rpi2/3 and I can check where the corruption comes from in parallel with a smaller patch queue.
Alex
v2 cover Enable caches for the RPi2
In reply to Stephen WarrenQuoted 44 lines · Stephen Warren
Quoted 10 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
This series mostly works OK. I found the following results, with my
rpi_devbranch on github if you want to test the exact same commits:RPi B+ (running
rpi_1build):
- Very minor transient corruption when running "ls mmc 0:2 /etc"RPi 2 (running
rpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_3_32bbuild):
- Obvious transient corruption when running "ls mmc 0:2 /etc"RPi 3 (booting in 64-bit mode and running
rpi_3build):
- No issuesI suspect the transient corruptions that I saw were missing cache flush operations; during the large "memcpy" while scrolling the LCD, I would see corruption in the copied data. This would soon disappear; presumably as new data is written to the bottom lines of the frame-buffer flushes out old cache lines while doing a write-allocate?
Still, I'm not 100% sure this is an issue with these patches since the RPi B+ has a similar (although much less obvious) issue. Perhaps U-Boot is using the wrong VC/GPU cache alias (top 2 bits of 32-bit physical address) for the frame-buffer, i.e. the issue is in the GPU cache, not in the ARM cache?
Quoted 6 lines
As far as I can tell, USB worked fine in all cases (at least, the on-board hub/Ethernet device seemed to be enumerated without issue according to "usb tree" and "usb info".)
As such, I'm tempted to just ack the patches, but it'd be nice if you could take a look and see if something obvious is wrong.
Ugh. It helps when you get the parameters for ALIGN() correctly.
Please just squash the patch below into the last patch, then things should work fine. If you like I can resend a v3, but I guess the change is small enough?
Alex
drivers/video/bcm2835.c +0 -1
@@ -109,7 +109,7 @@ void lcd_ctrl_init(void *lcdbase)/* Enable dcache for the frame buffer */ mmu_set_region_dcache_behaviour(gd->fb_base, - ALIGN(PAGE_SIZE,
msg_setup->allocate_buffer.body.resp.fb_size),
+ ALIGN(msg_setup->allocate_buffer.body.resp.fb_size,PAGE_SIZE),
DCACHE_WRITEBACK);
lcd_set_flush_dcache(1);}
v2 cover Enable caches for the RPi2
Quoted 34 lines · Alexander Graf
Quoted 31 lines · Stephen Warren
Quoted 10 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
This series mostly works OK. I found the following results, with my
rpi_devbranch on github if you want to test the exact same commits:RPi B+ (running
rpi_1build):
- Very minor transient corruption when running "ls mmc 0:2 /etc"RPi 2 (running
rpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_2build):
RPi 3 (booting in 32-bit mode and runningrpi_3_32bbuild):
- Obvious transient corruption when running "ls mmc 0:2 /etc"RPi 3 (booting in 64-bit mode and running
rpi_3build):
- No issues
...
Quoted 5 lines
Ugh. It helps when you get the parameters for
ALIGN()correctly.Please just squash the patch below into the last patch, then things should work fine. If you like I can resend a v3, but I guess the change is small enough?
With that fix squashed in, the series,
(You probably want to Cc Tom Rini on the revised patches since he applies ARM board patches these days.)
v2 cover Enable caches for the RPi2
In reply to Alexander GrafQuoted 10 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
I did find one quirk with this series (as tested in my rpi_dev branch on github): HDMI console scrolling is now extremely fast for 32-bit builds. However, it's noticeably slower on the 64-bit RPi 3 build. I wonder if the DCACHE_* constants aren't optimal for AArch64? Perhaps this can all be explained instead by RPi 3 needing a slower core clock to support a fixed mini UART frequency; that probably slows down the ARM access to DRAM.
v2 cover Enable caches for the RPi2
Quoted 18 lines · Stephen Warren
Quoted 10 lines · Alexander Graf
This patch set converts the Raspberry Pi 2 system to properly make use of the caches available in it.
Because we're running in HYP mode, we first need to teach U-Boot how to make use of HYP registers and the LPAE page layout which is mandated by hardware when running in HYP mode.
Then while we're at it, also mark the frame buffer cached to speed up screen updates.
Quoted 6 lines
With this patch set, my Raspberry Pi 3 running in AArch32 mode is a *lot* faster than without.
Please verify that the code works on a RPi2 as well and doesn't break the original Pi. In theory it should work, but I only have a 3 to test on available here.
Quoted 6 lines
I did find one quirk with this series (as tested in my
rpi_devbranch on github): HDMI console scrolling is now extremely fast for 32-bit builds. However, it's noticeably slower on the 64-bit RPi 3 build. I wonder if the DCACHE_* constants aren't optimal for AArch64? Perhaps this can all be explained instead by RPi 3 needing a slower core clock to support a fixed mini UART frequency; that probably slows down the ARM access to DRAM.
I tried with the latest code and my patches that allow for disabled uart, so that the core shouldn't get slowed down anymore.
It still does feel significantly slower than it should.
We set the memory type to WRITEBACK which translates to index 4 into MAIR
DCACHE_WRITEBACK = 4 << 2,
->
#define MT_NORMAL 4
So we need to look at what MAIR 4 looks like:
#define MEMORY_ATTRIBUTES [...] |
(UL(0xff) << (MT_NORMAL * 8)))and that is
Normal Memory, Outer Write-back non-transient
Outer Read Allocate
Outer Write Allocate
Normal Memory, Inner Write-back non-transient
Inner Read Allocate
Inner Write Allocate
So we should be using as much cache as we can ;). I'm not quite sure why it's still slower than you'd expect though. Hrm.
Alex