From patchwork Mon Nov 7 17:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 16581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2180979wru; Mon, 7 Nov 2022 09:16:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM4FRKh4OyWRi1ZpnypLmtvyHXgBnSgV7u7UN95oL5aiadja/21fZJ0LS4W+nJrWogsTJzN7 X-Received: by 2002:a17:903:11cd:b0:170:cde8:18b7 with SMTP id q13-20020a17090311cd00b00170cde818b7mr35281126plh.165.1667841384819; Mon, 07 Nov 2022 09:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667841384; cv=none; d=google.com; s=arc-20160816; b=cwxtLFBJOywgRhMbgadUCL5wiCbV7Ba8AhAlAl0edeBqiy6thlX3P98qnr64a27VRN i5LZUOPEmFrf9Ui8r2VsDuaA1ZR2e2VLNhdOQeLJkiOsFu8mt4WgB56/6eNfNkEKjZYS 4hY9lk9QVz9Qroz5W11qs3RHBAO+L8SMNvsAORMUtmhICuKUazsvCXGMfXs5+7y1t4GJ YuXkYuJaR+JKAqP1+nskhue61TSDe/ykT0tCu9ximO+vzpOtiyP4tW5Woa6G8UwN3R0r f4YdVBR6MNLHfSjpsaTRJS4xoy1B3SeA54y/jvAdHhGDYamaun2srPIyIZLAsms/+aif +3bg== 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=hjEUwtW5sL8GuJYm/+Q478PkR3HMmEg3Xukh/a9IkLc=; b=xgOQkhDVu2CuBPYs2F18JDaxR8Vgkk0unn127Jx/d3qGCjXVaUHJXgK+d9j2y3f5uh I1x/iVQgF/Wjp5SeJFt+LCVfp6Ws7xKR6OlxgLj7PIVNBzwgnMOyJQQ0xkaSMAFtlDxn zqaIMxH0EZSkkUDX+OSKAy/vrZnrlh7JNu0V+tNsHJFsCWsaNBycE62WoDatid1wuWkf a1Hckjv/C/lME5UT5gWRxoQ1a76D1UWrBUq0g49g+/EsV/TJaXvuEjRF2nfKiOlxGRBr /Q1mbMLhjA2Okkqbot7wBM8HLcJF1Py3OF+vuQEUfvF5GYyLQ5V4TW1tUvSjy7QwqeLV f7NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="L0wrRao/"; 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 u19-20020a63f653000000b0046086f8f5cfsi10641947pgj.383.2022.11.07.09.16.09; Mon, 07 Nov 2022 09:16:24 -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="L0wrRao/"; 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 S232568AbiKGRPV (ORCPT + 99 others); Mon, 7 Nov 2022 12:15:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbiKGRPM (ORCPT ); Mon, 7 Nov 2022 12:15:12 -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 600101C42C; Mon, 7 Nov 2022 09:15:11 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id x21so7585546qkj.0; Mon, 07 Nov 2022 09:15:11 -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=hjEUwtW5sL8GuJYm/+Q478PkR3HMmEg3Xukh/a9IkLc=; b=L0wrRao/Xut4IM2FaxKpjdKujuZ1Yf/LBQd1EzW1Cf9wkQFEhgfCW8YK6MlK3v61vR /3bv3OFywufm8UK0IVlu09o+MQj/1yuKMSKHe60jwYPpbbSd3qUDN5E49xmtt7e98Wag 58lb4NEWqLTpHccsT4IXzn0hCu1uYADu6SVKsaNP2Tvm8Emnphe0c1+eK9rWVn8IIkTl bDAdvB66h9WIX/BkwOFUMYO7NTPOGYoZF70dKMwVRqmv/e+V8Z94eIEFcoASri09l7y3 /iTJjoQwi5D8uvYidgsyseF6NjKjN1itj82bfdwOpeygbvOE6c0qXb9vMCRgtv6LEnvE BREQ== 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=hjEUwtW5sL8GuJYm/+Q478PkR3HMmEg3Xukh/a9IkLc=; b=kREje7zXbthYz+fzmvmzg9tluRVwAlUw8mgHpRtwWM98JaQfEV7qfAMKuDlOlhRNLe U9GyLRrpTlGhrXjuIesKWBuLoEtsendmE0RFzH/HDOgn5Fzmrg2Hj5ltBrQtmx1P9tc0 8ObDR1NSpiuCN7PJKnNBF50gFuiNqMx5Ggk4yTUUKysK5hyYKDE94eC7/vOLgtL+Ciw+ njVVOJONOaxGG+0OfWsJpFXuEwLZAqdAWUaPUQYdjm6P7SC5FObdlgMGbQfXBZBZmjC6 X9rSuMKBbSl/Z/JcUw4UnguSRJwsFdDYK4Mqa+q3kqWmUUlLZdVK2h/YSTsDi3PreCLv F3Mg== X-Gm-Message-State: ACrzQf2BJPpSoyv8RJEBQqy/b1rUEmZU/DiV4ztze3yobluH5Yg3TWl7 Udwd/8hBukG9gXwkXmEzv7NmjOkboVPNRA== X-Received: by 2002:a05:620a:12b5:b0:6fa:8a0c:ffd9 with SMTP id x21-20020a05620a12b500b006fa8a0cffd9mr13426265qki.518.1667841310142; Mon, 07 Nov 2022 09:15:10 -0800 (PST) Received: from glsvmlin.ini.cmu.edu (GLSVMLIN.INI.CMU.EDU. [128.2.16.9]) by smtp.gmail.com with ESMTPSA id az36-20020a05620a172400b006ce9e880c6fsm7333611qkb.111.2022.11.07.09.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 09:15:09 -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@sifive.com, florent@enjoy-digital.fr Subject: [PATCH v1 2/3] serial: liteuart: separate RX loop from poll timer Date: Mon, 7 Nov 2022 12:14:59 -0500 Message-Id: <20221107171500.2537938-3-gsomlo@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221107171500.2537938-1-gsomlo@gmail.com> References: <20221107171500.2537938-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?1748858447630193988?= X-GMAIL-MSGID: =?utf-8?q?1748858447630193988?= Move the character-receive (RX) loop to its own dedicated function, and (for now) call that from the poll timer, liteuart_timer(). This is in preparation for adding IRQ support to the receive path. Signed-off-by: Gabriel Somlo --- drivers/tty/serial/liteuart.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c index 4b9cca249828..90a29ed79bff 100644 --- a/drivers/tty/serial/liteuart.c +++ b/drivers/tty/serial/liteuart.c @@ -69,29 +69,34 @@ static struct uart_driver liteuart_driver = { #endif }; -static void liteuart_timer(struct timer_list *t) +static void liteuart_rx_chars(struct uart_port *port) { - struct liteuart_port *uart = from_timer(uart, t, timer); - struct uart_port *port = &uart->port; unsigned char __iomem *membase = port->membase; - unsigned int flg = TTY_NORMAL; - int ch; - unsigned long status; + unsigned int status; + unsigned char ch; while ((status = !litex_read8(membase + OFF_RXEMPTY)) == 1) { ch = litex_read8(membase + OFF_RXTX); port->icount.rx++; /* necessary for RXEMPTY to refresh its value */ - litex_write8(membase + OFF_EV_PENDING, EV_TX | EV_RX); + litex_write8(membase + OFF_EV_PENDING, EV_RX); /* no overflow bits in status */ if (!(uart_handle_sysrq_char(port, ch))) - uart_insert_char(port, status, 0, ch, flg); - - tty_flip_buffer_push(&port->state->port); + uart_insert_char(port, status, 0, ch, TTY_NORMAL); } + tty_flip_buffer_push(&port->state->port); +} + +static void liteuart_timer(struct timer_list *t) +{ + struct liteuart_port *uart = from_timer(uart, t, timer); + struct uart_port *port = &uart->port; + + liteuart_rx_chars(port); + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); }