Skip to content

Commit faf73fa

Browse files
committed
Merge branch 'fixes' into next
2 parents 35ed78a + 48e1dc1 commit faf73fa

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

drivers/mmc/host/renesas_sdhi_internal_dmac.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
146146
WARN_ON(host->sg_len > 1);
147147

148148
/* This DMAC cannot handle if buffer is not 8-bytes alignment */
149-
if (!IS_ALIGNED(sg->offset, 8)) {
150-
host->force_pio = true;
151-
renesas_sdhi_internal_dmac_enable_dma(host, false);
152-
return;
153-
}
149+
if (!IS_ALIGNED(sg->offset, 8))
150+
goto force_pio;
154151

155152
if (data->flags & MMC_DATA_READ) {
156153
dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
@@ -163,8 +160,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
163160
}
164161

165162
ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir);
166-
if (ret < 0)
167-
return;
163+
if (ret == 0)
164+
goto force_pio;
168165

169166
renesas_sdhi_internal_dmac_enable_dma(host, true);
170167

@@ -176,6 +173,12 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
176173
dtran_mode);
177174
renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR,
178175
sg->dma_address);
176+
177+
return;
178+
179+
force_pio:
180+
host->force_pio = true;
181+
renesas_sdhi_internal_dmac_enable_dma(host, false);
179182
}
180183

181184
static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)

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)