Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1373154lqg; Sun, 3 Mar 2024 07:09:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5en86P7caqpDZQc+uc88MLfPa3BFnACu/4sf3cSA1V2Ka9/tWoVHcwIsQ6M4Z5Q+FePIZMVlbGKl9xKNZ9+Gx23KmR0QsZxY1ms7Mew== X-Google-Smtp-Source: AGHT+IEdGsi8DIGiqIRnsXaKy4eccPIrXqJMonSAp4SePdRwpmxZ83vT6P0f7dfkQw4va1q+JobL X-Received: by 2002:a17:90a:6341:b0:299:365a:3db0 with SMTP id v1-20020a17090a634100b00299365a3db0mr4399675pjs.5.1709478563021; Sun, 03 Mar 2024 07:09:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709478563; cv=pass; d=google.com; s=arc-20160816; b=I5cG5dowAYXcdgSRsBng86aHNY8GKDu9WfqWABjFx/CewWw0379gPJVQwr7gVmIUsn FCsmarElzYswsPjkvSEzvTZR26DQXWbu5r5JsH/dq5MLcF9eVf9VVZKOsaJ9RTCp7ktv cFe/3EXF5gymmlY/H5/nJKjKHLaHUpXijoP4K8HfkXqCK0iVpp1xmQhHnD0Nn4260NR0 DL2DA7Wu7Zxx/T1GF1oLYMXxLu0PfuhzqtgI14ldnvnVmYjZjvOUS2s1PrVM1VtZcLeu p1VBCtsPaVyvvBwpE1m0ImAZU9vDnTqGo0wpYFi+XyAgYZ75gAH1A0HXmZS23GbAKxIK nw4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=sb9pY7Lk2NLjqbhUMYCC/cMsKMTEm5a/ly9NPqt4Fgk=; fh=qt+4IO79oQVhh8NBn/nOF/p8r2WtJUE0LUnLzM1b3rI=; b=IKC5fxc8ztQvu0IfVdZz351Vdm2YovvbdCvItgQH4yq3EhscYSbPsb4kxRLo8+7Lel 1+ncOjjkLkIKEl5AGHUEozXP7dpWiMa6uH61koLYf3OBR/qvVtmvGwwsErzxWt6E6uiU ahoMuGXB6OpmeXRkEP87q8yxYKAVnb/wwqQD/3BoLKpduJM9dIuDSqLnEMiFtIu8Fw1d v4gFIpukdfZgc2IAphwMK4G6EIsM+glgqgRmlabcI/iudP1hT0pMoItlFE3BIZsXqGIq QO88jNgmRhRUxH7zs68clqz2N3ZzdEkWQ9PP3yQvlBZg/bEVtp9fZoXT2QqmOLqT6ueS oQ3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GqGnHZgZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89793-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v67-20020a632f46000000b005d8b69f8844si6885553pgv.498.2024.03.03.07.09.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 07:09:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89793-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GqGnHZgZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-89793-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AFBBB288709 for ; Sun, 3 Mar 2024 15:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C12A567A1F; Sun, 3 Mar 2024 15:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GqGnHZgZ" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 6C2552E412; Sun, 3 Mar 2024 15:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709478555; cv=none; b=ern8CoRfGXeyEnUsVJV2RautAa+ksFXuReIsy4wM/DQmd/G9sBzk4EnunbuzmeU+JjpKUsynSjKpd5cM65n4LPqNHLvPEnMB3BNX4Uqp6yz9wNx5FyukyftPPwiQ+LaHNMLaaKBU9Pd6ujBM/Z/dEvCqfuxxb57Uei2Gsh166W4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709478555; c=relaxed/simple; bh=/1wh8J2QS8Yr1f07mrXqDFKaFHq+DR4G9sxTgBBjnD4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=YCIkmCDCsXmMfqss/F41uWpbQDOsljV06pc2O8ebNm0Go8sOlShYJOfHpBi5akHB1Rd0K3VZrc+yG3mVwbOhCpbLs15s30X34Js9ydN2J8LrlPeCgsoDDVbsFdjqOzwXDygstKV2C2o4hPxlOQsU5Cbg9WeITq/ekWriWiJb9OA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GqGnHZgZ; arc=none smtp.client-ip=209.85.208.177 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 Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d3b93e992aso2240321fa.1; Sun, 03 Mar 2024 07:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709478552; x=1710083352; 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=sb9pY7Lk2NLjqbhUMYCC/cMsKMTEm5a/ly9NPqt4Fgk=; b=GqGnHZgZJPzkBnNMZifNEDk+oQ+Ui/6WS+TNgMNMcLlkNvETgtakGp3RP97Z56VMLO hBIoC2n9B81/CsawGcpms2Ihp3h2s2YihlXaZsNlsydfUutigFOfCg8CRWOlH0DRs3QX xMiXJI+47InoqPylcKaVA724iSM+UA3GOnzd7vA2W4LZuqq3P+drBjb7iPTv0rzxNyPz uOawtSNQD6Gw0/CJ3rQC2DLunFV9exKg83s6yLd6SVsoDqLPpcp0eLK+7g0wYSRrpEqW xF+Q/GNsdeNm9TbVDPiQW09TRowrL8QKsKvdjFKHuLfOZ1BouxRvXdv6XmfvLWyL7bsR bSxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709478552; x=1710083352; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sb9pY7Lk2NLjqbhUMYCC/cMsKMTEm5a/ly9NPqt4Fgk=; b=EdZg2Ql78x4F5p23rAAhobnKq8D88NSInsZNdf5O+fILwvhpek71b589QdPGQLE7qr KdTAD7LgiURpo5Hg4LGmRUcGvzvyplbX/QRpWPNVM/ZRi9LDiwXi1Qt/zRQAWoM5Gt6M DHEvNzkfYWe+dRUlfmaFkA0s57xv863BrmloISerkX/aiETlBpSd3nZk3c/n+5lHLG3T mglVKJmp3CFie5vQuMOBRSglegrmOo9A8ynGSFPwNmgm5T23h4KL7O25wiflUIC9aOj+ 23NUXzloxGY0MPsKdarlf74yXw5yPMQvSp4vjhOPj6AXnO2oC6Kit+O/+v8VyFXltFeS mncw== X-Forwarded-Encrypted: i=1; AJvYcCV0erWtjJnfyXY2+v+BG3YEWWttXleRe7dLEMMyaRE+dUg40IFrogr3Mre+ny6JRNbD+mSMlvUokWLBLhrokN3oK3KOeDh3+i19fvGSG8Y01/h9f+4Vx2693CXNJ5NhN1FZHDHp X-Gm-Message-State: AOJu0Yxu82bocolMWt4+2uirZfYrnr9KUHj8EPzVhM2EnXjeqbn+ALho L0GjxPrn+SX0gnYZZxqfKVf5C5c0S03XXjRbxEXWAag9nt/L45jkZSxjoxKG X-Received: by 2002:a05:651c:1414:b0:2d2:e2b1:4488 with SMTP id u20-20020a05651c141400b002d2e2b14488mr3784348lje.22.1709478551399; Sun, 03 Mar 2024 07:09:11 -0800 (PST) Received: from localhost (dslb-002-205-020-122.002.205.pools.vodafone-ip.de. [2.205.20.122]) by smtp.gmail.com with ESMTPSA id p3-20020a05640243c300b0055edfb81384sm3543129edc.60.2024.03.03.07.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 07:09:10 -0800 (PST) From: Jonas Gorski To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Florian Fainelli , stable@vger.kernel.org Subject: [PATCH v2] serial: core: only stop transmit when HW fifo is empty Date: Sun, 3 Mar 2024 16:08:07 +0100 Message-Id: <20240303150807.68117-1-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If the circular buffer is empty, it just means we fit all characters to send into the HW fifo, but not that the hardware finished transmitting them. So if we immediately call stop_tx() after that, this may abort any pending characters in the HW fifo, and cause dropped characters on the console. Fix this by only stopping tx when the tx HW fifo is actually empty. Fixes: 8275b48b2780 ("tty: serial: introduce transmit helpers") Cc: stable@vger.kernel.org Signed-off-by: Jonas Gorski --- (this is v2 of the bcm63xx-uart fix attempt) v1 -> v2 * replace workaround with fix for core issue * add Cc: for stable I'm somewhat confident this is the core issue causing the broken output with bcm63xx-uart, and there is no actual need for the UART_TX_NOSTOP. I wouldn't be surprised if this also fixes mxs-uart for which UART_TX_NOSTOP was introduced. If it does, there is no need for the flag anymore. include/linux/serial_core.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 55b1f3ba48ac..bb0f2d4ac62f 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -786,7 +786,8 @@ enum UART_TX_FLAGS { if (pending < WAKEUP_CHARS) { \ uart_write_wakeup(__port); \ \ - if (!((flags) & UART_TX_NOSTOP) && pending == 0) \ + if (!((flags) & UART_TX_NOSTOP) && pending == 0 && \ + __port->ops->tx_empty(__port)) \ __port->ops->stop_tx(__port); \ } \ \ -- 2.34.1