Skip to contentSkip to conversation

mmc: Do not read eMMC partition access bits by default on OMAP2PLUS and BCM283X

PATCH In review Pali Rohár 2 participants 3 messages May 16, 2023 – Jun 14, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: Do not read eMMC partition access bits by default on OMAP2PLUS and BCM283X

OMAP2PLUS and BCM283X mmc controllers do not work correctly with new emmc code which reads partition access bits prior mmc controller reset.

So introduce a new config option MMC_ENABLE_PART_ACCESS, which is by default disabled for ARCH_OMAP2PLUS and ARCH_BCM283X; and selected for 32-bit mvebu mmc booting (which requires it).

---
 arch/arm/mach-mvebu/Kconfig |  1 +
 drivers/mmc/Kconfig         | 12 ++++++++++++
 drivers/mmc/mmc.c           |  2 ++
 3 files changed, 15 insertions(+)
arch/arm/mach-mvebu/Kconfig +1 -0
index ac484c73f62d..fe691cd435e7 100644
@@ -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
drivers/mmc/Kconfig +12 -0
index de01b9687bad..ea50dfdb62c5 100644
@@ -107,6 +107,18 @@ 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"
+	default n if ARCH_OMAP2PLUS || ARCH_BCM283X
+	default y
+	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
drivers/mmc/mmc.c +2 -0
index 9915610d82b1..fa3c4d1937c1 100644
@@ -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);
Signature · 1 line
2.20.1
#1 lore raw

Ping, what to do with this patch?
It is without any response too and is a is fix for this reported issue:
https://lore.kernel.org/u-boot/20230503171456.GF1134230@bill-the-cat/

Quoted 72 lines · On Tuesday 16 May 2023 20:49:43 Pali Rohár wrote:

OMAP2PLUS and BCM283X mmc controllers do not work correctly with new emmc code which reads partition access bits prior mmc controller reset.

So introduce a new config option MMC_ENABLE_PART_ACCESS, which is by default disabled for ARCH_OMAP2PLUS and ARCH_BCM283X; and selected for 32-bit mvebu mmc booting (which requires it).

---
 arch/arm/mach-mvebu/Kconfig |  1 +
 drivers/mmc/Kconfig         | 12 ++++++++++++
 drivers/mmc/mmc.c           |  2 ++
 3 files changed, 15 insertions(+)
arch/arm/mach-mvebu/Kconfig +1 -0
index ac484c73f62d..fe691cd435e7 100644
@@ -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
drivers/mmc/Kconfig +12 -0
index de01b9687bad..ea50dfdb62c5 100644
@@ -107,6 +107,18 @@ 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"
+	default n if ARCH_OMAP2PLUS || ARCH_BCM283X
+	default y
+	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
drivers/mmc/mmc.c +2 -0
index 9915610d82b1..fa3c4d1937c1 100644
@@ -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);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

OMAP2PLUS and BCM283X mmc controllers do not work correctly with new emmc code which reads partition access bits prior mmc controller reset.

So introduce a new config option MMC_ENABLE_PART_ACCESS, which is by default disabled for ARCH_OMAP2PLUS and ARCH_BCM283X; and selected for 32-bit mvebu mmc booting (which requires it).

Looks good to me.

I expect Jaehoon will handle this patch.

Regards,
Peng.

Quoted 61 lines
---
  arch/arm/mach-mvebu/Kconfig |  1 +
  drivers/mmc/Kconfig         | 12 ++++++++++++
  drivers/mmc/mmc.c           |  2 ++
  3 files changed, 15 insertions(+)
arch/arm/mach-mvebu/Kconfig +1 -0
index ac484c73f62d..fe691cd435e7 100644
@@ -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
drivers/mmc/Kconfig +12 -0
index de01b9687bad..ea50dfdb62c5 100644
@@ -107,6 +107,18 @@ 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"
+	default n if ARCH_OMAP2PLUS || ARCH_BCM283X
+	default y
+	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
drivers/mmc/mmc.c +2 -0
index 9915610d82b1..fa3c4d1937c1 100644
@@ -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);