public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Sujit Reddy Thumma <sthumma@codeaurora.org>
To: Per Forlin <per.lkml@gmail.com>
Cc: linux-mmc@vger.kernel.org, adrian.hunter@intel.com,
	linux-arm-msm@vger.kernel.org, cjb@laptop.org
Subject: Re: [PATCH] mmc: core: Kill block requests if card is removed
Date: Thu, 10 Nov 2011 11:01:58 +0530	[thread overview]
Message-ID: <4EBB61CE.4090306@codeaurora.org> (raw)
In-Reply-To: <CAFEEs1=rbYKv9uWXJ0A-aD5bsUfHEYbBrc98hcB7o+C9b+nvNQ@mail.gmail.com>

Hi Per,

On 11/10/2011 3:17 AM, Per Forlin wrote:
> Hi Sujit,
>
> On Wed, Nov 9, 2011 at 5:31 AM, Sujit Reddy Thumma
> <sthumma@codeaurora.org>  wrote:
>> Kill block requests when the host knows that the card is
>> removed from the slot and is sure that subsequent requests
>> are bound to fail. Do this silently so that the block
>> layer doesn't output unnecessary error messages.
>>
>> This patch implements suggestion from Adrian Hunter,
>> http://thread.gmane.org/gmane.linux.kernel.mmc/2714/focus=3474
>>
>> Signed-off-by: Sujit Reddy Thumma<sthumma@codeaurora.org>
>> ---
>>   drivers/mmc/card/queue.c |    5 +++++
>>   drivers/mmc/core/bus.c   |    2 ++
>>   include/linux/mmc/card.h |    3 +++
>>   3 files changed, 10 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
>> index dcad59c..f8a3298 100644
>> --- a/drivers/mmc/card/queue.c
>> +++ b/drivers/mmc/card/queue.c
>> @@ -29,6 +29,8 @@
>>   */
>>   static int mmc_prep_request(struct request_queue *q, struct request *req)
>>   {
>> +       struct mmc_queue *mq = q->queuedata;
>> +
>>         /*
>>          * We only like normal block requests and discards.
>>          */
>> @@ -37,6 +39,9 @@ static int mmc_prep_request(struct request_queue *q, struct request *req)
>>                 return BLKPREP_KILL;
>>         }
>>
>> +       if (mq&&  mq->card&&  !mmc_card_inserted(mq->card))
> I guess the card is not freed until all pending requests have been
> flushed? mq->card will be valid as long as the queue is active.

Agreed. This is a redundant check, will remove it in v2.

>
> Another way to detect card removal is to subscribe for
> "BUS_NOTIFY_DEL_DEVICE" mmc card device.

Thanks, this sounds good, for the current v1 patch.
I have a concern about this when we take Adrian's suggestion. If we want 
to set the card gone flag as soon as the card is removed, then we can 
stop any new block request. Registering for BUS_NOTIFY_DEL_DEVICE only 
stops sync requests issued in device_del().

>
>> +               return BLKPREP_KILL;
>> +
>>         req->cmd_flags |= REQ_DONTPREP;
>>
>>         return BLKPREP_OK;
>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>> index 46b6e84..ea3be5d 100644
>> --- a/drivers/mmc/core/bus.c
>> +++ b/drivers/mmc/core/bus.c
>> @@ -308,6 +308,7 @@ int mmc_add_card(struct mmc_card *card)
>>                         mmc_card_ddr_mode(card) ? "DDR " : "",
>>                         type, card->rca);
>>         }
>> +       mmc_card_set_inserted(card);
> If the card-alloction is freed when the card is removed. Is it
> necessary to set this bit for the new allocated card? Or could this be
> the same card allocation?
>
Adrian's suggestion, "It is safer to have zero initialisations so I 
suggest inverting the meaning of the state bit," I guess, answer your 
question. We set the card gone flag when the card is removed i.e., 
either in mmc_remove_card() or host driver's card detect irq handler and 
while card allocation is freed it is cleared anyways.


  reply	other threads:[~2011-11-10  5:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09  4:31 [PATCH] mmc: core: Kill block requests if card is removed Sujit Reddy Thumma
2011-11-09  9:34 ` Adrian Hunter
2011-11-09 20:53   ` Per Forlin
2011-11-09 22:05     ` Per Forlin
2011-11-10  4:13       ` Sujit Reddy Thumma
2011-11-10  4:02     ` Sujit Reddy Thumma
2011-11-10  9:35       ` Adrian Hunter
2011-11-10 14:20         ` Per Forlin
2011-11-14  4:19           ` Sujit Reddy Thumma
2011-11-14  7:52             ` Per Forlin
2011-11-14  8:24               ` Per Forlin
2011-11-14  8:46                 ` Sujit Reddy Thumma
2011-11-09 21:47 ` Per Forlin
2011-11-10  5:31   ` Sujit Reddy Thumma [this message]
2011-11-22 20:18 ` David Taylor
2011-11-24  9:30   ` Per Forlin
2011-11-24 11:31     ` Sujit Reddy Thumma

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=4EBB61CE.4090306@codeaurora.org \
    --to=sthumma@codeaurora.org \
    --cc=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 \
    /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