From patchwork Thu Nov 7 15:01:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 2008176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=pey01pzs; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=xH3ebjF4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xkwmy3NSjz1xy0 for ; Fri, 8 Nov 2024 08:53:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7CAD1881FD; Thu, 7 Nov 2024 22:53:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.b="pey01pzs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xH3ebjF4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 70C12892DB; Thu, 7 Nov 2024 16:01:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 719B389246 for ; Thu, 7 Nov 2024 16:01:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=namcao@linutronix.de From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730991677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JeLDy8qnfae8A7GHch+U1dALPh9WBs0FUsOu7zXDJJo=; b=pey01pzsn/KKEcm5MPLl3Xv2k21zQnxaYVFz8huKxvIZWURbgZaGh1HjqLGW+G7KI6dwHh knbXCgmm9TYNVxbm85nULWAZJGVaLFC2MuPLN+nHA+AmSPFZk6ub4FBq4QY9fJik9BmJVY 8ZLY0Sh1nYGCXCtXzEBbcIqttnytaRbhDc4v2JQPWIFBdD2MUmyvgHWlGJucfb4POn0mg4 oMsIVdO7Isu9qcjNRG306hgbav+EJjs6dqKBOYP/hLLiJ56BexrOk0DWRdwUNX77N4xbK6 h7ADx1BMMDsT4JOe5SikSsKJl4LXQkTgWfRLvsAg1aeXx/SpEtErrC33wCK4+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730991677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JeLDy8qnfae8A7GHch+U1dALPh9WBs0FUsOu7zXDJJo=; b=xH3ebjF4HwMdbpFkj3oH1xPgefROs1t2XUMoD8UaDCQvoBDlKatRDg5z6TWVfPbJx7z4uM iJoHsq0bxeJRSQCQ== To: Simon Glass , Tom Rini , Mattijs Korpershoek , Ion Agorria , Svyatoslav Ryhel , Nam Cao , Mayuresh Chitale , Sean Anderson , AKASHI Takahiro , Javier Fernandez Pastrana , u-boot@lists.denx.de Subject: [PATCH v2 0/2] Fix boot failure due to misaligned DMA buffer Date: Thu, 7 Nov 2024 16:01:04 +0100 Message-Id: MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 07 Nov 2024 22:53:17 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi, We observed the following sporadic boot failure while booting from MMC device: => boot CACHE: Misaligned operation at range [9efa25f8, 9efa27f8] CACHE: Misaligned operation at range [9efa25f8, 9efa27f8] CACHE: Misaligned operation at range [9efa25f8, 9efa27f8] CACHE: Misaligned operation at range [9efa25f8, 9efa27f8] ** Booting bootflow 'mmc@2194000.bootdev.part_1' with extlinux Ignoring unknown command: �D���D�� Boot failed (err=-14) The reason is because while allocating buffer to read a file from MMC, alignment of 1 byte is used. Thus, the buffer doesn't work for performing DMA, and garbage data is read. While looking at this issue, I also noticed that if no alignment specified (align=0) then fs_read_alloc() is documented to use the default. But the default is no alignment. Therefore, other users of fs_read_alloc() which specify align=0 may be broken as well. The first patch changes extlinux_read_bootflow() to use proper buffer alignment for DMA. The second patch changes the default alignment of fs_read_alloc() to be DMA-suitable, to fix other potential bugs. Nam Cao (2): boot: extlinux: Fix unaligned buffer for reading data from file system fs: Use ARCH_DMA_MINALIGN as default alignment for fs_read_alloc() boot/bootmeth_extlinux.c | 3 ++- fs/fs.c | 4 ++++ include/fs.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) Reviewed-by: Tony Dinh