mmc: core: Kill block requests if card is removed
Subsystems (2)
Kill block requests when the host knows that the card is removed from the slot and is sure that it can no longer accept any requests.
Kill this silently so that the block layer don't output error messages unnecessarily.
drivers/mmc/card/queue.c +5 -0
@@ -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)) +return BLKPREP_KILL ; + req->cmd_flags |=REQ_DONTPREP ;return BLKPREP_OK ;
drivers/mmc/core/bus.c +2 -0
@@ -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);#ifdef CONFIG_DEBUG_FS mmc_add_card_debugfs (card);
@@ -340,6 +341,7 @@ void mmc_remove_card(struct mmc_card *card)pr_info ("%s: card %04x removed\n" ,mmc_hostname (card->host), card->rca); } + card->state &= ~MMC_STATE_INSERTED ;device_del (&card->dev); }
include/linux/mmc/card.h +3 -0
@@ -196,6 +196,7 @@ struct mmc_card {#define MMC_STATE_HIGHSPEED_DDR (1<<4)/* card is in high speed mode */ #define MMC_STATE_ULTRAHIGHSPEED (1<<5)/* card is in ultra high speed mode */ #define MMC_CARD_SDXC (1<<6)/* card is SDXC */ +#define MMC_STATE_INSERTED (1<<7)/* card present in the slot */ unsigned int quirks;/* card quirks */ #define MMC_QUIRK_LENIENT_FN0 (1<<0)/* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)/* use func->cur_blksize */
@@ -344,6 +345,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_sdio (c) ((c)->type == MMC_TYPE_SDIO)#define mmc_card_present (c) ((c)->state & MMC_STATE_PRESENT) +#define mmc_card_inserted (c) ((c)->state & MMC_STATE_INSERTED)#define mmc_card_readonly (c) ((c)->state & MMC_STATE_READONLY)#define mmc_card_highspeed (c) ((c)->state & MMC_STATE_HIGHSPEED)#define mmc_card_blockaddr (c) ((c)->state & MMC_STATE_BLOCKADDR)
@@ -352,6 +354,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_ext_capacity (c) ((c)->state & MMC_CARD_SDXC)#define mmc_card_set_present (c) ((c)->state |= MMC_STATE_PRESENT) +#define mmc_card_set_inserted (c) ((c)->state |= MMC_STATE_INSERTED)#define mmc_card_set_readonly (c) ((c)->state |= MMC_STATE_READONLY)#define mmc_card_set_highspeed (c) ((c)->state |= MMC_STATE_HIGHSPEED)#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)
Signature · 5 lines
1.7.3.3 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Hello Sujit,
Quoted 9 lines · Sujit Reddy Thumma
Kill block requests when the host knows that the card is removed from the slot and is sure that it can no longer accept any requests.
Kill this silently so that the block layer don't output error messages unnecessarily.
Signed-off-by Sujit Reddy Thumma <[email protected]>
<snip>
Quoted 22 lines
include/linux/mmc/card.h +2
-0@@ -196,6 +196,7 @@ struct mmc_card {#define MMC_STATE_HIGHSPEED_DDR (1<<4)/* card is in high speed mode */ #define MMC_STATE_ULTRAHIGHSPEED (1<<5)/* card is in ultra high speed mode */ #define MMC_CARD_SDXC (1<<6)/* card is SDXC */ +#define MMC_STATE_INSERTED (1<<7)/* card present in the slot */ unsigned int quirks;/* card quirks */ #define MMC_QUIRK_LENIENT_FN0 (1<<0)/* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)/* use func->cur_blksize */ @@ -344,6 +345,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_sdio (c) ((c)->type == MMC_TYPE_SDIO)#define mmc_card_present (c) ((c)->state & MMC_STATE_PRESENT) +#define mmc_card_inserted (c) ((c)->state & MMC_STATE_INSERTED)#define mmc_card_readonly (c) ((c)->state & MMC_STATE_READONLY)#define mmc_card_highspeed (c) ((c)->state & MMC_STATE_HIGHSPEED)#define mmc_card_blockaddr (c) ((c)->state & MMC_STATE_BLOCKADDR)
include/linux/mmc/card.h static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) · line 360
Quoted 7 lines
include/linux/mmc/card.h +1
-0@@ -352,6 +354,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_ext_capacity (c) ((c)->state & MMC_CARD_SDXC)#define mmc_card_set_present (c) ((c)->state |= MMC_STATE_PRESENT) +#define mmc_card_set_inserted (c) ((c)->state |= MMC_STATE_INSERTED)#define mmc_card_set_readonly (c) ((c)->state |= MMC_STATE_READONLY)#define mmc_card_set_highspeed (c) ((c)->state |= MMC_STATE_HIGHSPEED)#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)
Why do we need another flag to indicate card's presence? can not we use MMC_STATE_PRESENT flag? This flag is set in mmc_add_card(). But not cleared any where...
Thanks,
Pavan
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 37 lines · Pavan Kondeti
Hello Sujit,
Quoted 9 lines · Sujit Reddy Thumma
Kill block requests when the host knows that the card is removed from the slot and is sure that it can no longer accept any requests.
Kill this silently so that the block layer don't output error messages unnecessarily.
Signed-off-by Sujit Reddy Thumma<[email protected]><snip>
Quoted 24 lines
include/linux/mmc/card.h +2
-0@@ -196,6 +196,7 @@ struct mmc_card {#define MMC_STATE_HIGHSPEED_DDR (1<<4)/* card is in high speed mode */ #define MMC_STATE_ULTRAHIGHSPEED (1<<5)/* card is in ultra high speed mode */ #define MMC_CARD_SDXC (1<<6)/* card is SDXC */ +#define MMC_STATE_INSERTED (1<<7)/* card present in the slot */ unsigned int quirks;/* card quirks */ #define MMC_QUIRK_LENIENT_FN0 (1<<0)/* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1)/* use func->cur_blksize */ @@ -344,6 +345,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_sdio (c) ((c)->type == MMC_TYPE_SDIO)#define mmc_card_present (c) ((c)->state& MMC_STATE_PRESENT) +#define mmc_card_inserted (c) ((c)->state& MMC_STATE_INSERTED)#define mmc_card_readonly (c) ((c)->state& MMC_STATE_READONLY)#define mmc_card_highspeed (c) ((c)->state& MMC_STATE_HIGHSPEED)#define mmc_card_blockaddr (c) ((c)->state& MMC_STATE_BLOCKADDR)@@ -352,6 +354,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data)#define mmc_card_ext_capacity (c) ((c)->state& MMC_CARD_SDXC)
Quoted 10 lines
include/linux/mmc/card.h static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) · line 360
Quoted 5 lines
include/linux/mmc/card.h +1
-0#define mmc_card_set_present (c) ((c)->state |= MMC_STATE_PRESENT) +#define mmc_card_set_inserted (c) ((c)->state |= MMC_STATE_INSERTED)#define mmc_card_set_readonly (c) ((c)->state |= MMC_STATE_READONLY)#define mmc_card_set_highspeed (c) ((c)->state |= MMC_STATE_HIGHSPEED)#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)Why do we need another flag to indicate card's presence? can not we use
MMC_STATE_PRESENTflag? This flag is set inmmc_add_card(). But not cleared any where...
MMC_STATE_PRESENT signifies the card presence in sysfs i.e. after device_add() is called we can be sure that kobject for card device is created. This will be cleared automatically when we do mmc_release_card() after card removal. But before this when doing device_del() is called the FS layer flush/sync the dirty data onto card. This creates unnecessary noise in dmesg log when the card is removed from the slot (without unmounting).
Quoted 4 lines
Thanks,
Pavan
Thanks,
Sujit