linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support
@ 2021-06-24  9:39 Amelie Delaunay
  2021-06-24  9:39 ` [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma Amelie Delaunay
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Amelie Delaunay @ 2021-06-24  9:39 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Dan Williams, Maxime Coquelin, Alexandre Torgue
  Cc: dmaengine, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, Amelie Delaunay, Pierre-Yves Mordret

Default REQ/ACK protocol consists in maintaining ACK signal up to the
removal of REQuest and the transfer completion.
In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the
removal of the REQuest, but only the transfer completion.
Due to a possible DMA stream lock when transferring data to/from STM32
USART/UART, add support to select alternative REQ/ACK protocol.

Amelie Delaunay (2):
  dt-bindings: dma: add alternative REQ/ACK protocol selection in
    stm32-dma
  dmaengine: stm32-dma: add alternate REQ/ACK protocol management

 Documentation/devicetree/bindings/dma/st,stm32-dma.yaml | 7 +++++++
 drivers/dma/stm32-dma.c                                 | 8 ++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma
  2021-06-24  9:39 [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Amelie Delaunay
@ 2021-06-24  9:39 ` Amelie Delaunay
  2021-07-14 19:27   ` Rob Herring
  2021-06-24  9:39 ` [PATCH 2/2] dmaengine: stm32-dma: add alternate REQ/ACK protocol management Amelie Delaunay
  2021-07-28  7:09 ` [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Vinod Koul
  2 siblings, 1 reply; 5+ messages in thread
From: Amelie Delaunay @ 2021-06-24  9:39 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Dan Williams, Maxime Coquelin, Alexandre Torgue
  Cc: dmaengine, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, Amelie Delaunay, Pierre-Yves Mordret

Default REQ/ACK protocol consists in maintaining ACK signal up to the
removal of REQuest and the transfer completion.
In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the
removal of the REQuest, but only the transfer completion.
Due to a possible DMA stream lock when transferring data to/from STM32
USART/UART, this new bindings allow to select this alternative protocol in
device tree, especially for STM32 USART/UART nodes.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 Documentation/devicetree/bindings/dma/st,stm32-dma.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/dma/st,stm32-dma.yaml b/Documentation/devicetree/bindings/dma/st,stm32-dma.yaml
index 2a5325f480f6..4bf676fd25dc 100644
--- a/Documentation/devicetree/bindings/dma/st,stm32-dma.yaml
+++ b/Documentation/devicetree/bindings/dma/st,stm32-dma.yaml
@@ -40,6 +40,13 @@ description: |
          0x0: FIFO mode with threshold selectable with bit 0-1
          0x1: Direct mode: each DMA request immediately initiates a transfer
               from/to the memory, FIFO is bypassed.
+       -bit 4: alternative DMA request/acknowledge protocol
+         0x0: Use standard DMA ACK management, where ACK signal is maintained
+              up to the removal of request and transfer completion
+         0x1: Use alternative DMA ACK management, where ACK de-assertion does
+              not wait for the de-assertion of the REQuest, ACK is only managed
+              by transfer completion. This must only be used on channels
+              managing transfers for STM32 USART/UART.
 
 
 maintainers:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] dmaengine: stm32-dma: add alternate REQ/ACK protocol management
  2021-06-24  9:39 [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Amelie Delaunay
  2021-06-24  9:39 ` [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma Amelie Delaunay
@ 2021-06-24  9:39 ` Amelie Delaunay
  2021-07-28  7:09 ` [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Vinod Koul
  2 siblings, 0 replies; 5+ messages in thread
From: Amelie Delaunay @ 2021-06-24  9:39 UTC (permalink / raw)
  To: Vinod Koul, Rob Herring, Dan Williams, Maxime Coquelin, Alexandre Torgue
  Cc: dmaengine, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, Amelie Delaunay, Pierre-Yves Mordret

STM32 USART/UART is not managing correctly the default DMA REQ/ACK protocol
leading to possibly lock the DMA stream.
Default protocol consists in maintaining ACK signal up to the removal of
REQuest and the transfer completion.
In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the
removal of the REQuest, but only the transfer completion.

This patch retrieves the need of the alternative protocol through the
device tree, and sets the protocol accordingly.
It also unwrap STM32_DMA_DIRECT_MODE_GET macro definition for consistency
with new STM32_DMA_ALT_ACK_MODE_GET macro definition.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
---
 drivers/dma/stm32-dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index f54ecb123a52..d3aa34b3d2f7 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -60,6 +60,7 @@
 #define STM32_DMA_SCR_PSIZE_GET(n)	((n & STM32_DMA_SCR_PSIZE_MASK) >> 11)
 #define STM32_DMA_SCR_DIR_MASK		GENMASK(7, 6)
 #define STM32_DMA_SCR_DIR(n)		((n & 0x3) << 6)
+#define STM32_DMA_SCR_TRBUFF		BIT(20) /* Bufferable transfer for USART/UART */
 #define STM32_DMA_SCR_CT		BIT(19) /* Target in double buffer */
 #define STM32_DMA_SCR_DBM		BIT(18) /* Double Buffer Mode */
 #define STM32_DMA_SCR_PINCOS		BIT(15) /* Peripheral inc offset size */
@@ -138,8 +139,9 @@
 #define STM32_DMA_THRESHOLD_FTR_MASK	GENMASK(1, 0)
 #define STM32_DMA_THRESHOLD_FTR_GET(n)	((n) & STM32_DMA_THRESHOLD_FTR_MASK)
 #define STM32_DMA_DIRECT_MODE_MASK	BIT(2)
-#define STM32_DMA_DIRECT_MODE_GET(n)	(((n) & STM32_DMA_DIRECT_MODE_MASK) \
-					 >> 2)
+#define STM32_DMA_DIRECT_MODE_GET(n)	(((n) & STM32_DMA_DIRECT_MODE_MASK) >> 2)
+#define STM32_DMA_ALT_ACK_MODE_MASK	BIT(4)
+#define STM32_DMA_ALT_ACK_MODE_GET(n)	(((n) & STM32_DMA_ALT_ACK_MODE_MASK) >> 4)
 
 enum stm32_dma_width {
 	STM32_DMA_BYTE,
@@ -1252,6 +1254,8 @@ static void stm32_dma_set_config(struct stm32_dma_chan *chan,
 	chan->threshold = STM32_DMA_THRESHOLD_FTR_GET(cfg->features);
 	if (STM32_DMA_DIRECT_MODE_GET(cfg->features))
 		chan->threshold = STM32_DMA_FIFO_THRESHOLD_NONE;
+	if (STM32_DMA_ALT_ACK_MODE_GET(cfg->features))
+		chan->chan_reg.dma_scr |= STM32_DMA_SCR_TRBUFF;
 }
 
 static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma
  2021-06-24  9:39 ` [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma Amelie Delaunay
@ 2021-07-14 19:27   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2021-07-14 19:27 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Pierre-Yves Mordret, Dan Williams, Vinod Koul, Rob Herring,
	dmaengine, Alexandre Torgue, Maxime Coquelin, devicetree,
	linux-kernel, linux-stm32, linux-arm-kernel

On Thu, 24 Jun 2021 11:39:58 +0200, Amelie Delaunay wrote:
> Default REQ/ACK protocol consists in maintaining ACK signal up to the
> removal of REQuest and the transfer completion.
> In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the
> removal of the REQuest, but only the transfer completion.
> Due to a possible DMA stream lock when transferring data to/from STM32
> USART/UART, this new bindings allow to select this alternative protocol in
> device tree, especially for STM32 USART/UART nodes.
> 
> Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
> ---
>  Documentation/devicetree/bindings/dma/st,stm32-dma.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support
  2021-06-24  9:39 [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Amelie Delaunay
  2021-06-24  9:39 ` [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma Amelie Delaunay
  2021-06-24  9:39 ` [PATCH 2/2] dmaengine: stm32-dma: add alternate REQ/ACK protocol management Amelie Delaunay
@ 2021-07-28  7:09 ` Vinod Koul
  2 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2021-07-28  7:09 UTC (permalink / raw)
  To: Amelie Delaunay
  Cc: Rob Herring, Dan Williams, Maxime Coquelin, Alexandre Torgue,
	dmaengine, devicetree, linux-stm32, linux-arm-kernel,
	linux-kernel, Pierre-Yves Mordret

On 24-06-21, 11:39, Amelie Delaunay wrote:
> Default REQ/ACK protocol consists in maintaining ACK signal up to the
> removal of REQuest and the transfer completion.
> In case of alternative REQ/ACK protocol, ACK de-assertion does not wait the
> removal of the REQuest, but only the transfer completion.
> Due to a possible DMA stream lock when transferring data to/from STM32
> USART/UART, add support to select alternative REQ/ACK protocol.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-28  7:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  9:39 [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Amelie Delaunay
2021-06-24  9:39 ` [PATCH 1/2] dt-bindings: dma: add alternative REQ/ACK protocol selection in stm32-dma Amelie Delaunay
2021-07-14 19:27   ` Rob Herring
2021-06-24  9:39 ` [PATCH 2/2] dmaengine: stm32-dma: add alternate REQ/ACK protocol management Amelie Delaunay
2021-07-28  7:09 ` [PATCH 0/2] STM32 DMA alternative REQ/ACK protocol support Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).