public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: "Mårten Lindahl" <Marten.Lindahl@axis.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	kernel <kernel@axis.com>, Doug Anderson <dianders@google.com>
Subject: Re: [PATCH] mmc: dw_mmc: Avoid hung state if GEN_CMD transfer fails
Date: Thu, 11 Nov 2021 16:40:20 +0100	[thread overview]
Message-ID: <20211111154020.GA21634@axis.com> (raw)
In-Reply-To: <20211103182716.28419-1-marten.lindahl@axis.com>

On Wed, Nov 03, 2021 at 07:27:16PM +0100, Mårten Lindahl wrote:
> If we get a data error during a block transfer command, a stop command
> (CMD12) is normally initiated. But this does not work for the general
> command (CMD56), but instead the action is ignored and an uninitialized
> command struct is used for the stop action, with unexpected result.
> 
> Fix this by adding a check for GEN_CMD when preparing stop transmission.
> 
> Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..988c32e93e03 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -335,7 +335,8 @@ static u32 dw_mci_prep_stop_abort(struct dw_mci *host, struct mmc_command *cmd)
>  	    cmdr == MMC_WRITE_BLOCK ||
>  	    cmdr == MMC_WRITE_MULTIPLE_BLOCK ||
>  	    cmdr == MMC_SEND_TUNING_BLOCK ||
> -	    cmdr == MMC_SEND_TUNING_BLOCK_HS200) {
> +	    cmdr == MMC_SEND_TUNING_BLOCK_HS200 ||
> +	    cmdr == MMC_GEN_CMD) {
>  		stop->opcode = MMC_STOP_TRANSMISSION;
>  		stop->arg = 0;
>  		stop->flags = MMC_RSP_R1B | MMC_CMD_AC;

While this fix looks correct for CMD56, the "Data transfer mode"
sections of the eMMC and SD specifications list several more data
commands, all of which can be aborted by CMD12, but which aren't handled
in the if above.

If I'm not mistaken, those will also result in an uninitialized stop
command being sent in the case of an error, since the driver calls
send_stop_abort() on any data error.

Is there a reason why those other commands should not be in the list
above, or should we fix this list so that CMD12 is initialized for all
data commands except SD_IO_RW_EXTENDED?

  reply	other threads:[~2021-11-11 15:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 18:27 [PATCH] mmc: dw_mmc: Avoid hung state if GEN_CMD transfer fails Mårten Lindahl
2021-11-11 15:40 ` Vincent Whitchurch [this message]
2021-11-12 12:46   ` Marten Lindahl
2021-11-15 14:54     ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211111154020.GA21634@axis.com \
    --to=vincent.whitchurch@axis.com \
    --cc=Marten.Lindahl@axis.com \
    --cc=dianders@google.com \
    --cc=jh80.chung@samsung.com \
    --cc=kernel@axis.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox