From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209839; b=JfKNdk5XjeKtbd83Z4D+Uq1d1JC/XU7Sfbm0VXn95+lGmy5BmcnYG34SvJWOxiKKq8iT vIvpkPeFT77PtOM2JCBPSCDfjK5zaTpokFtYxmuPLZ5CZigkShuUaQkBp3ustxCvZsmrf dhWMofOt8MCTHXUTdW2vqx66JJjhThSimMGuuWEim7vM/cDaKBaI97GM+tq49h7DEIfV+ 4ZR/RoCHIvV+3cccERIX2EXUghpbtNyOFCa/dRnBjWsdljRNQEMPAdwhkgWU3R/jQoHx9 4D/LL0pZgdB9wtm/QFt+zoh9wVKF+wFEWmNGFbbjH2OqIQYz49dEsDFCtg1Vd3BQ0xQ== 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-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=jMl8Z6evTWvH6G0pDcyVzuaohd7EsbgK3VSH9q8NubAFle12cJl1Crag4GTgmM3AnIgb kVn78gkpoh6m/LegXXKXgZhV7jXDZWg8zf0N6Jj3bItfhp9wTp1LHWWjkVg1731awK+qk CHilQ9naSsh5IwvN8mvLdc+rwOuS5httW8kpiZVgMbaEkN66f52Iv/Mb+N4E6JIx9zXug PbRe3htKsGnFOdKiLdKgjHQtZbT8qP8xwNxlPFosNxfvaERy8i5brotfZQASIuwphTQ+a XtnCgkWmOUgJJdUeteRwLMHJ8ZqiPPu9sm+crXA+iHBIYE8uU86H+Oxam87FWf+UN+Q== 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.45 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 07DE7606A322 for ; Wed, 2 Dec 2026 11:10:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 07DE7606A322 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-f45.google.com with SMTP id 5b1f17b1804b1-4bbd2c5931bso12503905e9.2 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=IjJg+4I8DODuQSRvW5MWEGsL5ckMn++VFHO428Pd4z0z5nOnsqcAd7yghXCxVFJ8ga +7n6HBhdHHrV8Uij4UuQ/xnRJ2CEjcL83SctyMaZBDero6MZ9kt/GRhmD6lsKlLk0CfA 5Oe9nEq93PSe17soS/p+LPhBae195CAf3MglK6ArPdoxSG3oWkukVIygGwXgpZ63Wlby rYhsQwXyjyJwXAqW85hYDkLhCbIU277IsYHaYWFraBlDyYco9PMfDOt1tPC/59MF2HfZ 6CcUUm0u0HXYceI45Zf4NtUqdp8MmecYBx/IJd1+1R12tsFx4uli9+AsXnq3LDzAqFjR /SIw== X-Gm-Message-State: APuU4Z8kp1iMnYfOYXei84XakzYYpJHD8yCCqQiCVMkLNGzAI77jLHyd YfeJNLB7qOrauY5u/9u1a7PkQKeXNdJA4vGWyJyuweuL0cADaXUm/Blq X-Gm-Gg: AZFdTZebeIa4uqS1ZpMLVkPYc/bMw7oBWXskSlKDBGsqm0MB6F9ArqPaPcPimpXj/od YS7avJAGwsvmCMlznRismLqv/b2Gwta9mbyj7vz/chjyQPhzydY1ORo9IskNlnTYWwRXEeuhony yYbefhwtM4GZVQY3wxrpLPa1bBJaziTzdC+KVcI5YbYyY3BPWd/rCvyLb0gwB/Plqv9+HLFXDk2 iDxoRIeovQIwdXUNVEe3WZxurY6k4RW8eGzQhiv/ruYDkUr3e71UkCV1eGaAtHFVg5nVo78se99 40429onvnvl7q3kXW9y9b+DvKxuh9knweSvIAxrnKFhSgN+ELTbcq3q7zJb8SOrAFFvYYy0zOqw 2uTBh2eZ2L/Yc+5tsUoKR5l4XoNpxWsvndMnKwpY3ymHmLS8gapJPcTt7rQW6z/vRYZlCmOSdDq uw05hvXuYHFy24TS0SyWVMMEfc8ZEHmu9zuc/8Du1fr0e+VhO3wbFGx/NDzsYZc/xrOKpX79ABb 9yPzvHoS0B5t6P0ITS6NMxEqi86sIyw+JrVMdgIIM6MKeOMrfDL1fw7WveltOTt1Aw7N+KwpFr/ yHB3kY3HHNLEIs9nAK6D3sLfHsbVVbZXCxsFth+gtaA/kVrKFYeJm07Hg51wdBzxmocqH9H5Tjq VafBIuE70dVvg2TWXUjrBw7uuHKRJ7JZK8ClHAqAgI2JdCVu/hCR9/fXW 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-serial@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