aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/queue.c
diff options
context:
space:
mode:
authorMing Lei <[email protected]>2019-02-27 16:02:11 +0000
committerUlf Hansson <[email protected]>2019-02-27 17:01:25 +0000
commitc53336c8f5f29043fded57912cc06c24e12613d7 (patch)
treec498a37b659a6e2de273832fd990a2314d28f67d /drivers/mmc/core/queue.c
parentmmc: cqhci: Fix a tiny potential memory leak on error condition (diff)
downloadkernel-c53336c8f5f29043fded57912cc06c24e12613d7.tar.gz
kernel-c53336c8f5f29043fded57912cc06c24e12613d7.zip
mmc: core: align max segment size with logical block size
Logical block size is the lowest possible block size that the storage device can address. Max segment size is often related with controller's DMA capability. And it is reasonable to align max segment size with logical block size. SDHCI sets un-aligned max segment size, and causes ADMA error, so fix it by aligning max segment size with logical block size. Reported-by: Naresh Kamboju <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Naresh Kamboju <[email protected]> Cc: Faiz Abbas <[email protected]> Cc: [email protected] Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
Diffstat (limited to 'drivers/mmc/core/queue.c')
-rw-r--r--drivers/mmc/core/queue.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index 35cc138b096d..15a45ec6518d 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -355,6 +355,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
{
struct mmc_host *host = card->host;
u64 limit = BLK_BOUNCE_HIGH;
+ unsigned block_size = 512;
if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
@@ -368,7 +369,13 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
blk_queue_max_hw_sectors(mq->queue,
min(host->max_blk_count, host->max_req_size / 512));
blk_queue_max_segments(mq->queue, host->max_segs);
- blk_queue_max_segment_size(mq->queue, host->max_seg_size);
+
+ if (mmc_card_mmc(card))
+ block_size = card->ext_csd.data_sector_size;
+
+ blk_queue_logical_block_size(mq->queue, block_size);
+ blk_queue_max_segment_size(mq->queue,
+ round_down(host->max_seg_size, block_size));
INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler);
INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);