From patchwork Sun Feb 25 15:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 775811 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 74912134A9; Sun, 25 Feb 2024 15:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874080; cv=none; b=mozd/zwTv1a0XqWFgRfOWmAo8URwF7jnTJ4LvFFLht0A2ujLswWxjzwOO3NTmt3ziNF6eV5cRoEeCrQFjoV+q5z2d7J9+VPdZW+dpogBXMn1+ka6QHJJPF7JlEew54HKlgO4vDGMj2PW/4mOg+AMvDKsQjN8dy2F4l3wIEEoZg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874080; c=relaxed/simple; bh=TpyL4kQVxe3uBdq1klt+8d1vmiRINhKLOGIAiZVoUdE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=R20ZRuakLYyQE4xJPKab80UZF3jB+WcN5uUhFJd0/S/iTgOaipJhLsvvOhduq47irOwH1HtaFRgL6jXGAmQNB92kaQZMKFtca+I5iEr9xmdaqVlcQBBKVxOtm31BCOsMtxy+IHpYrPmFk232rR7jkr0uenhvASHOrJx/xrmR1cE= 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=fkWiVz1G; arc=none smtp.client-ip=209.85.208.169 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.b="fkWiVz1G" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d09cf00214so36997431fa.0; Sun, 25 Feb 2024 07:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708874076; x=1709478876; 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=1WcXyxSf5IgU8jdpiPrHseEASR6WgEzsyYofdlCO6+I=; b=fkWiVz1GZ2fYkMBsTpiP3pntkQIb0wpMTi2NPKFxPIoZhGcRUujPZjxQnGutmrGIDi WtCq7AwtclfpT4xEyXDJpjQEuVV8Hy6ys5A3EVvKJHARzun7Gddr3NlolQ6zgZOLrULJ VmxnTaKpd2q8wn7qp83vK+7Wq/Sqwp+TpEvA4ncvrCa7C1YkkSQbF87kCzylzF7AxVyw zTvZUbAI2Chc9UppWyAmeuIhEtG5TnLDo1/vivB4HW7ErBW6pqA8fWbT835nXRo5GF53 S/syNlWdiWiC/yAqhf1bNg82zp4j8DfYr0Pa6I31NSF+zNL8Apg/a4d3HUmVY1y9Vl/e EbjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708874076; x=1709478876; 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=1WcXyxSf5IgU8jdpiPrHseEASR6WgEzsyYofdlCO6+I=; b=wSqgOGz+ge9qBG7TWpCkWd2bDttgC3yA6ViXG1/DjYv6I5oyitDYOAS4KQw04yvpoT 8OZ0UUSmR9zcim/OdieFkB3halPf2ruQAKveXcieoFN4cR4udTZ+rkwOh6c1Bw5eABFp BfcaNLa106ynEWT0RO37AiVK6yODlc89/uZmjGYDfTVwKG5v/2FSNHKZ5Y11L2pul1DY nOtuPXYEzFaeW0Lw3bYOO90vw8OKc/v4NKFyKtoWoxdLlokCt+CvJk2D1oWGdPEeAYBP OFH2AvXC3JaRCX2oUXaFrqK1pSRGzGK+UXFzTIWL5u+QsUQUIsSHZgDKmkSGOgyTZk4N F6yg== X-Forwarded-Encrypted: i=1; AJvYcCXxTCvjkoMBZ7kr684OCt2sopcNLa7OoDUqu2iEvKBGvx10fjXrhN6hpxRdzRO/LLIJinL6MzSgIVCV07OXrpIzakECxK1iMiED68J9 X-Gm-Message-State: AOJu0YxA27gvyE2jFX7K6e76bwFjxR0wZQeGSPaTcRIJBttVY91+BKhK tMKMSN69z9jSxJtSZX8n0yYTHT3kg1ofcN8ZZdzaixTplIgBYZpVQ99OXEzy X-Google-Smtp-Source: AGHT+IGwRu9t58O662cNWh7HIbYa2m5/h6TXMcVXKCW8V1EBpoKyYaTm1oJOrVYN4o1vH4MvArjQxg== X-Received: by 2002:a19:700e:0:b0:512:d91f:2e57 with SMTP id h14-20020a19700e000000b00512d91f2e57mr2453525lfc.55.1708874076216; Sun, 25 Feb 2024 07:14:36 -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 s1-20020a170906060100b00a3d9e6e9983sm1565616ejb.174.2024.02.25.07.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 07:14:35 -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_J=C3=A4rvinen?= , Florian Fainelli Subject: [PATCH 1/2] serial: core: introduce uart_port_tx_limited_flags() Date: Sun, 25 Feb 2024 16:14:25 +0100 Message-Id: <20240225151426.1342285-1-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Analogue to uart_port_tx_flags() introduced in commit 3ee07964d407 ("serial: core: introduce uart_port_tx_flags()"), add a _flags variant for uart_port_tx_limited(). Fixes: d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()") Signed-off-by: Jonas Gorski --- include/linux/serial_core.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 55b1f3ba48ac..e25e20034a19 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -825,6 +825,24 @@ enum UART_TX_FLAGS { __count--); \ }) +/** + * uart_port_tx_limited_flags -- transmit helper for uart_port with count limiting with flags + * @port: uart port + * @ch: variable to store a character to be written to the HW + * @flags: %UART_TX_NOSTOP or similar + * @count: a limit of characters to send + * @tx_ready: can HW accept more data function + * @put_char: function to write a character + * @tx_done: function to call after the loop is done + * + * See uart_port_tx_limited() for more details. + */ +#define uart_port_tx_limited_flags(port, ch, flags, count, tx_ready, put_char, tx_done) ({ \ + unsigned int __count = (count); \ + __uart_port_tx(port, ch, flags, tx_ready, put_char, tx_done, __count, \ + __count--); \ +}) + /** * uart_port_tx -- transmit helper for uart_port * @port: uart port From patchwork Sun Feb 25 15:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 777636 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 754E91401C; Sun, 25 Feb 2024 15:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874081; cv=none; b=GQ/FSUCnnh2vhMM7G12q+vXbjua5Z8QbxmkLwLpEGjER2NB9MFs1vcmTwharFMM4sHIh/XSymvAdl7KEXRxd5thKPrKOmWoZ4US0Z8jaGJgZls2m98tnwvBmbdR9VVSpueisj9LfoXpxkRVEYWqC5iqNtlsjBGbsQCgUqFEEbQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708874081; c=relaxed/simple; bh=vIKsCCNlA2ZnRDQ7xikBE41S9NfcNPFJ+Cbs46XztqI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZENuaMqGzWov/Br7eMVyA4jwE8PHy5L2+4YgHuPUV0CzRhqks1Ir52lNCd2DKX9RwiDYzIBfNI2AQS81dPVwUnie/FHt2QRdQUnEJPj9w4/oX/vTFmWeF8TqhIiZqHOEsfjwj4JV/cV15qiXtZmmDc58bV6eGsD9541GcdGFfkg= 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=XVJebiD7; arc=none smtp.client-ip=209.85.167.41 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.b="XVJebiD7" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-512f5484a37so1008275e87.3; Sun, 25 Feb 2024 07:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708874078; x=1709478878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2cKFGsI4XaMR+5dCCv63udFhft6EyPcLc+uriJaHY5I=; b=XVJebiD7gImTK7SWDWL9v/+e/XbP5aRrhrAW8n3gkZvkCYklukgyeznp7iMVgBqnrX 4k4O1zGikO2JpIr2JXJ6ncabFH7C0EEnj/QRpkFAA1i2NxdlE4sH+5eckssFeyeKaqNw mF8xfOf/Q89LCYPN/LQEtecDknfgQU0UMCflXUYjPAG1aPKdUKqdlb1isTbPyo02TBK9 ZugY/gBfC6RcpIk1JinYFM8vwUwFRZ5+4zkBPIG9EfTSkFbd9XqpKjQZCj7Tg4XVuuFA hZbUbF0K78yYlXK6f918DxIHIdVIb2VAbkY+/rLRX9wcbgvWUimqDADx3jDfuHpeyTHn g7tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708874078; x=1709478878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2cKFGsI4XaMR+5dCCv63udFhft6EyPcLc+uriJaHY5I=; b=O32xYAjOFSLRVGHQxTCS/Yb8Zw9lS01uAjAl/8tPc90TB0bZUKh7uXI4L2BJ186Xt+ /MF5xZDABrR3/4RgW+2hVw268PNyaPQwzooEvai0ipw1gFRbpChkl1A9QJD4XexdOdHl EkJ7z//gXqIMrY/hJGZXfm6CYr7kruOdpRCcXK6S0LXnVYq+HeB4U+IC9otbNd/r891t VAEOGQ1nKS9+bXi3mRTD4Up9yuIkkP8PKyV3NS692OmJi5PqP/4zB64mmFyyYAwwvvDl Rs4VYPRIc9abH/Qusw3QeSODjeOcrloDQB9gdG0/tAyviNAn9c5wLp7aqAVoRSH4ReIT H1tA== X-Forwarded-Encrypted: i=1; AJvYcCW5QKAGK9gC5gVPyDsYZbRH0wrFDYtxbcoKIqmxr0hk8Px+ThI1p/wybLwrT0XJlm6YpmB1PrYwwz3LY0YEnKcCQIqc9co4VsXHovYk X-Gm-Message-State: AOJu0YwYpadJQO7V6o3hhp5tMEq8xAUzS8MXeQsvEiz8pIcE9WqPS5x8 5xWJeElxrxk2RqOeQB43AKST0ivi3oLjn/8q8O8abTtLVIjiarwfoY2RbJw0 X-Google-Smtp-Source: AGHT+IEWwm4ZP1OImkLJzbEQbCbalLsyYkWvn5afQwHorbDRp0hd+b4vl84B0EAVRDR5AzBM2YRz7A== X-Received: by 2002:a05:6512:3052:b0:512:fd90:b4dc with SMTP id b18-20020a056512305200b00512fd90b4dcmr503220lfb.33.1708874077559; Sun, 25 Feb 2024 07:14:37 -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 ga13-20020a170906b84d00b00a3d5efc65e0sm1556313ejb.91.2024.02.25.07.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 07:14:36 -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_J=C3=A4rvinen?= , Florian Fainelli Subject: [PATCH 2/2] serial: bcm63xx-uart: fix tx after conversion to uart_port_tx_limited() Date: Sun, 25 Feb 2024 16:14:26 +0100 Message-Id: <20240225151426.1342285-2-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240225151426.1342285-1-jonas.gorski@gmail.com> References: <20240225151426.1342285-1-jonas.gorski@gmail.com> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When bcm63xx-uart was converted to uart_port_tx_limited(), it implicitly added a call to stop_tx(). This causes garbage to be put out on the serial console. To fix this, pass UART_TX_NOSTOP in flags, and manually call stop_tx() ourselves analogue to how a similar issue was fixed in commit 7be50f2e8f20 ("serial: mxs-auart: fix tx"). Fixes: d11cc8c3c4b6 ("tty: serial: use uart_port_tx_limited()") Signed-off-by: Jonas Gorski --- drivers/tty/serial/bcm63xx_uart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c index a3cefa153456..259fe5895032 100644 --- a/drivers/tty/serial/bcm63xx_uart.c +++ b/drivers/tty/serial/bcm63xx_uart.c @@ -309,8 +309,8 @@ static void bcm_uart_do_tx(struct uart_port *port) val = bcm_uart_readl(port, UART_MCTL_REG); val = (val & UART_MCTL_TXFIFOFILL_MASK) >> UART_MCTL_TXFIFOFILL_SHIFT; - - pending = uart_port_tx_limited(port, ch, port->fifosize - val, + pending = uart_port_tx_limited_flags(port, ch, UART_TX_NOSTOP, + port->fifosize - val, true, bcm_uart_writel(port, ch, UART_FIFO_REG), ({})); @@ -321,6 +321,9 @@ static void bcm_uart_do_tx(struct uart_port *port) val = bcm_uart_readl(port, UART_IR_REG); val &= ~UART_TX_INT_MASK; bcm_uart_writel(port, val, UART_IR_REG); + + if (uart_tx_stopped(port)) + bcm_uart_stop_tx(port); } /*