Two minor changes of eMMC sanitize
v3 cover Two minor changes of eMMC sanitize
From: Bean Huo <[email protected]>
Changelog:
V1--V2:
1. change wrong nouns in patch 1/2 commit message
v2--v3:
1. Replace the original patch 1/2 with the new patch 1/2 based on the Ulf's suggestion.
Bean Huo (2):
mmc: core: Pass down user specified timeout value to sanitize
mmc: core: Let sanitize not retry in case of timeout/failure
drivers/mmc/core/block.c | 15 +++++++----- drivers/mmc/core/mmc.c | 47 ++++++++++++++++++++++---------------- drivers/mmc/core/mmc_ops.c | 24 +++++++++++-------- drivers/mmc/core/mmc_ops.h | 6 ++--- 4 files changed, 53 insertions(+), 39 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 mmc: core: Pass down user specified timeout value to sanitize
From: Bean Huo <[email protected]>
As the density increases, the 4-minute timeout value for sanitize is no longer feasible. At the same time, devices of different densities have different timeout values, and it is difficult to obtain a unified standard timeout value. Therefore, it is better to pass down user-specified sanitize timeout value.
--- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/mmc_ops.c | 7 +++++-- drivers/mmc/core/mmc_ops.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/mmc/core/block.c +1 -1
@@ -539,7 +539,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,if ((MMC_EXTRACT_INDEX_FROM_ARG (cmd.arg) ==EXT_CSD_SANITIZE_START ) && (cmd.opcode ==MMC_SWITCH )) -return mmc_sanitize (card); +return mmc_sanitize (card, idata->ic.cmd_timeout_ms);mmc_wait_for_req (card->host, &mrq);
drivers/mmc/core/mmc_ops.c +5 -2
@@ -1010,7 +1010,7 @@ int mmc_cmdq_disable(struct mmc_card *card) }EXPORT_SYMBOL_GPL (mmc_cmdq_disable); -int mmc_sanitize (struct mmc_card *card) +int mmc_sanitize (struct mmc_card *card,unsigned int timeout_ms) {struct mmc_host *host = card->host;int err;
@@ -1020,12 +1020,15 @@ int mmc_sanitize(struct mmc_card *card)return -EOPNOTSUPP ; } +if (!timeout_ms) + timeout_ms =MMC_SANITIZE_TIMEOUT_MS ; +pr_debug ("%s: Sanitize in progress...\n" ,mmc_hostname (host));mmc_retune_hold (host); err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_SANITIZE_START , -1 ,MMC_SANITIZE_TIMEOUT_MS ); +1 , timeout_ms);if (err)pr_err ("%s: Sanitize failed err=%d\n" ,mmc_hostname (host), err);
drivers/mmc/core/mmc_ops.h +1 -1
@@ -46,7 +46,7 @@ void mmc_run_bkops(struct mmc_card *card);int mmc_flush_cache (struct mmc_card *card);int mmc_cmdq_enable (struct mmc_card *card);int mmc_cmdq_disable (struct mmc_card *card); -int mmc_sanitize (struct mmc_card *card); +int mmc_sanitize (struct mmc_card *card,unsigned int timeout_ms);#endif
Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] mmc: core: Pass down user specified timeout value to sanitize
Quoted 10 lines · Bean Huo
From: Bean Huo <[email protected]>
As the density increases, the 4-minute timeout value for sanitize is no longer feasible. At the same time, devices of different densities have different timeout values, and it is difficult to obtain a unified standard timeout value. Therefore, it is better to pass down user-specified sanitize timeout value.
Signed-off-by Bean Huo <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 65 lines
--- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/mmc_ops.c | 7 +++++-- drivers/mmc/core/mmc_ops.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-)drivers/mmc/core/block.c +1
-1@@ -539,7 +539,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,if ((MMC_EXTRACT_INDEX_FROM_ARG (cmd.arg) ==EXT_CSD_SANITIZE_START ) && (cmd.opcode ==MMC_SWITCH )) -return mmc_sanitize (card); +return mmc_sanitize (card, idata->ic.cmd_timeout_ms);mmc_wait_for_req (card->host, &mrq);drivers/mmc/core/mmc_ops.c +5
-2@@ -1010,7 +1010,7 @@ int mmc_cmdq_disable(struct mmc_card *card) }EXPORT_SYMBOL_GPL (mmc_cmdq_disable); -int mmc_sanitize (struct mmc_card *card) +int mmc_sanitize (struct mmc_card *card,unsigned int timeout_ms) {struct mmc_host *host = card->host;int err;@@ -1020,12 +1020,15 @@ int mmc_sanitize(struct mmc_card *card)return -EOPNOTSUPP ; } +if (!timeout_ms) + timeout_ms =MMC_SANITIZE_TIMEOUT_MS ; +pr_debug ("%s: Sanitize in progress...\n" ,mmc_hostname (host));mmc_retune_hold (host); err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_SANITIZE_START , -1 ,MMC_SANITIZE_TIMEOUT_MS ); +1 , timeout_ms);if (err)pr_err ("%s: Sanitize failed err=%d\n" ,mmc_hostname (host), err);drivers/mmc/core/mmc_ops.h +1
-2@@ -46,7 +46,7 @@ void mmc_run_bkops(struct mmc_card *card);int mmc_flush_cache (struct mmc_card *card);int mmc_cmdq_enable (struct mmc_card *card);int mmc_cmdq_disable (struct mmc_card *card); -int mmc_sanitize (struct mmc_card *card); +int mmc_sanitize (struct mmc_card *card,unsigned int timeout_ms);#endif --2.25.1
PATCH v3 2/2 mmc: core: Let sanitize not retry in case of timeout/failure
In reply to Bean HuoFrom: Bean Huo <[email protected]>
Not any commands need to retry in case of timeout/failure. Currently, the sanitize command is issued by the IOCTL interface, and once its timeouts, the user normally decides to retry or not . Just blindly retry three times sanitize in the driver, it doesn't help sanitize retry succeed in the end, on the contrary, it only makes the user feel sanitize timeouts after 12 minutes.
--- drivers/mmc/core/block.c | 13 +++++++---- drivers/mmc/core/mmc.c | 47 ++++++++++++++++++++++---------------- drivers/mmc/core/mmc_ops.c | 19 +++++++-------- drivers/mmc/core/mmc_ops.h | 4 ++-- 4 files changed, 47 insertions(+), 36 deletions(-)
drivers/mmc/core/block.c +8 -5
@@ -836,7 +836,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, ret =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , part_config, - card->ext_csd.part_time); + card->ext_csd.part_time,MMC_CMD_RETRIES );if (ret) {mmc_blk_part_switch_post (card, part_type);return ret;
@@ -1007,7 +1007,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) ret =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_BOOT_WP , card->ext_csd.boot_ro_lock |EXT_CSD_BOOT_WP_B_PWR_WP_EN , - card->ext_csd.part_time); + card->ext_csd.part_time,MMC_CMD_RETRIES );if (ret)pr_err ("%s: Locking boot partition ro until next power on failed: %d\n" , md->disk->disk_name, ret);
@@ -1058,7 +1058,8 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) card->erase_arg ==MMC_TRIM_ARG ?INAND_CMD38_ARG_TRIM :INAND_CMD38_ARG_ERASE , - card->ext_csd.generic_cmd6_time); + card->ext_csd.generic_cmd6_time, + MMC_CMD_RETRIES); }if (!err) err =mmc_erase (card, from, nr, card->erase_arg);
@@ -1100,7 +1101,8 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, arg ==MMC_SECURE_TRIM1_ARG ?INAND_CMD38_ARG_SECTRIM1 :INAND_CMD38_ARG_SECERASE , - card->ext_csd.generic_cmd6_time); + card->ext_csd.generic_cmd6_time, + MMC_CMD_RETRIES);if (err) goto out_retry; }
@@ -1118,7 +1120,8 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,INAND_CMD38_ARG_EXT_CSD ,INAND_CMD38_ARG_SECTRIM2 , - card->ext_csd.generic_cmd6_time); + card->ext_csd.generic_cmd6_time, +MMC_CMD_RETRIES );if (err) goto out_retry; }
drivers/mmc/core/mmc.c +27 -20
167 lines not on this page · raw message
drivers/mmc/core/mmc_ops.c +10 -9
@@ -532,12 +532,13 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,* @timing: new timing to change to * @send_status: send status cmd to poll for busy * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy +* @retries: number of retries * * Modifies the EXT_CSD register for selected card. */ int __mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value,unsigned int timeout_ms,unsigned char timing, -bool send_status,bool retry_crc_err) +bool send_status,bool retry_crc_err,unsigned int retries) {struct mmc_host *host = card->host;int err;
@@ -563,7 +564,6 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,if (!(host->caps &MMC_CAP_NEED_RSP_BUSY ) && host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) use_r1b_resp = false; - cmd.opcode =MMC_SWITCH ; cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE <<24 ) | (index << 16) |
@@ -577,7 +577,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, cmd.flags |=MMC_RSP_SPI_R1 |MMC_RSP_R1 ; } - err =mmc_wait_for_cmd (host, &cmd,MMC_CMD_RETRIES ); + err =mmc_wait_for_cmd (host, &cmd, retries);if (err) goto out;
@@ -609,10 +609,10 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, }int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value, -unsigned int timeout_ms) +unsigned int timeout_ms,unsigned int retries) {return __mmc_switch (card, set, index, value, timeout_ms,0 , - true, false); + true, false, retries); }EXPORT_SYMBOL_GPL (mmc_switch);
@@ -951,7 +951,8 @@ void mmc_run_bkops(struct mmc_card *card)* urgent levels by using an asynchronous background task, when idle. */ err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_BKOPS_START ,1 ,MMC_BKOPS_TIMEOUT_MS ); +EXT_CSD_BKOPS_START ,1 ,MMC_BKOPS_TIMEOUT_MS , +MMC_CMD_RETRIES );if (err)pr_warn ("%s: Error %d starting bkops\n" ,mmc_hostname (card->host), err);
@@ -972,7 +973,7 @@ int mmc_flush_cache(struct mmc_card *card) (card->ext_csd.cache_ctrl & 1)) { err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_FLUSH_CACHE ,1 , -MMC_CACHE_FLUSH_TIMEOUT_MS ); +MMC_CACHE_FLUSH_TIMEOUT_MS ,MMC_CMD_RETRIES );if (err)pr_err ("%s: cache flush error %d\n" ,mmc_hostname (card->host), err);
@@ -991,7 +992,7 @@ static int mmc_cmdq_switch(struct mmc_card *card, bool enable)return -EOPNOTSUPP ; err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_CMDQ_MODE_EN , - val, card->ext_csd.generic_cmd6_time); + val, card->ext_csd.generic_cmd6_time,MMC_CMD_RETRIES );if (!err) card->ext_csd.cmdq_en = enable;
@@ -1028,7 +1029,7 @@ int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms)mmc_retune_hold (host); err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_SANITIZE_START , -1 , timeout_ms); +1 , timeout_ms,0 );if (err)pr_err ("%s: Sanitize failed err=%d\n" ,mmc_hostname (host), err);
drivers/mmc/core/mmc_ops.h +2 -2
@@ -39,9 +39,9 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, enum mmc_busy_cmd busy_cmd);int __mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value,unsigned int timeout_ms,unsigned char timing, -bool send_status,bool retry_crc_err); +bool send_status,bool retry_crc_err,unsigned int retries);int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value, -unsigned int timeout_ms); +unsigned int timeout_ms,unsigned int retries);void mmc_run_bkops (struct mmc_card *card);int mmc_flush_cache (struct mmc_card *card);int mmc_cmdq_enable (struct mmc_card *card);
Signature · 1 line
2.25.1
Re: [PATCH v3 2/2] mmc: core: Let sanitize not retry in case of timeout/failure
Quoted 23 lines · Bean Huo
From: Bean Huo <[email protected]>
Not any commands need to retry in case of timeout/failure. Currently, the sanitize command is issued by the IOCTL interface, and once its timeouts, the user normally decides to retry or not . Just blindly retry three times sanitize in the driver, it doesn't help sanitize retry succeed in the end, on the contrary, it only makes the user feel sanitize timeouts after 12 minutes.
Signed-off-by Bean Huo <[email protected]>--- drivers/mmc/core/block.c | 13 +++++++---- drivers/mmc/core/mmc.c | 47 ++++++++++++++++++++++---------------- drivers/mmc/core/mmc_ops.c | 19 +++++++-------- drivers/mmc/core/mmc_ops.h | 4 ++-- 4 files changed, 47 insertions(+), 36 deletions(-)drivers/mmc/core/block.c +0
-0
drivers/mmc/core/block.c static inline int mmc_blk_part_switch(struct mmc_card *card, · line 839
Quoted 5 lines
drivers/mmc/core/block.c +1
-1@@ -836,7 +836,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, ret =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , part_config, - card->ext_csd.part_time); + card->ext_csd.part_time,MMC_CMD_RETRIES );
I would rather not change the mmc_switch() function definition, but only __mmc_switch(). Just let mmc_switch() pass another in-parameter (MMC_CMD_RETRIES) to __mmc_switch(), which means all callers of mmc_switch() doesn't need to get changed, but only callers of __mmc_switch().
[...]
Kind regards
Uffe
Re: [PATCH v3 2/2] mmc: core: Let sanitize not retry in case of timeout/failure
Quoted 19 lines · Ulf Hansson
drivers/mmc/core/block.c static inline int mmc_blk_part_switch(struct · line 840
Quoted 11 lines
drivers/mmc/core/block.c +1
-1@@ -836,7 +836,7 @@ static inline int mmc_blk_part_switch(structmmc_card *card, ret =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_PART_CONFIG , part_config, - card->ext_csd.part_time); + card->ext_csd.part_time,MMC_CMD_RETRIES );I would rather not change the
mmc_switch()function definition, butonly
__mmc_switch(). Just letmmc_switch()pass another in-parameter(
MMC_CMD_RETRIES) to__mmc_switch(), which means all callers of
Quoted 10 lines
mmc_switch()doesn't need to get changed, but only callers of
__mmc_switch().[...]
Hi Uffe,
Good point, I will change it in the next version of this patch.
thanks,
Bean
Quoted 3 lines
Kind regards
Uffe