From patchwork Mon Oct 9 12:39:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Gray X-Patchwork-Id: 823230 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 3y9fw274ZMz9s83 for ; Mon, 9 Oct 2017 23:40:02 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 837D2C21DD7; Mon, 9 Oct 2017 12:39:59 +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=none 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 1CEEBC21CB1; Mon, 9 Oct 2017 12:39:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E1C81C21CB1; Mon, 9 Oct 2017 12:39:55 +0000 (UTC) Received: from lechuck.jsg.id.au (jsg.id.au [210.15.216.215]) by lists.denx.de (Postfix) with ESMTPS id 588B4C21C57 for ; Mon, 9 Oct 2017 12:39:53 +0000 (UTC) Received: from largo.jsg.id.au (largo.jsg.id.au [192.168.1.43]) by lechuck.jsg.id.au (OpenSMTPD) with ESMTP id 74243102; Mon, 9 Oct 2017 23:39:50 +1100 (AEDT) Received: from largo.jsg.id.au (localhost [127.0.0.1]) by largo.jsg.id.au (OpenSMTPD) with ESMTP id 97adf48e; Mon, 9 Oct 2017 23:39:50 +1100 (AEDT) From: Jonathan Gray To: u-boot@lists.denx.de Date: Mon, 9 Oct 2017 23:39:50 +1100 Message-Id: <20171009123950.94375-1-jsg@jsg.id.au> X-Mailer: git-send-email 2.12.2 Cc: trini@konsulko.com Subject: [U-Boot] [PATCH] fs/fat: fix unaligned access regression 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" Since 2460098cffacd18729262e3ed36656e6943783ed (fs/fat: Reduce stack usage) Trying to load a file off a FAT fs on i.MX 6 based CuBox-i4Pro fails: switch to partitions #0, OK mmc0 is current device Scanning mmc 0:1... CACHE: Misaligned operation at range [8f89da30, 8f89e230] CACHE: Misaligned operation at range [8f89da30, 8f89e230] ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x8f89da30 ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x8f89e230 CACHE: Misaligned operation at range [8f89da30, 8f89e230] CACHE: Misaligned operation at range [8f89da30, 8f89e230] ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x8f89da30 ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x8f89e230 CACHE: Misaligned operation at range [8f89dca0, 8f89e4a0] CACHE: Misaligned operation at range [8f89dca0, 8f89e4a0] CACHE: Misaligned operation at range [8f89dca0, 8f89e4a0] CACHE: Misaligned operation at range [8f89dca0, 8f89e4a0] CACHE: Misaligned operation at range [8f89dc68, 8f89e468] CACHE: Misaligned operation at range [8f89dc68, 8f89e468] ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x8f89dc68 ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x8f89e468 ... Switching the malloc() calls to malloc_cache_aligned() avoids the alignment errors and allows booting to continue. Signed-off-by: Jonathan Gray --- fs/fat/fat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 3d3e17e8fa..d299f317a9 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1038,7 +1038,7 @@ int fat_exists(const char *filename) fat_itr *itr; int ret; - itr = malloc(sizeof(fat_itr)); + itr = malloc_cache_aligned(sizeof(fat_itr)); ret = fat_itr_root(itr, &fsdata); if (ret) return 0; @@ -1055,7 +1055,7 @@ int fat_size(const char *filename, loff_t *size) fat_itr *itr; int ret; - itr = malloc(sizeof(fat_itr)); + itr = malloc_cache_aligned(sizeof(fat_itr)); ret = fat_itr_root(itr, &fsdata); if (ret) return ret; @@ -1089,7 +1089,7 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer, fat_itr *itr; int ret; - itr = malloc(sizeof(fat_itr)); + itr = malloc_cache_aligned(sizeof(fat_itr)); ret = fat_itr_root(itr, &fsdata); if (ret) return ret;