From patchwork Fri Oct 27 10:28:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 831183 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yNg8G2sjDz9t30 for ; Fri, 27 Oct 2017 21:28:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0A8CFC21DB5; Fri, 27 Oct 2017 10:28:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9B5F6C21C51; Fri, 27 Oct 2017 10:28:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A2D03C21C51; Fri, 27 Oct 2017 10:28:32 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id 3E8F3C21C4E for ; Fri, 27 Oct 2017 10:28:32 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3yNg7y1DfVz1qqkS; Fri, 27 Oct 2017 12:28:30 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3yNg7y075lz1qqkD; Fri, 27 Oct 2017 12:28:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id d4bjfq1VJ7E4; Fri, 27 Oct 2017 12:28:27 +0200 (CEST) X-Auth-Info: XDiZE5ds2jMdOIjlnH/U1x4ZzLNcaqKZjFix3cqu4W4= Received: from localhost.localdomain (89-64-27-66.dynamic.chello.pl [89.64.27.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 27 Oct 2017 12:28:27 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Fri, 27 Oct 2017 12:28:10 +0200 Message-Id: <1509100090-21903-1-git-send-email-lukma@denx.de> X-Mailer: git-send-email 2.1.4 Cc: Alison Chaiken , Peter Jones , Vincent Tinelli , Maxime Ripard Subject: [U-Boot] [PATCH] gpt: Use cache aligned buffers for gpt_h and gpt_e X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Before this patch one could receive following errors when executing "gpt write" command on machine with cache enabled: display5 factory > gpt write mmc ${mmcdev} ${partitions} Writing GPT: CACHE: Misaligned operation at range [4ef8f7f0, 4ef8f9f0] CACHE: Misaligned operation at range [4ef8f9f8, 4ef939f8] CACHE: Misaligned operation at range [4ef8f9f8, 4ef939f8] CACHE: Misaligned operation at range [4ef8f7f0, 4ef8f9f0] success! To alleviate this problem - the calloc()s have been replaced with malloc_cache_aligned() and memset(). After those changes the buffers are properly aligned (with both start address and size) to SoC cache line. Signed-off-by: Lukasz Majewski --- disk/part_efi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 7862bee..f6f5bee 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -622,25 +622,27 @@ int gpt_fill_header(struct blk_desc *dev_desc, gpt_header *gpt_h, int gpt_restore(struct blk_desc *dev_desc, char *str_disk_guid, disk_partition_t *partitions, int parts_count) { - int ret; - - gpt_header *gpt_h = calloc(1, PAD_TO_BLOCKSIZE(sizeof(gpt_header), - dev_desc)); + gpt_header *gpt_h; gpt_entry *gpt_e; + int ret, size; + size = PAD_TO_BLOCKSIZE(sizeof(gpt_header), dev_desc); + gpt_h = malloc_cache_aligned(size); if (gpt_h == NULL) { printf("%s: calloc failed!\n", __func__); return -1; } + memset(gpt_h, 0, size); - gpt_e = calloc(1, PAD_TO_BLOCKSIZE(GPT_ENTRY_NUMBERS - * sizeof(gpt_entry), - dev_desc)); + size = PAD_TO_BLOCKSIZE(GPT_ENTRY_NUMBERS * sizeof(gpt_entry), + dev_desc); + gpt_e = malloc_cache_aligned(size); if (gpt_e == NULL) { printf("%s: calloc failed!\n", __func__); free(gpt_h); return -1; } + memset(gpt_e, 0, size); /* Generate Primary GPT header (LBA1) */ ret = gpt_fill_header(dev_desc, gpt_h, str_disk_guid, parts_count);