From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1CD6C433EF for ; Wed, 12 Jan 2022 08:08:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 450A580F90; Wed, 12 Jan 2022 09:08:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="Q/vu/9yx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2524E83102; Wed, 12 Jan 2022 09:08:39 +0100 (CET) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5115B80394 for ; Wed, 12 Jan 2022 09:08:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mkorpershoek@baylibre.com Received: by mail-wr1-x433.google.com with SMTP id q8so2597306wra.12 for ; Wed, 12 Jan 2022 00:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=v4YrvekhiAUDLBod0JS+FVDWLQZh4sABV0eHrkH1p0I=; b=Q/vu/9yxOVATrloZVb5W6ekrsfCZtu6YqGpdDG9qGiy2pM/w9VahBloFC0ZDtgTZCA AKwwEZUHPUrVk/bqetkVaicn1NdSoO037ZZsyZaD6Zf4BqsR5lW4d6F10gcP6P4O8qOX v67mjnsz6A2NV5OPSpAUXX46Rv8d3+r3MnDHlLHpt/hbYdOJsdghczSP4Ft23NtRQ+sb WNAm/jhwhQdpbEnMH+vWv7AN+inHuIVXpSnJ79ZI45S02+fWUc5OrIUk4L60pH3VXOsW PEhx0Ic79aWItJzPyy0kur0RRkSiMV7UllPYKuJ3oZClxdvvyRx9pCOFqhxlqNh54irz l9NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=v4YrvekhiAUDLBod0JS+FVDWLQZh4sABV0eHrkH1p0I=; b=tT1yzGk+CnrIjyx3QqlWpgGm47dwpvT6mQ3S4ug6H4KVnmPxJQZeOnC51bYhXBzJ4c CLXVStD7PpHRP6pHrx3BtajLQLnz3w4TCqOnQUgASAnKnVQyWbnhUkzgw0l0D9bREYlc PqVCRx1RdVQr/7mfsF9mA6gCOqrkZBZnMN6KoJnqjaDzHzKkE8NizdiB6GhkC+pWbK+h UN2jldvD4+pN32skgEWT4d6M60FCSk4BKniaYfVtIUXXYrUVHm2ZvHo7lBA6pJeShLUj 1lY8/BQQGbUcXOyfN1n87nKpDwcKnidW634Ma78LOJmwOUk6GQTVl2+crYOmlmbvKHUa W8sw== X-Gm-Message-State: AOAM5302elHiZ1ehVV9ikcpLbIHFNXS/2uw40DJV+YRo713gwJorj/ER 5Xp0fEAB3tIKAMEwilzGL+FnwQ== X-Google-Smtp-Source: ABdhPJyU4gHHFM0BF3hdQhBpVGYsmJhiuqZCdojC+nPHtwpLLtg3WTwDx3QxRn018fk61SojeX7udA== X-Received: by 2002:a05:6000:c4:: with SMTP id q4mr6996022wrx.131.1641974915776; Wed, 12 Jan 2022 00:08:35 -0800 (PST) Received: from localhost ([2a01:cb19:826e:8e00:3dc1:3ded:30c3:9d14]) by smtp.gmail.com with ESMTPSA id g84sm3561957wme.7.2022.01.12.00.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 00:08:35 -0800 (PST) From: Mattijs Korpershoek To: Gary Bisson , u-boot@lists.denx.de Cc: roman.kovalivskyi@globallogic.com, erosca@de.adit-jv.com, Gary Bisson Subject: Re: [PATCH] cmd: bcb: fix bcb struct alignment issue In-Reply-To: <20220111170606.2042950-1-gary.bisson@boundarydevices.com> References: <20220111170606.2042950-1-gary.bisson@boundarydevices.com> Date: Wed, 12 Jan 2022 09:08:34 +0100 Message-ID: <87wnj5l6kd.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain 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.2 at phobos.denx.de X-Virus-Status: Clean Hi Gary, Thank you for your patch. Gary Bisson writes: > Without this patch the bcb struct could be located at an odd address > which resulted in data not being copied to the buffer. > > Here was the repro steps (from Mattijs): > => mmc dev 1 > => bcb load 1 misc > => bcb dump command > 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > => part start mmc 1 misc misc_start > => mmc read ${loadaddr} ${misc_start} 4 > => bcb load 1 misc > => bcb dump command > 00000000: 62 6f 6f 74 6f 6e 63 65 2d 62 6f 6f 74 6c 6f 61 > 00000010: 64 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 > > This behavior was observed on an Amlogic A311D (ARM64) platform with a > recent GCC toolchain (11.2.0) but is most likely affecting other > platforms. > > To avoid issues the structure is aligned on DMA minimum alignment value > as it is passed directly to the read function. > > Signed-off-by: Gary Bisson > --- > cmd/bcb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Tested-by: Mattijs Korpershoek # on khadas vim3 > > diff --git a/cmd/bcb.c b/cmd/bcb.c > index 6b6f1e9a2f1..92f4d27990d 100644 > --- a/cmd/bcb.c > +++ b/cmd/bcb.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > enum bcb_cmd { > BCB_CMD_LOAD, > @@ -24,7 +25,7 @@ enum bcb_cmd { > > static int bcb_dev = -1; > static int bcb_part = -1; > -static struct bootloader_message bcb = { { 0 } }; > +static struct bootloader_message bcb __aligned(ARCH_DMA_MINALIGN) = { { 0 } }; > > static int bcb_cmd_get(char *cmd) > { > -- > 2.34.1