FAILED: patch "[PATCH] mmc: core: Optimize time for secure erase/trim for some" failed to apply to 6.18-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x d6bf2e64dec87322f2b11565ddb59c0e967f96e3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050303-enroll-hulk-16c2@gregkh' --subject-prefix 'PATCH 6.18.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d6bf2e64dec87322f2b11565ddb59c0e967f96e3 Mon Sep 17 00:00:00 2001
From: Luke Wang <[email protected]>
Date: Wed, 4 Feb 2026 11:40:03 +0800
Subject: [PATCH] mmc: core: Optimize time for secure erase/trim for some
Kingston eMMCs
Kingston eMMC IY2964 and IB2932 takes a fixed ~2 seconds for each secure erase/trim operation regardless of size - that is, a single secure erase/trim operation of 1MB takes the same time as 1GB. With default calculated 3.5MB max discard size, secure erase 1GB requires ~300 separate operations taking ~10 minutes total.
Add a card quirk, MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME, to set maximum secure erase size for those devices. This allows 1GB secure erase to complete in a single operation, reducing time from 10 minutes to just 2 seconds.
drivers/mmc/core/card.h +5 -0
@@ -311,4 +311,9 @@ static inline int mmc_card_broken_mdt(const struct mmc_card *c) return c->quirks & MMC_QUIRK_BROKEN_MDT; } +static inline int mmc_card_fixed_secure_erase_trim_time (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ; +} +#endif
drivers/mmc/core/queue.c +7 -2
@@ -184,8 +184,13 @@ static void mmc_queue_setup_discard(struct mmc_card *card,return ; lim->max_hw_discard_sectors = max_discard; -if (mmc_card_can_secure_erase_trim (card)) - lim->max_secure_erase_sectors = max_discard; +if (mmc_card_can_secure_erase_trim (card)) { +if (mmc_card_fixed_secure_erase_trim_time (card)) + lim->max_secure_erase_sectors =UINT_MAX >> card->erase_shift; +else + lim->max_secure_erase_sectors = max_discard; + } +if (mmc_card_can_trim (card) && card->erased_byte ==0 ) lim->max_write_zeroes_sectors = max_discard;
drivers/mmc/core/quirks.h +9 -0
@@ -153,6 +153,15 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {MMC_FIXUP ("M62704" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc,MMC_QUIRK_TRIM_BROKEN ), +/* +* On Some Kingston eMMCs, secure erase/trim time is independent +* of erase size, fixed at approximately 2 seconds. +*/ +MMC_FIXUP ("IY2964" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ), +MMC_FIXUP ("IB2932" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ), + END_FIXUP };
include/linux/mmc/card.h +1 -0
@@ -330,6 +330,7 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17)/* Disable broken SD poweroff notify support */ #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 */ bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */
Sasha Levin
maintainerPATCH 1/3 mmc: core: Adjust MDT beyond 2025
From: Avri Altman <[email protected]>
[ Upstream commit 3e487a634bc019166e452ea276f7522710eda9f4 ]
JEDEC JESD84-B51B which was released in September 2025, increases the manufacturing year limit for eMMC devices. The eMMC manufacturing year is stored in a 4-bit field in the CID register. Originally, it covered 1997–2012. Later, with EXT_CSD_REV=8, it was extended up to 2025. Now, with EXT_CSD_REV=9, the range is rolled over by another 16 years, up to 2038.
The mapping is as follows:
cid[8..11] | rev ≤ 4 | 8 ≥ rev > 4 | rev > 8
---------------------------------------------
0 | 1997 | 2013 | 2029 1 | 1998 | 2014 | 2030 2 | 1999 | 2015 | 2031 3 | 2000 | 2016 | 2032 4 | 2001 | 2017 | 2033 5 | 2002 | 2018 | 2034 6 | 2003 | 2019 | 2035 7 | 2004 | 2020 | 2036 8 | 2005 | 2021 | 2037 9 | 2006 | 2022 | 2038 10 | 2007 | 2023 | 11 | 2008 | 2024 | 12 | 2009 | 2025 | 13 | 2010 | | 2026 14 | 2011 | | 2027 15 | 2012 | | 2028
Stable-dep-of: d6bf2e64dec8 ("mmc: core: Optimize time for secure erase/trim for some Kingston eMMCs")
--- drivers/mmc/core/mmc.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/mmc.c +7 -0
@@ -671,7 +671,14 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.enhanced_rpmb_supported = (card->ext_csd.rel_param &EXT_CSD_WR_REL_PARAM_EN_RPMB_REL_WR ); + +if (card->ext_csd.rev >=9 ) { +/* Adjust production date as per JEDEC JESD84-B51B September 2025 */ +if (card->cid.year <2023 ) + card->cid.year +=16 ; + } } + out:return err; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 mmc: core: Add quirk for incorrect manufacturing date
From: Avri Altman <[email protected]>
[ Upstream commit 263ff314cc5602599d481b0912a381555fcbad28 ]
Some eMMC vendors need to report manufacturing dates beyond 2025 but are reluctant to update the EXT_CSD revision from 8 to 9. Changing the Updating the EXT_CSD revision may involve additional testing or qualification steps with customers. To ease this transition and avoid a full re-qualification process, a workaround is needed. This patch introduces a temporary quirk that re-purposes the year codes corresponding to 2010, 2011, and 2012 to represent the years 2026, 2027, and 2028, respectively. This solution is only valid for this three-year period.
After 2028, vendors must update their firmware to set EXT_CSD_REV=9 to continue reporting the correct manufacturing date in compliance with the JEDEC standard.
The MMC_QUIRK_BROKEN_MDT is introduced and enabled for all Sandisk devices to handle this behavior.
Stable-dep-of: d6bf2e64dec8 ("mmc: core: Optimize time for secure erase/trim for some Kingston eMMCs")
--- drivers/mmc/core/card.h | 6 ++++++ drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/quirks.h | 3 +++ include/linux/mmc/card.h | 1 + 4 files changed, 15 insertions(+)
drivers/mmc/core/card.h +6 -0
@@ -89,6 +89,7 @@ struct mmc_fixup {#define CID_MANFID_MICRON 0x13#define CID_MANFID_SAMSUNG 0x15#define CID_MANFID_APACER 0x27 +#define CID_MANFID_SANDISK_MMC 0x45#define CID_MANFID_SWISSBIT 0x5D#define CID_MANFID_KINGSTON 0x70#define CID_MANFID_HYNIX 0x90
@@ -305,4 +306,9 @@ static inline int mmc_card_no_uhs_ddr50_tuning(const struct mmc_card *c) return c->quirks & MMC_QUIRK_NO_UHS_DDR50_TUNING; } +static inline int mmc_card_broken_mdt (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_BROKEN_MDT ; +} +#endif
drivers/mmc/core/mmc.c +5 -0
@@ -676,6 +676,11 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)/* Adjust production date as per JEDEC JESD84-B51B September 2025 */ if (card->cid.year <2023 ) card->cid.year +=16 ; + }else { +/* Handle vendors with broken MDT reporting */ +if (mmc_card_broken_mdt (card) && card->cid.year >=2010 && + card->cid.year <=2012 ) + card->cid.year +=16 ; } }
drivers/mmc/core/quirks.h +3 -0
@@ -170,6 +170,9 @@ static const struct mmc_fixup __maybe_unused mmc_ext_csd_fixups[] = {MMC_FIXUP_EXT_CSD_REV (CID_NAME_ANY ,CID_MANFID_NUMONYX ,0x014e , add_quirk,MMC_QUIRK_BROKEN_HPI ,6 ), +MMC_FIXUP (CID_NAME_ANY ,CID_MANFID_SANDISK_MMC ,CID_OEMID_ANY , add_quirk_mmc, +MMC_QUIRK_BROKEN_MDT ), + END_FIXUP };
include/linux/mmc/card.h +1 -0
@@ -330,6 +330,7 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16)/* Don't flush cache until the write has occurred */ #define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17)/* Disable broken SD poweroff notify support */ #define MMC_QUIRK_NO_UHS_DDR50_TUNING (1<<18)/* Disable DDR50 tuning */ +#define MMC_QUIRK_BROKEN_MDT (1<<19)/* Wrong manufacturing year */ bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 mmc: core: Optimize time for secure erase/trim for some Kingston eMMCs
In reply to Sasha LevinFrom: Luke Wang <[email protected]>
[ Upstream commit d6bf2e64dec87322f2b11565ddb59c0e967f96e3 ]
Kingston eMMC IY2964 and IB2932 takes a fixed ~2 seconds for each secure erase/trim operation regardless of size - that is, a single secure erase/trim operation of 1MB takes the same time as 1GB. With default calculated 3.5MB max discard size, secure erase 1GB requires ~300 separate operations taking ~10 minutes total.
Add a card quirk, MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME, to set maximum secure erase size for those devices. This allows 1GB secure erase to complete in a single operation, reducing time from 10 minutes to just 2 seconds.
--- drivers/mmc/core/card.h | 5 +++++ drivers/mmc/core/queue.c | 9 +++++++-- drivers/mmc/core/quirks.h | 9 +++++++++ include/linux/mmc/card.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-)
drivers/mmc/core/card.h +5 -0
@@ -311,4 +311,9 @@ static inline int mmc_card_broken_mdt(const struct mmc_card *c) return c->quirks & MMC_QUIRK_BROKEN_MDT; } +static inline int mmc_card_fixed_secure_erase_trim_time (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ; +} +#endif
drivers/mmc/core/queue.c +7 -2
@@ -184,8 +184,13 @@ static void mmc_queue_setup_discard(struct mmc_card *card,return ; lim->max_hw_discard_sectors = max_discard; -if (mmc_card_can_secure_erase_trim (card)) - lim->max_secure_erase_sectors = max_discard; +if (mmc_card_can_secure_erase_trim (card)) { +if (mmc_card_fixed_secure_erase_trim_time (card)) + lim->max_secure_erase_sectors =UINT_MAX >> card->erase_shift; +else + lim->max_secure_erase_sectors = max_discard; + } +if (mmc_card_can_trim (card) && card->erased_byte ==0 ) lim->max_write_zeroes_sectors = max_discard;
drivers/mmc/core/quirks.h +9 -0
@@ -153,6 +153,15 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {MMC_FIXUP ("M62704" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc,MMC_QUIRK_TRIM_BROKEN ), +/* +* On Some Kingston eMMCs, secure erase/trim time is independent +* of erase size, fixed at approximately 2 seconds. +*/ +MMC_FIXUP ("IY2964" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ), +MMC_FIXUP ("IB2932" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME ), + END_FIXUP };
include/linux/mmc/card.h +1 -0
@@ -331,6 +331,7 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17)/* Disable broken SD poweroff notify support */ #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 */ bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */
Signature · 1 line
2.53.0