All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Per Förlin" <per.forlin@stericsson.com>
To: Ulf HANSSON <ulf.hansson@stericsson.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Chris Ball <cjb@laptop.org>,
	Johan RUDHOLM <johan.rudholm@stericsson.com>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH] mmc: core: Clean up after mmc_pre_req if card was removed
Date: Fri, 2 Mar 2012 07:38:01 +0100	[thread overview]
Message-ID: <4F506AC9.5000108@stericsson.com> (raw)
In-Reply-To: <1330616671-11952-1-git-send-email-ulf.hansson@stericsson.com>

On 03/01/2012 04:44 PM, Ulf HANSSON wrote:
> Make sure mmc_start_req cancel the prepared job, if the request
> was prevented to be started due to the card has been removed.
> 
> This bug was introduced in commit:
> mmc: allow upper layers to know immediately if card has been removed
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
> ---
>  drivers/mmc/core/core.c |   35 +++++++++++++++--------------------
>  1 files changed, 15 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 0b317f0..9e562ab 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -249,16 +249,17 @@ static void mmc_wait_done(struct mmc_request *mrq)
>  	complete(&mrq->completion);
>  }
>  
> -static void __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq)
> +static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq)
>  {
>  	init_completion(&mrq->completion);
>  	mrq->done = mmc_wait_done;
>  	if (mmc_card_removed(host->card)) {
>  		mrq->cmd->error = -ENOMEDIUM;
>  		complete(&mrq->completion);
> -		return;
> +		return -ENOMEDIUM;
>  	}
>  	mmc_start_request(host, mrq);
> +	return 0;
>  }
>  
>  static void mmc_wait_for_req_done(struct mmc_host *host,
> @@ -342,6 +343,7 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>  				    struct mmc_async_req *areq, int *error)
>  {
>  	int err = 0;
> +	int start_err = 0;
>  	struct mmc_async_req *data = host->areq;
>  
>  	/* Prepare a new request */
> @@ -351,30 +353,23 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host,
>  	if (host->areq) {
>  		mmc_wait_for_req_done(host, host->areq->mrq);
>  		err = host->areq->err_check(host->card, host->areq);
> -		if (err) {
> -			/* post process the completed failed request */
> -			mmc_post_req(host, host->areq->mrq, 0);
> -			if (areq)
> -				/*
> -				 * Cancel the new prepared request, because
> -				 * it can't run until the failed
> -				 * request has been properly handled.
> -				 */
> -				mmc_post_req(host, areq->mrq, -EINVAL);
> -
> -			host->areq = NULL;
> -			goto out;
> -		}
>  	}
>  
> -	if (areq)
> -		__mmc_start_req(host, areq->mrq);
> +	if (!err && areq)
> +		start_err = __mmc_start_req(host, areq->mrq);
>  
>  	if (host->areq)
>  		mmc_post_req(host, host->areq->mrq, 0);
>  
> -	host->areq = areq;
> - out:
> +	if (err || start_err) {
> +		if (areq)
> +			/* The prepared request was not started, cancel it. */
> +			mmc_post_req(host, areq->mrq, -EINVAL);
> +		host->areq = NULL;
> +	} else {
> +		host->areq = areq;
> +	}
> +
>  	if (error)
>  		*error = err;
>  	return data;
I have reviewed this patch offline. Patch looks good to me.

Reviewed-by: Per Forlin <per.forlin@stericsson.com>

Br
Per

  parent reply	other threads:[~2012-03-02  6:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01 15:44 [PATCH] mmc: core: Clean up after mmc_pre_req if card was removed Ulf Hansson
2012-03-01 18:42 ` Linus Walleij
2012-03-02  6:38 ` Per Förlin [this message]
2012-03-02  8:28 ` Jaehoon Chung
2012-03-02  8:51   ` Ulf Hansson
2012-03-02 15:29     ` Per Förlin
2012-03-05  5:08       ` Jaehoon Chung
2012-03-05  6:08         ` Jaehoon Chung
2012-03-05  8:35           ` Per Förlin

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=4F506AC9.5000108@stericsson.com \
    --to=per.forlin@stericsson.com \
    --cc=cjb@laptop.org \
    --cc=johan.rudholm@stericsson.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@stericsson.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.