[U-Boot] [PATCH v2 7/7] part_efi: dcache: allocate cacheline aligned buffers
Anton Staaf
robotboy at chromium.org
Tue Oct 4 23:24:51 CEST 2011
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.
Signed-off-by: Anton Staaf <robotboy at chromium.org>
Cc: Lukasz Majewski <l.majewski at samsung.com>
Cc: Mike Frysinger <vapier at gentoo.org>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
---
disk/part_efi.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 1b04c27..1942503 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -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) {
--
1.7.3.1
More information about the U-Boot
mailing list