mmc: Read eMMC partition access bits before card reset

Pali Rohár pali at kernel.org
Fri May 5 21:37:10 CEST 2023


On Wednesday 03 May 2023 13:14:56 Tom Rini wrote:
> On Wed, May 03, 2023 at 11:18:39AM +0200, Stefan Roese wrote:
> 
> > Hi Tom,
> > 
> > please pull this next batch of mostly Marvell related patches:
> 
> NAK.  With commit:
> commit 461fa17970de418a93832f734a595031c0b72128
> Author: Pali Rohár <pali at kernel.org>
> Date:   Thu Apr 13 22:57:48 2023 +0200
> 
>     mmc: Read eMMC partition access bits before card reset
>     
>     eMMC specification in section "Access partitions" says that all reset
>     events will restore the access bits in PARTITION_CONFIG CSD register to
>     default User Data Area value (0b000).
>     
>     So read partition access bits from PARTITION_CONFIG CSD register before
>     issuing card reset. This allows SPL/U-Boot to get information which eMMC
>     partition was in use before SPL/U-Boot was booted. For some platforms this
>     is the way how to determinate boot partition from which BootROM loaded SPL.
>     
>     Signed-off-by: Pali Rohár <pali at kernel.org>
> 
> My am335x_evm now fails to boot with:
> 
> U-Boot SPL 2023.07-rc1-00021-g461fa17970de (May 03 2023 - 13:10:10 -0400)
> Trying to boot from MMC1
> omap_hsmmc_send_cmd: timedout waiting on cmd inhibit to clear
> spl: mmc init failed with error: -110
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###
> 
> I can provide more details / test patches as needed.
> 
> -- 
> Tom

I do not know what to do with this... The only idea is to hide this code
behind CONFIG symbol and enable it only for mvebu. For example by this:

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index ac484c73f62d..fe691cd435e7 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -353,6 +353,7 @@ config MVEBU_SPL_BOOT_DEVICE_MMC
 	imply SPL_GPIO
 	imply SPL_LIBDISK_SUPPORT
 	imply SPL_MMC
+	select MMC_ENABLE_PART_ACCESS if SPL_MMC
 	select SUPPORT_EMMC_BOOT if SPL_MMC
 	select SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR if SPL_MMC
 	select SPL_BOOTROM_SUPPORT
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index de01b9687bad..c28598fc295c 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -107,6 +107,16 @@ config MMC_HW_PARTITIONING
 	  This adds a command and an API to do hardware partitioning on eMMC
 	  devices.
 
+config MMC_ENABLE_PART_ACCESS
+	bool "Support for MMC partition access bits"
+	help
+	  Read partition access bits from partition config register before card reset command
+	  because these bits are reset to default value (User Data Area) during card reset.
+	  This allows us to preserve original value of partition access bits used by the code
+	  which loaded us (for example BootROM) and use it for board specific boot purposes.
+	  .
+	  This is required when U-Boot is using EXT_CSD_EXTRACT_PARTITION_ACCESS macro.
+
 config SUPPORT_EMMC_RPMB
 	bool "Support eMMC replay protected memory block (RPMB)"
 	imply CMD_MMC_RPMB
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 9915610d82b1..fa3c4d1937c1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2864,6 +2864,7 @@ int mmc_get_op_cond(struct mmc *mmc, bool quiet)
 retry:
 	mmc_set_initial_state(mmc);
 
+#ifdef CONFIG_MMC_ENABLE_PART_ACCESS
 	/*
 	 * Read partition access bits from partition config register before card reset command
 	 * because these bits are reset to default value (User Data Area) during card reset.
@@ -2878,6 +2879,7 @@ retry:
 		     ext_csd[EXT_CSD_BOOT_MULT]))
 			mmc->part_config = ext_csd[EXT_CSD_PART_CONF] & PART_ACCESS_MASK;
 	}
+#endif
 
 	/* Reset the Card */
 	err = mmc_go_idle(mmc);



More information about the U-Boot mailing list