All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
@ 2026-07-25 18:51 Mayur Kumar
  2026-07-27 16:19 ` Ulf Hansson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mayur Kumar @ 2026-07-25 18:51 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, linux-kernel, Mayur Kumar

ESMT eMMC (SM0000) supports normal TRIM discard, but fails when TRIM
is used to offload WRITE_ZEROES operations.

Add a new card quirk, MMC_QUIRK_BROKEN_WRITE_ZEROES, to prevent setting
max_write_zeroes_sectors during queue setup when this quirk is present.
Apply this fixup to ESMT eMMC devices (CID_MANFID_ESM_MMC 0xEC,
CID 'SM0000').

Signed-off-by: Mayur Kumar <kmayur809@gmail.com>
---
 drivers/mmc/core/card.h   | 1 +
 drivers/mmc/core/queue.c  | 3 ++-
 drivers/mmc/core/quirks.h | 6 ++++++
 include/linux/mmc/card.h  | 1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h
index a7c364d0030..144a8f5e7d2 100644
--- a/drivers/mmc/core/card.h
+++ b/drivers/mmc/core/card.h
@@ -94,6 +94,7 @@ struct mmc_fixup {
 #define CID_MANFID_KINGSTON     0x70
 #define CID_MANFID_HYNIX	0x90
 #define CID_MANFID_KINGSTON_SD	0x9F
+#define CID_MANFID_ESMT_MMC	0xEC
 #define CID_MANFID_NUMONYX	0xFE
 
 #define END_FIXUP { NULL }
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 5d187e063da..3ee640056a5 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -191,7 +191,8 @@ static void mmc_queue_setup_discard(struct mmc_card *card,
 			lim->max_secure_erase_sectors = max_discard;
 	}
 
-	if (mmc_card_can_trim(card) && card->erased_byte == 0)
+	if (mmc_card_can_trim(card) && card->erased_byte == 0 &&
+	    !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))
 		lim->max_write_zeroes_sectors = max_discard;
 
 	/* granularity must not be greater than max. discard */
diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
index ae3ece89d0a..91758fd7fc2 100644
--- a/drivers/mmc/core/quirks.h
+++ b/drivers/mmc/core/quirks.h
@@ -91,6 +91,12 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 	MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
 		  MMC_QUIRK_BLK_NO_CMD23),
 
+	/* SM0000 supports normal TRIM discard but fails when TRIM is
+	 * used to offload WRITE_ZEROES, so we disable it.
+	 */
+	MMC_FIXUP("SM0000", CID_MANFID_ESMT_MMC, 0x0100, add_quirk_mmc,
+		  MMC_QUIRK_BROKEN_WRITE_ZEROES),
+
 	/*
 	 * Some SD cards lockup while using CMD23 multiblock transfers.
 	 */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 9dc4750296a..938a4296b55 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -331,6 +331,7 @@ struct mmc_card {
 #define MMC_QUIRK_NO_UHS_DDR50_TUNING	(1<<18) /* Disable DDR50 tuning */
 #define MMC_QUIRK_BROKEN_MDT    (1<<19) /* Wrong manufacturing year */
 #define MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME	(1<<20) /* Secure erase/trim time is fixed regardless of size */
+#define MMC_QUIRK_BROKEN_WRITE_ZEROES	(1<<21)	/* Broken write zeroes via trim */
 
 	bool			written_flag;	/* Indicates eMMC has been written since power on */
 	bool			reenable_cmdq;	/* Re-enable Command Queue */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
  2026-07-25 18:51 [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC Mayur Kumar
@ 2026-07-27 16:19 ` Ulf Hansson
  2026-08-07 21:47 ` kernel test robot
  2026-08-08 10:56 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2026-07-27 16:19 UTC (permalink / raw)
  To: Mayur Kumar; +Cc: Ulf Hansson, linux-mmc, linux-kernel

On Sat, Jul 25, 2026 at 8:51 PM Mayur Kumar <kmayur809@gmail.com> wrote:
>
> ESMT eMMC (SM0000) supports normal TRIM discard, but fails when TRIM
> is used to offload WRITE_ZEROES operations.

Out of curiosity, how does it fail?

>
> Add a new card quirk, MMC_QUIRK_BROKEN_WRITE_ZEROES, to prevent setting
> max_write_zeroes_sectors during queue setup when this quirk is present.
> Apply this fixup to ESMT eMMC devices (CID_MANFID_ESM_MMC 0xEC,
> CID 'SM0000').
>
> Signed-off-by: Mayur Kumar <kmayur809@gmail.com>
> ---
>  drivers/mmc/core/card.h   | 1 +
>  drivers/mmc/core/queue.c  | 3 ++-
>  drivers/mmc/core/quirks.h | 6 ++++++
>  include/linux/mmc/card.h  | 1 +
>  4 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h
> index a7c364d0030..144a8f5e7d2 100644
> --- a/drivers/mmc/core/card.h
> +++ b/drivers/mmc/core/card.h
> @@ -94,6 +94,7 @@ struct mmc_fixup {
>  #define CID_MANFID_KINGSTON     0x70
>  #define CID_MANFID_HYNIX       0x90
>  #define CID_MANFID_KINGSTON_SD 0x9F
> +#define CID_MANFID_ESMT_MMC    0xEC
>  #define CID_MANFID_NUMONYX     0xFE
>
>  #define END_FIXUP { NULL }
> diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
> index 5d187e063da..3ee640056a5 100644
> --- a/drivers/mmc/core/queue.c
> +++ b/drivers/mmc/core/queue.c
> @@ -191,7 +191,8 @@ static void mmc_queue_setup_discard(struct mmc_card *card,
>                         lim->max_secure_erase_sectors = max_discard;
>         }
>
> -       if (mmc_card_can_trim(card) && card->erased_byte == 0)
> +       if (mmc_card_can_trim(card) && card->erased_byte == 0 &&
> +           !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))

Please add a helper in card.h, similar to the others "mmc_card_broken_*".

>                 lim->max_write_zeroes_sectors = max_discard;
>
>         /* granularity must not be greater than max. discard */
> diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
> index ae3ece89d0a..91758fd7fc2 100644
> --- a/drivers/mmc/core/quirks.h
> +++ b/drivers/mmc/core/quirks.h
> @@ -91,6 +91,12 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
>         MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
>                   MMC_QUIRK_BLK_NO_CMD23),
>
> +       /* SM0000 supports normal TRIM discard but fails when TRIM is
> +        * used to offload WRITE_ZEROES, so we disable it.
> +        */
> +       MMC_FIXUP("SM0000", CID_MANFID_ESMT_MMC, 0x0100, add_quirk_mmc,
> +                 MMC_QUIRK_BROKEN_WRITE_ZEROES),
> +
>         /*
>          * Some SD cards lockup while using CMD23 multiblock transfers.
>          */
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index 9dc4750296a..938a4296b55 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -331,6 +331,7 @@ struct mmc_card {
>  #define MMC_QUIRK_NO_UHS_DDR50_TUNING  (1<<18) /* Disable DDR50 tuning */
>  #define MMC_QUIRK_BROKEN_MDT    (1<<19) /* Wrong manufacturing year */
>  #define MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME (1<<20) /* Secure erase/trim time is fixed regardless of size */
> +#define MMC_QUIRK_BROKEN_WRITE_ZEROES  (1<<21) /* Broken write zeroes via trim */
>
>         bool                    written_flag;   /* Indicates eMMC has been written since power on */
>         bool                    reenable_cmdq;  /* Re-enable Command Queue */
> --
> 2.34.1
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
  2026-07-25 18:51 [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC Mayur Kumar
  2026-07-27 16:19 ` Ulf Hansson
@ 2026-08-07 21:47 ` kernel test robot
  2026-08-08 10:56 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-08-07 21:47 UTC (permalink / raw)
  To: Mayur Kumar, Ulf Hansson
  Cc: oe-kbuild-all, linux-mmc, linux-kernel, Mayur Kumar

Hi Mayur,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.2-rc6 next-20260807]
[cannot apply to ulf-hansson-mmc-mirror/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mayur-Kumar/mmc-core-add-MMC_QUIRK_BROKEN_WRITE_ZEROES-for-ESMT-eMMC/20260807-212705
base:   linus/master
patch link:    https://lore.kernel.org/r/20260725185129.43397-1-kmayur809%40gmail.com
patch subject: [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260808/202608080412.ueBVGtOw-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260808/202608080412.ueBVGtOw-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608080412.ueBVGtOw-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/mmc/core/queue.c: In function 'mmc_queue_setup_discard':
>> drivers/mmc/core/queue.c:195:30: error: 'MMC_QUIRK_BROKEN_WRITE_ZEROS' undeclared (first use in this function); did you mean 'MMC_QUIRK_BROKEN_WRITE_ZEROES'?
     195 |             !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))
         |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                              MMC_QUIRK_BROKEN_WRITE_ZEROES
   drivers/mmc/core/queue.c:195:30: note: each undeclared identifier is reported only once for each function it appears in


vim +195 drivers/mmc/core/queue.c

   176	
   177	static void mmc_queue_setup_discard(struct mmc_card *card,
   178			struct queue_limits *lim)
   179	{
   180		unsigned max_discard;
   181	
   182		max_discard = mmc_calc_max_discard(card);
   183		if (!max_discard)
   184			return;
   185	
   186		lim->max_hw_discard_sectors = max_discard;
   187		if (mmc_card_can_secure_erase_trim(card)) {
   188			if (mmc_card_fixed_secure_erase_trim_time(card))
   189				lim->max_secure_erase_sectors = UINT_MAX >> card->erase_shift;
   190			else
   191				lim->max_secure_erase_sectors = max_discard;
   192		}
   193	
   194		if (mmc_card_can_trim(card) && card->erased_byte == 0 &&
 > 195		    !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))
   196			lim->max_write_zeroes_sectors = max_discard;
   197	
   198		/* granularity must not be greater than max. discard */
   199		if (card->pref_erase > max_discard)
   200			lim->discard_granularity = SECTOR_SIZE;
   201		else
   202			lim->discard_granularity = card->pref_erase << 9;
   203	}
   204	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
  2026-07-25 18:51 [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC Mayur Kumar
  2026-07-27 16:19 ` Ulf Hansson
  2026-08-07 21:47 ` kernel test robot
@ 2026-08-08 10:56 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-08-08 10:56 UTC (permalink / raw)
  To: Mayur Kumar, Ulf Hansson
  Cc: llvm, oe-kbuild-all, linux-mmc, linux-kernel, Mayur Kumar

Hi Mayur,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.2-rc6 next-20260807]
[cannot apply to ulf-hansson-mmc-mirror/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mayur-Kumar/mmc-core-add-MMC_QUIRK_BROKEN_WRITE_ZEROES-for-ESMT-eMMC/20260807-212705
base:   linus/master
patch link:    https://lore.kernel.org/r/20260725185129.43397-1-kmayur809%40gmail.com
patch subject: [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260808/202608081816.H4q7m1Wl-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260808/202608081816.H4q7m1Wl-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608081816.H4q7m1Wl-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/mmc/core/queue.c:195:23: error: use of undeclared identifier 'MMC_QUIRK_BROKEN_WRITE_ZEROS'
     195 |             !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))
         |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 error generated.


vim +/MMC_QUIRK_BROKEN_WRITE_ZEROS +195 drivers/mmc/core/queue.c

   176	
   177	static void mmc_queue_setup_discard(struct mmc_card *card,
   178			struct queue_limits *lim)
   179	{
   180		unsigned max_discard;
   181	
   182		max_discard = mmc_calc_max_discard(card);
   183		if (!max_discard)
   184			return;
   185	
   186		lim->max_hw_discard_sectors = max_discard;
   187		if (mmc_card_can_secure_erase_trim(card)) {
   188			if (mmc_card_fixed_secure_erase_trim_time(card))
   189				lim->max_secure_erase_sectors = UINT_MAX >> card->erase_shift;
   190			else
   191				lim->max_secure_erase_sectors = max_discard;
   192		}
   193	
   194		if (mmc_card_can_trim(card) && card->erased_byte == 0 &&
 > 195		    !(card->quirks & MMC_QUIRK_BROKEN_WRITE_ZEROS))
   196			lim->max_write_zeroes_sectors = max_discard;
   197	
   198		/* granularity must not be greater than max. discard */
   199		if (card->pref_erase > max_discard)
   200			lim->discard_granularity = SECTOR_SIZE;
   201		else
   202			lim->discard_granularity = card->pref_erase << 9;
   203	}
   204	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-08 10:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-25 18:51 [PATCH] mmc: core: add MMC_QUIRK_BROKEN_WRITE_ZEROES for ESMT eMMC Mayur Kumar
2026-07-27 16:19 ` Ulf Hansson
2026-08-07 21:47 ` kernel test robot
2026-08-08 10:56 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.