From nobody Thu Apr 2 10:57:47 2026 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4263D2475F7 for ; Mon, 9 Feb 2026 20:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770670768; cv=none; b=L68gGvyJq3iSPzlIG9SUVXSMRSNnI+ZGKMAbw1DgKbKTLwIy4PkGTksz6I7x+hmYPBKhDKdhb8b8lloH4Y9p2+Y9qyFRa+Da8dXtnz2j4VOqay/BQkKRrGpz1rEE4Fo+2vjNgqB7SAXwExj8b/ee0XmCMTMMH1QTe0eDSNF+mew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770670768; c=relaxed/simple; bh=V+nB4qVLD9kd898rqz8BpxYpKJZOQQnZHtIM3gVQkYc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rn/MuYK/XI2yT4/zXLojaeQvl9YPzuBftvuHngg0rjp1vldK567nJB0pD7BeZuHT6JvqHUcKGjcz0SHeJgjpLRYa10QoIp9622OzL7kZHLR24uUwV18ZDCiP3hOoa2AVeItSvubbNSzmwn0eUdNv1DRTct+28q6kt4dCOWKYxdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=iuHn/gFC; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iuHn/gFC" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7cfcb46ffc9so3334131a34.0 for ; Mon, 09 Feb 2026 12:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1770670766; x=1771275566; 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; bh=aduJlgD3b6UC0biOWy3CFWbM9K0Gqo/oShp1Bs/OvoY=; b=iuHn/gFCybNPyM8fjMPusMkeS7gJ8OqlAWbqhYZkVr+YdbfPgxOxz2p+bBmXvYbkw8 iuPMv2/3m8dTYQcjMoSuukJgVOJnqp0KcNoi6kA0+mxdgVn+gBXrg0Sz2h7KYHaZIp4C 4cpCogoyArv/pBgT1wbdFik7GvsRwwEJ3hxJc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770670766; x=1771275566; 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; bh=aduJlgD3b6UC0biOWy3CFWbM9K0Gqo/oShp1Bs/OvoY=; b=rwPgXoINRi7FL2V8bCo8bFbji6PBoMwkhFtJL/PazJ8LiSA/k0vtmtxH2wOIjk8Cbr feI/TMIfi+Yj/0oLxtR09mwCoBNIIfthBDSnoFEQy7YF2g4b8BxJCNmUQKTN0lWr41mJ A5mjxSGHlBcOhBkOimIu1rkOvwRRE9ICBijFZNnqOc/nJ89TH9Z8f/y2KCPxuNEKtnB5 QgnLhD0OIr1FF6RuCzW98nfg4hb6WYaWvW6H42Wx1lfWaCOGnT4bhzGJ2K3bk416TXRU f60sywugIypnAMlAI52/ivuS7r5c95Jd38HbteLv8jNvdITpetTxu+tU4S0CxltVeu80 aTBw== X-Forwarded-Encrypted: i=1; AJvYcCX87xX/J9uk3yRX+qeoxCYpoUnkdK6TS8iKF9/nptidWq55n9epo4E+Q6S++WiGYL9InE2te831H5Bvt0g=@vger.kernel.org X-Gm-Message-State: AOJu0YzUXahDyRI2M7VSt5/9VsfS99LoRpTSrHs8xq31uZwFfOn0YRUb Y1ZsP72X/yQ9zR0RGzOvl2OtEyEAVu+0/W72dVDnIVt66YJKMnd8JhQOjwCFvLqXBPUXUH2oNG+ CLno= X-Gm-Gg: AZuq6aKQ8uNVLjswaLPmnyE/vGDpp1hW7i9BwKDvOnjIafKNMQlruoRJQ+iwyWogJhH GrKiP3ANxL0nTA+4Cm25cr/hkiINh6Hp9M6pP1mlUkA3OwTOfX5ar8hRp2oFULJFqdvWNV7xz+D 3PgTCbz/Ww5KEPCRto+joJehiBWa0uZx5IP8eCbO5T+a4mWbqa8I7YDKF+LqmTQlYg2cEI+G1gF 0qLqnEnDD3KyjOfgvuydXu77f6c/8qTMoQf32p63YIFjt2RLemC7QfMsjp/NXhXQ68k4X6g1l6N it/GTFwwVzlSTIGSf9LfA+b2VWP6snOiMfsylG2kZpxVarTlMGKnpIG7bbp1Y88ngYQ9nbznWfl Poku8bDIqxyy7AW0OnMZiL0XI9ATkrP5sg3oEM6a7sAPYowDOqU46D9DoT33Qj024yQ00meiJ+j nRgeWaB/EcqAr/6YWSptUKhzjoKbMX4MTpuFsaMryMvh7UGKgEfEZyZ/S41tj7VBSFTgWmkPg6A YDtm7cfrGT8//gqYnH4FnhrXGU= X-Received: by 2002:a05:6820:99a:b0:65c:faa7:7077 with SMTP id 006d021491bc7-672ebb9d7c4mr59285eaf.23.1770670766205; Mon, 09 Feb 2026 12:59:26 -0800 (PST) Received: from rrangel920.bld.corp.google.com (h96-60-216-201.arvdco.broadband.dynamic.tds.net. [96.60.216.201]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-672662e6b30sm706337eaf.6.2026.02.09.12.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 12:59:25 -0800 (PST) From: Raul E Rangel X-Google-Original-From: Raul E Rangel To: linux-serial@vger.kernel.org Cc: jkeeping@inmusicbrands.com, Raul E Rangel , Greg Kroah-Hartman , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Jiri Slaby , linux-kernel@vger.kernel.org Subject: [PATCH] serial: 8250: Fix TX deadlock when using DMA Date: Mon, 9 Feb 2026 13:58:18 -0700 Message-ID: <20260209135815.1.I16366ecb0f62f3c96fe3dd5763fcf6f3c2b4d8cd@changeid> X-Mailer: git-send-email 2.53.0.rc2.204.g2597b5adb4-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" `dmaengine_terminate_async` does not guarantee that the `__dma_tx_complete` callback will run. The callback is currently the only place where `dma->tx_running` gets cleared. If the transaction is canceled and the callback never runs, then `dma->tx_running` will never get cleared and we will never schedule new TX DMA transactions again. This change makes it so we clear `dma->tx_running` after we terminate the DMA transaction. This is "safe" because `serial8250_tx_dma_flush` is holding the UART port lock. The first thing the callback does is also grab the UART port lock, so access to `dma->tx_running` is serialized. Fixes: 9e512eaaf8f4 ("serial: 8250: Fix fifo underflow on flush") Signed-off-by: Raul E Rangel --- drivers/tty/serial/8250/8250_dma.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8= 250_dma.c index bdd26c9f34bd..3b6452e759d5 100644 --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c @@ -162,7 +162,22 @@ void serial8250_tx_dma_flush(struct uart_8250_port *p) */ dma->tx_size =3D 0; =20 + /* + * We can't use `dmaengine_terminate_sync` because `uart_flush_buffer` is + * holding the uart port spinlock. + */ dmaengine_terminate_async(dma->txchan); + + /* + * The callback might or might not run. If it doesn't run, we need to ens= ure + * that `tx_running` is cleared so that we can schedule new transactions. + * If it does run, then the zombie callback will clear `tx_running` again + * and perform a no-op since `tx_size` was cleared above. + * + * In either case, we ASSUME the DMA transaction will terminate before we + * issue a new `serial8250_tx_dma`. + */ + dma->tx_running =3D 0; } =20 int serial8250_rx_dma(struct uart_8250_port *p) --=20 2.53.0.rc2.204.g2597b5adb4-goog