* [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support @ 2020-12-16 10:29 Yoshihiro Shimoda 2020-12-16 10:29 ` [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Yoshihiro Shimoda @ 2020-12-16 10:29 UTC (permalink / raw) To: ulf.hansson, wsa+renesas; +Cc: linux-mmc, linux-renesas-soc, Yoshihiro Shimoda To improve performance, add pre_req and post_req support into renesas_internal_dmac. Note that the patch [1/2] is a bug fix patch. Changes from v1: - Add a bug fix patch for hardware limitation in patch 1. - Remove a redundant argument in the unmap function in patch 2. - Describe the reason why we should not use host->sg_ptr in patch 2. - Rename argument of struct mmc_request from req to mrq in patch 2. Takeshi Saito (1): mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda (1): mmc: renesas_internal_dmac: add pre_req and post_req support drivers/mmc/host/renesas_sdhi_internal_dmac.c | 91 ++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 8 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes 2020-12-16 10:29 [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda @ 2020-12-16 10:29 ` Yoshihiro Shimoda 2020-12-17 7:09 ` Wolfram Sang 2020-12-16 10:29 ` [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda 2021-01-13 11:24 ` [PATCH v2 0/2] " Ulf Hansson 2 siblings, 1 reply; 6+ messages in thread From: Yoshihiro Shimoda @ 2020-12-16 10:29 UTC (permalink / raw) To: ulf.hansson, wsa+renesas Cc: linux-mmc, linux-renesas-soc, Takeshi Saito, Yoshihiro Shimoda From: Takeshi Saito <takeshi.saito.xv@renesas.com> According to the latest datasheet, the internal DMAC buffer alignment R-Car Gen3 SDHI HW should be 128-bytes. So, fix it. Signed-off-by: Takeshi Saito <takeshi.saito.xv@renesas.com> [shimoda: revise commit description, rebase] Fixes: 2a68ea7896e3 ("mmc: renesas-sdhi: add support for R-Car Gen3 SDHI DMAC") Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index fe13e1e..f3e76d6 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -186,8 +186,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, mmc_get_dma_dir(data))) goto force_pio; - /* This DMAC cannot handle if buffer is not 8-bytes alignment */ - if (!IS_ALIGNED(sg_dma_address(sg), 8)) + /* This DMAC cannot handle if buffer is not 128-bytes alignment */ + if (!IS_ALIGNED(sg_dma_address(sg), 128)) goto force_pio_with_unmap; if (data->flags & MMC_DATA_READ) { -- 2.7.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes 2020-12-16 10:29 ` [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda @ 2020-12-17 7:09 ` Wolfram Sang 0 siblings, 0 replies; 6+ messages in thread From: Wolfram Sang @ 2020-12-17 7:09 UTC (permalink / raw) To: Yoshihiro Shimoda Cc: ulf.hansson, linux-mmc, linux-renesas-soc, Takeshi Saito [-- Attachment #1: Type: text/plain, Size: 649 bytes --] On Wed, Dec 16, 2020 at 07:29:31PM +0900, Yoshihiro Shimoda wrote: > From: Takeshi Saito <takeshi.saito.xv@renesas.com> > > According to the latest datasheet, the internal DMAC buffer alignment > R-Car Gen3 SDHI HW should be 128-bytes. So, fix it. > > Signed-off-by: Takeshi Saito <takeshi.saito.xv@renesas.com> > [shimoda: revise commit description, rebase] > Fixes: 2a68ea7896e3 ("mmc: renesas-sdhi: add support for R-Car Gen3 SDHI DMAC") > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support 2020-12-16 10:29 [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda 2020-12-16 10:29 ` [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda @ 2020-12-16 10:29 ` Yoshihiro Shimoda 2020-12-16 14:11 ` Wolfram Sang 2021-01-13 11:24 ` [PATCH v2 0/2] " Ulf Hansson 2 siblings, 1 reply; 6+ messages in thread From: Yoshihiro Shimoda @ 2020-12-16 10:29 UTC (permalink / raw) To: ulf.hansson, wsa+renesas; +Cc: linux-mmc, linux-renesas-soc, Yoshihiro Shimoda Add pre_req and post_req support to improve performance. Inspired by a patch in the BSP by Masaharu Hayakawa. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 91 ++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index f3e76d6..ff97f15 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -56,6 +56,12 @@ #define INFO2_DTRANERR1 BIT(17) #define INFO2_DTRANERR0 BIT(16) +enum renesas_sdhi_dma_cookie { + COOKIE_UNMAPPED, + COOKIE_PRE_MAPPED, + COOKIE_MAPPED, +}; + /* * Specification of this driver: * - host->chan_{rx,tx} will be used as a flag of enabling/disabling the dma @@ -172,6 +178,50 @@ renesas_sdhi_internal_dmac_dataend_dma(struct tmio_mmc_host *host) { tasklet_schedule(&priv->dma_priv.dma_complete); } +/* + * renesas_sdhi_internal_dmac_map() will be called with two difference + * sg pointers in two mmc_data by .pre_req(), but tmio host can have a single + * sg_ptr only. So, renesas_sdhi_internal_dmac_{un}map() should use a sg + * pointer in a mmc_data instead of host->sg_ptr. + */ +static void +renesas_sdhi_internal_dmac_unmap(struct tmio_mmc_host *host, + struct mmc_data *data, + enum renesas_sdhi_dma_cookie cookie) +{ + bool unmap = cookie == COOKIE_UNMAPPED ? (data->host_cookie != cookie) : + (data->host_cookie == cookie); + + if (unmap) { + dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, + mmc_get_dma_dir(data)); + data->host_cookie = COOKIE_UNMAPPED; + } +} + +static bool +renesas_sdhi_internal_dmac_map(struct tmio_mmc_host *host, + struct mmc_data *data, + enum renesas_sdhi_dma_cookie cookie) +{ + if (data->host_cookie == COOKIE_PRE_MAPPED) + return true; + + if (!dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, + mmc_get_dma_dir(data))) + return false; + + data->host_cookie = cookie; + + /* This DMAC cannot handle if buffer is not 128-bytes alignment */ + if (!IS_ALIGNED(sg_dma_address(data->sg), 128)) { + renesas_sdhi_internal_dmac_unmap(host, data, cookie); + return false; + } + + return true; +} + static void renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, struct mmc_data *data) @@ -182,14 +232,9 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, if (!test_bit(SDHI_INTERNAL_DMAC_ADDR_MODE_FIXED_ONLY, &global_flags)) dtran_mode |= DTRAN_MODE_ADDR_MODE; - if (!dma_map_sg(&host->pdev->dev, sg, host->sg_len, - mmc_get_dma_dir(data))) + if (!renesas_sdhi_internal_dmac_map(host, data, COOKIE_MAPPED)) goto force_pio; - /* This DMAC cannot handle if buffer is not 128-bytes alignment */ - if (!IS_ALIGNED(sg_dma_address(sg), 128)) - goto force_pio_with_unmap; - if (data->flags & MMC_DATA_READ) { dtran_mode |= DTRAN_MODE_CH_NUM_CH1; if (test_bit(SDHI_INTERNAL_DMAC_ONE_RX_ONLY, &global_flags) && @@ -212,7 +257,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, return; force_pio_with_unmap: - dma_unmap_sg(&host->pdev->dev, sg, host->sg_len, mmc_get_dma_dir(data)); + renesas_sdhi_internal_dmac_unmap(host, data, COOKIE_UNMAPPED); force_pio: renesas_sdhi_internal_dmac_enable_dma(host, false); @@ -245,7 +290,7 @@ static bool renesas_sdhi_internal_dmac_complete(struct tmio_mmc_host *host) dir = DMA_TO_DEVICE; renesas_sdhi_internal_dmac_enable_dma(host, false); - dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->sg_len, dir); + renesas_sdhi_internal_dmac_unmap(host, host->data, COOKIE_MAPPED); if (dir == DMA_FROM_DEVICE) clear_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags); @@ -274,6 +319,32 @@ static void renesas_sdhi_internal_dmac_end_dma(struct tmio_mmc_host *host) renesas_sdhi_internal_dmac_complete(host); } +static void renesas_sdhi_internal_dmac_post_req(struct mmc_host *mmc, + struct mmc_request *mrq, + int err) +{ + struct tmio_mmc_host *host = mmc_priv(mmc); + struct mmc_data *data = mrq->data; + + if (!data) + return; + + renesas_sdhi_internal_dmac_unmap(host, data, COOKIE_UNMAPPED); +} + +static void renesas_sdhi_internal_dmac_pre_req(struct mmc_host *mmc, + struct mmc_request *mrq) +{ + struct tmio_mmc_host *host = mmc_priv(mmc); + struct mmc_data *data = mrq->data; + + if (!data) + return; + + data->host_cookie = COOKIE_UNMAPPED; + renesas_sdhi_internal_dmac_map(host, data, COOKIE_PRE_MAPPED); +} + static void renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) @@ -295,6 +366,10 @@ renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host, tasklet_init(&host->dma_issue, renesas_sdhi_internal_dmac_issue_tasklet_fn, (unsigned long)host); + + /* Add pre_req and post_req */ + host->ops.pre_req = renesas_sdhi_internal_dmac_pre_req; + host->ops.post_req = renesas_sdhi_internal_dmac_post_req; } static void -- 2.7.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support 2020-12-16 10:29 ` [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda @ 2020-12-16 14:11 ` Wolfram Sang 0 siblings, 0 replies; 6+ messages in thread From: Wolfram Sang @ 2020-12-16 14:11 UTC (permalink / raw) To: Yoshihiro Shimoda; +Cc: ulf.hansson, linux-mmc, linux-renesas-soc [-- Attachment #1: Type: text/plain, Size: 812 bytes --] On Wed, Dec 16, 2020 at 07:29:32PM +0900, Yoshihiro Shimoda wrote: > Add pre_req and post_req support to improve performance. > > Inspired by a patch in the BSP by Masaharu Hayakawa. > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> So, I tested this on H3 ES2.0 and M3-N with interesting results. H3 ES2.0 has a significant speedup: with: 254MB/s, without 207MB/s M3-N speedup is smaller but general throughput is much better: with: 262MB/s, without 250MB/s Same kernel, both systems idle otherwise. I don't think it has to do with the number of CPU cores, but more that the SDHI revision is a tad newer maybe? Patch looks good, too: Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support 2020-12-16 10:29 [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda 2020-12-16 10:29 ` [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda 2020-12-16 10:29 ` [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda @ 2021-01-13 11:24 ` Ulf Hansson 2 siblings, 0 replies; 6+ messages in thread From: Ulf Hansson @ 2021-01-13 11:24 UTC (permalink / raw) To: Yoshihiro Shimoda; +Cc: Wolfram Sang, linux-mmc, Linux-Renesas On Wed, 16 Dec 2020 at 11:29, Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> wrote: > > To improve performance, add pre_req and post_req support into > renesas_internal_dmac. Note that the patch [1/2] is a bug fix patch. > > Changes from v1: > - Add a bug fix patch for hardware limitation in patch 1. > - Remove a redundant argument in the unmap function in patch 2. > - Describe the reason why we should not use host->sg_ptr in patch 2. > - Rename argument of struct mmc_request from req to mrq in patch 2. > > Takeshi Saito (1): > mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to > 128-bytes > > Yoshihiro Shimoda (1): > mmc: renesas_internal_dmac: add pre_req and post_req support > > drivers/mmc/host/renesas_sdhi_internal_dmac.c | 91 ++++++++++++++++++++++++--- > 1 file changed, 83 insertions(+), 8 deletions(-) > Applied for next, thanks! Kind regards Uffe ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-13 11:26 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-16 10:29 [PATCH v2 0/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda 2020-12-16 10:29 ` [PATCH v2 1/2] mmc: renesas_sdhi_internal_dmac: Fix DMA buffer alignment from 8 to 128-bytes Yoshihiro Shimoda 2020-12-17 7:09 ` Wolfram Sang 2020-12-16 10:29 ` [PATCH v2 2/2] mmc: renesas_internal_dmac: add pre_req and post_req support Yoshihiro Shimoda 2020-12-16 14:11 ` Wolfram Sang 2021-01-13 11:24 ` [PATCH v2 0/2] " Ulf Hansson
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.