* [PATCH] mmc: moxart: set maximum request/block/segment sizes
@ 2023-02-10 14:38 Sergei Antonov
2023-02-14 12:18 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Sergei Antonov @ 2023-02-10 14:38 UTC (permalink / raw)
To: linux-mmc, ulf.hansson; +Cc: jonas.jensen, Sergei Antonov
Per datasheet: maximum block length is 2048 bytes,
data length field is in bits 0-23 of the Data Length Register.
Also for DMA mode we have to take into account rx/tx buffers' sizes.
In my tests this change doubles SD card I/O performance on big files.
Before the change Linux used default request size of 4 KB.
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
drivers/mmc/host/moxart-mmc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index 52ed30f2d9f4..2d002c81dcf3 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -611,6 +611,9 @@ static int moxart_probe(struct platform_device *pdev)
mmc->f_max = DIV_ROUND_CLOSEST(host->sysclk, 2);
mmc->f_min = DIV_ROUND_CLOSEST(host->sysclk, CLK_DIV_MASK * 2);
mmc->ocr_avail = 0xffff00; /* Support 2.0v - 3.6v power. */
+ mmc->max_blk_size = 2048; /* Max. block length in REG_DATA_CONTROL */
+ mmc->max_req_size = DATA_LEN_MASK; /* bits 0-23 in REG_DATA_LENGTH */
+ mmc->max_blk_count = mmc->max_req_size / 512;
if (IS_ERR(host->dma_chan_tx) || IS_ERR(host->dma_chan_rx)) {
if (PTR_ERR(host->dma_chan_tx) == -EPROBE_DEFER ||
@@ -628,6 +631,8 @@ static int moxart_probe(struct platform_device *pdev)
}
dev_dbg(dev, "PIO mode transfer enabled\n");
host->have_dma = false;
+
+ mmc->max_seg_size = mmc->max_req_size;
} else {
dev_dbg(dev, "DMA channels found (%p,%p)\n",
host->dma_chan_tx, host->dma_chan_rx);
@@ -646,6 +651,10 @@ static int moxart_probe(struct platform_device *pdev)
cfg.src_addr = host->reg_phys + REG_DATA_WINDOW;
cfg.dst_addr = 0;
dmaengine_slave_config(host->dma_chan_rx, &cfg);
+
+ mmc->max_seg_size = min3(mmc->max_req_size,
+ dma_get_max_seg_size(host->dma_chan_rx->device->dev),
+ dma_get_max_seg_size(host->dma_chan_tx->device->dev));
}
if (readl(host->base + REG_BUS_WIDTH) & BUS_WIDTH_4_SUPPORT)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: moxart: set maximum request/block/segment sizes
2023-02-10 14:38 [PATCH] mmc: moxart: set maximum request/block/segment sizes Sergei Antonov
@ 2023-02-14 12:18 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2023-02-14 12:18 UTC (permalink / raw)
To: Sergei Antonov; +Cc: linux-mmc, jonas.jensen
On Fri, 10 Feb 2023 at 15:38, Sergei Antonov <saproj@gmail.com> wrote:
>
> Per datasheet: maximum block length is 2048 bytes,
> data length field is in bits 0-23 of the Data Length Register.
>
> Also for DMA mode we have to take into account rx/tx buffers' sizes.
>
> In my tests this change doubles SD card I/O performance on big files.
> Before the change Linux used default request size of 4 KB.
>
> Signed-off-by: Sergei Antonov <saproj@gmail.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/host/moxart-mmc.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
> index 52ed30f2d9f4..2d002c81dcf3 100644
> --- a/drivers/mmc/host/moxart-mmc.c
> +++ b/drivers/mmc/host/moxart-mmc.c
> @@ -611,6 +611,9 @@ static int moxart_probe(struct platform_device *pdev)
> mmc->f_max = DIV_ROUND_CLOSEST(host->sysclk, 2);
> mmc->f_min = DIV_ROUND_CLOSEST(host->sysclk, CLK_DIV_MASK * 2);
> mmc->ocr_avail = 0xffff00; /* Support 2.0v - 3.6v power. */
> + mmc->max_blk_size = 2048; /* Max. block length in REG_DATA_CONTROL */
> + mmc->max_req_size = DATA_LEN_MASK; /* bits 0-23 in REG_DATA_LENGTH */
> + mmc->max_blk_count = mmc->max_req_size / 512;
>
> if (IS_ERR(host->dma_chan_tx) || IS_ERR(host->dma_chan_rx)) {
> if (PTR_ERR(host->dma_chan_tx) == -EPROBE_DEFER ||
> @@ -628,6 +631,8 @@ static int moxart_probe(struct platform_device *pdev)
> }
> dev_dbg(dev, "PIO mode transfer enabled\n");
> host->have_dma = false;
> +
> + mmc->max_seg_size = mmc->max_req_size;
> } else {
> dev_dbg(dev, "DMA channels found (%p,%p)\n",
> host->dma_chan_tx, host->dma_chan_rx);
> @@ -646,6 +651,10 @@ static int moxart_probe(struct platform_device *pdev)
> cfg.src_addr = host->reg_phys + REG_DATA_WINDOW;
> cfg.dst_addr = 0;
> dmaengine_slave_config(host->dma_chan_rx, &cfg);
> +
> + mmc->max_seg_size = min3(mmc->max_req_size,
> + dma_get_max_seg_size(host->dma_chan_rx->device->dev),
> + dma_get_max_seg_size(host->dma_chan_tx->device->dev));
> }
>
> if (readl(host->base + REG_BUS_WIDTH) & BUS_WIDTH_4_SUPPORT)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-14 12:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 14:38 [PATCH] mmc: moxart: set maximum request/block/segment sizes Sergei Antonov
2023-02-14 12:18 ` 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.