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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55595C433EF for ; Wed, 29 Sep 2021 13:08:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BE99661407 for ; Wed, 29 Sep 2021 13:08:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BE99661407 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5EE9E80612; Wed, 29 Sep 2021 15:08:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="dO5E2L/p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C042383216; Wed, 29 Sep 2021 15:08:14 +0200 (CEST) Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) (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 98E178022E for ; Wed, 29 Sep 2021 15:08:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52c.google.com with SMTP id v18so8296916edc.11 for ; Wed, 29 Sep 2021 06:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Yg9LNFlMwS7pH2m6Tim/mhoA0Zmal3lCK/GSvJN4ur8=; b=dO5E2L/pD452Cmglk7xMBAhVGybXf0rwp7OrJiGDJPaUfvFGZtouG4+0h5X27iYhQk i5kAJIcFbewUZAFa1NsJ3aYKzz47SQtbJ7B/FKjjJa/p9Qho/KmBVJ7MKVgHM3FIPhNp vKTYhkAscmO6JUAFhUPeCWQWXQFVFccD2dTPCiNf+hdZbyUMo5EAz2ICP8GH8FyuGbP/ 6S/pYnTfaaUyIgW6gq9Rkm3LTMrUyqxrkQf3gDvkK551hHITNA30dQY60OaeTZykFynP zWoC/j3dlZMnPSXSlwK3N3Zy208FCA+Ls1pfHmfCcH1ShWkbA4Du3DsdnLvSi65kSSHs vrVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Yg9LNFlMwS7pH2m6Tim/mhoA0Zmal3lCK/GSvJN4ur8=; b=pcpZR5iqI1JDvg3Ay7idmqrAQD+lWfdvD4UP5npa2qCTZnDcPUuclFygODCdVkdjUM AziOzOAl81MCpEFwZvHbVlwxBGzvNPgc4GY4UXa9xprE16gZMRKCzcaC1N97r0OE7oCf 79y5p/PrUg+yAm60TpYVfDuisT3FK9gsH/3+qCIkaPwYkfZ2ANa2ZprLkOLInCcCRu90 9iYViTTaRR8EO6op5PxiOBhGeL16XTnEVCaHLhcYSHIzilMElrbDRJ+ChT14F7IJCmQz YVNSQz9pCDegl/Jc3epZKvqIMiL3l86lUM3Y4jmTo0GBihKWJjzQwk2jkH7XggA4llfT EZ7A== X-Gm-Message-State: AOAM5322mrX8HDRhjOt+UNXa3qKxCQI4mSRkIEBCK3XT40Sb3lfXfkso afT9y//BKkSv++6eU/tJ4v7boQ== X-Google-Smtp-Source: ABdhPJyE23+Bkz7sR9ue9kKDHFPLEPbqNyhLxqv1GJde9tOAuHYJ8VO/wcF0EAUl95LOubW2bs9cmQ== X-Received: by 2002:a50:e009:: with SMTP id e9mr14617092edl.254.1632920869938; Wed, 29 Sep 2021 06:07:49 -0700 (PDT) Received: from apalos.home (ppp-94-66-220-209.home.otenet.gr. [94.66.220.209]) by smtp.gmail.com with ESMTPSA id f10sm1566470edu.70.2021.09.29.06.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 06:07:49 -0700 (PDT) Date: Wed, 29 Sep 2021 16:07:47 +0300 From: Ilias Apalodimas To: Bin Meng Cc: Zong Li , Leo Yu-Chi Liang , Rick Chen , u-boot@lists.denx.de Subject: Re: [PATCH v2] board: sifive: Fix a potential build warning in board_fdt_blob_setup() Message-ID: References: <20210911143123.10423-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210911143123.10423-1-bmeng.cn@gmail.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Bin There's a similar discussion in a cleanup series I've sent [1] On Sat, Sep 11, 2021 at 10:31:23PM +0800, Bin Meng wrote: > Commit 47d73ba4f4a4 ("board: sifive: overwrite board_fdt_blob_setup in u-boot proper") > added a board-specific implementation of board_fdt_blob_setup() which > takes a pointer as the return value, but it does not return anything > if CONFIG_OF_SEPARATE is not enabled. This will cause a build warning > seen when testing booting S-mode U-Boot directly from QEMU, per the > instructions in [1]: It's not only a build warning, you don't even have a DTB to begin with. > > board/sifive/unleashed/unleashed.c: In function ‘board_fdt_blob_setup’: > board/sifive/unleashed/unleashed.c:125:1: warning: control reaches end of non-void function [-Wreturn-type] > > Return &_end as the default case. > > [1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot > > Signed-off-by: Bin Meng > > --- > > Changes in v2: > - Correct the commit title > > board/sifive/unleashed/unleashed.c | 4 ++-- > board/sifive/unmatched/unmatched.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c > index 8cd514df30..33baeda986 100644 > --- a/board/sifive/unleashed/unleashed.c > +++ b/board/sifive/unleashed/unleashed.c > @@ -119,9 +119,9 @@ void *board_fdt_blob_setup(void) > if (IS_ENABLED(CONFIG_OF_SEPARATE)) { > if (gd->arch.firmware_fdt_addr) > return (ulong *)gd->arch.firmware_fdt_addr; > - else > - return (ulong *)&_end; > } > + > + return (ulong *)&_end; > } > > int board_init(void) > diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c > index d90b252bae..8773b660fa 100644 > --- a/board/sifive/unmatched/unmatched.c > +++ b/board/sifive/unmatched/unmatched.c > @@ -16,9 +16,9 @@ void *board_fdt_blob_setup(void) > if (IS_ENABLED(CONFIG_OF_SEPARATE)) { > if (gd->arch.firmware_fdt_addr) > return (ulong *)gd->arch.firmware_fdt_addr; > - else > - return (ulong *)&_end; > } > + > + return (ulong *)&_end; is _end correct here? Doesn't the placement depend on CONFIG_SPL_BUILD and CONFIG_SPL_SEPARATE_BSS? To sum up the other thread I think the overall approach here is not ideal. OF_SEPARATE is used in conjunction with SPL in these boards. What happens (assuming I didn't miss anything), is that SPL passes the DTB to OpenSBI, which in it turn copies to a1 before invoking U-Boot. But we are better of with stricter rules for DTB. - OF_SEPARATE means: I'll read the DTB from the U-Boot binary. - OF_BOARD: The board will somehow provide it. So II think the patch should look something along the lines of: if (IS_ENABLED(CONFIG_OF_SEPARATE)) { #ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) fdt_blob = (void *)&_image_binary_end; else fdt_blob = (void *)&__bss_end; #else /* FDT is at end of image */ fdt_blob = (void *)&_end; } if (IS_ENABLED(CONFIG_OF_BOARD)) { fdt_blob = (void *)gd->arch.firmware_fdt_addr; } > } > > int board_init(void) > -- > 2.25.1 > [1] https://lore.kernel.org/u-boot/YVRiVFP+sYGZhJiY@apalos.home/ Cheers /Ilias