From: Huang Shijie <b32955@freescale.com> To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, shawn.guo@linaro.org, Huang Shijie <b32955@freescale.com> Subject: [PATCH 1/4] serial: imx: implement the flush_buffer hook Date: Fri, 11 Oct 2013 18:30:58 +0800 [thread overview] Message-ID: <1381487461-12850-2-git-send-email-b32955@freescale.com> (raw) In-Reply-To: <1381487461-12850-1-git-send-email-b32955@freescale.com> The current driver does not implement the flush_buffer hook for uart_ops. When we enable the DMA for the driver, and test it with Bluetooth, we may meet the following bug for TX: [1] User application may call the flush operation at any time. The uart_flush_buffer() calls the uart_circ_clear() to set the xmit->head and xmit->tail with 0. [2] The TX DMA callback can be called at any time too. The dma_tx_call() will update the xmit->tail. If [2] occurs just after the [1], we will get the wrong xmit->tail. This patch implements the flush_buffer hook to fix this issue. Signed-off-by: Huang Shijie <b32955@freescale.com> --- drivers/tty/serial/imx.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index c07d9bb..708ba89 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1303,6 +1303,16 @@ static void imx_shutdown(struct uart_port *port) clk_disable_unprepare(sport->clk_ipg); } +static void imx_flush_buffer(struct uart_port *port) +{ + struct imx_port *sport = (struct imx_port *)port; + + if (sport->dma_is_enabled) { + sport->tx_bytes = 0; + dmaengine_terminate_all(sport->dma_chan_tx); + } +} + static void imx_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) @@ -1623,6 +1633,7 @@ static struct uart_ops imx_pops = { .break_ctl = imx_break_ctl, .startup = imx_startup, .shutdown = imx_shutdown, + .flush_buffer = imx_flush_buffer, .set_termios = imx_set_termios, .type = imx_type, .release_port = imx_release_port, -- 1.7.2.rc3
WARNING: multiple messages have this Message-ID (diff)
From: b32955@freescale.com (Huang Shijie) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/4] serial: imx: implement the flush_buffer hook Date: Fri, 11 Oct 2013 18:30:58 +0800 [thread overview] Message-ID: <1381487461-12850-2-git-send-email-b32955@freescale.com> (raw) In-Reply-To: <1381487461-12850-1-git-send-email-b32955@freescale.com> The current driver does not implement the flush_buffer hook for uart_ops. When we enable the DMA for the driver, and test it with Bluetooth, we may meet the following bug for TX: [1] User application may call the flush operation at any time. The uart_flush_buffer() calls the uart_circ_clear() to set the xmit->head and xmit->tail with 0. [2] The TX DMA callback can be called at any time too. The dma_tx_call() will update the xmit->tail. If [2] occurs just after the [1], we will get the wrong xmit->tail. This patch implements the flush_buffer hook to fix this issue. Signed-off-by: Huang Shijie <b32955@freescale.com> --- drivers/tty/serial/imx.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index c07d9bb..708ba89 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1303,6 +1303,16 @@ static void imx_shutdown(struct uart_port *port) clk_disable_unprepare(sport->clk_ipg); } +static void imx_flush_buffer(struct uart_port *port) +{ + struct imx_port *sport = (struct imx_port *)port; + + if (sport->dma_is_enabled) { + sport->tx_bytes = 0; + dmaengine_terminate_all(sport->dma_chan_tx); + } +} + static void imx_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) @@ -1623,6 +1633,7 @@ static struct uart_ops imx_pops = { .break_ctl = imx_break_ctl, .startup = imx_startup, .shutdown = imx_shutdown, + .flush_buffer = imx_flush_buffer, .set_termios = imx_set_termios, .type = imx_type, .release_port = imx_release_port, -- 1.7.2.rc3
next prev parent reply other threads:[~2013-10-11 10:45 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-10-11 10:30 [PATCH 0/4] serail: imx: patches for DMA Huang Shijie 2013-10-11 10:30 ` Huang Shijie 2013-10-11 10:30 ` Huang Shijie [this message] 2013-10-11 10:30 ` [PATCH 1/4] serial: imx: implement the flush_buffer hook Huang Shijie 2014-06-03 5:51 ` Wang, Jiada (ESD) 2014-06-03 5:51 ` Wang, Jiada (ESD) 2013-10-11 10:30 ` [PATCH 2/4] serial: imx: check the DMA for imx_tx_empty Huang Shijie 2013-10-11 10:30 ` Huang Shijie 2013-10-11 10:31 ` [PATCH 3/4] serial: imx: fix the wrong number of scatterlist entries when xmit->head is 0 Huang Shijie 2013-10-11 10:31 ` Huang Shijie 2013-10-11 10:31 ` [PATCH 4/4] serial: imx: use the dmaengine_tx_status Huang Shijie 2013-10-11 10:31 ` Huang Shijie
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=1381487461-12850-2-git-send-email-b32955@freescale.com \ --to=b32955@freescale.com \ --cc=gregkh@linuxfoundation.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-serial@vger.kernel.org \ --cc=shawn.guo@linaro.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.