mtd: nand: mxs: fix cache alignment for cache lines >32
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
From: Stefan Agner <[email protected]>
Currently the command buffer gets allocated with a size of 32 bytes. This causes warning messages on systems with cache lines bigger than 32 bytes:
CACHE: Misaligned operation at range [9df17a00, 9df17a20]
Define command buffer to be at least 32 bytes, but more if cache line is bigger.
---
This appeared after Simon enable the message in check_cache_range by default...
drivers/mtd/nand/mxs_nand.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/nand/mxs_nand.c +5 -0
@@ -37,7 +37,12 @@#endif #define MXS_NAND_METADATA_SIZE 10#define MXS_NAND_BITS_PER_ECC_LEVEL 13 + +#if !defined(CONFIG_SYS_CACHELINE_SIZE ) ||CONFIG_SYS_CACHELINE_SIZE <32 #define MXS_NAND_COMMAND_BUFFER_SIZE 32 +#else +#define MXS_NAND_COMMAND_BUFFER_SIZE CONFIG_SYS_CACHELINE_SIZE +#endif #define MXS_NAND_BCH_TIMEOUT 10000
Signature · 1 line
2.9.0
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Hi Stefan,
Quoted 7 lines · Stefan Agner
From: Stefan Agner <[email protected]>
Currently the command buffer gets allocated with a size of 32 bytes. This causes warning messages on systems with cache lines bigger than 32 bytes:
CACHE: Misaligned operation at range [9df17a00,9df17a20]
I've never seen this on NAND....
Quoted 7 lines
Define command buffer to be at least 32 bytes, but more if cache line is bigger.
Signed-off-by Stefan Agner <[email protected]>---
This appeared after Simon enable the message incheck_cache_rangeby default...
ok, this explains why !
Quoted 12 lines
drivers/mtd/nand/mxs_nand.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/mtd/nand/mxs_nand.c +0
-0@@ -37,7 +37,12 @@#endif #define MXS_NAND_METADATA_SIZE 10
drivers/mtd/nand/mxs_nand.c line 48
Quoted 10 lines
drivers/mtd/nand/mxs_nand.c +5
-0#define MXS_NAND_BITS_PER_ECC_LEVEL 13 + +#if !defined(CONFIG_SYS_CACHELINE_SIZE ) ||CONFIG_SYS_CACHELINE_SIZE <32 #define MXS_NAND_COMMAND_BUFFER_SIZE 32 +#else +#define MXS_NAND_COMMAND_BUFFER_SIZE CONFIG_SYS_CACHELINE_SIZE +#endif #define MXS_NAND_BCH_TIMEOUT 10000
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
In reply to Stefan AgnerQuoted 7 lines · Stefan Agner
From: Stefan Agner <[email protected]>
Currently the command buffer gets allocated with a size of 32 bytes. This causes warning messages on systems with cache lines bigger than 32 bytes:
CACHE: Misaligned operation at range [9df17a00,9df17a20]
Quoted 5 lines
Define command buffer to be at least 32 bytes, but more if cache line is bigger.
Signed-off-by Stefan Agner <[email protected]>---
Applied to -u-boot-imx, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
Fabio Estevam
reviewerPATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
In reply to Stefan AgnerQuoted 7 lines · Stefan Agner
From: Stefan Agner <[email protected]>
Currently the command buffer gets allocated with a size of 32 bytes. This causes warning messages on systems with cache lines bigger than 32 bytes:
CACHE: Misaligned operation at range [9df17a00,9df17a20]
Quoted 7 lines
Define command buffer to be at least 32 bytes, but more if cache line is bigger.
Signed-off-by Stefan Agner <[email protected]>---
This appeared after Simon enable the message incheck_cache_rangeby default...
On mx6ul pico I also get similar warnings even though NAND is not used on this board:
U-Boot 2016.09-rc1-00245-gad6a303 (Aug 03 2016 - 10:31:52 -0300)
CPU: Freescale i.MX6UL rev1.0 at 396 MHz Reset cause: WDOG Board: PICO-IMX6UL-EMMC I2C: ready DRAM: 256 MiB CACHE: Misaligned operation at range [8fff0000, 8fff0004] CACHE: Misaligned operation at range [8fff0024, 8fff0028] PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11 MMC: FSL_SDHC: 0
*** Warning - bad CRC, using default environment
In: serial Out: serial Err: serial Net: FEC Hit any key to stop autoboot: 0
Looks like we need a more generic fix?
Thanks
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Quoted 32 lines · Fabio Estevam
Quoted 7 lines · Stefan Agner
From: Stefan Agner <[email protected]>
Currently the command buffer gets allocated with a size of 32 bytes. This causes warning messages on systems with cache lines bigger than 32 bytes:
CACHE: Misaligned operation at range [9df17a00,9df17a20]Quoted 7 lines
Define command buffer to be at least 32 bytes, but more if cache line is bigger.
Signed-off-by Stefan Agner <[email protected]>---
This appeared after Simon enable the message incheck_cache_rangeby default...On mx6ul pico I also get similar warnings even though NAND is not used on this board:
U-Boot 2016.09-rc1-00245-gad6a303 (Aug 03 2016 - 10:31:52 -0300)
CPU: Freescale i.MX6UL rev1.0 at 396 MHz Reset cause: WDOG Board: PICO-IMX6UL-EMMC I2C: ready DRAM: 256 MiB CACHE: Misaligned operation at range [8fff0000, 8fff0004] CACHE: Misaligned operation at range [8fff0024, 8fff0028] PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11 MMC: FSL_SDHC: 0*** Warning - bad CRC, using default environment
Quoted 7 lines
In: serial Out: serial Err: serial Net: FEC Hit any key to stop autoboot: 0Looks like we need a more generic fix?
As you noted, this particular case is due to cache flush of the page table and should be fixed with:
arm: cache: always flush cache line size for page table
Afaik, there is no such thing as a generic fix for cache line alignment issues... Every call site need to make sure to keep data cache line aligned, especially in case a external device (DMA) are modifying the same data...
--
Stefan
Fabio Estevam
reviewerPATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Quoted 3 lines · Stefan Agner
As you noted, this particular case is due to cache flush of the page table and should be fixed with:
arm: cache: always flush cache line size for page table
Yes, just noticed that on a imx7d-sdb I still get these cache warnings even with "arm: cache: always flush cache line size for page table" applied:
....
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#############################################
9.1 MiB/sdone
Bytes transferred = 7334512 (6fea70 hex)
CACHE: Misaligned operation at range [80800000, 80efea70] BOOTP broadcast 1
*** Unhandled DHCP Option in OFFER/ACK: 44
*** Unhandled DHCP Option in OFFER/ACK: 46
*** Unhandled DHCP Option in OFFER/ACK: 44
*** Unhandled DHCP Option in OFFER/ACK: 46
DHCP client bound to address 10.29.244.54 (356 ms) Using FEC0 device
TFTP from server 10.29.244.110; our IP address is 10.29.244.54 Filename 'imx7d-sdb.dtb'.
Load address: 0x83000000
Loading: ##
376 KiB/s
done
Bytes transferred = 27742 (6c5e hex)
CACHE: Misaligned operation at range [83000000, 83006c5e] Kernel image @ 0x80800000 [ 0x000000 - 0x6fea70 ] ## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000 Using Device Tree in place at 83000000, end 83009c5d
Starting kernel ...
CACHE: Misaligned operation at range [00900000, 00900529]
[ 0.000000] Booting Linux on physical CPU 0x0
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Quoted 22 lines · Fabio Estevam
Quoted 3 lines · Stefan Agner
As you noted, this particular case is due to cache flush of the page table and should be fixed with:
arm: cache: always flush cache line size for page tableYes, just noticed that on a imx7d-sdb I still get these cache warnings even with "arm: cache: always flush cache line size for page table" applied:
....
Filename 'zImage'.
Load address:0x80800000
Loading: ################################################################################################################################## ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############################################# 9.1 MiB/s
Quoted 3 lines
done
Bytes transferred = 7334512 (6fea70 hex)
CACHE: Misaligned operation at range [80800000,80efea70]
I feel like we must have done something wrong of late, can you bisect when these came in? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160803/1ae80ae7/attachment.sig>
Fabio Estevam
reviewerPATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Hi Tom,
Quoted 2 lines · Tom Rini
I feel like we must have done something wrong of late, can you bisect when these came in? Thanks!
This cache warnings start to appear since commit:
commit bcc53bf095893fbdae531a9a7b5d4ef4a125a7fc
Author: Simon Glass <[email protected]> Date: Sun Jun 19 19:43:05 2016 -0600
arm: Show cache warnings in U-Boot proper only
Avoid bloating the SPL image size.
Prior to this commit the cache warnings would be printed only with DEBUG enabled. Now they are always enabled when we build a non-spl target.
We could restore the original behavior and also keep Simon's intention of not bloating the SPL image size with the following change:
arch/arm/lib/cache.c +5 -4
@@ -60,10 +60,11 @@ int check_cache_range(unsigned long start, unsigned long stoif (stop & (CONFIG_SYS_CACHELINE_SIZE -1 )) ok =0 ; -if (!ok) { - warn_non_spl("CACHE: Misaligned operation at range [%08lx, %08lx - start, stop); - } +#ifndef CONFIG_SPL_BUILD +if (!ok) +debug ("CACHE: Misaligned operation at range [%08lx, %08lx]\n" , + start, stop); +#endif return ok; }
If this looks OK, I can submit a formal patch.
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Hi,
Quoted 45 lines · Fabio Estevam
Hi Tom,
Quoted 2 lines · Tom Rini
I feel like we must have done something wrong of late, can you bisect when these came in? Thanks!
This cache warnings start to appear since commit:
commit
bcc53bf095893fbdae531a9a7b5d4ef4a125a7fcAuthor: Simon Glass <[email protected]> Date: Sun Jun 19 19:43:05 2016 -0600arm: Show cache warnings in U-Boot proper only
Avoid bloating the SPL image size.
Signed-off-by Simon Glass <[email protected]>Prior to this commit the cache warnings would be printed only with DEBUG enabled. Now they are always enabled when we build a non-spl target.
We could restore the original behavior and also keep Simon's intention of not bloating the SPL image size with the following change:
arch/arm/lib/cache.c +5
-4@@ -60,10 +60,11 @@ int check_cache_range(unsigned long start, unsigned long stoif (stop & (CONFIG_SYS_CACHELINE_SIZE -1 )) ok =0 ; -if (!ok) { - warn_non_spl("CACHE: Misaligned operation at range [%08lx, %08lx - start, stop); - } +#ifndef CONFIG_SPL_BUILD +if (!ok) +debug ("CACHE: Misaligned operation at range [%08lx, %08lx]\n" , + start, stop); +#endif return ok; }
Quoted 1 line
If this looks OK, I can submit a formal patch.
Actually I think these are bugs and should be fixed. In this case, from what I can tell netboot_common() should cache-align the size in the call to:
/* flush cache */flush_cache(load_addr, size);
Regards,
Simon
Fabio Estevam
reviewerPATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Hi Simon,
Quoted 6 lines · Simon Glass
Actually I think these are bugs and should be fixed. In this case, from what I can tell
netboot_common()should cache-align the size in the call to:/* flush cache */
flush_cache(load_addr, size);
Do you mean like this?
cmd/net.c +2 -0
@@ -244,6 +244,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmd }/* flush cache */ + load_addr &= ~(CONFIG_SYS_CACHELINE_SIZE -1 ); + size =ALIGN (size,CONFIG_SYS_CACHELINE_SIZE );flush_cache (load_addr, size);bootstage_mark (BOOTSTAGE_ID_NET_LOADED );
This makes the net warnings go away.
There is still this one that I am seeing:
Kernel image @ 0x80800000 [ 0x000000 - 0x6fea70 ] ## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000 Using Device Tree in place at 83000000, end 83009c5d
Starting kernel ...
CACHE: Misaligned operation at range [00900000, 00900529]
[ 0.000000] Booting Linux on physical CPU 0x0
Any ideas where it may come from?
Thanks
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Hi Fabio,
Quoted 34 lines · Fabio Estevam
Hi Simon,
Quoted 6 lines · Simon Glass
Actually I think these are bugs and should be fixed. In this case, from what I can tell
netboot_common()should cache-align the size in the call to:/* flush cache */
flush_cache(load_addr, size);Do you mean like this?
cmd/net.c +2
-0@@ -244,6 +244,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmd }/* flush cache */ + load_addr &= ~(CONFIG_SYS_CACHELINE_SIZE -1 ); + size =ALIGN (size,CONFIG_SYS_CACHELINE_SIZE );flush_cache (load_addr, size);bootstage_mark (BOOTSTAGE_ID_NET_LOADED );This makes the net warnings go away.
There is still this one that I am seeing:
Kernel image @
0x80800000[0x000000-0x6fea70] ## Flattened Device Tree blob at 83000000
Booting using the fdt blob at0x83000000Using Device Tree in place at 83000000, end83009c5d
Quoted 6 lines
Starting kernel ...
CACHE: Misaligned operation at range [00900000, 00900529]
[ 0.000000] Booting Linux on physical CPU 0x0Any ideas where it may come from?
Not really...maybe boot_ramdisk_high()?
It's clearly pretty late in the process.
Regards,
Simon
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
Quoted 39 lines · Simon Glass
Hi Fabio,
Quoted 36 lines · Fabio Estevam
Hi Simon,
Quoted 6 lines · Simon Glass
Actually I think these are bugs and should be fixed. In this case, from what I can tell
netboot_common()should cache-align the size in the call to:/* flush cache */
flush_cache(load_addr, size);Do you mean like this?
cmd/net.c +2
-0@@ -244,6 +244,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmd }/* flush cache */ + load_addr &= ~(CONFIG_SYS_CACHELINE_SIZE -1 ); + size =ALIGN (size,CONFIG_SYS_CACHELINE_SIZE );flush_cache (load_addr, size);bootstage_mark (BOOTSTAGE_ID_NET_LOADED );This makes the net warnings go away.
There is still this one that I am seeing:
Kernel image @
0x80800000[0x000000-0x6fea70] ## Flattened Device Tree blob at 83000000
Booting using the fdt blob at0x83000000Using Device Tree in place at 83000000, end83009c5dStarting kernel ...
Quoted 8 lines
Quoted 4 lines
CACHE: Misaligned operation at range [00900000, 00900529]
[ 0.000000] Booting Linux on physical CPU 0x0Any ideas where it may come from?
Not really...maybe
boot_ramdisk_high()?It's clearly pretty late in the process.
That looks like a SRAM address, and it is used for the secure stuff for instance (CONFIG_ARMV7_SECURE_BASE).
I bet its from relocate_secure_section in arch/arm/cpu/armv7/virt-v7.c.
Will send out a patch for that.
--
Stefan
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
In reply to Fabio EstevamQuoted 5 lines · Fabio Estevam
Hi Simon,
Quoted 1 line · Simon Glass
Actually I think these are bugs and should be fixed. In this case,
I am completely with you Simon!
check_cache_range return 0, which actually leads to the cache operation not being executed at all! Depending on the situation this can be quite catastrophic...
Quoted 20 lines
Quoted 5 lines
from what I can tell
netboot_common()should cache-align the size in the call to:/* flush cache */
flush_cache(load_addr, size);Do you mean like this?
cmd/net.c +2
-0@@ -244,6 +244,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmd }/* flush cache */ + load_addr &= ~(CONFIG_SYS_CACHELINE_SIZE -1 ); + size =ALIGN (size,CONFIG_SYS_CACHELINE_SIZE );flush_cache (load_addr, size);bootstage_mark (BOOTSTAGE_ID_NET_LOADED );
Quoted 1 line
This makes the net warnings go away.
Yes, see my patch too.
https://patchwork.ozlabs.org/patch/654585/
So up until now, that stuff did not get flushed whenever the file size was not cache line aligned, and nobody noticed... Is that cache flush necessary at all?
Quoted 8 lines
There is still this one that I am seeing:
Kernel image @
0x80800000[0x000000-0x6fea70] ## Flattened Device Tree blob at 83000000
Booting using the fdt blob at0x83000000Using Device Tree in place at 83000000, end83009c5d
Quoted 6 lines
Starting kernel ...
CACHE: Misaligned operation at range [00900000, 00900529]
[ 0.000000] Booting Linux on physical CPU 0x0Any ideas where it may come from?
I did not had that one on i.MX 7
--
Stefan
PATCH 1/1 mtd: nand: mxs: fix cache alignment for cache lines >32
In reply to Tom RiniQuoted 25 lines · Tom Rini
Quoted 21 lines · Fabio Estevam
Quoted 3 lines · Stefan Agner
As you noted, this particular case is due to cache flush of the page table and should be fixed with:
arm: cache: always flush cache line size for page tableYes, just noticed that on a imx7d-sdb I still get these cache warnings even with "arm: cache: always flush cache line size for page table" applied:
....
Filename 'zImage'.
Load address:0x80800000
Loading: ################################################################################################################################## ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############################################# 9.1 MiB/sQuoted 3 lines
done
Bytes transferred = 7334512 (6fea70 hex)
CACHE: Misaligned operation at range [80800000,80efea70]
Quoted 2 lines
I feel like we must have done something wrong of late, can you bisect when these came in? Thanks!
The mistake(s) must have been long time ago, but since commit bcc53bf095893fbdae531a9a7b5d4ef4a125a7fc it comes out visible.
I think we have to check every those warning for correct alignment.
cheers,
Hannes