set a suitable max_discard_sectors value for mmc queue
PATCH 2/3 set a suitable max_discard_sectors value for mmc queue
Quoted 1 line
From
40c55714de6b4c9eb2c7105c8b01e70d645c1089Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <[email protected]>
Date: Thu, 11 Nov 2010 15:42:18 +0800
Subject: [PATCH 2/3] mmc: set a suitable max_discard_sectors value for mmc queue
For some SDHCI host controller, eraseing unlimited sectors one time may caused a data timeout interrupt since the erasing time is larger than the host timeout time.
If host driver implemented get_tmclk callback for mmc_host_ops, mmc_set_discard_limit() will calculated a suitable max_discard_sectors value for mmc queue. Otherwise, use the unlimited value.
Signed-off-by Chuanxiao Dong <[email protected]>
--- drivers/mmc/card/queue.c | 8 ++- drivers/mmc/core/core.c | 145 ++++++++++++++++++++++++++++++++++++--------- include/linux/mmc/core.h | 1 + include/linux/mmc/host.h | 3 + 4 files changed, 127 insertions(+), 30 deletions(-)
drivers/mmc/card/queue.c +7 -1
@@ -131,7 +131,13 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lockqueue_flag_set_unlocked (QUEUE_FLAG_NONROT , mq->queue);if (mmc_can_erase (card)) {queue_flag_set_unlocked (QUEUE_FLAG_DISCARD , mq->queue); - mq->queue->limits.max_discard_sectors =UINT_MAX ; +/* get a suitable max_discard_sectors limitation */ + ret =mmc_set_discard_limit (card); +if (ret >0 ) + mq->queue->limits.max_discard_sectors = ret; +else + mq->queue->limits.max_discard_sectors =UINT_MAX ; +if (card->erased_byte ==0 ) mq->queue->limits.discard_zeroes_data =1 ;if (!mmc_can_trim (card) &&is_power_of_2 (card->erase_size)) {
drivers/mmc/core/core.c +116 -29
163 lines not on this page · raw message
include/linux/mmc/core.h +1 -0
@@ -152,6 +152,7 @@ extern int mmc_can_trim(struct mmc_card *card);extern int mmc_can_secure_erase_trim (struct mmc_card *card);extern int mmc_erase_group_aligned (struct mmc_card *card,unsigned int from,unsigned int nr); +extern int mmc_set_discard_limit (struct mmc_card *card);extern int mmc_set_blocklen (struct mmc_card *card,unsigned int blocklen);
include/linux/mmc/host.h +3 -0
@@ -117,6 +117,9 @@ struct mmc_host_ops {/* optional callback for HC quirks */ void (*init_card)(struct mmc_host *host,struct mmc_card *card); + +/* Get host controller timeout clk */ +unsigned int (*get_tmclk)(struct mmc_host *host); };struct mmc_card ;
Signature · 1 line
1.6.6.1