* [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst
@ 2025-12-21 8:04 Chen-Yu Tsai
2025-12-21 15:57 ` Jernej Škrabec
2025-12-23 11:28 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2025-12-21 8:04 UTC (permalink / raw)
To: Vinod Koul, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: Andre Przywara, dmaengine, linux-sunxi, linux-arm-kernel,
linux-kernel
maxburst, as provided by the client, specifies the largest amount of
data that is allowed to be transferred in one burst. This limit is
normally provided to avoid a data burst overflowing the target FIFO.
It does not mean that the DMA engine can only do bursts in that size.
Let the driver pick the largest supported burst length within the
given limit. This lets the driver work correctly with some clients that
give a large maxburst value. In particular, the 8250_dw driver will give
a quarter of the UART's FIFO size as maxburst. On some systems the FIFO
size is 256 bytes, giving a maxburst of 64 bytes, while the hardware
only supports bursts of up to 16 bytes.
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
---
drivers/dma/sun6i-dma.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index 2215ff877bf7..f9d876deb1f0 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -583,6 +583,22 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id)
return ret;
}
+static u32 find_burst_size(const u32 burst_lengths, u32 maxburst)
+{
+ if (!maxburst)
+ return 1;
+
+ if (BIT(maxburst) & burst_lengths)
+ return maxburst;
+
+ /* Hardware only does power-of-two bursts. */
+ for (u32 burst = rounddown_pow_of_two(maxburst); burst > 0; burst /= 2)
+ if (BIT(burst) & burst_lengths)
+ return burst;
+
+ return 1;
+}
+
static int set_config(struct sun6i_dma_dev *sdev,
struct dma_slave_config *sconfig,
enum dma_transfer_direction direction,
@@ -616,15 +632,13 @@ static int set_config(struct sun6i_dma_dev *sdev,
return -EINVAL;
if (!(BIT(dst_addr_width) & sdev->slave.dst_addr_widths))
return -EINVAL;
- if (!(BIT(src_maxburst) & sdev->cfg->src_burst_lengths))
- return -EINVAL;
- if (!(BIT(dst_maxburst) & sdev->cfg->dst_burst_lengths))
- return -EINVAL;
src_width = convert_buswidth(src_addr_width);
dst_width = convert_buswidth(dst_addr_width);
- dst_burst = convert_burst(dst_maxburst);
- src_burst = convert_burst(src_maxburst);
+ src_burst = find_burst_size(sdev->cfg->src_burst_lengths, src_maxburst);
+ dst_burst = find_burst_size(sdev->cfg->dst_burst_lengths, dst_maxburst);
+ dst_burst = convert_burst(dst_burst);
+ src_burst = convert_burst(src_burst);
*p_cfg = DMA_CHAN_CFG_SRC_WIDTH(src_width) |
DMA_CHAN_CFG_DST_WIDTH(dst_width);
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst
2025-12-21 8:04 [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst Chen-Yu Tsai
@ 2025-12-21 15:57 ` Jernej Škrabec
2025-12-23 11:28 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Jernej Škrabec @ 2025-12-21 15:57 UTC (permalink / raw)
To: Vinod Koul, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
Chen-Yu Tsai
Cc: Andre Przywara, dmaengine, linux-sunxi, linux-arm-kernel,
linux-kernel
Dne nedelja, 21. december 2025 ob 09:04:48 Srednjeevropski standardni čas je Chen-Yu Tsai napisal(a):
> maxburst, as provided by the client, specifies the largest amount of
> data that is allowed to be transferred in one burst. This limit is
> normally provided to avoid a data burst overflowing the target FIFO.
> It does not mean that the DMA engine can only do bursts in that size.
>
> Let the driver pick the largest supported burst length within the
> given limit. This lets the driver work correctly with some clients that
> give a large maxburst value. In particular, the 8250_dw driver will give
> a quarter of the UART's FIFO size as maxburst. On some systems the FIFO
> size is 256 bytes, giving a maxburst of 64 bytes, while the hardware
> only supports bursts of up to 16 bytes.
>
> Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst
2025-12-21 8:04 [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst Chen-Yu Tsai
2025-12-21 15:57 ` Jernej Škrabec
@ 2025-12-23 11:28 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-12-23 11:28 UTC (permalink / raw)
To: Jernej Skrabec, Samuel Holland, Chen-Yu Tsai
Cc: Andre Przywara, dmaengine, linux-sunxi, linux-arm-kernel,
linux-kernel
On Sun, 21 Dec 2025 16:04:48 +0800, Chen-Yu Tsai wrote:
> maxburst, as provided by the client, specifies the largest amount of
> data that is allowed to be transferred in one burst. This limit is
> normally provided to avoid a data burst overflowing the target FIFO.
> It does not mean that the DMA engine can only do bursts in that size.
>
> Let the driver pick the largest supported burst length within the
> given limit. This lets the driver work correctly with some clients that
> give a large maxburst value. In particular, the 8250_dw driver will give
> a quarter of the UART's FIFO size as maxburst. On some systems the FIFO
> size is 256 bytes, giving a maxburst of 64 bytes, while the hardware
> only supports bursts of up to 16 bytes.
>
> [...]
Applied, thanks!
[1/1] dmaengine: sun6i: Choose appropriate burst length under maxburst
commit: 7178c3586ab42693b28bb81014320a7783e5c435
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-23 11:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-21 8:04 [PATCH] dmaengine: sun6i: Choose appropriate burst length under maxburst Chen-Yu Tsai
2025-12-21 15:57 ` Jernej Škrabec
2025-12-23 11:28 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox