From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209839; b=y444je3cS3RwYMb8jVv/1yNaH7fj271YpAmH001leeWpO/FbyodAiYB4fTeEntK0pyoB fhHDezIELoBzh8sE5eLq9ikDPe0fIrxo0aVHnXdemYSkrT5bZpytdzyihzlD6hZyiQq6+ QakW9mRQfODP4QuzH5zOwjl4Fk8Ty3jokybyYRlwXytBRdY/E0YNT3syYsfMfohLabFZL 6GoHTKEGpgGPD5ooL1NYogLT534agXTDnZ7dBYAVuwhgwUpmwUP+rwDoZ9czQ7yUu2i3G JpA9j3wBxNKwYhLBUDQKUkwOtvVpps2ShzzuAC0eyCJZqIy4S/mcjQ9KPGXhBEjU+fg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796209839; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=+WlEWgAcbjVCG91JAprwlZvxOQ7a3usFdX7A6qhKdEQ=; b=JEGQA0L/174DFDje0J4Hel1D9NHhdlgxasvRkrinQPWz8x1nakk4pUTEzgJNFisooPqM yhDH5c00o+AEPII9sLverZHP1SP7fuvu98tNaoDasos3laLtMFReeTfCe+KACro2smksR lapnIwR0OOqmgbZz88+fMc8fNeO3duF0xAi3tOshDI14j/KwhNX2PbaqnxNSYuksdWH73 jB1pHiMg65bbM+C8e2fZiWpPBUSd/JJozacWoxf5ZvkigS1niz9zOlXnmRdzMryAwtJ/u qtwW1Z8ByNPkcNUAds+Q6OFeW3utJbjF2JElVib1jI+hVubX7VFtvmawrpfn3BHw7Fg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HsQotapA; arc=none smtp.remote-ip=209.85.128.51 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F4021606A31A for ; Wed, 2 Dec 2026 11:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F4021606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HsQotapA Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb5b8ef642so106633745e9.1 for ; Wed, 02 Dec 2026 03:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796209837; x=1796814637; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=+WlEWgAcbjVCG91JAprwlZvxOQ7a3usFdX7A6qhKdEQ=; b=HsQotapALnMMvCUC0OOqISf5PlqiDW4/jYTX/NOwgS5qh95b7I776xmhndooTSuvFI 2A/SKA9HTiL8aEtY/jtK+c3SaqmgI1Tyc0gZH9VmE20aNNwggzQhH7/uPCbFFBbsmGWP PuWo7FnbpO6n3O4VMP38Cnt6A2YxAZkrwh18RACkNbJatRRoYbXA9L+UBWr4SU9V3rh3 EHn8FnKO2fbHTVL7yQ+6KHoPTxozSSnK8dwHsbiHtA/f72aLuBRbXNYHd9hN50zY7UZD daPhVIb6Fc7KbU+ssfXOwHbGbBxoYULAD6gGIrDyuMprcFYYF/jwuBVBfyEqeUhzEBe4 g15w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796209837; x=1796814637; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+WlEWgAcbjVCG91JAprwlZvxOQ7a3usFdX7A6qhKdEQ=; b=jNj7xYxO4huRFlOcKBUfs/s5ya07wWx3W2KIB13x3JTDJc+Wap7a0dG2GFw1DbK9WW fwDD+GySad6PyTW+kidzR0BP44xEbhkwOdjgQSQCPKoXwMZZHhFeE4jj4cYTyDqBS6iX i06l4XIZmf/cyDb1wLt8XDrYGr4TCTPyBh+BqjKYX8hVgM9AeSBz27qsRSh0oqCG2dk0 HQ072EcNtcJ1bM9fPCpmyYwYNPbA6JoqGjS2Sf8eYWC2cLBAn1Ulp9RBvXdB4nnP8/fB 0HX8VLUhpmtDoVoaBygG76dfa6HkqVuaUehQPvL42WqZ49DBMdQuAJcSCSUSLQnfmRJi 5DRg== X-Forwarded-Encrypted: i=1; AL+hErFiuAFZ/w2+UyzJhuBmzRtj3+lpJkrDoNBh9oTURhQJZgBcw0h0FyG+1wAWIygiUK66ws8VklinoazQi0g=@vger.kernel.org X-Gm-Message-State: APuU4Z9tmr+j9oeTqS23atiUUzKn3dlvPSr3x//JUxdMWQEsGvBF4K37 uYaZr3UtOKI3VXONkPMH3m0GmTtxlzaHN812g9e8P/R1M5rmwwRxbcN8 X-Gm-Gg: AZFdTZeTVD21ST5nQI2zAXjwlClhw4IW9TcIaxn5Ps/EyUdDKraza0+mhD0Cm/s7SfW 1h+tcZIkCsQxkVT/cbNjuN0MXI0qKwFzKXVd+4trICmNdNIWN8X8OSv3Ng1rY9FxyqAyq7+WZYi 1sewrjQ3mH3j9sbqcUK5CNza9O9XQVoIe7Ax7/3BBZh7/CaM+WHzmFi9HGKNFgdmokrzw97C+UN 1sIGMxH0GkHpriZfnz4R9ujoFPN41xbFYdgmmwj5P/H8E0EkflYfIsA3ukaNtKGC7WPnpFCbAdl xALUoJoKtB/GXqzP+8p+ha5OMKt0yh6ltllYn8OVdggvSb71gRoFb/twBl45HecUguuQFpC8n6G QqMqAW6LuFrS+rTQcZiFS0kI3GbSfcnKBKI4vuEkP6/HGYNZ7gWpp46pUQ864WzQhLBDdKm2jvp qMcYLDYWz5A/xiSRLtew6Jq5jc3RzXAdwGb/BzrzZBVHxswwpWD3ViW4vFPk2G/TWsc5u9igDU/ H7mds0G/nJaYVP22VF6W/3rQMEFGD0zNW3/Cmq6n216Cs2em+hJ+LHjZFMmiXZNB1TC2xETtZ7P /gaZzlS+YkyqrGHornUWUR96uNP8IsNdenrmKT3MibVydw6cBgZvnS5hXasoovQ6Ro6kMoShjW6 jWRhIlEqItVfCeYyvke8NsDfzElRJApw0k4Kg+Reqh5YUz3NC9zHeCrLT X-Received: by 2002:a05:600c:5493:b0:4bb:d8fc:22f9 with SMTP id 5b1f17b1804b1-4bbd8fc239dmr23054285e9.8.1796209837369; Wed, 02 Dec 2026 03:10:37 -0800 (PST) Received: from MYL150-3871.blob.core.windows.net (57.11.28.93.rev.sfr.net. [93.28.11.57]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8533579csm922138365e9.2.2026.12.02.03.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 03:10:36 -0800 (PST) From: Nicolas Thibert To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Schocher , stable@vger.kernel.org Subject: [PATCH v2] serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios Date: Wed, 2 Dec 2026 12:10:32 +0100 Message-Id: <20261202111032.981532-1-nithibert@gmail.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since commit 0c11b88883db ("tty: 8250_of: Use software emulated RS485 direction control"), 8250_of uses the software RS485 emulation (em485). At the end of a transmission, em485 releases the direction line only once the transmitter is empty (TEMT). A 16550 has no interrupt on TEMT, so when the last THRE interrupt comes before the shift register is empty, __stop_tx() returns and nothing releases the direction line later: it stays asserted and the board cannot receive the answer from the other RS485 node. 8250_dw solves the same problem by setting UART_CAP_NOTEMT, which makes __stop_tx() release the line one frame time later instead. Do the same in 8250_of for ports whose direction line is a GPIO (rts-gpios). UART_CAP_NOTEMT is only used by the em485 stop path, so ports without RS485 are not affected. Tested on a QCA9531 board (ns16550a UART) with a CA-IS2092A RS485 transceiver whose DE/RE pins are driven by a GPIO (rts-gpios, linux,rs485-enabled-at-boot-time). Without this patch the GPIO stays high after the first transmission and no answer is received. With it, the GPIO goes low after each transmission and the answers are received. The problem was analysed and this patch written with the help of an AI coding assistant (Claude, Anthropic); the tests were run on hardware. Fixes: 0c11b88883db ("tty: 8250_of: Use software emulated RS485 direction control") Cc: stable@vger.kernel.org Signed-off-by: Nicolas Thibert --- v2: - Rewrite the commit message. - Drop the code comment. - Put Signed-off-by last. Answers to the review of v1: - What changes on existing systems: UART_CAP_NOTEMT is only checked in the em485 stop path, so only RS485 ports whose direction line is a GPIO are affected. If the transmitter is already empty at the last THRE interrupt, nothing changes. Otherwise the direction line is now released one frame time later, instead of staying asserted. - How it was tested: see the last paragraph of the commit message. - v1 was sent twice by mistake, first with a mail client, then with git send-email. drivers/tty/serial/8250/8250_of.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index b41ca604083f..b58535f73cb8 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -292,6 +292,9 @@ static int of_platform_serial_probe(struct platform_device *ofdev) &port8250.overrun_backoff_time_ms) != 0) port8250.overrun_backoff_time_ms = 0; + if (of_property_present(ofdev->dev.of_node, "rts-gpios")) + port8250.capabilities |= UART_CAP_NOTEMT; + info->uport = serial8250_register_8250_port(&port8250); if (IS_ERR(info->uport)) { ret = PTR_ERR(info->uport); -- 2.34.1