Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1631341
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Richard Genoud <richard.genoud@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] serial: sh-sci: Fix race condition causing garbage during shutdown |
| Date | Wed, 26 Apr 2017 12:10:02 +0200 |
| Message-ID | <tAs3w-Rc-21@gated-at.bofh.it> (permalink) |
| References | <tAdea-88w-23@gated-at.bofh.it> |
| X-Original-To | Geert Uytterhoeven <geert+renesas@glider.be>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=DUkvyfZ8cZlGoPJr+WBGWWPbrxIMBg2S6SdxW9ORmaI=; b=Ue5U0phDE22NvL9tgzTCRoLCsZJls07ZQ160ApgU2U5/hvbNzweaTm+HNdEyAScQ/J sCtwCVBklxm+wQBlzDKUpSXgp7mke4QHx0FJmA+D1tqV3NnnFlrDHOxArLmxclpEc9Hj u5XinqxU9XprYKacsJijcsrtPJvje3ymB3y4w4Yikwxi1kxuvnMjDYrop620ghVWRkfx JSRg44c8NBEKUosSUXHnBPfVqmLVwTzNwHT0QuVqlYlTrNY+mrTi/1Jamr1D23sz/If5 //suK3AUBHOD29ADD4mWpRYWbPzrZdeKnuW1AeNjbI7gWbggn3mQWqzAWvgoqNrB/CBK 6L9A== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=DUkvyfZ8cZlGoPJr+WBGWWPbrxIMBg2S6SdxW9ORmaI=; b=sITl6CrKplHjSKUqqu+WW323kimk9FKHeDsTBnCH95kLSyOtjiNWAmGqiLnnsHfScC uhPAWy8j6+8oMRq4zIPgjmAhOLl9+EwDS4YGCDieCCRmfXYbo2NV22syizXHZACdc3UF 9Tr5x/OZLiWpDn6/umb8AT2ubwipEMfq8dydUZOY3X2FDeTl2EKsgVR+SAMHo5kB6z5k SG5NG6A26ULfH29fawVKY324OT+laxlDzJqMUrgXLXY9MxW/40cb8RwaqpOrNISBY//6 gutLSD1a0f0xF3sI7pRkDXOOsEekv8xyx7SjbmM3FeRF/PQE2+JwU0BYOOQYCkmZHlwc Tdbg== |
| X-Gm-Message-State | AN3rC/60V7ZZok1B4ipxWLPqwZ2GCaIu78Mf190kLJNxl1Hb1hxq6F5F 1t67iRTU2rlcig== |
| X-Received | by 10.28.0.142 with SMTP id 136mr178638wma.123.1493201315690; Wed, 26 Apr 2017 03:08:35 -0700 (PDT) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 68 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Jiri Slaby <jslaby@suse.com>, Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>, linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Wed, 26 Apr 2017 12:08:28 +0200 |
| X-Original-Message-ID | <fd16d1a4-674a-c1cf-d8ef-ab20796ec7e6@gmail.com> |
| X-Original-References | <1493144135-898-1-git-send-email-geert+renesas@glider.be> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1631341 |
Show key headers only | View raw
On 25/04/2017 20:15, Geert Uytterhoeven wrote:
> If DMA is enabled and used, a burst of old data may be seen on the
> serial console during "poweroff" or "reboot". uart_flush_buffer()
> clears the circular buffer, but sci_port.tx_dma_len is not reset.
> This leads to a circular buffer overflow, dumping (UART_XMIT_SIZE -
> sci_port.tx_dma_len) bytes.
>
> To fix this, add a .flush_buffer() callback that resets
> sci_port.tx_dma_len.
>
> Inspired by commit 31ca2c63fdc0aee7 ("tty/serial: atmel: fix race
> condition (TX+DMA)").
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> A big thanks to Richard!
> I had no idea what was happening here, until I saw his patch passing by
> in a stable backport.
:)
you're welcome !
> In v4.3 and older, the field is called sg_len_tx.
> ---
> drivers/tty/serial/sh-sci.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 9a47cc4f16a2798f..a15739202d6c75f2 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1545,7 +1545,16 @@ static void sci_free_dma(struct uart_port *port)
> if (s->chan_rx)
> sci_rx_dma_release(s, false);
> }
> -#else
> +
> +static void sci_flush_buffer(struct uart_port *port)
> +{
> + /*
> + * In uart_flush_buffer(), the xmit circular buffer has just been
> + * cleared, so we have to reset tx_dma_len accordingly.
> + */
> + to_sci_port(port)->tx_dma_len = 0;
> +}
> +#else /* !CONFIG_SERIAL_SH_SCI_DMA */
> static inline void sci_request_dma(struct uart_port *port)
> {
> }
> @@ -1553,7 +1562,9 @@ static inline void sci_request_dma(struct uart_port *port)
> static inline void sci_free_dma(struct uart_port *port)
> {
> }
> -#endif
> +
> +#define sci_flush_buffer NULL
> +#endif /* !CONFIG_SERIAL_SH_SCI_DMA */
>
> static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
> {
> @@ -2566,6 +2577,7 @@ static const struct uart_ops sci_uart_ops = {
> .break_ctl = sci_break_ctl,
> .startup = sci_startup,
> .shutdown = sci_shutdown,
> + .flush_buffer = sci_flush_buffer,
> .set_termios = sci_set_termios,
> .pm = sci_pm,
> .type = sci_type,
>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] serial: sh-sci: Fix race condition causing garbage during shutdown Geert Uytterhoeven <geert+renesas@glider.be> - 2017-04-25 20:20 +0200 Re: [PATCH] serial: sh-sci: Fix race condition causing garbage during shutdown Richard Genoud <richard.genoud@gmail.com> - 2017-04-26 12:10 +0200
csiph-web