From patchwork Thu Feb 23 04:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13149852 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D68EEC61DA4 for ; Thu, 23 Feb 2023 04:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hPzv4Q8MZCE0CrfdpneakHzP9vpki0/aGVeZMlQCcjI=; b=vWeWII+t1Pg3Mj ut9wrpsRWlUwDMLWy29w268lNpbWQ04FPKThAEYgSlSfzeFQcN2Q/8wSGl76dk6/rxhN6XnCHzUuD W6DgaVCfzuQoU3j2VSF3pfp03SwnjZ4GPlGJGHR5c4egkXhIy5T+8MqmDfe6IJonHzcb/Mbk/CzRO sZftKEmRUS3WXIdmabirxIfDbKJRDj/ErygLC497LK1gFgOyM/QVwFZC/0ZoSm/7Ri8f7cYpTfulf tcXCSTNWoj5iKYpfeCz+Z2P5kKSBW7bvhjJRkkS+NM8o3a1TbZTI5rzJwUIUOyTXoc0/hf0pLaJOx 3l6DjlUioUfI4H2fwpQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV3Ak-00F00c-Iu; Thu, 23 Feb 2023 04:25:35 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV38O-00Eyna-VW for linux-arm-kernel@lists.infradead.org; Thu, 23 Feb 2023 04:23:13 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 24DEB85AD6; Thu, 23 Feb 2023 05:23:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1677126185; bh=dN/XVzBDhXcjXM25KgY+bixsmEMi13ZvR4n3mQFnt00=; h=From:To:Cc:Subject:Date:From; b=CbkUXw0RWgzSrBGnlhu9GjoZ/EXvbhO62DxN/v0izHkWqNx2BDwqViOYKDc664u4y yO3uWeYfGf6n2+daOOTixXeTqw9y4+CrH7UrpSgpWNp9oEfMvqggbO4SA6ZqLnUT8J joveJAYpdXHR26CyGI6LxHLXw796qQjqFfICbsLhjSJYyCRyJN+6IP4iyH3cNzEIWd YlU1Zb49ErVgUXwtCzl1lkms9YzurFnHA3iZVm6DzFkeRQaI52gl7iPCkXPzOaFl2Q ZjIrpJ884i4lsO6UhoVtnw9K95woEkI0X7c1JTyHid2W67r3+I7dvmHgp3HagQEEED 8WGlKQyO5UbSQ== From: Marek Vasut To: linux-serial@vger.kernel.org Cc: Marek Vasut , Alexandre Torgue , Erwan Le Ray , Greg Kroah-Hartman , Jean Philippe Romain , Jiri Slaby , Johan Hovold , Lukas Wunner , Maxime Coquelin , Valentin Caron , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 1/2] serial: stm32: Remove unused struct stm32_port txdone element Date: Thu, 23 Feb 2023 05:22:51 +0100 Message-Id: <20230223042252.95480-1-marex@denx.de> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230222_202309_299433_68BCFF73 X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The txdone element is only ever assigned, once, and never used. Drop it. Signed-off-by: Marek Vasut --- Cc: Alexandre Torgue Cc: Erwan Le Ray Cc: Greg Kroah-Hartman Cc: Jean Philippe Romain Cc: Jiri Slaby Cc: Johan Hovold Cc: Lukas Wunner Cc: Maxime Coquelin Cc: Valentin Caron Cc: linux-arm-kernel@lists.infradead.org Cc: linux-serial@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com --- drivers/tty/serial/stm32-usart.c | 1 - drivers/tty/serial/stm32-usart.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 767ff9fdb2e58..bf51e2152dd5a 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -743,7 +743,6 @@ static void stm32_usart_transmit_chars(struct uart_port *port) stm32_usart_tx_interrupt_disable(port); if (!stm32_port->hw_flow_control && port->rs485.flags & SER_RS485_ENABLED) { - stm32_port->txdone = true; stm32_usart_tc_interrupt_enable(port); } } diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index 0ec41a732c888..903285b5aea75 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -203,7 +203,6 @@ struct stm32_port { bool hw_flow_control; bool swap; /* swap RX & TX pins */ bool fifoen; - bool txdone; int rxftcfg; /* RX FIFO threshold CFG */ int txftcfg; /* TX FIFO threshold CFG */ bool wakeup_src; From patchwork Thu Feb 23 04:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13149851 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56FFDC636D7 for ; Thu, 23 Feb 2023 04:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8oaWu0oWR/8esdLon4+XIukn1KHOqzxK8Ftd52shobI=; b=KCdQbq4BtgSQ4X GrAez+GLzwUGAdoqSSh58GQWeVCi4BOS4p8qgIuhmliu+BJvUUe3UrQH5RXQdzYV1+76h5sO7+Bcf rWcEVrHOgbFzV95GN0NZG8Yni8J28zLMlCqs6PggX2FgsbiTLnCt/wom6jE8I/vFMwufYYEVsp4av rAtXN9NSbRxJxQ5gNwQzAXkTqboJZyEzRWGja+OtR8DH29/8nUKeceuK1VCJBXm4R2y7nHdLoJdN1 6sW3KqGHnQtkiWa0tgCuGaGs2P3lYa42aOfq4Kvfb32ATRymF/hwGOuk880ewzU8lj46SvarhZuih ztr4mMy3t55vJfiwrj9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV39y-00Ezdq-7j; Thu, 23 Feb 2023 04:24:46 +0000 Received: from phobos.denx.de ([2a01:238:438b:c500:173d:9f52:ddab:ee01]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV38Q-00Eyom-Re for linux-arm-kernel@lists.infradead.org; Thu, 23 Feb 2023 04:23:13 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id CD6B680ADF; Thu, 23 Feb 2023 05:23:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1677126187; bh=a3O2TGgOusMKS5UkGFPkp696mfXETUFA4hkni+79F8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sxll1XHBq0EdMVrBhnjyddtAgXkmLif11P+b/AVTEeZvNg1tSQ4cVXmgZxlOkxRHC LDBIReWdMR69/JYEXucG03RFqI1UX8ftKt5l89gR7MJuVQ5RHDLdppqir2CKW0Iocw mVT2UA+ZXvOMQBdrod0WLu5dSFVzLJpoKO6GOpSiVYyWU2ojae9eYjnBYQp+C47x5A oVuUCu4HE4erpaLIi/b0xX6R73I0IF8Xff2TdAUmvnb/S1jTaxtaCjwZEtg8f6n8p/ WLdOLBmVJ9qc3aySIfixsVA8ofaYZw6XyPYv3hL4xg9xHlGllthhMCvoLX85Nuhsw1 R74O/N2xic1jA== From: Marek Vasut To: linux-serial@vger.kernel.org Cc: Marek Vasut , Alexandre Torgue , Erwan Le Ray , Greg Kroah-Hartman , Jean Philippe Romain , Jiri Slaby , Johan Hovold , Lukas Wunner , Maxime Coquelin , Valentin Caron , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 2/2] serial: stm32: Re-assert RTS/DE GPIO in RS485 mode only if more data are transmitted Date: Thu, 23 Feb 2023 05:22:52 +0100 Message-Id: <20230223042252.95480-2-marex@denx.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223042252.95480-1-marex@denx.de> References: <20230223042252.95480-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230222_202311_121729_DCFDCD7F X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The stm32_usart_transmit_chars() may be called with empty or stopped transmit queue, and no XON/OFF character pending. This can happen at the end of transmission, where this last call is used to either handle the XON/XOFF x_char, or disable TX interrupt if queue is empty or stopped. If that occurs, do not assert the RS485 RTS/DE GPIO anymore, as the GPIO would remain asserted past the end of transmission and that would block the RS485 bus after the transmission. Only assert the RS485 RTS/DE GPIO if there is either pending XON/XOFF x_char, or at least one character in running transmit queue. Fixes: d7c76716169d ("serial: stm32: Use TC interrupt to deassert GPIO RTS in RS485 mode") Signed-off-by: Marek Vasut --- Cc: Alexandre Torgue Cc: Erwan Le Ray Cc: Greg Kroah-Hartman Cc: Jean Philippe Romain Cc: Jiri Slaby Cc: Johan Hovold Cc: Lukas Wunner Cc: Maxime Coquelin Cc: Valentin Caron Cc: linux-arm-kernel@lists.infradead.org Cc: linux-serial@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com --- drivers/tty/serial/stm32-usart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index bf51e2152dd5a..1e38fc9b10c11 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -693,8 +693,9 @@ static void stm32_usart_transmit_chars(struct uart_port *port) int ret; if (!stm32_port->hw_flow_control && - port->rs485.flags & SER_RS485_ENABLED) { - stm32_port->txdone = false; + port->rs485.flags & SER_RS485_ENABLED && + (port->x_char || + !(uart_circ_empty(xmit) || uart_tx_stopped(port)))) { stm32_usart_tc_interrupt_disable(port); stm32_usart_rs485_rts_enable(port); }