Skip to contentSkip to conversation

am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

PATCH In review Tom Rini 3 participants 7 messages Aug 23, 2013 – Dec 13, 2013 Arm (32-bit)

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +8 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

Hi Tom,

Quoted 14 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +0 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();

arch/arm/cpu/armv7/am33xx/board.c void s_init(void) · line 235

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/board.c +8 -0
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */

This is fine. Do we have secure devices here ?

If so, we should take care of setting the domains permissions for avoiding prefetch aborts. As it was done for OMAP using arm_init_domains. So that function and the above should be executed on am33xx as well.

Thanks to Lokesh for reminding this.

Regards,
Sricharan

author
#2 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 29 lines · Sricharan R

Hi Tom,

Quoted 14 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +0 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();

arch/arm/cpu/armv7/am33xx/board.c void s_init(void) · line 235

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/board.c +8 -0
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */

This is fine. Do we have secure devices here ?

Quoted 6 lines

If so, we should take care of setting the domains permissions for avoiding prefetch aborts. As it was done for OMAP using arm_init_domains. So that function and the above should be executed on am33xx as well.

Thanks to Lokesh for reminding this.

Yes, but I can't easily test them. I'll see if arm_init_domains just works on non-HS devices (I know I had a failure pulling all the OMAP4 code over, but didn't try hard, just looked again at the "easy" path).

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSIQmFAAoJENk4IS6UOR1WkpUP/1dFyNkM9qk5xr37yBwmha/7 NbW0HYx2YyIHrEZ5W1KZJOXjaB6yQWtVAVKvcs2nrmo5GL+6e2ObY667EzrmxOlY UPcXguJ1TvtiMIH+TZjzTUudeIBOQU8Tj5y2ryauvebJGYr8vlzbF22Unc3I/ehO cRI49H573Yu+W0kReeM7lWel+uV2kx1Q4TjRqli5lj2vSjQijBEVhgdn3RQsjkVE ff8+4N6exzczUYzSjUUh5N5RDWQnQ6qAbDKW3fkVIfo7JsgxAz1zjyqZk7j7cBAL Xo28W4wtDY2HcwFs2wl3SlYly2Kvx+qY7IAbWhULaV5NbpNMn6ShUHO8W8fh4IDF bQckJ1UTek5Y4VEP+3PmOcWi0EPIuRxCtYenhZAbweaUZE+YyBUCfunM85BH+NuJ G68T7+4gNas1KFCMLFzUXFpxAN25erH5kh3A6CNbEJLhvhq+kv+zAHb/3nOO2N30 5OuyxKlQRNDZI7M/JYaxAB+8WAqzkOaAx25+ZnrBVRD6CmtrQ+67YePQlLhJamYB nBZn/qM03JqsbacntEgL+b7gGqS62OM8ivyUegUJudfXSWfn9XZoL6ilISeezCj0 +/7jAdFDk0h2SYOhmp8zUFigsWzn7QsF3AIgBbikYZUJ9jBGbwUSc8+YaDuM79nI LtEUu/4BbWlzKrpVC4wT
=tpnc
-----END PGP SIGNATURE-----

author
#3 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

Quoted 38 lines · Tom Rini

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 34 lines · Sricharan R

Hi Tom,

Quoted 14 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +0 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();

arch/arm/cpu/armv7/am33xx/board.c void s_init(void) · line 235

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/board.c +8 -0
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */

This is fine. Do we have secure devices here ?

If so, we should take care of setting the domains permissions for avoiding prefetch aborts. As it was done for OMAP using arm_init_domains. So that function and the above should be executed on am33xx as well.

Quoted 5 lines
Quoted 1 line

Thanks to Lokesh for reminding this.

Yes, but I can't easily test them. I'll see if arm_init_domains just works on non-HS devices (I know I had a failure pulling all the OMAP4 code over, but didn't try hard, just looked again at the "easy" path).

Yeah, that code as-is hangs the boards. So if the HS devices need something, it'll go with the rest of their patches until we're moving it upstream. But good to note a potential problem area!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130830/8a5b601d/attachment.pgp>
#4 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

Hi Tom,

Quoted 42 lines · Tom Rini
Quoted 40 lines · Tom Rini

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 35 lines · Sricharan R

Hi Tom,

Quoted 14 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +0 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();

arch/arm/cpu/armv7/am33xx/board.c void s_init(void) · line 235

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/board.c +8 -0
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */

This is fine. Do we have secure devices here ?

If so, we should take care of setting the domains permissions for avoiding prefetch aborts. As it was done for OMAP using arm_init_domains. So that function and the above should be executed on am33xx as well.

Thanks to Lokesh for reminding this.

Quoted 7 lines
Quoted 3 lines

Yes, but I can't easily test them. I'll see if arm_init_domains just works on non-HS devices (I know I had a failure pulling all the OMAP4 code over, but didn't try hard, just looked again at the "easy" path).

Yeah, that code as-is hangs the boards. So if the HS devices need something, it'll go with the rest of their patches until we're moving it upstream. But good to note a potential problem area!

I added the following diff and I am able to boot my BBB over cpsw.

arch/arm/cpu/armv7/am33xx/board.c +42 -0
index 2ea3d69..8a1a29a 100644
@@ -31,6 +31,11 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/musb.h>
 #include <asm/omap_musb.h>
+#include <asm/cache.h>
+
+#define ARMV7_DCACHE_WRITEBACK  0xe
+#define ARMV7_DOMAIN_CLIENT	1
+#define ARMV7_DOMAIN_MASK	(0x3 << 0)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -225,3 +230,40 @@ void s_init(void)
 	sdram_init();
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+
+void dram_bank_mmu_setup(int bank)
+{
+	bd_t *bd = gd->bd;
+	int	i;
+
+	u32 start = bd->bi_dram[bank].start >> 20;
+	u32 size = bd->bi_dram[bank].size >> 20;
+	u32 end = start + size;
+
+	debug("%s: bank: %d\n", __func__, bank);
+	for (i = start; i < end; i++)
+		set_section_dcache(i, ARMV7_DCACHE_WRITEBACK);
+
+}
+
+void arm_init_domains(void)
+{
+	u32 reg;
+
+	reg = get_dacr();
+	/*
+	* Set DOMAIN to client access so that all permissions
+	* set in pagetables are validated by the mmu.
+	*/
+	reg &= ~ARMV7_DOMAIN_MASK;
+	reg |= ARMV7_DOMAIN_CLIENT;
+	set_dacr(reg);
+}
+#endif

AM I missing something here ?

Thanks and regards,
Lokesh

Quoted 8 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

author
#5 lore raw

PATCH 1/1 am33xx: Enable D-CACHE on !CONFIG_SYS_DCACHE_OFF

Quoted 111 lines · Lokesh Vutla

Hi Tom,

Quoted 42 lines · Tom Rini
Quoted 40 lines · Tom Rini

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 35 lines · Sricharan R

Hi Tom,

Quoted 14 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

---
 arch/arm/cpu/armv7/am33xx/board.c |    8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/cpu/armv7/am33xx/board.c +0 -0
index 2ea3d69..c261af5 100644
@@ -225,3 +225,11 @@ void s_init(void)
 	sdram_init();

arch/arm/cpu/armv7/am33xx/board.c void s_init(void) · line 235

Quoted 10 lines
arch/arm/cpu/armv7/am33xx/board.c +8 -0
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+#endif /* !CONFIG_SYS_DCACHE_OFF */

This is fine. Do we have secure devices here ?

If so, we should take care of setting the domains permissions for avoiding prefetch aborts. As it was done for OMAP using arm_init_domains. So that function and the above should be executed on am33xx as well.

Thanks to Lokesh for reminding this.

Quoted 7 lines
Quoted 3 lines

Yes, but I can't easily test them. I'll see if arm_init_domains just works on non-HS devices (I know I had a failure pulling all the OMAP4 code over, but didn't try hard, just looked again at the "easy" path).

Yeah, that code as-is hangs the boards. So if the HS devices need something, it'll go with the rest of their patches until we're moving it upstream. But good to note a potential problem area!

I added the following diff and I am able to boot my BBB over cpsw.

arch/arm/cpu/armv7/am33xx/board.c +42 -0
index 2ea3d69..8a1a29a 100644
@@ -31,6 +31,11 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/musb.h>
 #include <asm/omap_musb.h>
+#include <asm/cache.h>
+
+#define ARMV7_DCACHE_WRITEBACK  0xe
+#define ARMV7_DOMAIN_CLIENT	1
+#define ARMV7_DOMAIN_MASK	(0x3 << 0)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -225,3 +230,40 @@ void s_init(void)
 	sdram_init();
 #endif
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+
+void dram_bank_mmu_setup(int bank)
+{
+	bd_t *bd = gd->bd;
+	int	i;
+
+	u32 start = bd->bi_dram[bank].start >> 20;
+	u32 size = bd->bi_dram[bank].size >> 20;
+	u32 end = start + size;
+
+	debug("%s: bank: %d\n", __func__, bank);
+	for (i = start; i < end; i++)
+		set_section_dcache(i, ARMV7_DCACHE_WRITEBACK);
+
+}
+
+void arm_init_domains(void)
+{
+	u32 reg;
+
+	reg = get_dacr();
+	/*
+	* Set DOMAIN to client access so that all permissions
+	* set in pagetables are validated by the mmu.
+	*/
+	reg &= ~ARMV7_DOMAIN_MASK;
+	reg |= ARMV7_DOMAIN_CLIENT;
+	set_dacr(reg);
+}
+#endif
Quoted 1 line

AM I missing something here ?

Or I am. That gives me a straight up hang, like I saw before. What toolchain are you using? I'm trying ELDK 5.2 and Linaro 2013.04.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130906/3ebb9f23/attachment.pgp>
author
#6 lore raw
In reply to Tom Rini
Quoted 4 lines · Tom Rini

Test on Beaglebone white over cpsw, usb ether and SD card (read and write), performance increased, crc32 of data matches.

Applied to u-boot-ti/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131213/8d6cf073/attachment.pgp>