Skip to content

Commit e90e8da

Browse files
shimodaystorulf
authored andcommitted
mmc: tmio: fix swiotlb buffer is full
Since the commit de3ee99 ("mmc: Delete bounce buffer handling") deletes the bounce buffer handling, a request data size will be referred to max_{req,seg}_size instead of MMC_QUEUE_BOUNCESZ (64k bytes). In other hand, renesas_sdhi_internal_dmac.c will set very big value of max_{req,seg}_size because the max_blk_count is set to 0xffffffff. And then, "swiotlb buffer is full" happens because swiotlb can handle a memory size up to 256k bytes only (IO_TLB_SEGSIZE = 128 and IO_TLB_SHIFT = 11). So, as a workaround, this patch avoids the issue by setting the max_{req,seg}_size up to 256k bytes if swiotlb is running. Reported-by: Dirk Behme <[email protected]> Signed-off-by: Yoshihiro Shimoda <[email protected]> Acked-by: Wolfram Sang <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent eb701ce commit e90e8da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <linux/mmc/sdio.h>
4848
#include <linux/scatterlist.h>
4949
#include <linux/spinlock.h>
50+
#include <linux/swiotlb.h>
5051
#include <linux/workqueue.h>
5152

5253
#include "tmio_mmc.h"
@@ -1215,6 +1216,18 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
12151216
mmc->max_blk_count = pdata->max_blk_count ? :
12161217
(PAGE_SIZE / mmc->max_blk_size) * mmc->max_segs;
12171218
mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
1219+
/*
1220+
* Since swiotlb has memory size limitation, this will calculate
1221+
* the maximum size locally (because we don't have any APIs for it now)
1222+
* and check the current max_req_size. And then, this will update
1223+
* the max_req_size if needed as a workaround.
1224+
*/
1225+
if (swiotlb_max_segment()) {
1226+
unsigned int max_size = (1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
1227+
1228+
if (mmc->max_req_size > max_size)
1229+
mmc->max_req_size = max_size;
1230+
}
12181231
mmc->max_seg_size = mmc->max_req_size;
12191232

12201233
_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||

0 commit comments

Comments
 (0)