Skip to contentSkip to conversation

add uart DMA function

PATCH Applied Long Cheng 5 participants 13 messages Apr 27, 2019 – May 21, 2020

Subsystems (5)

v12 of 13 Applied Latest is v13 →

lore
Share & tools
lore

Long Cheng

author
#0 lore raw

v12 cover add uart DMA function

In Mediatek SOCs, the uart can support DMA function.
Base on DMA engine formwork, we add the DMA code to support uart. And put the code under drivers/dma/mediatek.

This series contains document bindings, Kconfig to control the function enable or not, device tree including interrupt and dma device node, the code of UART DMA

Changes compared to v11
-modify TX/RX
-pause function by software
Changes compared to v10
-modify DMA tx status function
-modify 8250_mtk for DMA rx
-add notes to binding Document.
Changes compared to v9
-rename dt-bindings file
-remove direction from device_config
-simplified code
Changes compared to v8
-revise missing items
Changes compared to v7:
-modify apdma uart tx
Changes compared to v6:
-Correct spelling
Changes compared to v5:
-move 'requst irqs' to alloc channel
-remove tasklet.
Changes compared to v4:
-modify Kconfig depends on.
Changes compared to v3:
-fix CONFIG_PM, will cause build fail
Changes compared to v2:
-remove unimportant parameters
-instead of cookie, use APIs of virtual channel.
-use of_dma_xlate_by_chan_id.
Changes compared to v1:
-mian revised file, 8250_mtk_dma.c
--parameters renamed for standard
--remove atomic operation

Long Cheng (4):
dmaengine: mediatek: Add MediaTek UART APDMA support
arm: dts: mt2712: add uart APDMA to device tree
dt-bindings: dma: uart: rename binding
serial: 8250-mtk: modify uart DMA rx

 .../devicetree/bindings/dma/8250_mtk_dma.txt       |   33 -
 .../devicetree/bindings/dma/mtk-uart-apdma.txt     |   55 ++
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi          |   51 ++
 drivers/dma/mediatek/Kconfig                       |   11 +
 drivers/dma/mediatek/Makefile                      |    1 +
 drivers/dma/mediatek/mtk-uart-apdma.c              |  666 ++++++++++++++++++++
 drivers/tty/serial/8250/8250_mtk.c                 |   53 +-
 7 files changed, 807 insertions(+), 63 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt
 create mode 100644 drivers/dma/mediatek/mtk-uart-apdma.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v12 1/4 dmaengine: mediatek: Add MediaTek UART APDMA support

Add 8250 UART APDMA to support MediaTek UART. If MediaTek UART is enabled by SERIAL_8250_MT6577, and we can enable this driver to offload the UART device moving bytes.

---
 drivers/dma/mediatek/Kconfig          |   11 +
 drivers/dma/mediatek/Makefile         |    1 +
 drivers/dma/mediatek/mtk-uart-apdma.c |  666 +++++++++++++++++++++++++++++++++
 3 files changed, 678 insertions(+)
 create mode 100644 drivers/dma/mediatek/mtk-uart-apdma.c
drivers/dma/mediatek/Kconfig +11 -0
index 680fc05..ac49eb6 100644
@@ -24,3 +24,14 @@ config MTK_CQDMA
 
 	  This controller provides the channels which is dedicated to
 	  memory-to-memory transfer to offload from CPU.
+
+config MTK_UART_APDMA
+	tristate "MediaTek SoCs APDMA support for UART"
+	depends on OF && SERIAL_8250_MT6577
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  Support for the UART DMA engine found on MediaTek MTK SoCs.
+	  When SERIAL_8250_MT6577 is enabled, and if you want to use DMA,
+	  you can enable the config. The DMA engine can only be used
+	  with MediaTek SoCs.
drivers/dma/mediatek/Makefile +1 -0
index 41bb381..61a6d29 100644
@@ -1,2 +1,3 @@
+obj-$(CONFIG_MTK_UART_APDMA) += mtk-uart-apdma.o
 obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o
 obj-$(CONFIG_MTK_CQDMA) += mtk-cqdma.o
drivers/dma/mediatek/mtk-uart-apdma.c new file +666 -0

666 lines not on this page · raw message

maintainer Applied
#2 lore raw

Re: [PATCH 1/4] dmaengine: mediatek: Add MediaTek UART APDMA support

Quoted 3 lines · Long Cheng

Add 8250 UART APDMA to support MediaTek UART. If MediaTek UART is enabled by SERIAL_8250_MT6577, and we can enable this driver to offload the UART device moving bytes.

Applied, thanks

Signature · 1 line
~Vinod
author
#3 lore raw

PATCH v12 2/4 arm: dts: mt2712: add uart APDMA to device tree

In reply to Long Cheng

1. add uart APDMA controller device node
2. add uart 0/1/2/3/4/5 DMA function

---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   51 +++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt2712e.dtsi +51 -0
index 976d92a..f1e419e 100644
@@ -300,6 +300,9 @@
 		interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 10
+			&apdma 11>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -369,6 +372,39 @@
 			 (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>;
 	};
 
+	apdma: dma-controller@11000400 {
+		compatible = "mediatek,mt2712-uart-dma",
+			     "mediatek,mt6577-uart-dma";
+		reg = <0 0x11000400 0 0x80>,
+		      <0 0x11000480 0 0x80>,
+		      <0 0x11000500 0 0x80>,
+		      <0 0x11000580 0 0x80>,
+		      <0 0x11000600 0 0x80>,
+		      <0 0x11000680 0 0x80>,
+		      <0 0x11000700 0 0x80>,
+		      <0 0x11000780 0 0x80>,
+		      <0 0x11000800 0 0x80>,
+		      <0 0x11000880 0 0x80>,
+		      <0 0x11000900 0 0x80>,
+		      <0 0x11000980 0 0x80>;
+		interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>;
+		dma-requests = <12>;
+		clocks = <&pericfg CLK_PERI_AP_DMA>;
+		clock-names = "apdma";
+		#dma-cells = <1>;
+	};
+
 	auxadc: adc@11001000 {
 		compatible = "mediatek,mt2712-auxadc";
 		reg = <0 0x11001000 0 0x1000>;
@@ -385,6 +421,9 @@
 		interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 0
+			&apdma 1>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -395,6 +434,9 @@
 		interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 2
+			&apdma 3>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -405,6 +447,9 @@
 		interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 4
+			&apdma 5>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -415,6 +460,9 @@
 		interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 6
+			&apdma 7>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -629,6 +677,9 @@
 		interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 8
+			&apdma 9>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
maintainer Applied
#4 lore raw

Re: [PATCH 2/4] arm: dts: mt2712: add uart APDMA to device tree

Quoted 4 lines · Long Cheng

1. add uart APDMA controller device node
2. add uart 0/1/2/3/4/5 DMA function

Queued now for v5.7-next/dts64

Thanks!

Quoted 109 lines
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   51 +++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt2712e.dtsi +51 -0
index 976d92a..f1e419e 100644
@@ -300,6 +300,9 @@
 		interrupts = <GIC_SPI 127 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 10
+			&apdma 11>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -369,6 +372,39 @@
 			 (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>;
 	};
 
+	apdma: dma-controller@11000400 {
+		compatible = "mediatek,mt2712-uart-dma",
+			     "mediatek,mt6577-uart-dma";
+		reg = <0 0x11000400 0 0x80>,
+		      <0 0x11000480 0 0x80>,
+		      <0 0x11000500 0 0x80>,
+		      <0 0x11000580 0 0x80>,
+		      <0 0x11000600 0 0x80>,
+		      <0 0x11000680 0 0x80>,
+		      <0 0x11000700 0 0x80>,
+		      <0 0x11000780 0 0x80>,
+		      <0 0x11000800 0 0x80>,
+		      <0 0x11000880 0 0x80>,
+		      <0 0x11000900 0 0x80>,
+		      <0 0x11000980 0 0x80>;
+		interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 105 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 106 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 107 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 108 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 109 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 111 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 112 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 113 IRQ_TYPE_LEVEL_LOW>,
+			     <GIC_SPI 114 IRQ_TYPE_LEVEL_LOW>;
+		dma-requests = <12>;
+		clocks = <&pericfg CLK_PERI_AP_DMA>;
+		clock-names = "apdma";
+		#dma-cells = <1>;
+	};
+
 	auxadc: adc@11001000 {
 		compatible = "mediatek,mt2712-auxadc";
 		reg = <0 0x11001000 0 0x1000>;
@@ -385,6 +421,9 @@
 		interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 0
+			&apdma 1>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -395,6 +434,9 @@
 		interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 2
+			&apdma 3>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -405,6 +447,9 @@
 		interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 4
+			&apdma 5>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -415,6 +460,9 @@
 		interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 6
+			&apdma 7>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
@@ -629,6 +677,9 @@
 		interrupts = <GIC_SPI 126 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&baud_clk>, <&sys_clk>;
 		clock-names = "baud", "bus";
+		dmas = <&apdma 8
+			&apdma 9>;
+		dma-names = "tx", "rx";
 		status = "disabled";
 	};
 
author
#5 lore raw

PATCH v12 3/4 dt-bindings: dma: uart: rename binding

In reply to Long Cheng

The filename matches mtk-uart-apdma.c.
So using "mtk-uart-apdma.txt" should be better.
And add some property.

---
 .../devicetree/bindings/dma/8250_mtk_dma.txt       |   33 ------------
 .../devicetree/bindings/dma/mtk-uart-apdma.txt     |   55 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt
Documentation/devicetree/bindings/dma/8250_mtk_dma.txt deleted +0 -33
deleted file mode 100644
index 3fe0961..0000000
@@ -1,33 +0,0 @@
-* Mediatek UART APDMA Controller
-
-Required properties:
-- compatible should contain:
-  * "mediatek,mt2712-uart-dma" for MT2712 compatible APDMA
-  * "mediatek,mt6577-uart-dma" for MT6577 and all of the above
-
-- reg: The base address of the APDMA register bank.
-
-- interrupts: A single interrupt specifier.
-
-- clocks : Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names: The APDMA clock for register accesses
-
-Examples:
-
-	apdma: dma-controller@11000380 {
-		compatible = "mediatek,mt2712-uart-dma";
-		reg = <0 0x11000380 0 0x400>;
-		interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 64 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 65 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 66 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 67 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 68 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 69 IRQ_TYPE_LEVEL_LOW>,
-			     <GIC_SPI 70 IRQ_TYPE_LEVEL_LOW>;
-		clocks = <&pericfg CLK_PERI_AP_DMA>;
-		clock-names = "apdma";
-		#dma-cells = <1>;
-	};
-
Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt new file +55 -0

55 lines not on this page · raw message

maintainer
#6 lore raw

Re: [PATCH 3/4] dt-bindings: dma: uart: rename binding

Quoted 4 lines · Long Cheng

The filename matches mtk-uart-apdma.c.
So using "mtk-uart-apdma.txt" should be better.
And add some property.

Quoted 8 lines
---
 .../devicetree/bindings/dma/8250_mtk_dma.txt       |   33 ------------
 .../devicetree/bindings/dma/mtk-uart-apdma.txt     |   55 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

maintainer
#7 lore raw

Re: [PATCH 3/4] dt-bindings: dma: uart: rename binding

In reply to Long Cheng
Quoted 3 lines · Long Cheng

The filename matches mtk-uart-apdma.c.
So using "mtk-uart-apdma.txt" should be better.
And add some property.

Applied with Robs r-b tag in last version, thanks
Also fixed a trailing line in patch :(

Signature · 1 line
~Vinod
author
#8 lore raw

PATCH v12 4/4 serial: 8250-mtk: modify uart DMA rx

In reply to Long Cheng

Modify uart rx and complete for DMA.

---
 drivers/tty/serial/8250/8250_mtk.c |   53 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +23 -30
index c1fdbc0..04081a6 100644
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX	0x2
 #define MTK_UART_DMA_EN_RX	0x5
 
-#define MTK_UART_TX_SIZE	UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE	0x8000
 #define MTK_UART_TX_TRIGGER	1
 #define MTK_UART_RX_TRIGGER	MTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
 	struct mtk8250_data *data = up->port.private_data;
 	struct tty_port *tty_port = &up->port.state->port;
 	struct dma_tx_state state;
+	int copied, cnt, tmp;
 	unsigned char *ptr;
-	int copied;
 
-	dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-				dma->rx_size, DMA_FROM_DEVICE);
+	if (data->rx_status == DMA_RX_SHUTDOWN)
+		return;
 
 	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
+	cnt = dma->rx_size - state.residue;
+	tmp = cnt;
 
-	if (data->rx_status == DMA_RX_SHUTDOWN)
-		return;
+	if ((data->rx_pos + cnt) > dma->rx_size)
+		tmp = dma->rx_size - data->rx_pos;
 
-	if ((data->rx_pos + state.residue) <= dma->rx_size) {
-		ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-		copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-	} else {
-		ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-		copied = tty_insert_flip_string(tty_port, ptr,
-						dma->rx_size - data->rx_pos);
+	ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+	copied = tty_insert_flip_string(tty_port, ptr, tmp);
+	data->rx_pos += tmp;
+
+	if (cnt > tmp) {
 		ptr = (unsigned char *)(dma->rx_buf);
-		copied += tty_insert_flip_string(tty_port, ptr,
-				data->rx_pos + state.residue - dma->rx_size);
+		tmp = cnt - tmp;
+		copied += tty_insert_flip_string(tty_port, ptr, tmp);
+		data->rx_pos = tmp;
 	}
+
 	up->port.icount.rx += copied;
 
 	tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
 	struct uart_8250_dma *dma = up->dma;
-	struct mtk8250_data *data = up->port.private_data;
 	struct dma_async_tx_descriptor	*desc;
-	struct dma_tx_state	 state;
 
 	desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
 					   dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
 	dma->rx_cookie = dmaengine_submit(desc);
 
-	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
-	data->rx_pos = state.residue;
-
-	dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-				   dma->rx_size, DMA_FROM_DEVICE);
-
 	dma_async_issue_pending(dma->rxchan);
 }
 
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
 	if (data->rx_status != DMA_RX_START)
 		return;
 
-	dma->rxconf.direction		= DMA_DEV_TO_MEM;
-	dma->rxconf.src_addr_width	= dma->rx_size / 1024;
-	dma->rxconf.src_addr		= dma->rx_addr;
+	dma->rxconf.direction				= DMA_DEV_TO_MEM;
+	dma->rxconf.src_port_window_size	= dma->rx_size;
+	dma->rxconf.src_addr				= dma->rx_addr;
 
-	dma->txconf.direction		= DMA_MEM_TO_DEV;
-	dma->txconf.dst_addr_width	= MTK_UART_TX_SIZE / 1024;
-	dma->txconf.dst_addr		= dma->tx_addr;
+	dma->txconf.direction				= DMA_MEM_TO_DEV;
+	dma->txconf.dst_port_window_size	= UART_XMIT_SIZE;
+	dma->txconf.dst_addr				= dma->tx_addr;
 
 	serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
 		UART_FCR_CLEAR_XMIT);
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
 	 * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
 	 *
 	 * We need to recalcualte the quot register, as the claculation depends
-	 * on the vaule in the highspeed register.
+	 * on the value in the highspeed register.
 	 *
 	 * Some baudrates are not supported by the chip, so we use the next
 	 * lower rate supported and update termios c_flag.
#9 lore raw

Re: [PATCH 4/4] serial: 8250-mtk: modify uart DMA rx

Quoted 2 lines · Long Cheng

Modify uart rx and complete for DMA.

I don't know much about the DMA framework, but can you please explain why you are making the changes in this CL? I see that you are dropping dma_sync_single_for_device calls, for example, why?

Quoted 24 lines
---
 drivers/tty/serial/8250/8250_mtk.c |   53 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +1 -1
index c1fdbc0..04081a6 100644
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX     0x2
 #define MTK_UART_DMA_EN_RX     0x5
 
-#define MTK_UART_TX_SIZE       UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE       0x8000
 #define MTK_UART_TX_TRIGGER    1
 #define MTK_UART_RX_TRIGGER    MTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
        struct mtk8250_data *data = up->port.private_data;
        struct tty_port *tty_port = &up->port.state->port;
        struct dma_tx_state state;
+       int copied, cnt, tmp;
        unsigned char *ptr;

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_rx_complete(void *param) · line 74

Quoted 10 lines
drivers/tty/serial/8250/8250_mtk.c +4 -3
-       int copied;
 
-       dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-                               dma->rx_size, DMA_FROM_DEVICE);
+       if (data->rx_status == DMA_RX_SHUTDOWN)
+               return;
 
        dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
+       cnt = dma->rx_size - state.residue;
+       tmp = cnt;

I ponder, maybe we should rename cnt to left? (like, how many bytes are left to transfer, in total) Or maybe "total"
Then maybe rename tmp to cnt.

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_rx_complete(void *param) · line 77

Quoted 5 lines
drivers/tty/serial/8250/8250_mtk.c +2 -2
-       if (data->rx_status == DMA_RX_SHUTDOWN)
-               return;
+       if ((data->rx_pos + cnt) > dma->rx_size)
+               tmp = dma->rx_size - data->rx_pos;

Maybe replace this and the line above:
tmp = max_t(int, cnt, dma->rx_size - data->rx_pos);

Quoted 68 lines
drivers/tty/serial/8250/8250_mtk.c +15 -23
-       if ((data->rx_pos + state.residue) <= dma->rx_size) {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-       } else {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr,
-                                               dma->rx_size - data->rx_pos);
+       ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+       copied = tty_insert_flip_string(tty_port, ptr, tmp);
+       data->rx_pos += tmp;
+
+       if (cnt > tmp) {
                ptr = (unsigned char *)(dma->rx_buf);
-               copied += tty_insert_flip_string(tty_port, ptr,
-                               data->rx_pos + state.residue - dma->rx_size);
+               tmp = cnt - tmp;
+               copied += tty_insert_flip_string(tty_port, ptr, tmp);
+               data->rx_pos = tmp;
        }
+
        up->port.icount.rx += copied;
 
        tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
        struct uart_8250_dma *dma = up->dma;
-       struct mtk8250_data *data = up->port.private_data;
        struct dma_async_tx_descriptor  *desc;
-       struct dma_tx_state      state;
 
        desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
                                           dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
        dma->rx_cookie = dmaengine_submit(desc);
 
-       dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
-       data->rx_pos = state.residue;
-
-       dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-                                  dma->rx_size, DMA_FROM_DEVICE);
-
        dma_async_issue_pending(dma->rxchan);
 }
 
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
        if (data->rx_status != DMA_RX_START)
                return;
 
-       dma->rxconf.direction           = DMA_DEV_TO_MEM;
-       dma->rxconf.src_addr_width      = dma->rx_size / 1024;
-       dma->rxconf.src_addr            = dma->rx_addr;
+       dma->rxconf.direction                           = DMA_DEV_TO_MEM;
+       dma->rxconf.src_port_window_size        = dma->rx_size;
+       dma->rxconf.src_addr                            = dma->rx_addr;
 
-       dma->txconf.direction           = DMA_MEM_TO_DEV;
-       dma->txconf.dst_addr_width      = MTK_UART_TX_SIZE / 1024;
-       dma->txconf.dst_addr            = dma->tx_addr;
+       dma->txconf.direction                           = DMA_MEM_TO_DEV;
+       dma->txconf.dst_port_window_size        = UART_XMIT_SIZE;
+       dma->txconf.dst_addr                            = dma->tx_addr;
 
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
                UART_FCR_CLEAR_XMIT);

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_shutdown(struct uart_port *port) · line 213

Quoted 5 lines
drivers/tty/serial/8250/8250_mtk.c +1 -1
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
         * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
         *
         * We need to recalcualte the quot register, as the claculation depends
-        * on the vaule in the highspeed register.
+        * on the value in the highspeed register.

Since you're doing some cosmetic changes here, you might as well fix recalcualte => recalculate and claculation => calculation on the line above.

But technically, this should belong in another patch...

Quoted 6 lines
drivers/tty/serial/8250/8250_mtk.c +0 -1
         *
         * Some baudrates are not supported by the chip, so we use the next
         * lower rate supported and update termios c_flag.
--

1.7.9.5

author
#10 lore raw

Re: [PATCH 4/4] serial: 8250-mtk: modify uart DMA rx

Quoted 8 lines · Nicolas Boichat
Quoted 2 lines · Long Cheng

Modify uart rx and complete for DMA.

I don't know much about the DMA framework, but can you please explain why you are making the changes in this CL? I see that you are dropping dma_sync_single_for_device calls, for example, why?

the rx buffer is create by 'dma_alloc_coherent'. in the function, the buffer is uncache. We don't need to sync between CPU and DMA. So I remove it.

Quoted 31 lines
Quoted 31 lines
---
 drivers/tty/serial/8250/8250_mtk.c |   53 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +3 -4
index c1fdbc0..04081a6 100644
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX     0x2
 #define MTK_UART_DMA_EN_RX     0x5
 
-#define MTK_UART_TX_SIZE       UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE       0x8000
 #define MTK_UART_TX_TRIGGER    1
 #define MTK_UART_RX_TRIGGER    MTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
        struct mtk8250_data *data = up->port.private_data;
        struct tty_port *tty_port = &up->port.state->port;
        struct dma_tx_state state;
+       int copied, cnt, tmp;
        unsigned char *ptr;
-       int copied;
 
-       dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-                               dma->rx_size, DMA_FROM_DEVICE);
+       if (data->rx_status == DMA_RX_SHUTDOWN)
+               return;
 
Quoted 8 lines

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_rx_complete(void *param) · line 74

Quoted 3 lines
drivers/tty/serial/8250/8250_mtk.c +2 -0
        dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
+       cnt = dma->rx_size - state.residue;
+       tmp = cnt;

I ponder, maybe we should rename cnt to left? (like, how many bytes are left to transfer, in total) Or maybe "total"
Then maybe rename tmp to cnt.

like better.

Quoted 9 lines

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_rx_complete(void *param) · line 77

Quoted 5 lines
drivers/tty/serial/8250/8250_mtk.c +2 -2
-       if (data->rx_status == DMA_RX_SHUTDOWN)
-               return;
+       if ((data->rx_pos + cnt) > dma->rx_size)
+               tmp = dma->rx_size - data->rx_pos;

Maybe replace this and the line above:
tmp = max_t(int, cnt, dma->rx_size - data->rx_pos);

Yes. It's better.

Quoted 65 lines
Quoted 65 lines
drivers/tty/serial/8250/8250_mtk.c +15 -23
-       if ((data->rx_pos + state.residue) <= dma->rx_size) {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-       } else {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr,
-                                               dma->rx_size - data->rx_pos);
+       ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+       copied = tty_insert_flip_string(tty_port, ptr, tmp);
+       data->rx_pos += tmp;
+
+       if (cnt > tmp) {
                ptr = (unsigned char *)(dma->rx_buf);
-               copied += tty_insert_flip_string(tty_port, ptr,
-                               data->rx_pos + state.residue - dma->rx_size);
+               tmp = cnt - tmp;
+               copied += tty_insert_flip_string(tty_port, ptr, tmp);
+               data->rx_pos = tmp;
        }
+
        up->port.icount.rx += copied;
 
        tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
        struct uart_8250_dma *dma = up->dma;
-       struct mtk8250_data *data = up->port.private_data;
        struct dma_async_tx_descriptor  *desc;
-       struct dma_tx_state      state;
 
        desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
                                           dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
        dma->rx_cookie = dmaengine_submit(desc);
 
-       dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
-       data->rx_pos = state.residue;
-
-       dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-                                  dma->rx_size, DMA_FROM_DEVICE);
-
        dma_async_issue_pending(dma->rxchan);
 }
 
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
        if (data->rx_status != DMA_RX_START)
                return;
 
-       dma->rxconf.direction           = DMA_DEV_TO_MEM;
-       dma->rxconf.src_addr_width      = dma->rx_size / 1024;
-       dma->rxconf.src_addr            = dma->rx_addr;
+       dma->rxconf.direction                           = DMA_DEV_TO_MEM;
+       dma->rxconf.src_port_window_size        = dma->rx_size;
+       dma->rxconf.src_addr                            = dma->rx_addr;
 
-       dma->txconf.direction           = DMA_MEM_TO_DEV;
-       dma->txconf.dst_addr_width      = MTK_UART_TX_SIZE / 1024;
-       dma->txconf.dst_addr            = dma->tx_addr;
+       dma->txconf.direction                           = DMA_MEM_TO_DEV;
+       dma->txconf.dst_port_window_size        = UART_XMIT_SIZE;
+       dma->txconf.dst_addr                            = dma->tx_addr;
 
Quoted 13 lines

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_shutdown(struct uart_port *port) · line 213

Quoted 8 lines
drivers/tty/serial/8250/8250_mtk.c +1 -1
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
                UART_FCR_CLEAR_XMIT);
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
         * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
         *
         * We need to recalcualte the quot register, as the claculation depends
-        * on the vaule in the highspeed register.
+        * on the value in the highspeed register.

Since you're doing some cosmetic changes here, you might as well fix recalcualte => recalculate and claculation => calculation on the line above.

I see.

Quoted 8 lines

But technically, this should belong in another patch...

Quoted 6 lines
drivers/tty/serial/8250/8250_mtk.c +0 -1
         *
         * Some baudrates are not supported by the chip, so we use the next
         * lower rate supported and update termios c_flag.
--

1.7.9.5

author
#11 lore raw

Re: [PATCH 4/4] serial: 8250-mtk: modify uart DMA rx

Quoted 61 lines · Long Cheng
Quoted 8 lines · Nicolas Boichat
Quoted 2 lines · Long Cheng

Modify uart rx and complete for DMA.

I don't know much about the DMA framework, but can you please explain why you are making the changes in this CL? I see that you are dropping dma_sync_single_for_device calls, for example, why?

the rx buffer is create by 'dma_alloc_coherent'. in the function, the buffer is uncache. We don't need to sync between CPU and DMA. So I remove it.

Quoted 31 lines
Quoted 31 lines
---
 drivers/tty/serial/8250/8250_mtk.c |   53 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +3 -4
index c1fdbc0..04081a6 100644
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX     0x2
 #define MTK_UART_DMA_EN_RX     0x5
 
-#define MTK_UART_TX_SIZE       UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE       0x8000
 #define MTK_UART_TX_TRIGGER    1
 #define MTK_UART_RX_TRIGGER    MTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
        struct mtk8250_data *data = up->port.private_data;
        struct tty_port *tty_port = &up->port.state->port;
        struct dma_tx_state state;
+       int copied, cnt, tmp;
        unsigned char *ptr;
-       int copied;
 
-       dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-                               dma->rx_size, DMA_FROM_DEVICE);
+       if (data->rx_status == DMA_RX_SHUTDOWN)
+               return;
 
Quoted 8 lines

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_rx_complete(void *param) · line 74

Quoted 3 lines
drivers/tty/serial/8250/8250_mtk.c +2 -0
        dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
+       cnt = dma->rx_size - state.residue;
+       tmp = cnt;

I ponder, maybe we should rename cnt to left? (like, how many bytes are left to transfer, in total) Or maybe "total"
Then maybe rename tmp to cnt.

like better.

Quoted 6 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_mtk.c +2 -2
-       if (data->rx_status == DMA_RX_SHUTDOWN)
-               return;
+       if ((data->rx_pos + cnt) > dma->rx_size)
+               tmp = dma->rx_size - data->rx_pos;
Quoted 5 lines
Quoted 3 lines

Maybe replace this and the line above:
tmp = max_t(int, cnt, dma->rx_size - data->rx_pos);

Yes. It's better.

can't replace by 'max_t'. So I will keep original code.

Quoted 90 lines
Quoted 65 lines
Quoted 65 lines
drivers/tty/serial/8250/8250_mtk.c +15 -23
-       if ((data->rx_pos + state.residue) <= dma->rx_size) {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-       } else {
-               ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-               copied = tty_insert_flip_string(tty_port, ptr,
-                                               dma->rx_size - data->rx_pos);
+       ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+       copied = tty_insert_flip_string(tty_port, ptr, tmp);
+       data->rx_pos += tmp;
+
+       if (cnt > tmp) {
                ptr = (unsigned char *)(dma->rx_buf);
-               copied += tty_insert_flip_string(tty_port, ptr,
-                               data->rx_pos + state.residue - dma->rx_size);
+               tmp = cnt - tmp;
+               copied += tty_insert_flip_string(tty_port, ptr, tmp);
+               data->rx_pos = tmp;
        }
+
        up->port.icount.rx += copied;
 
        tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
        struct uart_8250_dma *dma = up->dma;
-       struct mtk8250_data *data = up->port.private_data;
        struct dma_async_tx_descriptor  *desc;
-       struct dma_tx_state      state;
 
        desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
                                           dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
        dma->rx_cookie = dmaengine_submit(desc);
 
-       dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
-       data->rx_pos = state.residue;
-
-       dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-                                  dma->rx_size, DMA_FROM_DEVICE);
-
        dma_async_issue_pending(dma->rxchan);
 }
 
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
        if (data->rx_status != DMA_RX_START)
                return;
 
-       dma->rxconf.direction           = DMA_DEV_TO_MEM;
-       dma->rxconf.src_addr_width      = dma->rx_size / 1024;
-       dma->rxconf.src_addr            = dma->rx_addr;
+       dma->rxconf.direction                           = DMA_DEV_TO_MEM;
+       dma->rxconf.src_port_window_size        = dma->rx_size;
+       dma->rxconf.src_addr                            = dma->rx_addr;
 
-       dma->txconf.direction           = DMA_MEM_TO_DEV;
-       dma->txconf.dst_addr_width      = MTK_UART_TX_SIZE / 1024;
-       dma->txconf.dst_addr            = dma->tx_addr;
+       dma->txconf.direction                           = DMA_MEM_TO_DEV;
+       dma->txconf.dst_port_window_size        = UART_XMIT_SIZE;
+       dma->txconf.dst_addr                            = dma->tx_addr;
 
Quoted 13 lines

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_shutdown(struct uart_port *port) · line 213

Quoted 8 lines
drivers/tty/serial/8250/8250_mtk.c +1 -1
        serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
                UART_FCR_CLEAR_XMIT);
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
         * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
         *
         * We need to recalcualte the quot register, as the claculation depends
-        * on the vaule in the highspeed register.
+        * on the value in the highspeed register.

Since you're doing some cosmetic changes here, you might as well fix recalcualte => recalculate and claculation => calculation on the line above.

I see.

Quoted 8 lines

But technically, this should belong in another patch...

Quoted 6 lines
drivers/tty/serial/8250/8250_mtk.c +0 -1
         *
         * Some baudrates are not supported by the chip, so we use the next
         * lower rate supported and update termios c_flag.
--

1.7.9.5

maintainer
#12 lore raw

Re: [PATCH 4/4] serial: 8250-mtk: modify uart DMA rx

In reply to Long Cheng
Quoted 88 lines · Long Cheng

Modify uart rx and complete for DMA.

---
 drivers/tty/serial/8250/8250_mtk.c |   53 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
drivers/tty/serial/8250/8250_mtk.c +16 -23
index c1fdbc0..04081a6 100644
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX	0x2
 #define MTK_UART_DMA_EN_RX	0x5
 
-#define MTK_UART_TX_SIZE	UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE	0x8000
 #define MTK_UART_TX_TRIGGER	1
 #define MTK_UART_RX_TRIGGER	MTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
 	struct mtk8250_data *data = up->port.private_data;
 	struct tty_port *tty_port = &up->port.state->port;
 	struct dma_tx_state state;
+	int copied, cnt, tmp;
 	unsigned char *ptr;
-	int copied;
 
-	dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-				dma->rx_size, DMA_FROM_DEVICE);
+	if (data->rx_status == DMA_RX_SHUTDOWN)
+		return;
 
 	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
+	cnt = dma->rx_size - state.residue;
+	tmp = cnt;
 
-	if (data->rx_status == DMA_RX_SHUTDOWN)
-		return;
+	if ((data->rx_pos + cnt) > dma->rx_size)
+		tmp = dma->rx_size - data->rx_pos;
 
-	if ((data->rx_pos + state.residue) <= dma->rx_size) {
-		ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-		copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-	} else {
-		ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-		copied = tty_insert_flip_string(tty_port, ptr,
-						dma->rx_size - data->rx_pos);
+	ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+	copied = tty_insert_flip_string(tty_port, ptr, tmp);
+	data->rx_pos += tmp;
+
+	if (cnt > tmp) {
 		ptr = (unsigned char *)(dma->rx_buf);
-		copied += tty_insert_flip_string(tty_port, ptr,
-				data->rx_pos + state.residue - dma->rx_size);
+		tmp = cnt - tmp;
+		copied += tty_insert_flip_string(tty_port, ptr, tmp);
+		data->rx_pos = tmp;
 	}
+
 	up->port.icount.rx += copied;
 
 	tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
 	struct uart_8250_dma *dma = up->dma;
-	struct mtk8250_data *data = up->port.private_data;
 	struct dma_async_tx_descriptor	*desc;
-	struct dma_tx_state	 state;
 
 	desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
 					   dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
 	dma->rx_cookie = dmaengine_submit(desc);
 
-	dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
-	data->rx_pos = state.residue;
-
-	dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-				   dma->rx_size, DMA_FROM_DEVICE);
-
 	dma_async_issue_pending(dma->rxchan);
 }
 

drivers/tty/serial/8250/8250_mtk.c static void mtk8250_dma_enable(struct uart_8250_port *up) · line 127

Quoted 7 lines
drivers/tty/serial/8250/8250_mtk.c +1 -3
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
 	if (data->rx_status != DMA_RX_START)
 		return;
 
-	dma->rxconf.direction		= DMA_DEV_TO_MEM;
-	dma->rxconf.src_addr_width	= dma->rx_size / 1024;
-	dma->rxconf.src_addr		= dma->rx_addr;
+	dma->rxconf.direction				= DMA_DEV_TO_MEM;

Direction field is deprecated, please do not use this anymore...

Quoted 23 lines
drivers/tty/serial/8250/8250_mtk.c +6 -4
+	dma->rxconf.src_port_window_size	= dma->rx_size;
+	dma->rxconf.src_addr				= dma->rx_addr;
 
-	dma->txconf.direction		= DMA_MEM_TO_DEV;
-	dma->txconf.dst_addr_width	= MTK_UART_TX_SIZE / 1024;
-	dma->txconf.dst_addr		= dma->tx_addr;
+	dma->txconf.direction				= DMA_MEM_TO_DEV;
+	dma->txconf.dst_port_window_size	= UART_XMIT_SIZE;
+	dma->txconf.dst_addr				= dma->tx_addr;
 
 	serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
 		UART_FCR_CLEAR_XMIT);
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
 	 * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
 	 *
 	 * We need to recalcualte the quot register, as the claculation depends
-	 * on the vaule in the highspeed register.
+	 * on the value in the highspeed register.
 	 *
 	 * Some baudrates are not supported by the chip, so we use the next
 	 * lower rate supported and update termios c_flag.
Signature · 1 line
1.7.9.5
Signature · 1 line
~Vinod