From patchwork Tue Jan 12 01:41:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 8013211 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9A0E9F1CC for ; Tue, 12 Jan 2016 01:44:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD5AA20172 for ; Tue, 12 Jan 2016 01:44:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02BBE201F4 for ; Tue, 12 Jan 2016 01:44:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aInz6-0003pu-7m; Tue, 12 Jan 2016 01:42:56 +0000 Received: from mail-bl2nam02on0042.outbound.protection.outlook.com ([104.47.38.42] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aInyX-0003b1-5D for linux-arm-kernel@lists.infradead.org; Tue, 12 Jan 2016 01:42:23 +0000 Received: from BL2NAM02FT058.eop-nam02.prod.protection.outlook.com (10.152.76.55) by BL2NAM02HT172.eop-nam02.prod.protection.outlook.com (10.152.77.60) with Microsoft SMTP Server (TLS) id 15.1.355.15; Tue, 12 Jan 2016 01:41:58 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; hurleysoftware.com; dkim=none (message not signed) header.d=none;hurleysoftware.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT058.mail.protection.outlook.com (10.152.76.176) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Tue, 12 Jan 2016 01:41:57 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1aIny8-0007hn-VW; Mon, 11 Jan 2016 17:41:56 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1aIny8-0005da-RD; Mon, 11 Jan 2016 17:41:56 -0800 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u0C1fsAA002934; Mon, 11 Jan 2016 17:41:55 -0800 Received: from [172.19.74.49] (helo=localhost) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1aIny6-0005dM-TP; Mon, 11 Jan 2016 17:41:54 -0800 From: Soren Brinkmann To: Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH LINUX 6/6] tty: xuartps: Consolidate TX handling Date: Mon, 11 Jan 2016 17:41:41 -0800 Message-ID: <1452562901-17848-7-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.7.0.3.g497ea1e In-Reply-To: <1452562901-17848-1-git-send-email-soren.brinkmann@xilinx.com> References: <1452562901-17848-1-git-send-email-soren.brinkmann@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22058.006 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.83; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(5003940100001)(1220700001)(50986999)(36756003)(19580405001)(48376002)(76176999)(6806005)(1096002)(5001770100001)(5001960100002)(5008740100001)(586003)(50226001)(87936001)(2950100001)(33646002)(36386004)(47776003)(19580395003)(81156007)(11100500001)(86362001)(189998001)(106466001)(107886002)(4001430100002)(63266004)(76506005)(92566002)(77096005)(2906002)(57986006)(229853001)(50466002)(4326007)(107986001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT172; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5e8ca320-24d4-458a-7e2c-08d31af18f09 X-Exchange-Antispam-Report-Test: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:BL2NAM02HT172; UriScan:(192813158149592); X-Microsoft-Antispam-PRVS: <604ba252168f4739b8dfd31528e69844@BL2NAM02HT172.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13017025)(520078)(13018025)(5005006)(8121501046)(3002001)(10201501046); SRVR:BL2NAM02HT172; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT172; X-Forefront-PRVS: 081904387B X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2016 01:41:57.5919 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT172 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160111_174221_419033_542CE927 X-CRM114-Status: GOOD ( 15.60 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Hurley , Michal Simek , linux-kernel@vger.kernel.org, Soren Brinkmann , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP start_tx and the ISR used largely identical code to transmit data. Consolidate that in one place. Signed-off-by: Soren Brinkmann --- drivers/tty/serial/xilinx_uartps.c | 97 ++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 57 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 3ff6e3c2347c..131a3117fbbb 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -239,6 +239,41 @@ static void cdns_uart_handle_rx(struct uart_port *port, unsigned int isrstatus) tty_flip_buffer_push(&port->state->port); } +static void cdns_uart_handle_tx(struct uart_port *port) +{ + unsigned int numbytes; + + if (uart_circ_empty(&port->state->xmit)) { + writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR); + return; + } + + numbytes = port->fifosize; + while (numbytes && !uart_circ_empty(&port->state->xmit) && + !(readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXFULL)) { + /* + * Get the data from the UART circular buffer + * and write it to the cdns_uart's TX_FIFO + * register. + */ + writel(port->state->xmit.buf[port->state->xmit.tail], + port->membase + CDNS_UART_FIFO); + port->icount.tx++; + + /* + * Adjust the tail of the UART buffer and wrap + * the buffer if it reaches limit. + */ + port->state->xmit.tail = + (port->state->xmit.tail + 1) & (UART_XMIT_SIZE - 1); + + numbytes--; + } + + if (uart_circ_chars_pending(&port->state->xmit) < WAKEUP_CHARS) + uart_write_wakeup(port); +} + /** * cdns_uart_isr - Interrupt handler * @irq: Irq number @@ -250,7 +285,7 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id) { struct uart_port *port = (struct uart_port *)dev_id; unsigned long flags; - unsigned int isrstatus, numbytes; + unsigned int isrstatus; spin_lock_irqsave(&port->lock, flags); @@ -262,40 +297,8 @@ static irqreturn_t cdns_uart_isr(int irq, void *dev_id) if (isrstatus & CDNS_UART_RX_IRQS) cdns_uart_handle_rx(port, isrstatus); - /* Dispatch an appropriate handler */ - if ((isrstatus & CDNS_UART_IXR_TXEMPTY) == CDNS_UART_IXR_TXEMPTY) { - if (uart_circ_empty(&port->state->xmit)) { - writel(CDNS_UART_IXR_TXEMPTY, - port->membase + CDNS_UART_IDR); - } else { - numbytes = port->fifosize; - /* Break if no more data available in the UART buffer */ - while (numbytes--) { - if (uart_circ_empty(&port->state->xmit)) - break; - /* Get the data from the UART circular buffer - * and write it to the cdns_uart's TX_FIFO - * register. - */ - writel(port->state->xmit.buf[ - port->state->xmit.tail], - port->membase + CDNS_UART_FIFO); - - port->icount.tx++; - - /* Adjust the tail of the UART buffer and wrap - * the buffer if it reaches limit. - */ - port->state->xmit.tail = - (port->state->xmit.tail + 1) & - (UART_XMIT_SIZE - 1); - } - - if (uart_circ_chars_pending( - &port->state->xmit) < WAKEUP_CHARS) - uart_write_wakeup(port); - } - } + if ((isrstatus & CDNS_UART_IXR_TXEMPTY) == CDNS_UART_IXR_TXEMPTY) + cdns_uart_handle_tx(port); writel(isrstatus, port->membase + CDNS_UART_ISR); @@ -502,7 +505,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, */ static void cdns_uart_start_tx(struct uart_port *port) { - unsigned int status, numbytes = port->fifosize; + unsigned int status; if (uart_tx_stopped(port)) return; @@ -519,31 +522,11 @@ static void cdns_uart_start_tx(struct uart_port *port) if (uart_circ_empty(&port->state->xmit)) return; - while (numbytes-- && ((readl(port->membase + CDNS_UART_SR) & - CDNS_UART_SR_TXFULL)) != CDNS_UART_SR_TXFULL) { - /* Break if no more data available in the UART buffer */ - if (uart_circ_empty(&port->state->xmit)) - break; - - /* Get the data from the UART circular buffer and - * write it to the cdns_uart's TX_FIFO register. - */ - writel(port->state->xmit.buf[port->state->xmit.tail], - port->membase + CDNS_UART_FIFO); - port->icount.tx++; + cdns_uart_handle_tx(port); - /* Adjust the tail of the UART buffer and wrap - * the buffer if it reaches limit. - */ - port->state->xmit.tail = (port->state->xmit.tail + 1) & - (UART_XMIT_SIZE - 1); - } writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_ISR); /* Enable the TX Empty interrupt */ writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IER); - - if (uart_circ_chars_pending(&port->state->xmit) < WAKEUP_CHARS) - uart_write_wakeup(port); } /**