public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Per Förlin" <per.forlin@stericsson.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Sujit Reddy Thumma <sthumma@codeaurora.org>,
	Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH] mmc: block: release host in case of error
Date: Fri, 18 Nov 2011 10:56:19 +0100	[thread overview]
Message-ID: <4EC62BC3.30300@stericsson.com> (raw)
In-Reply-To: <4EC4D151.1030008@intel.com>

On 11/17/2011 10:18 AM, Adrian Hunter wrote:
> On 14/11/11 13:12, Per Forlin wrote:
>> Host is claimed as long as there are requests in the block queue
>> and all request are completed successfully. If an error occur release
>> the host in case someone else needs to claim it, for instance if the card
>> is removed during a transfer.
>>
>> Signed-off-by: Per Forlin <per.forlin@stericsson.com>
>> ---
>>  drivers/mmc/card/block.c |   37 +++++++++++++++++++++++++++++--------
>>  1 files changed, 29 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index c80bb6d..c21fd2c 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1158,6 +1158,28 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
>>  	return ret;
>>  }
>>  
>> +/*
>> + * This function should be called to resend a request after failure.
>> + * Prepares and starts the request.
>> + */
>> +static inline struct mmc_async_req *mmc_blk_resend(struct mmc_card *card,
>> +						   struct mmc_queue *mq,
>> +						   struct mmc_queue_req *mqrq,
>> +						   int disable_multi,
>> +						   struct mmc_async_req *areq)
>> +{
>> +	/*
>> +	 * Release host after failure in case the host is needed
>> +	 * by someone else. For instance, if the card is removed the
>> +	 * worker thread needs to claim the host in order to do mmc_rescan.
>> +	 */
>> +	mmc_release_host(card->host);
>> +	mmc_claim_host(card->host);
> 
> Does this work?  Won't the current thread win the race
> to claim the host again?
> 
Good question. I've tested it and I haven't seen any cases where current has claimed the host again. Sujit has tested the patch as well.
But I can't say that your scenario can't happen. I will study the wake_up and wait_queue code to see if I can find the answer.

Thanks,
Per

  reply	other threads:[~2011-11-18  9:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 11:12 [PATCH] mmc: block: release host in case of error Per Forlin
2011-11-17  4:03 ` Sujit Reddy Thumma
2011-11-17  7:39 ` Linus Walleij
2011-11-17  9:18 ` Adrian Hunter
2011-11-18  9:56   ` Per Förlin [this message]
2011-11-20 20:50     ` Per Forlin
2011-11-24 18:58       ` Per Forlin
2011-11-25 12:03         ` Adrian Hunter
2011-11-25 13:00           ` Per Forlin

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=4EC62BC3.30300@stericsson.com \
    --to=per.forlin@stericsson.com \
    --cc=adrian.hunter@intel.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=sthumma@codeaurora.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