Skip to content

Commit c53336c

Browse files
Ming Leistorulf
authored andcommitted
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 <naresh.kamboju@linaro.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Naresh Kamboju <naresh.kamboju@linaro.org> Cc: Faiz Abbas <faiz_abbas@ti.com> Cc: linux-block@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent d07e9fa commit c53336c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/mmc/core/block.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
23802380
snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
23812381
"mmcblk%u%s", card->host->index, subname ? subname : "");
23822382

2383-
if (mmc_card_mmc(card))
2384-
blk_queue_logical_block_size(md->queue.queue,
2385-
card->ext_csd.data_sector_size);
2386-
else
2387-
blk_queue_logical_block_size(md->queue.queue, 512);
2388-
23892383
set_capacity(md->disk, size);
23902384

23912385
if (mmc_host_cmd23(card->host)) {

drivers/mmc/core/queue.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
355355
{
356356
struct mmc_host *host = card->host;
357357
u64 limit = BLK_BOUNCE_HIGH;
358+
unsigned block_size = 512;
358359

359360
if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
360361
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)
368369
blk_queue_max_hw_sectors(mq->queue,
369370
min(host->max_blk_count, host->max_req_size / 512));
370371
blk_queue_max_segments(mq->queue, host->max_segs);
371-
blk_queue_max_segment_size(mq->queue, host->max_seg_size);
372+
373+
if (mmc_card_mmc(card))
374+
block_size = card->ext_csd.data_sector_size;
375+
376+
blk_queue_logical_block_size(mq->queue, block_size);
377+
blk_queue_max_segment_size(mq->queue,
378+
round_down(host->max_seg_size, block_size));
372379

373380
INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler);
374381
INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);

0 commit comments

Comments
 (0)