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 33C32C77B6E for ; Thu, 13 Apr 2023 21:11:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DC8980A0C; Thu, 13 Apr 2023 23:11:50 +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="KkA/dCyV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 91F6085D6B; Thu, 13 Apr 2023 23:11:41 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3748880A0C for ; Thu, 13 Apr 2023 23:11:35 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0368860AB4; Thu, 13 Apr 2023 21:11:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AB89C433EF; Thu, 13 Apr 2023 21:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681420293; bh=Tt0WPFiasMieOO+kr+tLBlWG+M4Ut1/bkXlXxJiYex8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KkA/dCyV4Ch5PwW+GTJ1trk5cjqamW1I+v2XEAqSb1aqZ41CQMG9i24lsFdm6Mgul +BwX1nfBYQcfdYvxmfADNDqeNHxYI3fJRLBksCbcqWCKA95SQ4fctjuTTXtyPWqgs0 fC6VIlFjEJvwZS5WFgti/Peyd4b4JXnTJyTcMo+blBqkLWcpRD0cRbgcjosKgqcSBO D27Oo3A5woWZla4CSTBbBEh0fAzobzBCb5ndzrUn8WQH5lNGi8BW2Y4GfhbxZG2xxV 5n1LO07QvzYuunudiiSMSIPEUtunUJzVgCZ7tsI5As0sspBdEcAKim3vwwWXKGDVAd pEvC3Mjxb/96g== Received: by pali.im (Postfix) id AE4A3788; Thu, 13 Apr 2023 23:11:30 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jaehoon Chung , Peng Fan , Stefan Roese , Simon Glass , Harald Seiler Cc: u-boot@lists.denx.de Subject: [PATCH u-boot 1/4] mmc: spl: Make partition choice in default_spl_mmc_emmc_boot_partition() more explicit Date: Thu, 13 Apr 2023 23:10:54 +0200 Message-Id: <20230413211057.10975-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230413211057.10975-1-pali@kernel.org> References: <20230413211057.10975-1-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 --- 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/spl_mmc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 2426500dbcb9..df20a75efc29 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -408,15 +408,37 @@ 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 + 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"); +#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 + 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"); +#endif + part = 0; + break; + } + } #endif return part; } -- 2.20.1