From patchwork Wed Oct 12 23:56:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton staaf X-Patchwork-Id: 119332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7AA92B6F65 for ; Thu, 13 Oct 2011 10:56:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD31728B3C; Thu, 13 Oct 2011 01:56:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w-pVuJr4zEuw; Thu, 13 Oct 2011 01:56:43 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 755F028ABB; Thu, 13 Oct 2011 01:56:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E24C028931 for ; Thu, 13 Oct 2011 01:56:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6dHwb8oWFvxN for ; Thu, 13 Oct 2011 01:56:23 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id EA01928A74 for ; Thu, 13 Oct 2011 01:56:22 +0200 (CEST) Received: from hpaq7.eem.corp.google.com (hpaq7.eem.corp.google.com [172.25.149.7]) by smtp-out.google.com with ESMTP id p9CNuDGQ013537; Wed, 12 Oct 2011 16:56:13 -0700 Received: from servo.mtv.corp.google.com (servo.mtv.corp.google.com [172.22.72.56]) by hpaq7.eem.corp.google.com with ESMTP id p9CNuAVZ006633; Wed, 12 Oct 2011 16:56:11 -0700 Received: by servo.mtv.corp.google.com (Postfix, from userid 99248) id 44C1B4A18F; Wed, 12 Oct 2011 16:56:10 -0700 (PDT) From: Anton Staaf To: u-boot@lists.denx.de Date: Wed, 12 Oct 2011 16:56:04 -0700 Message-Id: <1318463764-28244-7-git-send-email-robotboy@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1318463764-28244-1-git-send-email-robotboy@chromium.org> References: <1318463764-28244-1-git-send-email-robotboy@chromium.org> X-System-Of-Record: true Cc: Anton Staaf Subject: [U-Boot] [PATCH v3 6/6] part_efi: dcache: allocate cacheline aligned buffers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Cc: Lukasz Majewski Cc: Mike Frysinger Cc: Albert ARIBAUD Acked-by: Mike Frysinger --- 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 0a513c6..e591724 100644 --- a/disk/part_efi.c +++ b/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) {