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 C1A9EEB64D9 for ; Thu, 6 Jul 2023 17:37:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65A0E86139; Thu, 6 Jul 2023 19:36:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.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=kernel.org header.i=@kernel.org header.b="qz+neddi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8968686308; Thu, 6 Jul 2023 19:36:57 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 BBF47846B6 for ; Thu, 6 Jul 2023 19:36:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D48A060B9E; Thu, 6 Jul 2023 17:36:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E900EC433C7; Thu, 6 Jul 2023 17:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688665012; bh=uxX6QAVecBxKQWuKIeiE6xMUkOxNjlIqSaNx5VpXEA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qz+neddi24Vm70+EReoo4XjpLw5NtyRPQxtuVG0PVZm7T4DNoVRh/EaR1EobPAvh3 Vq562SIJFTuK8HOjwWo7K6jvjQstcxmEIwB8vJCaCf/OmSgS1jCy/OihsuGc7IxjPK SJ9VdOXGATTcBvPaW7kVR2p0PXhKeaoWQxU6yivuh36X9mvAbjQbFxSMuWSl5P15FA eQWMoR9EDnZDJXz0TdQTNfMIHn2u2FD++oDlOgVTSvH7sDF4rVxD6VfvwyqlZOhucm HjaElho2Ttceg0+u0BjdaT5gn8FbpC52nBnbMdpPoYMFQgcrhJ0dQ/aPCjtxlCKWIw 8zsgFj0l61C3g== Received: by pali.im (Postfix) id 1E7D7970; Thu, 6 Jul 2023 19:36:49 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jaehoon Chung Cc: u-boot@lists.denx.de Subject: [PATCH v2 u-boot] mmc: spl: Make partition choice in default_spl_mmc_emmc_boot_partition() more explicit Date: Thu, 6 Jul 2023 19:35:02 +0200 Message-Id: <20230706173502.2796-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230413211057.10975-2-pali@kernel.org> References: <20230413211057.10975-2-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 To make eMMC partition choosing in default_spl_mmc_emmc_boot_partition() function better understandable, rewrite it via explicit switch-case code pattern. Also add a warning when eMMC EXT_CSD[179] register is configured by user to value which is not suitable for eMMC booting and SPL do not know how to interpret it. Note that when booting from eMMC device via EXT_CSD[179] register is explicitly disabled then SPL still loads and boots from this eMMC device from User Area partition. This behavior was not changed in this commit and should be revisited in the future. Signed-off-by: Pali Rohár --- Changes in v2: * Disable showing warning on sama5d2_xplained due to size restrictions --- This patch depends on another patch: mmc: spl: Add comments for default_spl_mmc_emmc_boot_partition() https://patchwork.ozlabs.org/project/uboot/patch/20230404202805.8523-1-pali@kernel.org/ --- common/spl/Kconfig | 7 +++++++ common/spl/spl_mmc.c | 46 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 865571d4579c..0574d22b3b25 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -855,6 +855,13 @@ config SPL_MMC_WRITE help Enable write access to MMC and SD Cards in SPL +config SPL_MMC_WARNINGS + bool "Print MMC warnings" + depends on SPL_MMC + default y if !TARGET_SAMA5D2_XPLAINED + help + Print SPL MMC warnings. You can disable this option to reduce SPL size. + config SPL_MPC8XXX_INIT_DDR bool "Support MPC8XXX DDR init" diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index f7a42a11477d..ec424ceded0e 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -408,15 +408,45 @@ int default_spl_mmc_emmc_boot_partition(struct mmc *mmc) * * Note: See difference between EXT_CSD_EXTRACT_PARTITION_ACCESS * and EXT_CSD_EXTRACT_BOOT_PART, specially about User area value. - * - * FIXME: When booting from this eMMC device is explicitly - * disabled then we use User area for booting. This is incorrect. - * Probably we should skip this eMMC device and select the next - * one for booting. Or at least throw warning about this fallback. */ - part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); - if (part == 7) - part = 0; + if (mmc->part_config == MMCPART_NOAVAILABLE) + part = 0; /* If partitions are not supported then we have only User Area partition */ + else { + switch(EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) { + case 0: /* Booting from this eMMC device is disabled */ +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +#ifdef CONFIG_SPL_MMC_WARNINGS + puts("spl: WARNING: Booting from this eMMC device is disabled in EXT_CSD[179] register\n"); + puts("spl: WARNING: Continuing anyway and selecting User Area partition for booting\n"); +#else + puts("spl: mmc: fallback to user area\n"); +#endif +#endif + /* FIXME: This is incorrect and probably we should select next eMMC device for booting */ + part = 0; + break; + case 1: /* Boot partition 1 is used for booting */ + part = 1; + break; + case 2: /* Boot partition 2 is used for booting */ + part = 2; + break; + case 7: /* User area is used for booting */ + part = 0; + break; + default: /* Other values are reserved */ +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT +#ifdef CONFIG_SPL_MMC_WARNINGS + puts("spl: WARNING: EXT_CSD[179] register is configured to boot from Reserved value\n"); + puts("spl: WARNING: Selecting User Area partition for booting\n"); +#else + puts("spl: mmc: fallback to user area\n"); +#endif +#endif + part = 0; + break; + } + } #endif return part; } -- 2.20.1