All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Chris Ball <cjb@laptop.org>,
	per.lkml@gmail.com, linux-mmc@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH V3] mmc: allow upper layers to determine immediately if a card has been removed
Date: Mon, 28 Nov 2011 16:23:32 +0200	[thread overview]
Message-ID: <4ED39964.7020806@intel.com> (raw)
In-Reply-To: <9a3d4e0770dc0d7421d6abf0e1a57166.squirrel@www.codeaurora.org>

On 28/11/11 15:37, Sujit Reddy Thumma wrote:
> 
>> Add a function mmc_detect_card_removed() which upper layers
>> can use to determine immediately if a card has been removed.
>> This function should be called after an I/O request fails so
>> that all queued I/O requests can be errored out immediately
>> instead of waiting for the card device to be removed.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>>  drivers/mmc/core/core.c  |   51
>> +++++++++++++++++++++++++++++++++++++++++++--
>>  drivers/mmc/core/core.h  |    3 ++
>>  drivers/mmc/core/mmc.c   |   12 ++++++++++-
>>  drivers/mmc/core/sd.c    |   12 ++++++++++-
>>  drivers/mmc/core/sdio.c  |   11 +++++++++-
>>  include/linux/mmc/card.h |    3 ++
>>  include/linux/mmc/core.h |    2 +
>>  include/linux/mmc/host.h |    1 +
>>  8 files changed, 89 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index 271efea..3dacc98 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -140,7 +140,7 @@ void mmc_request_done(struct mmc_host *host, struct
>> mmc_request *mrq)
>>  			cmd->retries = 0;
>>  	}
>>
>> -	if (err && cmd->retries) {
>> +	if (err && cmd->retries && !mmc_card_removed(host->card)) {
>>  		/*
>>  		 * Request starter must handle retries - see
>>  		 * mmc_wait_for_req_done().
>> @@ -247,6 +247,11 @@ static void __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;
>> +	}
>>  	mmc_start_request(host, mrq);
>>  }
>>
>> @@ -259,7 +264,8 @@ static void mmc_wait_for_req_done(struct mmc_host
>> *host,
>>  		wait_for_completion(&mrq->completion);
>>
>>  		cmd = mrq->cmd;
>> -		if (!cmd->error || !cmd->retries)
>> +		if (!cmd->error || !cmd->retries ||
>> +		    mmc_card_removed(host->card))
>>  			break;
>>
>>  		pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
>> @@ -1456,7 +1462,7 @@ void mmc_detect_change(struct mmc_host *host,
>> unsigned long delay)
>>  	WARN_ON(host->removed);
>>  	spin_unlock_irqrestore(&host->lock, flags);
>>  #endif
>> -
>> +	host->detect_change = 1;
>>  	mmc_schedule_delayed_work(&host->detect, delay);
>>  }
>>
>> @@ -2049,6 +2055,43 @@ static int mmc_rescan_try_freq(struct mmc_host
>> *host, unsigned freq)
>>  	return -EIO;
>>  }
>>
>> +int _mmc_detect_card_removed(struct mmc_host *host)
>> +{
>> +	int ret;
>> +
>> +	if (!(host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
>> +		return 0;
>> +
>> +	if (!host->card || mmc_card_removed(host->card))
>> +		return 1;
>> +
>> +	ret = host->bus_ops->alive(host);
>> +	if (ret) {
>> +		mmc_card_set_removed(host->card);
>> +		pr_info("%s: card removed\n", mmc_hostname(host));
> 
> We are printing the same information when mmc_remove_card() is called. Can
> we move this to pr_debug() here?

Changed in V4

      reply	other threads:[~2011-11-28 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-28 13:02 [PATCH V3] mmc: allow upper layers to determine immediately if a card has been removed Adrian Hunter
2011-11-28 13:32 ` Sujit Reddy Thumma
2011-11-28 14:22   ` Adrian Hunter
2011-11-28 13:37 ` Sujit Reddy Thumma
2011-11-28 14:23   ` Adrian Hunter [this message]

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=4ED39964.7020806@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=cjb@laptop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=per.lkml@gmail.com \
    --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 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.