diff mbox

mmc: core: check also R1 response for stop commands

Message ID 20170314101501.25463-1-wsa+renesas@sang-engineering.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wolfram Sang March 14, 2017, 10:15 a.m. UTC
Introduce a helper function to not only check the error value but also
error bits of a R1 response. Use the helper for the stop command.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Change since RFC:
* rebased to v4.11-rc2 and retested

So, since I got no complaints about the RFC, I'll declare it a PATCH now :)
Shimoda-san, is it possible for you to test it with the SD tester you once had
access to? I could only test it by setting the ECC bit in the driver manually.

I guess the key question here is still if R1_CARD_ECC_FAILED can be that easily
added to CMD_ERRORS without side-effects?

 drivers/mmc/core/block.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Yoshihiro Shimoda March 14, 2017, 10:41 a.m. UTC | #1
Hi Wolfram-san,

> From: Wolfram Sang
> Sent: Tuesday, March 14, 2017 7:15 PM
> 
> Introduce a helper function to not only check the error value but also
> error bits of a R1 response. Use the helper for the stop command.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Change since RFC:
> * rebased to v4.11-rc2 and retested
> 
> So, since I got no complaints about the RFC, I'll declare it a PATCH now :)
> Shimoda-san, is it possible for you to test it with the SD tester you once had
> access to? I could only test it by setting the ECC bit in the driver manually.

Sure. I am able to bring the SD tester from other department tomorrow.
So, I will check this patch tomorrow.

Best regards,
Yoshihiro Shimoda

> I guess the key question here is still if R1_CARD_ECC_FAILED can be that easily
> added to CMD_ERRORS without side-effects?
> 
>  drivers/mmc/core/block.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 1621fa08e20692..0e838b03709eb8 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -1287,9 +1287,18 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
>  	 R1_ADDRESS_ERROR |	/* Misaligned address */		\
>  	 R1_BLOCK_LEN_ERROR |	/* Transferred block length incorrect */\
>  	 R1_WP_VIOLATION |	/* Tried to write to protected block */	\
> +	 R1_CARD_ECC_FAILED |	/* Card ECC failed */			\
>  	 R1_CC_ERROR |		/* Card controller error */		\
>  	 R1_ERROR)		/* General/unknown error */
> 
> +static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
> +{
> +	if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
> +		cmd->error = -EIO;
> +
> +	return cmd->error;
> +}
> +
>  static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
>  					     struct mmc_async_req *areq)
>  {
> @@ -1311,7 +1320,7 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
>  	 * stop.error indicates a problem with the stop command.  Data
>  	 * may have been transferred, or may still be transferring.
>  	 */
> -	if (brq->sbc.error || brq->cmd.error || brq->stop.error ||
> +	if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
>  	    brq->data.error) {
>  		switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
>  		case ERR_RETRY:
> --
> 2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang March 14, 2017, 10:49 a.m. UTC | #2
> > So, since I got no complaints about the RFC, I'll declare it a PATCH now :)
> > Shimoda-san, is it possible for you to test it with the SD tester you once had
> > access to? I could only test it by setting the ECC bit in the driver manually.
> 
> Sure. I am able to bring the SD tester from other department tomorrow.
> So, I will check this patch tomorrow.

Good news, thank you very much!
diff mbox

Patch

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 1621fa08e20692..0e838b03709eb8 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -1287,9 +1287,18 @@  static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq,
 	 R1_ADDRESS_ERROR |	/* Misaligned address */		\
 	 R1_BLOCK_LEN_ERROR |	/* Transferred block length incorrect */\
 	 R1_WP_VIOLATION |	/* Tried to write to protected block */	\
+	 R1_CARD_ECC_FAILED |	/* Card ECC failed */			\
 	 R1_CC_ERROR |		/* Card controller error */		\
 	 R1_ERROR)		/* General/unknown error */
 
+static bool mmc_blk_has_cmd_err(struct mmc_command *cmd)
+{
+	if (!cmd->error && cmd->resp[0] & CMD_ERRORS)
+		cmd->error = -EIO;
+
+	return cmd->error;
+}
+
 static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
 					     struct mmc_async_req *areq)
 {
@@ -1311,7 +1320,7 @@  static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,
 	 * stop.error indicates a problem with the stop command.  Data
 	 * may have been transferred, or may still be transferring.
 	 */
-	if (brq->sbc.error || brq->cmd.error || brq->stop.error ||
+	if (brq->sbc.error || brq->cmd.error || mmc_blk_has_cmd_err(&brq->stop) ||
 	    brq->data.error) {
 		switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) {
 		case ERR_RETRY: