diff mbox series

[v2,1/3] mmc: Check support for TRIM operations

Message ID 20230126092419.534514-1-loic.poulain@linaro.org
State Accepted
Commit eeb739a6fde6e926b389b253668b2a8fd09a58c7
Headers show
Series [v2,1/3] mmc: Check support for TRIM operations | expand

Commit Message

Loic Poulain Jan. 26, 2023, 9:24 a.m. UTC
When secure/insecure TRIM operations are supported.
When used as erase command argument it applies the
erase operation to write blocks instead of erase
groups.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
v2: Add mmc unit test change to the series

 drivers/mmc/mmc.c | 3 +++
 include/mmc.h     | 4 ++++
 2 files changed, 7 insertions(+)

Comments

Simon Glass Jan. 28, 2023, 10:01 p.m. UTC | #1
On Thu, 26 Jan 2023 at 02:24, Loic Poulain <loic.poulain@linaro.org> wrote:
>
> When secure/insecure TRIM operations are supported.
> When used as erase command argument it applies the
> erase operation to write blocks instead of erase
> groups.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
> v2: Add mmc unit test change to the series
>
>  drivers/mmc/mmc.c | 3 +++
>  include/mmc.h     | 4 ++++
>  2 files changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Jaehoon Chung Feb. 6, 2023, 4:54 a.m. UTC | #2
> -----Original Message-----
> From: Loic Poulain <loic.poulain@linaro.org>
> Sent: Thursday, January 26, 2023 6:24 PM
> To: sjg@chromium.org; peng.fan@nxp.com; jh80.chung@samsung.com
> Cc: u-boot@lists.denx.de; Loic Poulain <loic.poulain@linaro.org>
> Subject: [PATCH v2 1/3] mmc: Check support for TRIM operations
> 
> When secure/insecure TRIM operations are supported.
> When used as erase command argument it applies the
> erase operation to write blocks instead of erase
> groups.
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
> v2: Add mmc unit test change to the series
> 
>  drivers/mmc/mmc.c | 3 +++
>  include/mmc.h     | 4 ++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 210703ea46..e5f5ccb5f4 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2432,6 +2432,9 @@ static int mmc_startup_v4(struct mmc *mmc)
> 
>  	mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
> 
> +	mmc->can_trim =
> +		!!(ext_csd[EXT_CSD_SEC_FEATURE] & EXT_CSD_SEC_FEATURE_TRIM_EN);
> +
>  	return 0;
>  error:
>  	if (mmc->ext_csd) {
> diff --git a/include/mmc.h b/include/mmc.h
> index 571fa625d0..f6e23625ca 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -241,6 +241,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>  #define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
>  #define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
>  #define EXT_CSD_BOOT_MULT		226	/* RO */
> +#define EXT_CSD_SEC_FEATURE		231	/* RO */
>  #define EXT_CSD_GENERIC_CMD6_TIME       248     /* RO */
>  #define EXT_CSD_BKOPS_SUPPORT		502	/* RO */
> 
> @@ -315,6 +316,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>  #define EXT_CSD_WR_DATA_REL_USR		(1 << 0)	/* user data area WR_REL */
>  #define EXT_CSD_WR_DATA_REL_GP(x)	(1 << ((x)+1))	/* GP part (x+1) WR_REL */
> 
> +#define EXT_CSD_SEC_FEATURE_TRIM_EN	(1 << 4) /* Support secure & insecure trim */
> +
>  #define R1_ILLEGAL_COMMAND		(1 << 22)
>  #define R1_APP_CMD			(1 << 5)
> 
> @@ -687,6 +690,7 @@ struct mmc {
>  	uint tran_speed;
>  	uint legacy_speed; /* speed for the legacy mode provided by the card */
>  	uint read_bl_len;
> +	bool can_trim;
>  #if CONFIG_IS_ENABLED(MMC_WRITE)
>  	uint write_bl_len;
>  	uint erase_grp_size;	/* in 512-byte sectors */
> --
> 2.34.1
Jaehoon Chung March 10, 2023, 2:31 a.m. UTC | #3
On 1/26/23 18:24, Loic Poulain wrote:
> When secure/insecure TRIM operations are supported.
> When used as erase command argument it applies the
> erase operation to write blocks instead of erase
> groups.
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>


Applied to u-boot-mmc/master.

Best Regards,
Jaehoon Chung


> ---
> v2: Add mmc unit test change to the series
> 
>  drivers/mmc/mmc.c | 3 +++
>  include/mmc.h     | 4 ++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 210703ea46..e5f5ccb5f4 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2432,6 +2432,9 @@ static int mmc_startup_v4(struct mmc *mmc)
>  
>  	mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
>  
> +	mmc->can_trim =
> +		!!(ext_csd[EXT_CSD_SEC_FEATURE] & EXT_CSD_SEC_FEATURE_TRIM_EN);
> +
>  	return 0;
>  error:
>  	if (mmc->ext_csd) {
> diff --git a/include/mmc.h b/include/mmc.h
> index 571fa625d0..f6e23625ca 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -241,6 +241,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>  #define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
>  #define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
>  #define EXT_CSD_BOOT_MULT		226	/* RO */
> +#define EXT_CSD_SEC_FEATURE		231	/* RO */
>  #define EXT_CSD_GENERIC_CMD6_TIME       248     /* RO */
>  #define EXT_CSD_BKOPS_SUPPORT		502	/* RO */
>  
> @@ -315,6 +316,8 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
>  #define EXT_CSD_WR_DATA_REL_USR		(1 << 0)	/* user data area WR_REL */
>  #define EXT_CSD_WR_DATA_REL_GP(x)	(1 << ((x)+1))	/* GP part (x+1) WR_REL */
>  
> +#define EXT_CSD_SEC_FEATURE_TRIM_EN	(1 << 4) /* Support secure & insecure trim */
> +
>  #define R1_ILLEGAL_COMMAND		(1 << 22)
>  #define R1_APP_CMD			(1 << 5)
>  
> @@ -687,6 +690,7 @@ struct mmc {
>  	uint tran_speed;
>  	uint legacy_speed; /* speed for the legacy mode provided by the card */
>  	uint read_bl_len;
> +	bool can_trim;
>  #if CONFIG_IS_ENABLED(MMC_WRITE)
>  	uint write_bl_len;
>  	uint erase_grp_size;	/* in 512-byte sectors */
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 210703ea46..e5f5ccb5f4 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2432,6 +2432,9 @@  static int mmc_startup_v4(struct mmc *mmc)
 
 	mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
 
+	mmc->can_trim =
+		!!(ext_csd[EXT_CSD_SEC_FEATURE] & EXT_CSD_SEC_FEATURE_TRIM_EN);
+
 	return 0;
 error:
 	if (mmc->ext_csd) {
diff --git a/include/mmc.h b/include/mmc.h
index 571fa625d0..f6e23625ca 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -241,6 +241,7 @@  static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define EXT_CSD_HC_WP_GRP_SIZE		221	/* RO */
 #define EXT_CSD_HC_ERASE_GRP_SIZE	224	/* RO */
 #define EXT_CSD_BOOT_MULT		226	/* RO */
+#define EXT_CSD_SEC_FEATURE		231	/* RO */
 #define EXT_CSD_GENERIC_CMD6_TIME       248     /* RO */
 #define EXT_CSD_BKOPS_SUPPORT		502	/* RO */
 
@@ -315,6 +316,8 @@  static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define EXT_CSD_WR_DATA_REL_USR		(1 << 0)	/* user data area WR_REL */
 #define EXT_CSD_WR_DATA_REL_GP(x)	(1 << ((x)+1))	/* GP part (x+1) WR_REL */
 
+#define EXT_CSD_SEC_FEATURE_TRIM_EN	(1 << 4) /* Support secure & insecure trim */
+
 #define R1_ILLEGAL_COMMAND		(1 << 22)
 #define R1_APP_CMD			(1 << 5)
 
@@ -687,6 +690,7 @@  struct mmc {
 	uint tran_speed;
 	uint legacy_speed; /* speed for the legacy mode provided by the card */
 	uint read_bl_len;
+	bool can_trim;
 #if CONFIG_IS_ENABLED(MMC_WRITE)
 	uint write_bl_len;
 	uint erase_grp_size;	/* in 512-byte sectors */