Skip to contentSkip to conversation

Add cache line alignment support

PATCH Superseded Anton Staaf 4 participants 18 messages Oct 4, 2011 – Oct 9, 2011

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add cache line alignment support

The cache line alignment issue has gone around a couple of times now. This patch set implements all of the details that we have discussed about the implementation of ALLOC_CACHE_ALIGN_BUFFER other than the switch to the Linux style L1_CACHE_BYTES, L1_CACHE_SHIFT, and ARCH_DMA_MINALIGN defines mentioned by Mike Frysinger. It also includes patches that use the macro to fix MMC and ext2 buffers, as well as define the CONFIG_SYS_CACHELINE_SIZE value for Tegra and add a default value for CONFIG_SYS_CACHELINE_SIZE with a warning if it is used.

About the Linux defines that Mike suggests. It may make sense to move these patches over to use that mechanism, especially since there are only a few configs that define CONFIG_SYS_CACHELINE_SIZE anyway. Also, since this is an architecture specific parameter and not a board specific one it makes sense that these configs would be architecture specific. I am also not supper happy with the fact that most boards generate a warning with this patchset, because they don't set CONFIG_SYS_CACHELINE_SIZE. But I'm not sure that silently providing a default is a good idea.

I think we can discuss the relative merrits of that move independently of the implementation of this fix though, and I wanted to get this discussion going again.

Thanks,
Anton

---

Changes for v2:
- Add comment describing why we are setting a default cacheline size
- Remove Gerrit generated Change-Id: tags from commit messages
- Add additional buffer alignments for mmc and part_efi code

Anton Staaf (7):
cache: add ALLOC_CACHE_ALIGN_BUFFER macro
cache: add default setting for CONFIG_SYS_CACHELINE_SIZE
tegra: define CONFIG_SYS_CACHELINE_SIZE for tegra
mmc: dcache: allocate cache aligned buffer for scr and switch_status
ext2: Cache line aligned partial sector bounce buffer
mmc: dcache: allocate cache aligned buffers for ext_csd
part_efi: dcache: allocate cacheline aligned buffers

 disk/part_efi.c                 |   18 +++++-----
 doc/README.arm-caches           |    2 +
 drivers/mmc/mmc.c               |   14 ++++----
 fs/ext2/dev.c                   |    2 +-
 include/common.h                |   73 +++++++++++++++++++++++++++++++++++++++
 include/configs/tegra2-common.h |    2 +
 6 files changed, 94 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH v2 1/7 cache: add ALLOC_CACHE_ALIGN_BUFFER macro

This macro is used to allocate cache line size aligned stack buffers for use with DMA hardware.

Cc Lukasz Majewski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Aneesh V <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 doc/README.arm-caches |    2 +
 include/common.h      |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)
doc/README.arm-caches +2 -0
index cd2b458..f6a52e3 100644
@@ -40,6 +40,8 @@ Buffer Requirements:
 - If the buffer is not cache-line aligned invalidation will be restricted
   to the aligned part. That is, one cache-line at the respective boundary
   may be left out while doing invalidation.
+- A suitable buffer can be alloced on the stack using the
+  ALLOC_CACHE_ALIGN_BUFFER macro.
 
 Cleanup Before Linux:
 - cleanup_before_linux() should flush the D-cache, invalidate I-cache, and
include/common.h +59 -0

65 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#2 lore raw

PATCH v2 1/7 cache: add ALLOC_CACHE_ALIGN_BUFFER macro

Dear Anton Staaf,

Quoted 11 lines · In message <[email protected]> you wrote:

This macro is used to allocate cache line size aligned stack buffers for use with DMA hardware.

Cc Lukasz Majewski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Aneesh V <[email protected]>
Cc Albert ARIBAUD <[email protected]>
Quoted 4 lines
---
 doc/README.arm-caches |    2 +
 include/common.h      |   59 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It may be that your whole purpose in life is simply  to  serve  as  a
warning to others.
#3 lore raw

PATCH v2 2/7 cache: add default setting for CONFIG_SYS_CACHELINE_SIZE

In reply to Anton Staaf

CONFIG_SYS_CACHELINE_SIZE is supposed to be defined for all configs. But most configs do not specify it. This patch will set CONFIG_SYS_CACHELINE_SIZE to a default value equal to the GCC builtin macro __BIGGEST_ALIGNMENT__. This is not strictly correct, so it also generates a warning if the default is used.

Cc Lukasz Majewski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Aneesh V <[email protected]>
Cc Albert ARIBAUD <[email protected]>

---

Changes for v2:
- Add comment describing why we are setting a default cacheline size

 include/common.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/common.h +14 -0
index cdd76c5..d50b182 100644
@@ -790,6 +790,20 @@ int cpu_release(int nr, int argc, char * const argv[]);
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
 
 /*
+ * All configurations should provide a value for their architectures cacheline
+ * size.  Most currently do not and thus we provide a default that will surely
+ * be wrong, and a warning that we have done so.
+ *
+ * An additional run time warning will be generated when the incorrect size
+ * is used to align a DMA buffer and the cache invalidation or flushing
+ * routines are called with the resulting incorrectly aligned address.
+ */
+#if !defined(CONFIG_SYS_CACHELINE_SIZE)
+#warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__
+#define CONFIG_SYS_CACHELINE_SIZE	__BIGGEST_ALIGNMENT__
+#endif
+
+/*
  * The ALLOC_CACHE_ALIGN_BUFFER macro is used to allocate a cache line size
  * aligned buffer on the stack.  Such a buffer is useful for DMA operations
  * where flushing and invalidating the cache before and after a read and/or
Signature · 1 line
1.7.3.1
#5 lore raw

PATCH v2 2/7 cache: add default setting for CONFIG_SYS_CACHELINE_SIZE

In reply to Anton Staaf

Dear Anton Staaf,

Quoted 14 lines · In message <[email protected]> you wrote:

CONFIG_SYS_CACHELINE_SIZE is supposed to be defined for all configs. But most configs do not specify it. This patch will set CONFIG_SYS_CACHELINE_SIZE to a default value equal to the GCC builtin macro __BIGGEST_ALIGNMENT__. This is not strictly correct, so it also generates a warning if the default is used.

Cc Lukasz Majewski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Aneesh V <[email protected]>
Cc Albert ARIBAUD <[email protected]>
Quoted 7 lines

---

Changes for v2:
- Add comment describing why we are setting a default cacheline size

 include/common.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I often quote myself; it adds spice to my conversation.  - G. B. Shaw
#6 lore raw

PATCH v2 3/7 tegra: define CONFIG_SYS_CACHELINE_SIZE for tegra

In reply to Anton Staaf
Cc Tom Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 include/configs/tegra2-common.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/configs/tegra2-common.h +2 -0
index 73e0f05..a9c665c 100644
@@ -33,6 +33,8 @@
 #define CONFIG_MACH_TEGRA_GENERIC	/* which is a Tegra generic machine */
 #define CONFIG_SYS_L2CACHE_OFF		/* No L2 cache */
 
+#define CONFIG_SYS_CACHELINE_SIZE	32
+
 #define CONFIG_ENABLE_CORTEXA9		/* enable CPU (A9 complex) */
 
 #include <asm/arch/tegra2.h>		/* get chip and board defs */
Signature · 1 line
1.7.3.1
#7 lore raw

PATCH v2 3/7 tegra: define CONFIG_SYS_CACHELINE_SIZE for tegra

Dear Anton Staaf,

Quoted 10 lines · In message <[email protected]> you wrote:
Cc Tom Warren <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 include/configs/tegra2-common.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I don't want to be young again, I just don't want to get any older.
#8 lore raw

PATCH v2 4/7 mmc: dcache: allocate cache aligned buffer for scr and switch_status

In reply to Anton Staaf

Currently the sd_change_freq function allocates two buffers on the stack that it passes down to the MMC device driver. These buffers could be unaligned to the L1 dcache line size. This causes problems when using DMA and with caches enabled.

This patch correctly cache alignes the buffers used for reading the scr register and switch status values from an MMC device.

Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 drivers/mmc/mmc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/mmc.c +5 -5
index 391bc2b..ba6fbfe 100644
@@ -702,8 +702,8 @@ int sd_change_freq(struct mmc *mmc)
 {
 	int err;
 	struct mmc_cmd cmd;
-	uint scr[2];
-	uint switch_status[16];
+	ALLOC_CACHE_ALIGN_BUFFER(uint, scr, 2);
+	ALLOC_CACHE_ALIGN_BUFFER(uint, switch_status, 16);
 	struct mmc_data data;
 	int timeout;
 
@@ -731,7 +731,7 @@ int sd_change_freq(struct mmc *mmc)
 	timeout = 3;
 
 retry_scr:
-	data.dest = (char *)&scr;
+	data.dest = (char *)scr;
 	data.blocksize = 8;
 	data.blocks = 1;
 	data.flags = MMC_DATA_READ;
@@ -773,7 +773,7 @@ retry_scr:
 	timeout = 4;
 	while (timeout--) {
 		err = sd_switch(mmc, SD_SWITCH_CHECK, 0, 1,
-				(u8 *)&switch_status);
+				(u8 *)switch_status);
 
 		if (err)
 			return err;
@@ -787,7 +787,7 @@ retry_scr:
 	if (!(__be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED))
 		return 0;
 
-	err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (u8 *)&switch_status);
+	err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (u8 *)switch_status);
 
 	if (err)
 		return err;
Signature · 1 line
1.7.3.1
#9 lore raw

PATCH v2 4/7 mmc: dcache: allocate cache aligned buffer for scr and switch_status

Dear Anton Staaf,

Quoted 8 lines · In message <[email protected]> you wrote:

Currently the sd_change_freq function allocates two buffers on the stack that it passes down to the MMC device driver. These buffers could be unaligned to the L1 dcache line size. This causes problems when using DMA and with caches enabled.

This patch correctly cache alignes the buffers used for reading the scr register and switch status values from an MMC device.

Quoted 8 lines
Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 drivers/mmc/mmc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
About the use of language: it is impossible to sharpen a pencil  with
a  blunt  ax.  It is equally vain to try to do it with ten blunt axes
instead.                                           -- Edsger Dijkstra
#10 lore raw

PATCH v2 5/7 ext2: Cache line aligned partial sector bounce buffer

In reply to Anton Staaf

Currently, if a device read request is done that does not begin or end on a sector boundary a stack allocated bounce buffer is used to perform the read, and then just the part of the sector that is needed is copied into the users buffer. This stack allocation can mean that the bounce buffer will not be aligned to the dcache line size. This is a problem when caches are enabled because unaligned cache invalidates are not safe.

This patch uses ALLOC_CACHE_ALIGN_BUFFER to create a stack allocated cache line size aligned bounce buffer.

Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Dave Liu <[email protected]>
Cc Andy Fleming <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 fs/ext2/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ext2/dev.c +1 -1
index 78851d0..874e211 100644
@@ -52,7 +52,7 @@ int ext2fs_set_blk_dev(block_dev_desc_t *rbdd, int part)
 
 int ext2fs_devread(int sector, int byte_offset, int byte_len, char *buf)
 {
-	char sec_buf[SECTOR_SIZE];
+	ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, SECTOR_SIZE);
 	unsigned sectors;
 
 	/*
Signature · 1 line
1.7.3.1
#11 lore raw

PATCH v2 5/7 ext2: Cache line aligned partial sector bounce buffer

Dear Anton Staaf,

Quoted 19 lines · In message <[email protected]> you wrote:

Currently, if a device read request is done that does not begin or end on a sector boundary a stack allocated bounce buffer is used to perform the read, and then just the part of the sector that is needed is copied into the users buffer. This stack allocation can mean that the bounce buffer will not be aligned to the dcache line size. This is a problem when caches are enabled because unaligned cache invalidates are not safe.

This patch uses ALLOC_CACHE_ALIGN_BUFFER to create a stack allocated cache line size aligned bounce buffer.

Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Dave Liu <[email protected]>
Cc Andy Fleming <[email protected]>
Cc Albert ARIBAUD <[email protected]>
Quoted 3 lines
---
 fs/ext2/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A weak mind is like a microscope, which magnifies trifling things,
but cannot receive great ones.      -- Philip Earl of Chesterfield
#12 lore raw

PATCH v2 6/7 mmc: dcache: allocate cache aligned buffers for ext_csd

In reply to Anton Staaf

Currently the mmc_change_freq and mmc_startup functions allocates buffers on the stack that are passed down to the MMC device driver. These buffers could be unaligned to the L1 dcache line size. This causes problems when using DMA and with caches enabled.

This patch correctly cache alignes the buffers used for reading the ext_csd data from an MMC device.

Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 drivers/mmc/mmc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/mmc.c +2 -2
index ba6fbfe..e5fedb3 100644
@@ -618,7 +618,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 int mmc_change_freq(struct mmc *mmc)
 {
-	char ext_csd[512];
+	ALLOC_CACHE_ALIGN_BUFFER(char, ext_csd, 512);
 	char cardtype;
 	int err;
 
@@ -860,7 +860,7 @@ int mmc_startup(struct mmc *mmc)
 	uint mult, freq;
 	u64 cmult, csize, capacity;
 	struct mmc_cmd cmd;
-	char ext_csd[512];
+	ALLOC_CACHE_ALIGN_BUFFER(char, ext_csd, 512);
 	int timeout = 1000;
 
 #ifdef CONFIG_MMC_SPI_CRC_ON
Signature · 1 line
1.7.3.1
#13 lore raw

PATCH v2 6/7 mmc: dcache: allocate cache aligned buffers for ext_csd

Dear Anton Staaf,

Quoted 8 lines · In message <[email protected]> you wrote:

Currently the mmc_change_freq and mmc_startup functions allocates buffers on the stack that are passed down to the MMC device driver. These buffers could be unaligned to the L1 dcache line size. This causes problems when using DMA and with caches enabled.

This patch correctly cache alignes the buffers used for reading the ext_csd data from an MMC device.

Quoted 7 lines
Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 drivers/mmc/mmc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You can observe a lot just by watchin'.                  - Yogi Berra
#14 lore raw

PATCH v2 7/7 part_efi: dcache: allocate cacheline aligned buffers

In reply to Anton Staaf

Currently part_efi.c allocates buffers for the gpt_header, the legacy_mbr, and the pte (partition table entry) that may be incorrectly aligned for DMA operations.

This patch uses ALLOC_CACHE_ALIGN_BUFFER for the stack allocated buffers and memalign to replace the malloc of the pte.

Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 disk/part_efi.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
disk/part_efi.c +9 -9
index 1b04c27..1942503 100644
@@ -105,7 +105,7 @@ static int is_pte_valid(gpt_entry * pte);
 
 void print_part_efi(block_dev_desc_t * dev_desc)
 {
-	gpt_header gpt_head;
+	ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
 	gpt_entry **pgpt_pte = NULL;
 	int i = 0;
 
@@ -115,7 +115,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	}
 	/* This function validates AND fills in the GPT header and PTE */
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
-			 &(gpt_head), pgpt_pte) != 1) {
+			 gpt_head, pgpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __FUNCTION__);
 		return;
 	}
@@ -123,7 +123,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	debug("%s: gpt-entry at 0x%08X\n", __FUNCTION__, (unsigned int)*pgpt_pte);
 
 	printf("Part  Start LBA  End LBA\n");
-	for (i = 0; i < le32_to_int(gpt_head.num_partition_entries); i++) {
+	for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
 
 		if (is_pte_valid(&(*pgpt_pte)[i])) {
 			printf("%s%d  0x%llX    0x%llX\n", GPT_ENTRY_NAME,
@@ -146,7 +146,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 				disk_partition_t * info)
 {
-	gpt_header gpt_head;
+	ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
 	gpt_entry **pgpt_pte = NULL;
 
 	/* "part" argument must be at least 1 */
@@ -157,7 +157,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 
 	/* This function validates AND fills in the GPT header and PTE */
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
-			&(gpt_head), pgpt_pte) != 1) {
+			 gpt_head, pgpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __FUNCTION__);
 		return -1;
 	}
@@ -185,11 +185,11 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 
 int test_part_efi(block_dev_desc_t * dev_desc)
 {
-	legacy_mbr legacymbr;
+	ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, legacymbr, 1);
 
 	/* Read legacy MBR from block 0 and validate it */
-	if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *) & legacymbr) != 1)
-		|| (is_pmbr_valid(&legacymbr) != 1)) {
+	if ((dev_desc->block_read(dev_desc->dev, 0, 1, (ulong *)legacymbr) != 1)
+		|| (is_pmbr_valid(legacymbr) != 1)) {
 		return -1;
 	}
 	return 0;
@@ -372,7 +372,7 @@ static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc,
 
 	/* Allocate memory for PTE, remember to FREE */
 	if (count != 0) {
-		pte = malloc(count);
+		pte = memalign(CONFIG_SYS_CACHELINE_SIZE, count);
 	}
 
 	if (count == 0 || pte == NULL) {
Signature · 1 line
1.7.3.1
#15 lore raw

PATCH v2 7/7 part_efi: dcache: allocate cacheline aligned buffers

Dear Anton Staaf,

Quoted 7 lines · In message <[email protected]> you wrote:

Currently part_efi.c allocates buffers for the gpt_header, the legacy_mbr, and the pte (partition table entry) that may be incorrectly aligned for DMA operations.

This patch uses ALLOC_CACHE_ALIGN_BUFFER for the stack allocated buffers and memalign to replace the malloc of the pte.

Quoted 7 lines
Cc Lukasz Majewski <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Albert ARIBAUD <[email protected]>
---
 disk/part_efi.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Go to Heaven for the climate, Hell for the company."    - Mark Twain
#16 lore raw

v2 cover Add cache line alignment support

In reply to Anton Staaf

Dear Anton Staaf,

Quoted 18 lines · In message <[email protected]> you wrote:

The cache line alignment issue has gone around a couple of times now. This patch set implements all of the details that we have discussed about the implementation of ALLOC_CACHE_ALIGN_BUFFER other than the switch to the Linux style L1_CACHE_BYTES, L1_CACHE_SHIFT, and ARCH_DMA_MINALIGN defines mentioned by Mike Frysinger. It also includes patches that use the macro to fix MMC and ext2 buffers, as well as define the CONFIG_SYS_CACHELINE_SIZE value for Tegra and add a default value for CONFIG_SYS_CACHELINE_SIZE with a warning if it is used.

About the Linux defines that Mike suggests. It may make sense to move these patches over to use that mechanism, especially since there are only a few configs that define CONFIG_SYS_CACHELINE_SIZE anyway. Also, since this is an architecture specific parameter and not a board specific one it makes sense that these configs would be architecture specific. I am also not supper happy with the fact that most boards generate a warning with this patchset, because they don't set CONFIG_SYS_CACHELINE_SIZE. But I'm not sure that silently providing a default is a good idea.

Quoted 3 lines

I think we can discuss the relative merrits of that move independently of the implementation of this fix though, and I wanted to get this discussion going again.

Sorry, but I'm going to back out all these patches from my tree again.

I can;t get this to work.

With the patches applied, I get all kinds of "#warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__" for Power Atchitecture systems (ppc4xx expecially).

Stefan Roese provided the "ppc: Include <asm/cache.h> in common.h" and "ppc: Fix DBSR_IAx defines in <bedbug/regs.h>" to fix this on PPC, but now I see the same on ARM, like that:

Configuring for jornada board...
In file included from /home/wd/git/u-boot/work/lib/asm-offsets.c:18:0:
/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] In file included from hello_world.c:24:0:
/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] In file included from /home/wd/git/u-boot/work/include/exports.h:6:0,

                 from stubs.c:1:

/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] ^Carm-linux-gnueabi-size: '/work/wd/tmp-arm/u-boot': No such file

Please fix, and resubmit. Please make sure to run MAKEALL not only for your boards, but for some architectures (say, ARM, MIPS and PPC).

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"When anyone says `theoretically,' they really mean `not really.'"
- David Parnas
#17 lore raw

v2 cover Add cache line alignment support

Quoted 49 lines · Wolfgang Denk

Dear Anton Staaf,

Quoted 18 lines · In message <[email protected]> you wrote:

The cache line alignment issue has gone around a couple of times now. ?This patch set implements all of the details that we have discussed about the implementation of ALLOC_CACHE_ALIGN_BUFFER other than the switch to the Linux style L1_CACHE_BYTES, L1_CACHE_SHIFT, and ARCH_DMA_MINALIGN defines mentioned by Mike Frysinger. ?It also includes patches that use the macro to fix MMC and ext2 buffers, as well as define the CONFIG_SYS_CACHELINE_SIZE value for Tegra and add a default value for CONFIG_SYS_CACHELINE_SIZE with a warning if it is used.

About the Linux defines that Mike suggests. ?It may make sense to move these patches over to use that mechanism, especially since there are only a few configs that define CONFIG_SYS_CACHELINE_SIZE anyway. ?Also, since this is an architecture specific parameter and not a board specific one it makes sense that these configs would be architecture specific. ?I am also not supper happy with the fact that most boards generate a warning with this patchset, because they don't set CONFIG_SYS_CACHELINE_SIZE. ?But I'm not sure that silently providing a default is a good idea.

Quoted 3 lines

I think we can discuss the relative merrits of that move independently of the implementation of this fix though, and I wanted to get this discussion going again.

Sorry, but I'm going to back out all these patches from my tree again.

I can;t get this to work.

With the patches applied, I get all kinds of "#warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__" for Power Atchitecture systems (ppc4xx expecially).

Stefan Roese provided the "ppc: Include <asm/cache.h> in common.h" and "ppc: Fix DBSR_IAx defines in <bedbug/regs.h>" to fix this on PPC, but now I see the same on ARM, like that:

Configuring for jornada board...
In file included from /home/wd/git/u-boot/work/lib/asm-offsets.c:18:0:
/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] In file included from hello_world.c:24:0:
/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] In file included from /home/wd/git/u-boot/work/include/exports.h:6:0,
? ? ? ? ? ? ? ? from stubs.c:1:
/home/wd/git/u-boot/work/include/common.h:825:2: warning: #warning CONFIG_SYS_CACHELINE_SIZE not defined, using __BIGGEST_ALIGNMENT__ [-Wcpp] ^Carm-linux-gnueabi-size: '/work/wd/tmp-arm/u-boot': No such file

Quoted 2 lines

Please fix, and resubmit. Please make sure to run MAKEALL not only for your boards, but for some architectures (say, ARM, MIPS and PPC).

Yup, I was surprised that it went in so quickly actually. I did point out the warnings that would be generated. But perhaps I should have been more clear about just how many would be generated. I'll look into a solution. I am hoping that it won't be that I need to understand the cache line sizes of all architectures and fix them all to define CONFIG_SYS_CACHELINE_SIZE. :)

Thanks,
Anton

Quoted 13 lines

Thanks.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "When anyone says theoretically,' they really mean not really.'"
- David Parnas