From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209839; b=ThJjmsfkGj8fiSQG9eWEGk4x5uKPHDOgHMVk/LRO+j640qa0QcSls5bY7kiJGhq81QQu JyM+yZSIliNyvf061Tgjr9aC0VFfIvnseqZWF3x84k527qdvoEB0ClIe1tP7/lUjUL8o7 9w7MCkdRQLLxwe0OM2TZmnqQU6zXy9MZ+JO3/j44uTxP1sA96KKcLmrLpqi3WDMOa7zL1 plp0zY9EBqp3OQHSAIp65s7N7/TK/tVpDy4KzSxiqc6fgZvO6TO1BAgcxUZbJZY4HcevS xg160/MLRffC5tCnNJhXVO1UuAbpLarVnu8+4Km5ee+P+Y3hMebvnw7ri5TzHnkNKhw== 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=su0lj7ZFkxMOLoze2EO1XLgqXDwcqDyXuZO0f5YhX3zzIgETS0oEZRnqkBA7wHGSfzQ6 Lzso2IXC7GRdQaXtlcqVRmydolP2hx3FASzjvjr/maCZqciR/aS4W0oClmyAc5yTfsqLj Bu4OMyqqyAjdbReB7KjLgcva4BrLQdfgWzfCWq7I0k4YA7CUN1+//6KkNY3QjIZXeoewk AzG46JXU2Af++PV1KpYusb2tv9GvmFyV4dDQN0AlxND7Xst7xm/E//j8Y3Rs3h3nGiKEV h98vVZ2HYVkuJtM14QZME8VOvvGAr53QXR8f726f7GEBSY52T1j1X40f36R2cwjiJpQ== 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.47 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 0B609606A323 for ; Wed, 2 Dec 2026 11:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0B609606A323 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-f47.google.com with SMTP id 5b1f17b1804b1-4bb6057b333so65938025e9.3 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=sOFGVASYGj8WNcJ4iOkoqTnfumnYGTcIueMG4GzoE+GP3R65JY6/IOY4aFHaacYeNf V2U6ujHfXELbMvsNC18tk1vJ6ETwFZ+0wVIUZBTT0z9DEsnGb3QoAF+f0rZIoFxWLfbA 2pPAT3KzFNAyi+UUz+d1qtdBODTA1oTePIyNgE+QNK8CeXNMAwk8hud1A3c/s/Dv27Oa jLNzSIY7jnhC8gMwj2/3c1U3ih14dp4V1FgIbGvXipEAJsW+EGUO6N/kto4mUUOc7nn5 xsISgd9hfaNFX+7dOvd77bR6mhMFwTm6pYi45aCoD3hKSyIwnbRtRr16e3uvHAOw3FA6 Fcow== X-Forwarded-Encrypted: i=1; AL+hErEHtnoUm4SPgI+gjHicGzUNg2usjpxbikBh7a/xGO3j1i5aUA89vNp9ntAKOUdgPg8FcxpMIjg=@vger.kernel.org X-Gm-Message-State: APuU4Z+LyRfi8I1vHbQrqo4MBGJY3piOe7ei5Pn+AxLuY05FFNQxN4em 0FotvW2F4g2Y/uUBEB5UMTIui3uDXRvmcSIVuCbwyLQ941tRxVgxfrzCMT+reeBsSJecug== X-Gm-Gg: AZFdTZdGubS/em+jNCWKwRGgDmDTTJtUE8lXlsCiz5RvTR44Ctc7CIEz/0IsNFWa73/ wz6iXpiRz88LjljbhFl3rY8TdEhOXP6O10Rvb3f3liPhdRpMGfhP9FXO4Fzhk84U3KFuVeK03YY k46aEtE3W2QlWYQgonLIkX4SQ1eqCpSseelrpD4dERPgOiaMrOQoq5VNUOblyofV17QmeJu0JIY YnkJKjcsZrGXP64Akmy6PxyEXr6HHNNwpn35H1TRNw90gfkXa6ytPS5DbMTegQ/Bh1+BVGnXN3G 36YrpowG0c9p+BdZ6Ej8zYxSyRbYEjhGMsNlORqcwlx563KBS4C9BpKot+bpAlKsu7xmzBj0vHB 2obI+aoh176ETz/MLhpYIqgmhwhLqGIynoGOTPH17W9EZo/59Oi4Y2AruOplj/wCN+IZzQjaS70 b3LJz/gwzaZT7MDE1bglrsPUwut4u7vwVIF+eRXKWPvQP12EKX2FhRz2JkcIRuuNWu0607TqLmG gPMyFrt4Eovy1iQzI/W3XWq51DjdH6lVvqaQ0NzRvCjERUrjmpyVJ0fEYYFv7uZ99wM9t4FE9+X eqhtQYg/lOLemPgfNKietOKhykSV0JGwbFggVOLT0R4ofsZU2gEi1AuQs8ZH8kZf16qTS8+7JHv 1PBmuB2odDwfLVoMi0O3dv0oe/779037UXqd/T2eVvxrYGD5SpXfJvGty 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: stable@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