Skip to content

Commit 63d20a9

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Fix max_seg_size for 64KiB PAGE_SIZE
blk_queue_max_segment_size() ensured: if (max_size < PAGE_SIZE) max_size = PAGE_SIZE; whereas: blk_validate_limits() makes it an error: if (WARN_ON_ONCE(lim->max_segment_size < PAGE_SIZE)) return -EINVAL; The change from one to the other, exposed sdhci which was setting maximum segment size too low in some circumstances. Fix the maximum segment size when it is too low. Fixes: 616f876 ("mmc: pass queue_limits to blk_mq_alloc_disk") Cc: [email protected] Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Jon Hunter <[email protected]> Tested-by: Jon Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent ab069ce commit 63d20a9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,6 +4727,21 @@ int sdhci_setup_host(struct sdhci_host *host)
47274727
if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) {
47284728
host->max_adma = 65532; /* 32-bit alignment */
47294729
mmc->max_seg_size = 65535;
4730+
/*
4731+
* sdhci_adma_table_pre() expects to define 1 DMA
4732+
* descriptor per segment, so the maximum segment size
4733+
* is set accordingly. SDHCI allows up to 64KiB per DMA
4734+
* descriptor (16-bit field), but some controllers do
4735+
* not support "zero means 65536" reducing the maximum
4736+
* for them to 65535. That is a problem if PAGE_SIZE is
4737+
* 64KiB because the block layer does not support
4738+
* max_seg_size < PAGE_SIZE, however
4739+
* sdhci_adma_table_pre() has a workaround to handle
4740+
* that case, and split the descriptor. Refer also
4741+
* comment in sdhci_adma_table_pre().
4742+
*/
4743+
if (mmc->max_seg_size < PAGE_SIZE)
4744+
mmc->max_seg_size = PAGE_SIZE;
47304745
} else {
47314746
mmc->max_seg_size = 65536;
47324747
}

0 commit comments

Comments
 (0)