linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: Clemens Gruber <clemens.gruber@pqgruber.com>
Cc: "linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Fabio Estevam" <fabio.estevam@nxp.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	stable <stable@vger.kernel.org>,
	"Fugang Duan" <fugang.duan@nxp.com>
Subject: Re: [PATCH] serial: imx: disable DMA for RS-485 on i.MX6 SMP
Date: Tue, 20 Jun 2017 20:49:28 -0300	[thread overview]
Message-ID: <CAOMZO5DA++c95DPrmzOHfFtD+zFcW6G9-0_cRBtg0E8TA8dwXg@mail.gmail.com> (raw)
In-Reply-To: <CAOMZO5Djf8OsqF=jUBo1Dkm2mw7pObxmkC=qq0U0RLZsYonXgQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

Hi Clemens,

On Tue, Jun 20, 2017 at 1:13 PM, Fabio Estevam <festevam@gmail.com> wrote:

> The subject gives the impression that the DMA will only be disabled
> for RS485, but the impact of this change is wider.
>
> For example: if I have a mx6q system with a Bluetooth serial
> connection I can no longer use DMA with your change applied.
>
> Ideally we should fix the RS485 DMA bug. If that is not possible, then
> at least we need to restrict this change to the RS485 case.
>
> Maybe we need to pass "linux,rs485-enabled-at-boot-time" in device
> tree and then use this property to deceide if DMA will be enabled or
> not:
>
> if (!uart_console(port) && !sport->dma_is_inited && !sport->rs485_enabled)

Could you please test the two attached patches and see if it solves the issue?

Unfortunately I no longer have access to the RS485 half-duplex board.

Just make sure to pass 'linux,rs485-enabled-at-boot-time' in your
device tree, thanks.

[-- Attachment #2: 0001-serial-imx-Allow-passing-linux-rs485-enabled-at-boot.patch --]
[-- Type: text/x-patch, Size: 1172 bytes --]

From 0a36d212228a8d093a03bbab94e9e6ffe99c87c3 Mon Sep 17 00:00:00 2001
From: Fabio Estevam <fabio.estevam@nxp.com>
Date: Tue, 20 Jun 2017 20:29:13 -0300
Subject: [PATCH 1/2] serial: imx: Support 'linux,rs485-enabled-at-boot-time'

According to Documentation/devicetree/bindings/serial/rs485.txt, the
"linux,rs485-enabled-at-boot-time" property can be used to indicate
that RS485 is enabled during boot time.

Add support for it in the driver.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/tty/serial/imx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 92606b1..90f8a5d 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2123,6 +2123,9 @@ static int serial_imx_probe(struct platform_device *pdev)
 	sport->port.rs485_config = imx_rs485_config;
 	sport->port.rs485.flags =
 		SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX;
+	if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL))
+		sport->port.rs485.flags |= SER_RS485_ENABLED;
+
 	sport->port.flags = UPF_BOOT_AUTOCONF;
 	init_timer(&sport->timer);
 	sport->timer.function = imx_timeout;
-- 
2.7.4


[-- Attachment #3: 0002-serial-imx-Disable-DMA-for-RS485.patch --]
[-- Type: text/x-patch, Size: 2240 bytes --]

From bf63a07c546ceed3d2c3d203d75e87001144423f Mon Sep 17 00:00:00 2001
From: Fabio Estevam <fabio.estevam@nxp.com>
Date: Tue, 20 Jun 2017 20:36:32 -0300
Subject: [PATCH 2/2] serial: imx: Disable DMA for RS485

Currently DMA support for half-duplex RS-485 does not work on i.MX6
as instead the real data being sent out, the rest of the transmit buffer
is sent (xmit->tail jumps over xmit->head in imx_transmit_buffer and
UART_XMIT_SIZE bytes are sent out).

Disable DMA for the RS485 case until a proper fix is found.

Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/tty/serial/imx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 90f8a5d..4812e11 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -213,6 +213,7 @@ struct imx_port {
 	struct clk		*clk_ipg;
 	struct clk		*clk_per;
 	const struct imx_uart_data *devdata;
+	bool			rs485_enabled_at_boot;
 
 	struct mctrl_gpios *gpios;
 
@@ -1278,7 +1279,8 @@ static int imx_startup(struct uart_port *port)
 	writel(temp & ~UCR4_DREN, sport->port.membase + UCR4);
 
 	/* Can we enable the DMA support? */
-	if (!uart_console(port) && !sport->dma_is_inited)
+	if (!uart_console(port) && !sport->dma_is_inited &&
+	    !sport->rs485_enabled_at_boot)
 		imx_uart_dma_init(sport);
 
 	spin_lock_irqsave(&sport->port.lock, flags);
@@ -2087,6 +2089,7 @@ static void serial_imx_probe_pdata(struct imx_port *sport,
 
 static int serial_imx_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct imx_port *sport;
 	void __iomem *base;
 	int ret = 0, reg;
@@ -2123,8 +2126,10 @@ static int serial_imx_probe(struct platform_device *pdev)
 	sport->port.rs485_config = imx_rs485_config;
 	sport->port.rs485.flags =
 		SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX;
-	if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL))
+	if (of_get_property(np, "linux,rs485-enabled-at-boot-time", NULL)) {
 		sport->port.rs485.flags |= SER_RS485_ENABLED;
+		sport->rs485_enabled_at_boot = true;
+	}
 
 	sport->port.flags = UPF_BOOT_AUTOCONF;
 	init_timer(&sport->timer);
-- 
2.7.4


  reply	other threads:[~2017-06-20 23:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 15:37 [PATCH] serial: imx: disable DMA for RS-485 on i.MX6 SMP Clemens Gruber
2017-06-20 16:13 ` Fabio Estevam
2017-06-20 23:49   ` Fabio Estevam [this message]
2017-07-02 20:47     ` Clemens Gruber
2017-07-02 23:09       ` Fabio Estevam
2017-06-21 14:05   ` [PATCH] " Clemens Gruber
2017-06-21 14:12     ` Fabio Estevam
2017-06-30 12:15       ` Fabio Estevam
2017-07-02 20:17         ` Clemens Gruber
2017-06-23  9:26 ` AW: [Customers.Eckelmann] " Schenk, Gavin
2017-07-17 11:34   ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOMZO5DA++c95DPrmzOHfFtD+zFcW6G9-0_cRBtg0E8TA8dwXg@mail.gmail.com \
    --to=festevam@gmail.com \
    --cc=clemens.gruber@pqgruber.com \
    --cc=fabio.estevam@nxp.com \
    --cc=fugang.duan@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).