From patchwork Tue Oct 4 21:24:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton staaf X-Patchwork-Id: 117696 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 8012D1007D1 for ; Wed, 5 Oct 2011 08:26:23 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C300A2A199; Tue, 4 Oct 2011 23:25:44 +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 fHPI2uLyF0KV; Tue, 4 Oct 2011 23:25:44 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CAC8C2A19A; Tue, 4 Oct 2011 23:25:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6183A2A195 for ; Tue, 4 Oct 2011 23:25:28 +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 Q12uYtSP30TE for ; Tue, 4 Oct 2011 23:25:27 +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 0F24B2A18F for ; Tue, 4 Oct 2011 23:25:22 +0200 (CEST) Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id p94LP2CS031490; Tue, 4 Oct 2011 14:25:03 -0700 Received: from servo.mtv.corp.google.com (servo.mtv.corp.google.com [172.22.72.56]) by wpaz24.hot.corp.google.com with ESMTP id p94LOw3s014871; Tue, 4 Oct 2011 14:24:58 -0700 Received: by servo.mtv.corp.google.com (Postfix, from userid 99248) id 6ED224A185; Tue, 4 Oct 2011 14:24:57 -0700 (PDT) From: Anton Staaf To: u-boot@lists.denx.de Date: Tue, 4 Oct 2011 14:24:51 -0700 Message-Id: <1317763491-7274-8-git-send-email-robotboy@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1317763491-7274-1-git-send-email-robotboy@chromium.org> References: <1317763491-7274-1-git-send-email-robotboy@chromium.org> X-System-Of-Record: true Cc: Anton Staaf Subject: [U-Boot] [PATCH v2 7/7] 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 --- 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) {