Skip to content

Commit 01ec3bb

Browse files
committed
Merge tag 'mmc-v6.10-rc4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC host fixes from Ulf Hansson: - davinci_mmc: Prevent transmitted data size from exceeding sgm's length - sdhci: Fix max_seg_size for 64KiB PAGE_SIZE * tag 'mmc-v6.10-rc4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: davinci_mmc: Prevent transmitted data size from exceeding sgm's length mmc: sdhci: Fix max_seg_size for 64KiB PAGE_SIZE
2 parents e091caf + 16198ee commit 01ec3bb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/mmc/host/davinci_mmc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host,
224224
}
225225
p = sgm->addr;
226226

227+
if (n > sgm->length)
228+
n = sgm->length;
229+
227230
/* NOTE: we never transfer more than rw_threshold bytes
228231
* to/from the fifo here; there's no I/O overlap.
229232
* This also assumes that access width( i.e. ACCWD) is 4 bytes

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)