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 5D542C433F5 for ; Sun, 6 Feb 2022 10:01:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9066483B84; Sun, 6 Feb 2022 11:00:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.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=canonical.com header.i=@canonical.com header.b="NN+N0oJz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A281783678; Sun, 6 Feb 2022 11:00:57 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 E769A83678 for ; Sun, 6 Feb 2022 11:00:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 2BD693F1A1 for ; Sun, 6 Feb 2022 10:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1644141651; bh=hE6Jenf+pXVMh8KjdQjwx0/hmPCu1IAdZzuhOQz6AVI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NN+N0oJzJ/hN8uQtKC/jrmcCUKOI8HRoc+q6ZRggyJ6yHoyCJeDh1BUWaarAp6Jbi y82MJhWrWI4YyD56XhSJpv2IwWqzC5iRyDlt2mbX+RALqs57XY/sXQnmKwEKGMWY+e 6Gs4Coj7aPrE5LBG0GLhOlhO/I7yUrCX98XIrWJESQl10ao80/SZFDExo57bHiRwjH YE+AX3AjzmrxCkIZoN8u+XxOSvL1qvsfvybIO9IjkOMOXErZbcdCfWCZLw6D5xJWfE PnFLkUsw3D/s47014Vt+lPaHufGi9Sz6SjFF931K0Q7MJDfqw9PKxRxMH5VcLrcxtP 016D6t1pLhDEg== Received: by mail-wm1-f70.google.com with SMTP id r205-20020a1c44d6000000b0037bb51b549aso1833359wma.4 for ; Sun, 06 Feb 2022 02:00:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=hE6Jenf+pXVMh8KjdQjwx0/hmPCu1IAdZzuhOQz6AVI=; b=yi2hkeLnoSeV+xV1d+Ny2jgjNAagpDvdKZVBH03RPitDS6rMhl6mOO8jBdxSj51BtA wKL8/k3mt8ofuEDuUVDAQycXwdIRu4JRRaC0KZiOl1HPw8MGCO6tMWR1P9BKtPbIjHjA dMOVoLhl90i7kC3rAYVuCVs6WFmmhnHDRILUJeuiW0/mF8IPRKvCCnTljT912fQk3xKR +ht4lcAn/5hbpq0c7c72giTEla09gm47NfG5T77Hu7gWZoCxOmhQoYv+NVxc3AIeEEDw Hrd3k16N1zYbvqH0MCwy8ajiO7cmbUl9JKfVmO9M5K2MPcpR8qrs7277Pb79WgkhasRs ssFA== X-Gm-Message-State: AOAM530kLE5xZgoPuvgCiA+LXqjFpl8yjxIKP2ZMLhAeWT6LB2adHhHf Y5+CeALY3I/dn1TSw0ogWb9f6dahFToPwZlECEm6P/YeAqmx6Or/23QSOqas7wT9B8082Bpp67g JO2doX+dT5uaA40zbz3T4rMUB9sfDnGM= X-Received: by 2002:a5d:4ad1:: with SMTP id y17mr4018753wrs.289.1644141650735; Sun, 06 Feb 2022 02:00:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/auOnF6TLgJYwbuk3HSjXTOKyuc3WEHeN7LMXleLgbsLpamcN0fspZizfKOgxOsUIOq9fDA== X-Received: by 2002:a5d:4ad1:: with SMTP id y17mr4018733wrs.289.1644141650534; Sun, 06 Feb 2022 02:00:50 -0800 (PST) Received: from [192.168.123.94] (ip-088-152-144-107.um26.pools.vodafone-ip.de. [88.152.144.107]) by smtp.gmail.com with ESMTPSA id f12sm6863355wrs.1.2022.02.06.02.00.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Feb 2022 02:00:49 -0800 (PST) Message-ID: Date: Sun, 6 Feb 2022 11:00:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v2 3/4] riscv: qemu: Implement is_flash_available() for MTD NOR Content-Language: en-US To: Anup Patel Cc: Atish Patra , Alistair Francis , Anup Patel , U-Boot Mailing List , Rick Chen , Bin Meng References: <20220127061110.721103-1-apatel@ventanamicro.com> <20220127061110.721103-4-apatel@ventanamicro.com> From: Heinrich Schuchardt In-Reply-To: <20220127061110.721103-4-apatel@ventanamicro.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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.5 at phobos.denx.de X-Virus-Status: Clean On 1/27/22 07:11, Anup Patel wrote: > Currently, if MTD NOR is enabled then U-Boot tries to issue flash > commands even when CFI flash DT node is not present. This causes > access fault on RISC-V emulators or ISS which do not emulate CFI > flash. To handle this issue, we implement is_flash_available() for > qemu-riscv board which will return 1 only if CFI flash DT node is > present. > > Fixes: d248627f9d42 ("riscv: qemu: Enable MTD NOR flash support") > Signed-off-by: Anup Patel > Reviewed-by: Rick Chen > --- > board/emulation/qemu-riscv/qemu-riscv.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c > index b0d9dd59b1..ae3b7a3295 100644 > --- a/board/emulation/qemu-riscv/qemu-riscv.c > +++ b/board/emulation/qemu-riscv/qemu-riscv.c > @@ -5,6 +5,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -16,6 +17,17 @@ > > DECLARE_GLOBAL_DATA_PTR; > > +#if IS_ENABLED(CONFIG_MTD_NOR_FLASH) I do not think that we need an #if here. The weak function is only defined and called if CONFIG_MTD_NOR_FLASH=y (cf. common/board_r.c). Without the #if the linker will detect that this function is not needed and will eliminate it if CONFIG_MTD_NOR_FLASH=n. As this ensures that the function is always compiled this is the preferred way of implementation. > +int is_flash_available(void) Currently there is no include defining the is_flash_available(). This needs to be fixed. Best regards Heinrich > +{ > + if (!ofnode_equal(ofnode_by_compatible(ofnode_null(), "cfi-flash"), > + ofnode_null())) > + return 1; > + > + return 0; > +} > +#endif > + > int board_init(void) > { > /*