From patchwork Fri Nov 22 06:13:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 11257231 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A718C1390 for ; Fri, 22 Nov 2019 06:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90CF12070B for ; Fri, 22 Nov 2019 06:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727678AbfKVGQY (ORCPT ); Fri, 22 Nov 2019 01:16:24 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:6348 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729496AbfKVGNw (ORCPT ); Fri, 22 Nov 2019 01:13:52 -0500 X-IronPort-AV: E=Sophos;i="5.69,228,1571670000"; d="scan'208";a="32366337" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 22 Nov 2019 15:13:51 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A515D400D0F9; Fri, 22 Nov 2019 15:13:51 +0900 (JST) From: Yoshihiro Shimoda To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda Subject: [PATCH RFC 1/4] mmc: host: renesas_sdhi_sys_dmac: Use dma_buswidth instead of hardcoded value Date: Fri, 22 Nov 2019 15:13:48 +0900 Message-Id: <1574403231-18512-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org This patch uses dma_buswidth instread of hardcoded value of TMIO_MMC_MIN_DMA_LEN (8) for increasing the buswidth in the future. Note that, since the dma_buswidth is 4 and the align is 2, when the sg_tmp->length is 6, it cannot transfer correcly. So, this patch changes the conditions. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Ulrich Hecht --- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index 13ff023..30f34a3 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -23,8 +23,6 @@ #include "renesas_sdhi.h" #include "tmio_mmc.h" -#define TMIO_MMC_MIN_DMA_LEN 8 - static const struct renesas_sdhi_of_data of_default_cfg = { .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, }; @@ -159,11 +157,12 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host) int ret, i; bool aligned = true, multiple = true; unsigned int align = (1 << host->pdata->alignment_shift) - 1; + unsigned int min_len = priv->dma_priv.dma_buswidth ? : align + 1; for_each_sg(sg, sg_tmp, host->sg_len, i) { if (sg_tmp->offset & align) aligned = false; - if (sg_tmp->length & align) { + if (sg_tmp->length % min_len) { multiple = false; break; } @@ -175,7 +174,7 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host) goto pio; } - if (sg->length < TMIO_MMC_MIN_DMA_LEN) + if (sg->length < min_len) return; /* The only sg element can be unaligned, use our bounce buffer then */ @@ -231,11 +230,12 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) int ret, i; bool aligned = true, multiple = true; unsigned int align = (1 << host->pdata->alignment_shift) - 1; + unsigned int min_len = priv->dma_priv.dma_buswidth ? : align + 1; for_each_sg(sg, sg_tmp, host->sg_len, i) { if (sg_tmp->offset & align) aligned = false; - if (sg_tmp->length & align) { + if (sg_tmp->length % min_len) { multiple = false; break; } @@ -247,7 +247,7 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) goto pio; } - if (sg->length < TMIO_MMC_MIN_DMA_LEN) + if (sg->length < min_len) return; /* The only sg element can be unaligned, use our bounce buffer then */ From patchwork Fri Nov 22 06:13:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 11257223 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 352EA1390 for ; Fri, 22 Nov 2019 06:13:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F1AD2072D for ; Fri, 22 Nov 2019 06:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729517AbfKVGNy (ORCPT ); Fri, 22 Nov 2019 01:13:54 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:37970 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729511AbfKVGNx (ORCPT ); Fri, 22 Nov 2019 01:13:53 -0500 X-IronPort-AV: E=Sophos;i="5.69,228,1571670000"; d="scan'208";a="32153145" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 22 Nov 2019 15:13:51 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id AE30E400D0F4; Fri, 22 Nov 2019 15:13:51 +0900 (JST) From: Yoshihiro Shimoda To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda Subject: [PATCH RFC 2/4] mmc: host: renesas_sdhi_sys_dmac: Do not fall back to PIO Date: Fri, 22 Nov 2019 15:13:49 +0900 Message-Id: <1574403231-18512-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Falling back to PIO forever is not convenience if a buffer condition is not match with the hardware once. So, this patch removes it. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Ulrich Hecht --- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 35 +++++++------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index 30f34a3..09137cc 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -175,7 +175,7 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host) } if (sg->length < min_len) - return; + goto pio; /* The only sg element can be unaligned, use our bounce buffer then */ if (!aligned) { @@ -200,23 +200,13 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host) ret = cookie; } host->dma_on = true; + renesas_sdhi_sys_dmac_enable_dma(host, true); } pio: if (!desc) { - /* DMA failed, fall back to PIO */ renesas_sdhi_sys_dmac_enable_dma(host, false); - if (ret >= 0) - ret = -EIO; - host->chan_rx = NULL; - dma_release_channel(chan); - /* Free the Tx channel too */ - chan = host->chan_tx; - if (chan) { - host->chan_tx = NULL; - dma_release_channel(chan); - } - dev_warn(&host->pdev->dev, - "DMA failed: %d, falling back to PIO\n", ret); + host->dma_on = false; + dev_dbg(&host->pdev->dev, "DMA failed: %d\n", ret); } } @@ -248,7 +238,7 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) } if (sg->length < min_len) - return; + goto pio; /* The only sg element can be unaligned, use our bounce buffer then */ if (!aligned) { @@ -281,20 +271,9 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host) } pio: if (!desc) { - /* DMA failed, fall back to PIO */ renesas_sdhi_sys_dmac_enable_dma(host, false); - if (ret >= 0) - ret = -EIO; - host->chan_tx = NULL; - dma_release_channel(chan); - /* Free the Rx channel too */ - chan = host->chan_rx; - if (chan) { - host->chan_rx = NULL; - dma_release_channel(chan); - } - dev_warn(&host->pdev->dev, - "DMA failed: %d, falling back to PIO\n", ret); + host->dma_on = false; + dev_dbg(&host->pdev->dev, "DMA failed: %d\n", ret); } } From patchwork Fri Nov 22 06:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 11257227 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB15C1593 for ; Fri, 22 Nov 2019 06:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 899AC20708 for ; Fri, 22 Nov 2019 06:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729511AbfKVGNy (ORCPT ); Fri, 22 Nov 2019 01:13:54 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:6348 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727569AbfKVGNx (ORCPT ); Fri, 22 Nov 2019 01:13:53 -0500 X-IronPort-AV: E=Sophos;i="5.69,228,1571670000"; d="scan'208";a="32366340" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 22 Nov 2019 15:13:51 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B741A400D0F7; Fri, 22 Nov 2019 15:13:51 +0900 (JST) From: Yoshihiro Shimoda To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda Subject: [PATCH RFC 3/4] mmc: host: renesas_sdhi_sys_dmac: add DMACR setting Date: Fri, 22 Nov 2019 15:13:50 +0900 Message-Id: <1574403231-18512-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org This patch adds DMACR setting which needs to use the 32 bytes transfer mode of SYS-DMAC. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Ulrich Hecht --- drivers/mmc/host/renesas_sdhi_core.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 234551a..d9a69f6 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -46,6 +47,12 @@ #define SDHI_VER_GEN3_SD 0xcc10 #define SDHI_VER_GEN3_SDMMC 0xcd10 +#define DMACR_SDR104 0x192 +#define DMACR_SDR104_32BYTE 0x0004 +#define DMACR_SDR50 0xe4 +#define DMACR_SDR50_32BYTE 0x000a +#define DMACR_2_OR_4BYTE 0x0000 + struct renesas_sdhi_quirks { bool hs400_disabled; bool hs400_4taps; @@ -604,6 +611,32 @@ static int renesas_sdhi_multi_io_quirk(struct mmc_card *card, return blk_size; } +static void renesas_sdhi_set_dmacr(struct tmio_mmc_host *host) +{ + struct renesas_sdhi *priv = host_to_priv(host); + u16 val = DMACR_2_OR_4BYTE; + u16 reg; + enum dma_slave_buswidth width = priv->dma_priv.dma_buswidth; + + switch (sd_ctrl_read16(host, CTL_VERSION)) { + case SDHI_VER_GEN2_SDR50: + if (width == DMA_SLAVE_BUSWIDTH_32_BYTES) + val = DMACR_SDR50_32BYTE; + reg = DMACR_SDR50; + break; + case SDHI_VER_GEN2_SDR104: + if (width == DMA_SLAVE_BUSWIDTH_32_BYTES) + val = DMACR_SDR104_32BYTE; + reg = DMACR_SDR104; + break; + default: + /* nothing to do */ + return; + } + + sd_ctrl_write16(host, reg, val); +} + static void renesas_sdhi_enable_dma(struct tmio_mmc_host *host, bool enable) { /* Iff regs are 8 byte apart, sdbuf is 64 bit. Otherwise always 32. */ @@ -611,6 +644,8 @@ static void renesas_sdhi_enable_dma(struct tmio_mmc_host *host, bool enable) sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? DMA_ENABLE_DMASDRW : 0); renesas_sdhi_sdbuf_width(host, enable ? width : 16); + + renesas_sdhi_set_dmacr(host); } static const struct renesas_sdhi_quirks sdhi_quirks_4tap_nohs400 = { From patchwork Fri Nov 22 06:13:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 11257225 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1591514C0 for ; Fri, 22 Nov 2019 06:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E837B20708 for ; Fri, 22 Nov 2019 06:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729530AbfKVGNz (ORCPT ); Fri, 22 Nov 2019 01:13:55 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:61957 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729514AbfKVGNy (ORCPT ); Fri, 22 Nov 2019 01:13:54 -0500 X-IronPort-AV: E=Sophos;i="5.69,228,1571670000"; d="scan'208";a="32153148" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 22 Nov 2019 15:13:51 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id C0654400D0F7; Fri, 22 Nov 2019 15:13:51 +0900 (JST) From: Yoshihiro Shimoda To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda Subject: [PATCH RFC 4/4] mmc: host: renesas_sdhi_sys_dmac: Set dma_buswidth value to 32 byte Date: Fri, 22 Nov 2019 15:13:51 +0900 Message-Id: <1574403231-18512-5-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1574403231-18512-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org To improve performance, this patch sets dma_buswidth value to 32 when transfer size is multiples of 32. In other words, a sd card transfer's size if not multiples of 32, this driver uses PIO and then the performance will be down. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Ulrich Hecht --- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index 09137cc..65e71b6 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -58,7 +58,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | MMC_CAP_CMD23, .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, - .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, + .dma_buswidth = DMA_SLAVE_BUSWIDTH_32_BYTES, .dma_rx_offset = 0x2000, .scc_offset = 0x0300, .taps = rcar_gen2_scc_taps,