[{"id":1766188,"web_url":"http://patchwork.ozlabs.org/comment/1766188/","msgid":"<CAGkQfmOBNYeYTrbzAZBZ6cC5==Pfm6pZnho-9P8ggPjMZXX4nA@mail.gmail.com>","list_archive_url":null,"date":"2017-09-11T09:52:12","subject":"Re: [PATCH v1 10/10] tty/serial: atmel: Prevent a warning on suspend","submitter":{"id":8236,"url":"http://patchwork.ozlabs.org/api/people/8236/","name":"Romain Izard","email":"romain.izard.pro@gmail.com"},"content":"2017-09-08 17:36 GMT+02:00 Romain Izard <romain.izard.pro@gmail.com>:\n> The atmel serial port driver reported the following warning on suspend:\n> atmel_usart f8020000.serial: ttyS1: Unable to drain transmitter\n>\n> As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared\n> when the transmitter is disabled, we need to know the transmitter's\n> state to return the real fifo state. And as ATMEL_US_CR is write-only,\n> it is necessary to save the state of the transmitter in a local\n> variable, and update the variable when TXEN and TXDIS is written in\n> ATMEL_US_CR.\n>\n> After those changes, atmel_tx_empty can return \"empty\" on suspend, the\n> warning in uart_suspend_port disappears, and suspending is 20ms shorter\n> for each enabled Atmel serial port.\n>\n> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>\n> ---\n>  drivers/tty/serial/atmel_serial.c | 13 +++++++++++++\n>  1 file changed, 13 insertions(+)\n>\n> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c\n> index 7551cab438ff..195c0d1b594e 100644\n> --- a/drivers/tty/serial/atmel_serial.c\n> +++ b/drivers/tty/serial/atmel_serial.c\n> @@ -171,6 +171,7 @@ struct atmel_uart_port {\n>         bool                    has_hw_timer;\n>         struct timer_list       uart_timer;\n>\n> +       bool                    tx_stopped;\n>         bool                    suspended;\n>         unsigned int            pending;\n>         unsigned int            pending_status;\n> @@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,\n>   */\n>  static u_int atmel_tx_empty(struct uart_port *port)\n>  {\n> +       struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);\n> +\n> +       if (atmel_port->tx_stopped)\n> +               return TIOCSER_TEMT;\n>         return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?\n>                 TIOCSER_TEMT :\n>                 0;\n> @@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)\n>          * is fully transmitted.\n>          */\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);\n> +       atmel_port->tx_stopped = true;\n>\n>         /* Disable interrupts */\n>         atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);\n> @@ -492,6 +498,7 @@ static void atmel_stop_tx(struct uart_port *port)\n>         if ((port->rs485.flags & SER_RS485_ENABLED) &&\n>             !(port->rs485.flags & SER_RS485_RX_DURING_TX))\n>                 atmel_start_rx(port);\n> +\n>  }\n>\n>  /*\n> @@ -521,6 +528,7 @@ static void atmel_start_tx(struct uart_port *port)\n>\n>         /* re-enable the transmitter */\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);\n> +       atmel_port->tx_stopped = false;\n>  }\n>\n>  /*\n> @@ -1866,6 +1874,7 @@ static int atmel_startup(struct uart_port *port)\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);\n>         /* enable xmit & rcvr */\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);\n> +       atmel_port->tx_stopped = false;\n>\n>         setup_timer(&atmel_port->uart_timer,\n>                         atmel_uart_timer_callback,\n> @@ -2122,6 +2131,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,\n>\n>         /* disable receiver and transmitter */\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);\n> +       atmel_port->tx_stopped = true;\n>\n>         /* mode */\n>         if (port->rs485.flags & SER_RS485_ENABLED) {\n> @@ -2207,6 +2217,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,\n>         atmel_uart_writel(port, ATMEL_US_BRGR, quot);\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);\n> +       atmel_port->tx_stopped = false;\n>\n>         /* restore interrupts */\n>         atmel_uart_writel(port, ATMEL_US_IER, imr);\n> @@ -2450,6 +2461,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)\n>\n>         /* Make sure that tx path is actually able to send characters */\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);\n> +       atmel_port->tx_stopped = false;\n>\n>         uart_console_write(port, s, count, atmel_console_putchar);\n>\n> @@ -2528,6 +2540,7 @@ static int __init atmel_console_setup(struct console *co, char *options)\n>         atmel_uart_writel(port, ATMEL_US_IDR, -1);\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);\n>         atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);\n> +       atmel_port->tx_stopped = false;\n>\n>         if (options)\n>                 uart_parse_options(options, &baud, &parity, &bits, &flow);\n> --\n> 2.11.0\n>\n\nUnfortunately this patch was broken when I reported it from my branch to\nthe v4.13, as it does not build because of the missing declaration of\n'atmel_port' in 'atmel_console_setup'.\n\nI'll send a corrected version for v2.","headers":{"Return-Path":"<linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"WXa31LhK\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tsecure) header.d=mobile-devices.fr header.i=@mobile-devices.fr\n\theader.b=\"sSOB3XLV\"; \n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"cJyRr5iJ\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrNYD1BJPz9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 19:53:52 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1drLPR-00006K-GZ; Mon, 11 Sep 2017 09:53:41 +0000","from mail-io0-x235.google.com ([2607:f8b0:4001:c06::235])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1drLOg-0007iD-MD\n\tfor linux-mtd@lists.infradead.org; Mon, 11 Sep 2017 09:53:05 +0000","by mail-io0-x235.google.com with SMTP id g32so5006747ioj.2\n\tfor <linux-mtd@lists.infradead.org>;\n\tMon, 11 Sep 2017 02:52:33 -0700 (PDT)","by 10.202.78.68 with HTTP; Mon, 11 Sep 2017 02:52:12 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=EqyDwrxOf+bVSjSo0KLgiuTRegKycRrrawxR+2AP4uE=;\n\tb=WXa31LhKXPRb+P\n\tcdtTOdHhDaEXWoTuKFU4w8QOHlrUbdAAtDwRUTAn9COadd9gG7eKrysYr2lFtxQlD+6Ze6GDzOMVr\n\tPLiKXCG9XSaqxM9u0aFHduWqJ+q2p1sW3iSixxhBN7uEywoiWaIE1pnr2eih/0ErV+jt3mPsYrPDe\n\t1+BGnK3IR9/Ae6LprW5YFLuuKLsZgbL2g4XjnAiBGuBxYoIoG14s/8pbLK29WIoUQdYikHehhPwOt\n\tWsNtqkNzrSuLjctJcTcHtNrKNzq+YlXcIxzhUlYrAse4TcPBtFK1ETXL55GtS2aoUJQrinVSUE3dF\n\tb6wXKkhTP89AFiB0ov2w==;","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=mobile-devices.fr; s=google;\n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=QmWv6SUBu2Efj6pJ+AxjvuNZCr3UKMFQkAno+5fhgpo=;\n\tb=sSOB3XLVSbCc7bmRcBhJGB7/EI9ujLTKm4MbR0g1Tq18B5qB1JNu8EcsAqQ/N87ZuL\n\tmtrFqvWhW44QAlkKI88fHFTjutaYPHe23curwuCePVPh/pgcAZeuPusSasu5BlAeQ2gx\n\twxkf82bnCsjU5BQtRziq6PQFsAU6FJ9KmLPMs=","v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=QmWv6SUBu2Efj6pJ+AxjvuNZCr3UKMFQkAno+5fhgpo=;\n\tb=cJyRr5iJbshbq5gfG7racGcpHS6Cwiv/zPj2mXQ/SIhlmf3xVS0ExN2AnT7IKM9Qmy\n\tjSchXIW0G4bIEvWSV5nPim39dsppGIvl1Sl56XPpO1ByH+UHB8lzW/Vyewv1MIdCJVG9\n\tDikIHY3dtQPS2JT8wZ5Nxuyk5lx2iUFxtl7lNBjKR8mGB01Rsn5CQw7w2h3RzbbNeVYd\n\tCekbAPEkzhKHTyETRpjILMnFCfvoefTRqbLP8T0BMzyA+P9H4vfoDwuUzs/F61ftm6cl\n\tFD3xIlMk1mtB9dtVTyIU8hDtTSTGx5UR6Cipq8ChTqdZCfLn6PaehEJq7DWPLJQIY8yK\n\tKkjQ=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=QmWv6SUBu2Efj6pJ+AxjvuNZCr3UKMFQkAno+5fhgpo=;\n\tb=cBH9Z4Vq7Mp1Gzagi/2b2vmNZ8L86JAW1AI1Ehv7AufNHIiZWESyumiN8zgIss77vL\n\tIC2CUPsXxltyj+1IULkc/6D6A+PBd+VPaTGtvCDb75DUDedeKH/ziVVfi0YoeUA1wMMQ\n\t6nv1KoIrr3TcvqrEjc+XKMVLwgEPNR8aZ/PIaNb2nC7Upw+sgc4lBM85IP/ZlreEQJSX\n\t3bY2EyDOvs040q+/fYq+kY+qfIujyGrSGpGz2fmR3kHniqSnoFLMZyRVh2ajBZ6XB1Xm\n\t89GqE+zGmWPfGPJONEKyoJWLBlZfObdeYLWIATX4jg/jwnXU7gbO7lOO89t0X5bBg/H/\n\tiLcg==","X-Gm-Message-State":"AHPjjUjKCPFaua/L6dvy1MMEs3AF2XJWHBAlB7CaOjKnjdyWREhV0xrf\n\tMordFWg5l3Rw8q+UZfzyTcFqxuNr9ro1","X-Google-Smtp-Source":"AOwi7QBwE7SEhp7nN3KLRdj9Odnxl4WHMxQ7WbayCtUdRcb1QKDhb8LwK6WDYr9lrY81HqNNpXuB4J/pmZRNFG2fIJU=","X-Received":"by 10.202.81.147 with SMTP id f141mr9936755oib.160.1505123552570;\n\tMon, 11 Sep 2017 02:52:32 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170908153604.28383-11-romain.izard.pro@gmail.com>","References":"<20170908153604.28383-1-romain.izard.pro@gmail.com>\n\t<20170908153604.28383-11-romain.izard.pro@gmail.com>","From":"Romain Izard <romain.izard.pro@gmail.com>","Date":"Mon, 11 Sep 2017 11:52:12 +0200","X-Google-Sender-Auth":"fbg3wLgAXM8aSFC80ZhGE9IZhRs","Message-ID":"<CAGkQfmOBNYeYTrbzAZBZ6cC5==Pfm6pZnho-9P8ggPjMZXX4nA@mail.gmail.com>","Subject":"Re: [PATCH v1 10/10] tty/serial: atmel: Prevent a warning on suspend","To":"Nicolas Ferre <nicolas.ferre@microchip.com>, \n\tBoris Brezillon <boris.brezillon@free-electrons.com>, \n\tMichael Turquette <mturquette@baylibre.com>,\n\tStephen Boyd <sboyd@codeaurora.org>, \n\tLudovic Desroches <ludovic.desroches@microchip.com>,\n\tJonathan Cameron <jic23@kernel.org>, \n\tWenyou Yang <wenyou.yang@atmel.com>, Josh Wu <rainyfeeling@outlook.com>, \n\tDavid Woodhouse <dwmw2@infradead.org>,\n\tBrian Norris <computersforpeace@gmail.com>, \n\tMarek Vasut <marek.vasut@gmail.com>,\n\tCyrille Pitchen <cyrille.pitchen@wedev4u.fr>, \n\tThierry Reding <thierry.reding@gmail.com>,\n\tRichard Genoud <richard.genoud@gmail.com>, \n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\tAlan Stern <stern@rowland.harvard.edu>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170911_025255_237052_5C8E87E4 ","X-CRM114-Status":"GOOD (  21.01  )","X-Spam-Score":"-2.5 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.5 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c06:0:0:0:235 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\n\tprovider (romain.izard.pro[at]gmail.com)\n\t0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level\n\tmail domains are different\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain\n\t0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and\n\tEnvelopeFrom freemail headers are different","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd/>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Cc":"linux-pwm@vger.kernel.org, linux-iio@vger.kernel.org,\n\tlinux-usb@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,\n\tlinux-mtd <linux-mtd@lists.infradead.org>, linux-serial@vger.kernel.org, \n\tRomain Izard <romain.izard.pro@gmail.com>, linux-clk@vger.kernel.org, \n\tlinux-arm-kernel <linux-arm-kernel@lists.infradead.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>","Errors-To":"linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"}}]