part_efi: dcache: allocate cacheline aligned buffers

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@chromium.org>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Acked-by: Mike Frysinger <vapier@gentoo.org>
master
Anton staaf 13 years ago committed by Wolfgang Denk
parent a1969923c9
commit f75dd584cd
  1. 18
      disk/part_efi.c

@ -120,7 +120,7 @@ static char *print_efiname(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;
@ -130,7 +130,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;
}
@ -138,7 +138,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\tName\t\t\tStart LBA\tEnd 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("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
@ -161,7 +161,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 */
@ -172,7 +172,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;
}
@ -201,11 +201,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;
@ -388,7 +388,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) {

Loading…
Cancel
Save