From patchwork Wed Nov 16 14:49:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 21106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp183827wru; Wed, 16 Nov 2022 06:56:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5fMXCpR3PSo1KBuvsEvDbmAYT6BltqYOOnlUkEMXKb6R5rVUhX2DJplXp3ndeuqcyQrkze X-Received: by 2002:a17:906:280c:b0:7ad:88f8:761f with SMTP id r12-20020a170906280c00b007ad88f8761fmr17048468ejc.417.1668610579081; Wed, 16 Nov 2022 06:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668610579; cv=none; d=google.com; s=arc-20160816; b=AziZWDKHj/megr25LWErgDVKJP2dccjX/5/GjAJaVZ3scWq8VjJXvjLU7kOTFr7x9j EkACdZ5fJapz+e69Ae/aJJP9xk0j3Ap1eh5o1rNoEGJkk/10nzELQ0a7Htpkys5Ath/X u5U17zW+JPBq2XuNXRbtc8nBmuTNif+jf/+vUVggLaknFOpwDR/ahX82Ku+XINqNxn7z PtA3X2rZbTL7HRm3bNM7IY5S4DaNHRIVEb83jIgjoKuob8jChx0VJqTY69N1ZZVHdwy7 sPK805meAyowtUhKylSyiqr5fDTTcuiTdbDDsuoVgQJknguCe4573x97t82utXVOUKUn eetQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bD7MdS5vDL9626kuFaCs08bkmWREVcZginG5UxkUB7M=; b=lcE6WVCfTLgKQCBuCB/jlBkgeYt8uEecNsWGNZQ/74xMFVBK7+6iLu3VguuqQuTQus leTuMmZttpOS3vexG6l6d6zpjOhcEejJsq9Y97LCx0JOUJQ3GwmT6IVuVy3o4LsEe2W+ Ou+f+ypsoioaq2K/YXDKP7c12AZM58ZhKzGSQ5WAQdwqjEGb5Cjk0TCdpjVji8ZboqGy mmYGmg/+RLsX2ThX8bS/5I9cV4lrMuLux255qSQ3EiCqmSpMy3Ds+lRZbJx3z5fIyXJu R3LGlU2SlsQLAVYi1pqUw9tAc3zTpByXF2UG9wegt8jQ81dCFRkD2jUqIUiAtov0bYL6 AspQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pH88cF+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb2-20020a1709076d8200b00780e89aecd1si14747224ejc.849.2022.11.16.06.55.54; Wed, 16 Nov 2022 06:56:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pH88cF+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233969AbiKPOu1 (ORCPT + 99 others); Wed, 16 Nov 2022 09:50:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbiKPOtk (ORCPT ); Wed, 16 Nov 2022 09:49:40 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8CF83FBBE; Wed, 16 Nov 2022 06:49:30 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id i9so11719332qki.10; Wed, 16 Nov 2022 06:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bD7MdS5vDL9626kuFaCs08bkmWREVcZginG5UxkUB7M=; b=pH88cF+6+fCCO8t2vnymPV45Mzm/I5WpC0TiRTmOrXy6ff5gi3fXdgDC00/f1djz04 4dPmABNZYkvNQeXWUYlliMOAjk2McGALqtk4OoGencURYqCgybr9OEYHlzHrYDsfQuSe ZVaO8K06t5cmk58K3RFmwSIS8ZX6G7arXO5QIMRBo9kt83YVOPkgca63u72Yxwg7T49e 6vGzaTkxp9CAUnDFA930tf/U8YRbbWXK1pLikdt7XzpfgSLbxBlEVYS2g6zAD9wbuZUE rObMeo1H0R5ttDPPKkiTVPHjWlZT1gSfpz++BT+e/UW3UMMbjKE/pjn8gQoNYwRhEFpm ejuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bD7MdS5vDL9626kuFaCs08bkmWREVcZginG5UxkUB7M=; b=tS1hllbGLbuynRYs3mDlUxLfcra6QlZYoSS0XDRZnRjFC2+fqXwh7C/jATLXrhuKZ6 IbTbHOlsJgO+ts+LYQpkz/1bzcqU8QatsoJZgfur/JXnMsAXsoecfSk1DC3sIO8Cj+mo OQD4rRwHvpauveVpTquVnfy8LqWtixpglRHJJnmg7cKG1q5tGG7OBMuUQ/b5EcnUAzan Xbg66NGkYoTPVazOv1CxsKq2tR/VB9mgpJQqeBzYCIDCNDbuR/9ogH/vHX+8bRlAfmKv HCselrj4t0alFfIf1vHGB9Xv8Ks2ZywuzdAmnQqIyltpyKw8v+iD3bwRuiurCuBjWsWq YPqA== X-Gm-Message-State: ANoB5pmQa3K1MFRODqw/ztjM4ZzBCt6CT0khw8qKYNU+HvGkB43HHYYB yTq+Q2XO19F3jP6OnpX03mUk6kxwbX7vfQ== X-Received: by 2002:a05:620a:c43:b0:6fa:6423:65b6 with SMTP id u3-20020a05620a0c4300b006fa642365b6mr12498013qki.324.1668610169549; Wed, 16 Nov 2022 06:49:29 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id g5-20020ac84805000000b0039a55f78792sm8729624qtq.89.2022.11.16.06.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 06:49:29 -0800 (PST) From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, kgugala@antmicro.com, mholenko@antmicro.com, joel@jms.id.au, david.abdurachmanov@gmail.com, florent@enjoy-digital.fr, geert@linux-m68k.org, ilpo.jarvinen@linux.intel.com Subject: [PATCH v4 13/14] serial: liteuart: add IRQ support for the TX path Date: Wed, 16 Nov 2022 09:49:07 -0500 Message-Id: <20221116144908.234154-14-gsomlo@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221116144908.234154-1-gsomlo@gmail.com> References: <20221116144908.234154-1-gsomlo@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749665006443961055?= X-GMAIL-MSGID: =?utf-8?q?1749665006443961055?= Switch the TX path to IRQ-driven operation, while maintaining support for polling mode via the poll timer. Signed-off-by: Gabriel Somlo Reviewed-by: Ilpo Järvinen --- Changes from v3: - remove superfluous curly braces from liteuart_interrupt() - simplified [start|stop]_tx() by using shadow irq register from patch 12/14 - simplified liteuart_tx_chars() by rebasing on top of tty-next tree drivers/tty/serial/liteuart.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index fad778578986..977fc4349b47 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -93,27 +93,12 @@ static void liteuart_update_irq_reg(struct uart_port *port, bool set, u8 mask) static void liteuart_stop_tx(struct uart_port *port) { + liteuart_update_irq_reg(port, false, EV_TX); } static void liteuart_start_tx(struct uart_port *port) { - struct circ_buf *xmit = &port->state->xmit; - unsigned char ch; - - if (unlikely(port->x_char)) { - litex_write8(port->membase + OFF_RXTX, port->x_char); - port->icount.tx++; - port->x_char = 0; - } else if (!uart_circ_empty(xmit)) { - while (xmit->head != xmit->tail) { - ch = xmit->buf[xmit->tail]; - uart_xmit_advance(port, 1); - liteuart_putchar(port, ch); - } - } - - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) - uart_write_wakeup(port); + liteuart_update_irq_reg(port, true, EV_TX); } static void liteuart_stop_rx(struct uart_port *port) @@ -144,6 +129,15 @@ static void liteuart_rx_chars(struct uart_port *port) tty_flip_buffer_push(&port->state->port); } +static void liteuart_tx_chars(struct uart_port *port) +{ + u8 ch; + + uart_port_tx(port, ch, + !litex_read8(port->membase + OFF_TXFULL), + litex_write8(port->membase + OFF_RXTX, ch)); +} + static irqreturn_t liteuart_interrupt(int irq, void *data) { struct liteuart_port *uart = data; @@ -154,6 +148,8 @@ static irqreturn_t liteuart_interrupt(int irq, void *data) isr = litex_read8(port->membase + OFF_EV_PENDING) & uart->irq_reg; if (isr & EV_RX) liteuart_rx_chars(port); + if (isr & EV_TX) + liteuart_tx_chars(port); spin_unlock(&port->lock); return IRQ_RETVAL(isr);