Skip to content

Commit

Permalink
mmc: tmio: rcar_gen3: Add DMA transfer address alignment check at wri…
Browse files Browse the repository at this point in the history
…ting

In R-Car Gen 3, there is a DMA controller restriction of SDHI.
When the transfer exceeding the 4 kByte boundary is performed while
the DRAM address is not 128 byte aligned, the bus is occupied.
This patch avoids this.

Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
  • Loading branch information
h-yokoya committed Feb 14, 2019
1 parent 9b61868 commit 3fae6a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/mmc/tmio-common.c
Expand Up @@ -375,14 +375,16 @@ static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
}

/* check if the address is DMA'able */
static bool tmio_sd_addr_is_dmaable(const char *src)
static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
{
uintptr_t addr = (uintptr_t)src;
uintptr_t addr = (uintptr_t)data->src;

if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
return false;

#if defined(CONFIG_RCAR_GEN3)
if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
return false;
/* Gen3 DMA has 32bit limit */
if (addr >> 32)
return false;
Expand Down Expand Up @@ -497,7 +499,7 @@ int tmio_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
if (data) {
/* use DMA if the HW supports it and the buffer is aligned */
if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL &&
tmio_sd_addr_is_dmaable(data->src))
tmio_sd_addr_is_dmaable(data))
ret = tmio_sd_dma_xfer(dev, data);
else
ret = tmio_sd_pio_xfer(dev, cmd, data);
Expand Down

0 comments on commit 3fae6a0

Please sign in to comment.