From patchwork Fri Nov 24 08:54:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 840988 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=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="x/vDYkEI"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yjqlG4z5gz9sQl for ; Fri, 24 Nov 2017 19:55:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 470BCC21DAB; Fri, 24 Nov 2017 08:54:57 +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, T_DKIM_INVALID 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 DDE41C21DA2; Fri, 24 Nov 2017 08:54:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 39920C21DA2; Fri, 24 Nov 2017 08:54:53 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id D1462C21D99 for ; Fri, 24 Nov 2017 08:54:52 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id r68so21077326wmr.3 for ; Fri, 24 Nov 2017 00:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=22egk3/srZ+uKA/lnaQdRFWf1iv2ylDE77xesOfSf8I=; b=x/vDYkEIA6kALIT7sa5RQvH4QfjVZzds66BcH1Unzv/RK+S7yGanZktWs5tYYFT3MN jpmT6RRvP+HSj/K+X8UGSs9W59AZfmvDB4lhw+XCWLJFw8IE9r4wr0yj3ogSf1hhxwbZ 1jH/Kyf7MEcR/8rFj21CjzwZZCx2mOhupkVjOhr9YSa0eAVoxGTvSMKGBPXvqYEs5kzZ m3AuxnW7boFI+I56fSdPh9oFCHjh/LnpiHPXQMHVxhaEHb644Je4tOaWdwCgxuOFHsWr 0CiD5DxevT4gHzfK06gbvY8amn+d1/W7yWwvDS73/xC5ftbDGjGg3iawbrt9woGZ2Qul y7Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=22egk3/srZ+uKA/lnaQdRFWf1iv2ylDE77xesOfSf8I=; b=Xp5heoq9O01O/nFPT+ydQjVl79WR59HHwGnlPCd3B1/QmFaie+02fVoJuXsmHBsCJW 4Vdy/RRc8o62sfACYft+xfRN5TKKn+FlKhnnmsVOgCXr9S/zZKsGuk0WMA7G1NxxsQL7 CbgcH4FpJMsjslEFxzsFxl9S9gHnfajY9xWrmrvptfDDxe8y0QiYBIoWOQAtdi2VUTmF yWExRRp6rMJtR39qA3FLLNqgf2Qg/5brhIzldrKin5dU1P4qKuGVwy5IoANuMuHgSa5u PNer8lcQklGg7DCwDdx3Bn3cp3hJKbuxISwbg3GIsRZeSpBWMvpnyv1h1lliNCrkHZ1n yImA== X-Gm-Message-State: AJaThX595pzJmpwgi6NJCzMZD+jMyWi5zdIIdWjVBxKyE9lPu7PDIfOw PhmmQF8564MIZQ0a42VncIA5JQ== X-Google-Smtp-Source: AGs4zMZDRqK0tJID9Jjtn+onqrgSLE3OaWS4eNumZO72dgqjMYu3vYypnPsOa1Tjq5831IbRIWcazQ== X-Received: by 10.28.138.12 with SMTP id m12mr10165559wmd.134.1511513692351; Fri, 24 Nov 2017 00:54:52 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 69sm6881934wmp.37.2017.11.24.00.54.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Nov 2017 00:54:51 -0800 (PST) From: Neil Armstrong To: trini@konsulko.com Date: Fri, 24 Nov 2017 09:54:41 +0100 Message-Id: <1511513681-12636-1-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 Cc: Fabio Estevam , u-boot@lists.denx.de Subject: [U-Boot] [PATCH] fat: Use cache aligned buffers for fat_opendir 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 "fatls" command on machine with cache enabled (ex i.MX6Q) : => fatls mmc 0:1 CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8] CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8] ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x4f59dfc8 ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x4f59e7c8 CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8] CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8] ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x4f59dfc8 ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x4f59e7c8 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. Fixes: 09fa964bba80 ("fs/fat: Fix 'CACHE: Misaligned operation at range' warnings") Suggested-by: Lukasz Majewski Signed-off-by: Neil Armstrong Reviewed-by: Lukasz Majewski Reviewed-by: Fabio Estevam --- fs/fat/fat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 7fe7843..d16883f 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1149,11 +1149,13 @@ typedef struct { int fat_opendir(const char *filename, struct fs_dir_stream **dirsp) { - fat_dir *dir = calloc(1, sizeof(*dir)); + fat_dir *dir; int ret; + dir = malloc_cache_aligned(sizeof(*dir)); if (!dir) return -ENOMEM; + memset(dir, 0, sizeof(*dir)); ret = fat_itr_root(&dir->itr, &dir->fsdata); if (ret)