From patchwork Thu Nov 18 07:31:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAB3FC433FE for ; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF86761269 for ; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243851AbhKRHe2 (ORCPT ); Thu, 18 Nov 2021 02:34:28 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:46338 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243829AbhKRHe1 (ORCPT ); Thu, 18 Nov 2021 02:34:27 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E235F218A8; Thu, 18 Nov 2021 07:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ee23+1ODnSdU/mKkgNL86qDgAQnmnZfSSHFlZkxlS0=; b=pKAk0YLLQwvXALQWicJR2QT9yCd9Q877o373+kvK54S2m95B4LoLhl9WINsGyMKe58xi4C ddteZu/Uz/81G8iCxTYRi4lQGmZDp4Cut+M1Q112CGnYnPut3psvhKEjdOFiVD9CXvI2vW v4H1W9rIIrQbBpuop8OohXfTfVyO+io= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220686; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ee23+1ODnSdU/mKkgNL86qDgAQnmnZfSSHFlZkxlS0=; b=6tgsk5qwEZ3ZBZGv6EisY9+JsLdzzD0T2xPd+cZOAgXPmKHHTMWNXk8BBXum6memIeWV1S DZ9Ooxrbz7/fm4Bg== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B9EC5A3B83; Thu, 18 Nov 2021 07:31:26 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 02/19] mxser: rename mxser_close_port() to mxser_stop_rx() Date: Thu, 18 Nov 2021 08:31:08 +0100 Message-Id: <20211118073125.12283-3-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org As it is the only thing it does now. This is one of the future serial_core hooks. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index f9615245a60a..e9248d39879c 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -874,16 +874,13 @@ static void mxser_flush_buffer(struct tty_struct *tty) tty_wakeup(tty); } - -static void mxser_close_port(struct tty_port *port) +/* + * To stop accepting input, we disable the receive line status interrupts, and + * tell the interrupt driver to stop checking the data ready bit in the line + * status register. + */ +static void mxser_stop_rx(struct mxser_port *info) { - struct mxser_port *info = container_of(port, struct mxser_port, port); - /* - * At this point we stop accepting input. To do this, we - * disable the receive line status interrupts, and tell the - * interrupt driver to stop checking the data ready bit in the - * line status register. - */ info->IER &= ~UART_IER_RLSI; if (info->board->must_hwid) info->IER &= ~MOXA_MUST_RECV_ISR; @@ -908,7 +905,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) return; info->closing = 1; mutex_lock(&port->mutex); - mxser_close_port(port); + mxser_stop_rx(info); mxser_flush_buffer(tty); if (tty_port_initialized(port) && C_HUPCL(tty)) tty_port_lower_dtr_rts(port); From patchwork Thu Nov 18 07:31:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43C71C433EF for ; Thu, 18 Nov 2021 07:31:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C21561875 for ; Thu, 18 Nov 2021 07:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243865AbhKRHe3 (ORCPT ); Thu, 18 Nov 2021 02:34:29 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:46346 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243836AbhKRHe1 (ORCPT ); Thu, 18 Nov 2021 02:34:27 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4645F218B0; Thu, 18 Nov 2021 07:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=twCXtdNMFjK6+ut7YGNVcpyx3BxA2wQIdmMshhy9FjQ=; b=G+IBM6FQOkwklFAl1mJ3zA6yFkJowqIe1IH11aQABUvx8rF8hXyuNUuxetxLuPqT4kAWDj TpJYFfs6sDeCY11CyVZOSIuf55oIYJbxqqTyFHcvH4Ycol4jlx2bJsf5Jm1OpvnAtAijCt baZusufTad0/PpHTcwyCEMQb2JRvfCA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=twCXtdNMFjK6+ut7YGNVcpyx3BxA2wQIdmMshhy9FjQ=; b=+1w3owIhhMe5GLYfnAOryi3kVGSQ/N2oSwNXE+OeSBT+NeI+4ld3LCiujvW6O93iA4DdGp KEFlGAa1yYJZoZBQ== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 272B8A3B83; Thu, 18 Nov 2021 07:31:27 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 04/19] mxser: move MSR read to mxser_check_modem_status() Date: Thu, 18 Nov 2021 08:31:10 +0100 Message-Id: <20211118073125.12283-5-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The MSR read is currently performed on both places where mxser_check_modem_status() is called. So move it there to avoid code duplication. Rename the variable to msr while we move it, to actually see what "status" we are testing. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index c8a56b0d900d..3d5c20e31836 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -683,27 +683,34 @@ static void mxser_change_speed(struct tty_struct *tty, struct ktermios *old_term outb(cval, info->ioaddr + UART_LCR); } -static void mxser_check_modem_status(struct tty_struct *tty, - struct mxser_port *port, int status) +static u8 mxser_check_modem_status(struct tty_struct *tty, + struct mxser_port *port) { + u8 msr = inb(port->ioaddr + UART_MSR); + + if (!(msr & UART_MSR_ANY_DELTA)) + return msr; + /* update input line counters */ - if (status & UART_MSR_TERI) + if (msr & UART_MSR_TERI) port->icount.rng++; - if (status & UART_MSR_DDSR) + if (msr & UART_MSR_DDSR) port->icount.dsr++; - if (status & UART_MSR_DDCD) + if (msr & UART_MSR_DDCD) port->icount.dcd++; - if (status & UART_MSR_DCTS) + if (msr & UART_MSR_DCTS) port->icount.cts++; wake_up_interruptible(&port->port.delta_msr_wait); - if (tty_port_check_carrier(&port->port) && (status & UART_MSR_DDCD)) { - if (status & UART_MSR_DCD) + if (tty_port_check_carrier(&port->port) && (msr & UART_MSR_DDCD)) { + if (msr & UART_MSR_DCD) wake_up_interruptible(&port->port.open_wait); } if (tty_port_cts_enabled(&port->port)) - mxser_handle_cts(tty, port, status); + mxser_handle_cts(tty, port, msr); + + return msr; } static void mxser_disable_and_clear_FIFO(struct mxser_port *info) @@ -1135,25 +1142,24 @@ static int mxser_get_lsr_info(struct mxser_port *info, static int mxser_tiocmget(struct tty_struct *tty) { struct mxser_port *info = tty->driver_data; - unsigned char control, status; + unsigned char control; unsigned long flags; + u8 msr; if (tty_io_error(tty)) return -EIO; spin_lock_irqsave(&info->slock, flags); control = info->MCR; - status = inb(info->ioaddr + UART_MSR); - if (status & UART_MSR_ANY_DELTA) - mxser_check_modem_status(tty, info, status); + msr = mxser_check_modem_status(tty, info); spin_unlock_irqrestore(&info->slock, flags); return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | - ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | - ((status & UART_MSR_RI) ? TIOCM_RNG : 0) | - ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) | - ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); + ((msr & UART_MSR_DCD) ? TIOCM_CAR : 0) | + ((msr & UART_MSR_RI) ? TIOCM_RNG : 0) | + ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0) | + ((msr & UART_MSR_CTS) ? TIOCM_CTS : 0); } static int mxser_tiocmset(struct tty_struct *tty, @@ -1656,7 +1662,7 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port static bool mxser_port_isr(struct mxser_port *port) { struct tty_struct *tty; - u8 iir, msr, status; + u8 iir, status; bool error = false; iir = inb(port->ioaddr + UART_IIR); @@ -1689,9 +1695,7 @@ static bool mxser_port_isr(struct mxser_port *port) status = mxser_receive_chars(tty, port, status); } - msr = inb(port->ioaddr + UART_MSR); - if (msr & UART_MSR_ANY_DELTA) - mxser_check_modem_status(tty, port, msr); + mxser_check_modem_status(tty, port); if (port->board->must_hwid) { if (iir == 0x02 && (status & UART_LSR_THRE)) From patchwork Thu Nov 18 07:31:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 236ABC433FE for ; Thu, 18 Nov 2021 07:31:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D69361875 for ; Thu, 18 Nov 2021 07:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243891AbhKRHef (ORCPT ); Thu, 18 Nov 2021 02:34:35 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52146 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243849AbhKRHe2 (ORCPT ); Thu, 18 Nov 2021 02:34:28 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E46C61FD37; Thu, 18 Nov 2021 07:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iqtdodw6qf92XPPiHkSJ05IPJu6Cc0cYUhgjELbsJOI=; b=rm65yxUZiAxVNd2Hs77jBTUrVk6E/J+JseJcVESNQYRx8b7Ahbq/STuca0LCMQ7zG5jnj3 Og+eAGTF9Io8jaKTlqOpd0Nxta/x9T1anbqz7tJFJUNrpFHxhztZZHlxARQaVceh3IGJu5 qqJNPQXA9JYfnbFBASAMHRyHrYLBtas= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220687; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iqtdodw6qf92XPPiHkSJ05IPJu6Cc0cYUhgjELbsJOI=; b=HBogkW3OE5ZZofPw7T58XO6uBVCtokiNXfGueQzyyXkiPzdMNvnPtkiUmIyBT/Ytei2dr4 RI76dzceeauKL3BQ== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id BC948A3B84; Thu, 18 Nov 2021 07:31:27 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 07/19] mxser: remove tty->driver_data NULL check Date: Thu, 18 Nov 2021 08:31:13 +0100 Message-Id: <20211118073125.12283-8-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Noone sets tty->driver_data to NULL in the driver, so there is no point to check that in mxser_close(). Remove the check. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 6e5e1c74bf3e..6b47a0607f59 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -905,8 +905,6 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) struct mxser_port *info = tty->driver_data; struct tty_port *port = &info->port; - if (info == NULL) - return; if (tty_port_close_start(port, tty, filp) == 0) return; mutex_lock(&port->mutex); From patchwork Thu Nov 18 07:31:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A861CC433EF for ; Thu, 18 Nov 2021 07:31:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F0C661A3D for ; Thu, 18 Nov 2021 07:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243901AbhKRHei (ORCPT ); Thu, 18 Nov 2021 02:34:38 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52162 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243855AbhKRHe3 (ORCPT ); Thu, 18 Nov 2021 02:34:29 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5183E1FD39; Thu, 18 Nov 2021 07:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/QwmVIo4NuJ1aRYyOTf7oP5YEDe0VshbVIMT5meUs0=; b=K+rSW6AFrcPiKJ7UfJ3E6O2eCibCQab5QXNo73+USM9gKs91kLAmDC7OQ6iLon1DyUvjv8 EKZPJpLxSf6sb/9gfFvFaOLYh0fS+gdMbN+nfuoO9DCyIs2De1O1tJoUTSZoRn5HDCFxOU huGrqvE6Sx0lC+epYgsRyDszF2LILPQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/QwmVIo4NuJ1aRYyOTf7oP5YEDe0VshbVIMT5meUs0=; b=OTCDnkF+ancg1xwGfE6mdr5Gb4H2hJPX6Nw4FFvhrAI7t74a47xshfCQvlZp7S+DB+dEP1 vQmRK3wjYYtCOFBw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2BB01A3B84; Thu, 18 Nov 2021 07:31:28 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 09/19] mxser: don't flush buffer from mxser_close() directly Date: Thu, 18 Nov 2021 08:31:15 +0100 Message-Id: <20211118073125.12283-10-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org I fail to see the point of calling mxser_flush_buffer() from mxser_close(): 1) The SW xmit buffer is freed in mxser_shutdown_port() right after the call to mxser_flush_buffer(). And all 'cnt', 'head', and 'tail' are properly initialized to 0 in mxser_activate(). 2) The HW buffer is flushed in mxser_shutdown_port() via mxser_disable_and_clear_FIFO() too. So the effect of doing it by mxser_flush_buffer() in mxser_close() is none. Hence remove it, so that when we use tty_port_close() later, the code is 1:1 identical. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 45ee1122a5f7..4dafa16aa29c 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -910,7 +910,6 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) if (tty_port_close_start(port, tty, filp) == 0) return; mutex_lock(&port->mutex); - mxser_flush_buffer(tty); if (tty_port_initialized(port) && C_HUPCL(tty)) tty_port_lower_dtr_rts(port); mxser_shutdown_port(port); From patchwork Thu Nov 18 07:31:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DA9CC433EF for ; Thu, 18 Nov 2021 07:31:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C3B261A3D for ; Thu, 18 Nov 2021 07:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243920AbhKRHel (ORCPT ); Thu, 18 Nov 2021 02:34:41 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:46368 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243856AbhKRHe3 (ORCPT ); Thu, 18 Nov 2021 02:34:29 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 87D4E217BA; Thu, 18 Nov 2021 07:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cTeOOnQNO75JtVQW4CESGGZ4HTSK1TMhZTUI4ncNsMk=; b=FLqjvskEniwX23Glto6wCPPPWIW0fwUjkMdYFPt0aio8fkSQIN3OCu9gprEyTFHLKkD8Cv EjI42MqlhNSVfJ6CQCItjusR2uW9jd0bLiOhpBGuQ5MP6rjQ62pk3QKyAkVHTek9Y5MkF4 tokEFXjjTzrCYhN+hZSwt0UIvug72xI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220688; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cTeOOnQNO75JtVQW4CESGGZ4HTSK1TMhZTUI4ncNsMk=; b=r0F+oj7TFLgEDE1iajFP/sGQ5sONiOn0TKs03Ww9CNHoHZ95caX9OnGt8Jl798nMmItkzb mk5JRfR30hwjAeCQ== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 619E1A3B83; Thu, 18 Nov 2021 07:31:28 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 10/19] mxser: use tty_port_close() in mxser_close() Date: Thu, 18 Nov 2021 08:31:16 +0100 Message-Id: <20211118073125.12283-11-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Finally, the mxser_close() code in is mostly identical to tty_port_close(), so replace the code by a single call to the function. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 4dafa16aa29c..6ab8899ada9c 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -896,29 +896,9 @@ static void mxser_flush_buffer(struct tty_struct *tty) tty_wakeup(tty); } -/* - * This routine is called when the serial port gets closed. First, we - * wait for the last remaining data to be sent. Then, we unlink its - * async structure from the interrupt chain if necessary, and we free - * that IRQ if nothing is left in the chain. - */ static void mxser_close(struct tty_struct *tty, struct file *filp) { - struct mxser_port *info = tty->driver_data; - struct tty_port *port = &info->port; - - if (tty_port_close_start(port, tty, filp) == 0) - return; - mutex_lock(&port->mutex); - if (tty_port_initialized(port) && C_HUPCL(tty)) - tty_port_lower_dtr_rts(port); - mxser_shutdown_port(port); - tty_port_set_initialized(port, 0); - mutex_unlock(&port->mutex); - /* Right now the tty_port set is done outside of the close_end helper - as we don't yet have everyone using refcounts */ - tty_port_close_end(port, tty); - tty_port_tty_set(port, NULL); + tty_port_close(tty->port, tty, filp); } static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) From patchwork Thu Nov 18 07:31:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC13C433F5 for ; Thu, 18 Nov 2021 07:31:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C077617E3 for ; Thu, 18 Nov 2021 07:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243930AbhKRHep (ORCPT ); Thu, 18 Nov 2021 02:34:45 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52178 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243860AbhKRHe3 (ORCPT ); Thu, 18 Nov 2021 02:34:29 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 31FE91FD3A; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tjnWMWGIfoPwUUlnn6KHn1yJDyNJ5XWkVE80iGAbOzY=; b=NBroRiGaVBAnwvsuMsQMPfxZPuK63QZp5Irq3cK2v03K/cvD2NSbf6bQjPzRVPkBM6I93g QeQsHtsJCFA50K7QITiD4q7RQg0KBpKJL58fmF5WuISl0cpCfkqYzUZkdw2y+9Abeyq4Gy yiEK1gq87BXI2LFncTLGPB7NYILFkRw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tjnWMWGIfoPwUUlnn6KHn1yJDyNJ5XWkVE80iGAbOzY=; b=DtIgzRgd/zCdWlR3WGGubvm9rD4nD9/vxbzHhVHyOVxt0LJLdjaWpbCUg701Fjlnm8NslS 1QGJAKltxQZxBLBw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 091BAA3B84; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 13/19] mxser: clean up timeout handling in mxser_wait_until_sent() Date: Thu, 18 Nov 2021 08:31:19 +0100 Message-Id: <20211118073125.12283-14-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org timeout cannot be zero at the point of use. So no need to check for zero. Also precompute the expiration time (into expire) and use it. This makes the code more clear. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index b3ae3b105af0..c3f262dc936d 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -1420,7 +1420,7 @@ static bool mxser_tx_empty(struct mxser_port *info) static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) { struct mxser_port *info = tty->driver_data; - unsigned long orig_jiffies, char_time; + unsigned long expire, char_time; if (info->type == PORT_UNKNOWN) return; @@ -1428,7 +1428,6 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) if (info->xmit_fifo_size == 0) return; /* Just in case.... */ - orig_jiffies = jiffies; /* * Set the check interval to be 1/5 of the estimated time to * send a single character, and make it at least 1. The check @@ -1458,11 +1457,13 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) if (!timeout || timeout > 2 * info->timeout) timeout = 2 * info->timeout; + expire = jiffies + timeout; + while (mxser_tx_empty(info)) { msleep_interruptible(char_time); if (signal_pending(current)) break; - if (timeout && time_after(jiffies, orig_jiffies + timeout)) + if (time_after(jiffies, expire)) break; } } From patchwork Thu Nov 18 07:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4FCEC43217 for ; Thu, 18 Nov 2021 07:31:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D085761A3D for ; Thu, 18 Nov 2021 07:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243932AbhKRHes (ORCPT ); Thu, 18 Nov 2021 02:34:48 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:46384 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243862AbhKRHe3 (ORCPT ); Thu, 18 Nov 2021 02:34:29 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 562C1218A8; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8uJEY6GawRVuGpeu4+3Tz6MShZ9mZUQ4e2P24QxckKI=; b=IEr94KtyGAiXSpZFb9vdBjO5Q9asvF3B3G9Z8MovL6F9PE04sRQyzjj1wBN29Tm2hGva3h mYtFd8zF97KzM7libLerNOwzraSanTeIoMNZyyLveVHKhby2QNrGslYnOXU+qiN6UCOgpt 8FJIojBQACCisKM0VyQzBBVabnvpCEU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8uJEY6GawRVuGpeu4+3Tz6MShZ9mZUQ4e2P24QxckKI=; b=nX3IzNhJKhGRsfdU1UYKdy5SUWx3tYPk49HoOMBR7BbfTJM8uTVnzAj8vyoZHv68/rhz10 mBwFUxzw+QFlOSAw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3863FA3B83; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 14/19] mxser: don't throttle manually Date: Thu, 18 Nov 2021 08:31:20 +0100 Message-Id: <20211118073125.12283-15-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org First, checking tty->receive_room to signalize whether there is enough space in the tty buffers does not make much sense. Provided the tty buffers are in tty_port and those are not checked at all. Second, if the rx path is throttled, with CRTSCTS, RTS is deasserted, but is never asserted again. This leads to port "lockup", not accepting any more input. So: 1) stty -F /dev/ttyMI0 crtscts # the mxser port 2) stty -F /dev/ttyS6 crtscts # the connected port 3) cat /dev/ttyMI0 4) "write in a loop" to /dev/ttyS6 5) cat from 3) produces the bytes from 4) 6) killall -STOP cat (the 3)'s one) 7) wait for RTS to drop on /dev/ttyMI0 8) killall -CONT cat (again the 3)'s one) cat erroneously produces no more output now (i.e. no data sent from ttyS6 to ttyMI can be seen). Note that the step 7) is performed twice: once from n_tty by tty_throttle_safe(), once by mxser_stoprx() from the receive path. Then after step 7), n_tty correctly unthrottles the input, but mxser calls mxser_stoprx() again as there is still only a little space in n_tty buffers (tty->receive_room mentioned at the beginning), but the device's FIFO is/can be already filled. After this patch, the output is correctly resumed, i.e. n_tty both throttles and unthrottles without interfering with mxser's attempts. This allows us to get rid of the non-standard ldisc_stop_rx flag from struct mxser_port. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index c3f262dc936d..2359b4aa68af 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -251,8 +251,6 @@ struct mxser_port { u8 MCR; /* Modem control register */ u8 FCR; /* FIFO control register */ - bool ldisc_stop_rx; - struct async_icount icount; /* kernel counters for 4 input interrupts */ unsigned int timeout; @@ -1286,11 +1284,14 @@ static int mxser_get_icount(struct tty_struct *tty, return 0; } -static void mxser_stoprx(struct tty_struct *tty) +/* + * This routine is called by the upper-layer tty layer to signal that + * incoming characters should be throttled. + */ +static void mxser_throttle(struct tty_struct *tty) { struct mxser_port *info = tty->driver_data; - info->ldisc_stop_rx = true; if (I_IXOFF(tty)) { if (info->board->must_hwid) { info->IER &= ~MOXA_MUST_RECV_ISR; @@ -1309,21 +1310,11 @@ static void mxser_stoprx(struct tty_struct *tty) } } -/* - * This routine is called by the upper-layer tty layer to signal that - * incoming characters should be throttled. - */ -static void mxser_throttle(struct tty_struct *tty) -{ - mxser_stoprx(tty); -} - static void mxser_unthrottle(struct tty_struct *tty) { struct mxser_port *info = tty->driver_data; /* startrx */ - info->ldisc_stop_rx = false; if (I_IXOFF(tty)) { if (info->x_char) info->x_char = 0; @@ -1515,9 +1506,6 @@ static bool mxser_receive_chars_new(struct tty_struct *tty, if (hwid == MOXA_MUST_MU150_HWID) gdl &= MOXA_MUST_GDL_MASK; - if (gdl >= tty->receive_room && !port->ldisc_stop_rx) - mxser_stoprx(tty); - while (gdl--) { u8 ch = inb(port->ioaddr + UART_RX); tty_insert_flip_char(&port->port, ch, 0); @@ -1530,10 +1518,8 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty, struct mxser_port *port, u8 status) { enum mxser_must_hwid hwid = port->board->must_hwid; - int recv_room = tty->receive_room; int ignored = 0; int max = 256; - int cnt = 0; u8 ch; do { @@ -1568,14 +1554,8 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty, port->icount.overrun++; } } - tty_insert_flip_char(&port->port, ch, flag); - cnt++; - if (cnt >= recv_room) { - if (!port->ldisc_stop_rx) - mxser_stoprx(tty); + if (!tty_insert_flip_char(&port->port, ch, flag)) break; - } - } if (hwid) @@ -1590,9 +1570,6 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty, static u8 mxser_receive_chars(struct tty_struct *tty, struct mxser_port *port, u8 status) { - if (tty->receive_room == 0 && !port->ldisc_stop_rx) - mxser_stoprx(tty); - if (!mxser_receive_chars_new(tty, port, status)) status = mxser_receive_chars_old(tty, port, status); @@ -1798,7 +1775,6 @@ static void mxser_initbrd(struct mxser_board *brd, bool high_baud) tty_port_init(&info->port); info->port.ops = &mxser_port_ops; info->board = brd; - info->ldisc_stop_rx = false; /* Enhance mode enabled here */ if (brd->must_hwid != MOXA_OTHER_UART) From patchwork Thu Nov 18 07:31:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDAA1C433F5 for ; Thu, 18 Nov 2021 07:31:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7802617E3 for ; Thu, 18 Nov 2021 07:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243940AbhKRHet (ORCPT ); Thu, 18 Nov 2021 02:34:49 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52184 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243869AbhKRHea (ORCPT ); Thu, 18 Nov 2021 02:34:30 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C3CF31FD3C; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+QZghgScWu28WLyT3PeJz/diGw34Qb4qYFQS/44/fw=; b=q2yqsRA8cRGV5YEDFx0S06c5EmvssJt1O8BJEOejQhB0//+Hxg/Cy/UuTdDHztNYXVqbkS sYNIABWF8ePnbxI4YQwA7F7ATQIV68gi2/ADT9Jc3gXvm5/s/RBpjjQKxxWV+2FwgfUK9e YUHSRWrnJiTkSFkqwpYpwYEVbebUUPc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220689; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9+QZghgScWu28WLyT3PeJz/diGw34Qb4qYFQS/44/fw=; b=vGDbKB+lpuC7IYSBz3S78hX4mSlBIZTEYyQ/gNlOTUNi131m7eD9Py1pXucX/Q93vEKb1p frAyV0+9EwqTyuAw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9E285A3B83; Thu, 18 Nov 2021 07:31:29 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 16/19] mxser: increase buf_overrun if tty_insert_flip_char() fails Date: Thu, 18 Nov 2021 08:31:22 +0100 Message-Id: <20211118073125.12283-17-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org mxser doesn't increase port->icount.buf_overrun at all. Do so if overrun happens, so that it can be read from the stats. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 10862d4bb885..65ea4baee5eb 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -1507,7 +1507,8 @@ static bool mxser_receive_chars_new(struct mxser_port *port, u8 status) while (gdl--) { u8 ch = inb(port->ioaddr + UART_RX); - tty_insert_flip_char(&port->port, ch, 0); + if (!tty_insert_flip_char(&port->port, ch, 0)) + port->icount.buf_overrun++; } return true; @@ -1553,8 +1554,10 @@ static u8 mxser_receive_chars_old(struct tty_struct *tty, port->icount.overrun++; } } - if (!tty_insert_flip_char(&port->port, ch, flag)) + if (!tty_insert_flip_char(&port->port, ch, flag)) { + port->icount.buf_overrun++; break; + } } if (hwid) From patchwork Thu Nov 18 07:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 517595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AA92C43219 for ; Thu, 18 Nov 2021 07:31:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A5FB61A62 for ; Thu, 18 Nov 2021 07:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243881AbhKRHev (ORCPT ); Thu, 18 Nov 2021 02:34:51 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:46422 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243873AbhKRHeb (ORCPT ); Thu, 18 Nov 2021 02:34:31 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 714B8218E0; Thu, 18 Nov 2021 07:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637220690; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yu0y74oMtF+lJUlNGiYgI7tMeVKHm6ikxOnBczy+TBI=; b=cdidaUYUcos5XS+hXMBqr5Gp/qjFdtCs72oVUr/J3SKGmHlLSV4BV2I29cc+SDzNsukcrs Yi6JE7WwqMxP8MTlJrMnSJlnk2ly4WLg3DrFAPmalLJD0Zy480iNaE9owifl1B4Nt8vUTG EmjIgzk/vYmuNm+1ydcd+OzhyRs9DFA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637220690; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yu0y74oMtF+lJUlNGiYgI7tMeVKHm6ikxOnBczy+TBI=; b=7MwmCi+KrRmUhPrveuMefWK6Bbu45i+FCewzSfKFyVdFxmhnxRb2VcIaqHdCv+3AwwLRXn wz4aaCp6IIN0UyAA== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 49500A3B84; Thu, 18 Nov 2021 07:31:30 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 19/19] mxser: use PCI_DEVICE_DATA Date: Thu, 18 Nov 2021 08:31:25 +0100 Message-Id: <20211118073125.12283-20-jslaby@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211118073125.12283-1-jslaby@suse.cz> References: <20211118073125.12283-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Now that we have all the PCI device IDs unified, we can use PCI_DEVICE_DATA() macro to simplify mxser's pci_device_id list, i.e. mxser_pcibrds. Signed-off-by: Jiri Slaby --- drivers/tty/mxser.c | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index ba96ffed193a..c858aff721c4 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c @@ -212,32 +212,32 @@ static const struct { /* driver_data correspond to the lines in the structure above see also ISA probe function before you change something */ static const struct pci_device_id mxser_pcibrds[] = { - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 2 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CT114), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102), .driver_data = 2 | MXSER_HIGHBAUD }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104U), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168U), .driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132U), .driver_data = 2 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP134U), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104JU),.driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_RC7000), .driver_data = 8 }, /* RC7000 */ - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118U), .driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UL),.driver_data = 2 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102U), .driver_data = 2 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP118EL),.driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP168EL),.driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP104EL),.driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB108), .driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB114), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CB134I), .driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP138U), .driver_data = 8 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_POS104UL),.driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP114UL),.driver_data = 4 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP102UF),.driver_data = 2 }, - { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP112UL),.driver_data = 2 }, + { PCI_DEVICE_DATA(MOXA, C168, 8) }, + { PCI_DEVICE_DATA(MOXA, C104, 4) }, + { PCI_DEVICE_DATA(MOXA, CP132, 2) }, + { PCI_DEVICE_DATA(MOXA, CP114, 4) }, + { PCI_DEVICE_DATA(MOXA, CT114, 4) }, + { PCI_DEVICE_DATA(MOXA, CP102, 2 | MXSER_HIGHBAUD) }, + { PCI_DEVICE_DATA(MOXA, CP104U, 4) }, + { PCI_DEVICE_DATA(MOXA, CP168U, 8) }, + { PCI_DEVICE_DATA(MOXA, CP132U, 2) }, + { PCI_DEVICE_DATA(MOXA, CP134U, 4) }, + { PCI_DEVICE_DATA(MOXA, CP104JU, 4) }, + { PCI_DEVICE_DATA(MOXA, RC7000, 8) }, /* RC7000 */ + { PCI_DEVICE_DATA(MOXA, CP118U, 8) }, + { PCI_DEVICE_DATA(MOXA, CP102UL, 2) }, + { PCI_DEVICE_DATA(MOXA, CP102U, 2) }, + { PCI_DEVICE_DATA(MOXA, CP118EL, 8) }, + { PCI_DEVICE_DATA(MOXA, CP168EL, 8) }, + { PCI_DEVICE_DATA(MOXA, CP104EL, 4) }, + { PCI_DEVICE_DATA(MOXA, CB108, 8) }, + { PCI_DEVICE_DATA(MOXA, CB114, 4) }, + { PCI_DEVICE_DATA(MOXA, CB134I, 4) }, + { PCI_DEVICE_DATA(MOXA, CP138U, 8) }, + { PCI_DEVICE_DATA(MOXA, POS104UL, 4) }, + { PCI_DEVICE_DATA(MOXA, CP114UL, 4) }, + { PCI_DEVICE_DATA(MOXA, CP102UF, 2) }, + { PCI_DEVICE_DATA(MOXA, CP112UL, 2) }, { } }; MODULE_DEVICE_TABLE(pci, mxser_pcibrds);