In IOMMU environment, since it's possible to merge scatter gather
buffers of memory requests to one iova, this patch changes the max_segs
value when init_card of mmc_host timing to improve the transfer
performance on renesas_sdhi_internal_dmac.

Notes that an sdio card may be possible to use scatter gather buffers
with non page aligned size, so that this driver will not use multiple
segments to avoid any trouble. Also, on renesas_sdhi_sys_dmac,
the max_segs value will change from 32 to 512, but the sys_dmac
can handle 512 segments, so that this init_card ops is added on
"TMIO_MMC_MIN_RCAR2" environment.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda...@renesas.com>
---
 drivers/mmc/host/renesas_sdhi_core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c 
b/drivers/mmc/host/renesas_sdhi_core.c
index 5e9e36e..29a7d66 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -203,6 +203,17 @@ static void renesas_sdhi_clk_disable(struct tmio_mmc_host 
*host)
        clk_disable_unprepare(priv->clk_cd);
 }
 
+static void renesas_sdhi_init_card(struct mmc_host *mmc, struct mmc_card *card)
+{
+       struct tmio_mmc_host *host = mmc_priv(mmc);
+
+       if (host->pdev->dev.iommu_group &&
+           (mmc_card_mmc(card) || mmc_card_sd(card)))
+               host->mmc->max_segs = 512;
+       else
+               host->mmc->max_segs = host->pdata->max_segs;
+}
+
 static int renesas_sdhi_card_busy(struct mmc_host *mmc)
 {
        struct tmio_mmc_host *host = mmc_priv(mmc);
@@ -726,6 +737,8 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 
        /* SDR speeds are only available on Gen2+ */
        if (mmc_data->flags & TMIO_MMC_MIN_RCAR2) {
+               host->ops.init_card = renesas_sdhi_init_card;
+
                /* card_busy caused issues on r8a73a4 (pre-Gen2) CD-less SDHI */
                host->ops.card_busy = renesas_sdhi_card_busy;
                host->ops.start_signal_voltage_switch =
-- 
2.7.4

Reply via email to