From nobody Fri Nov 29 18:37:10 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89D2A15AD9B; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; cv=none; b=lmVu6csPQGIA8IsKv2+sbf2QhRil8vEJUCx5y8dboc5EHSZWOrfGnFRd3n63d2Hnqmlp6SyJd+qKL2m3UxFoph3w8f8cJUU5ZC3Ca4ar9zvr2wK30WZXO53eVFuHVJHgA/+vyi2SBljWZCekcrPhT8npJ0tOS7bKRrxn7hO6f3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; c=relaxed/simple; bh=5qUhOm/N1xmDx37BzF4Us12jj7jxEK7J2OvOQCs+KIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RUgBYn2EnggjRgWwNY4T8UiOTOy6GAhAlMDmcRrQESysF5zq9gzPjtr+VqGU39/kkrdqZ7K4F33PSkWEK3PmLLL2vwa8gRPsrJKc9oYsrxSG1A5ClRt6p17h4Ripu74uT+kIkkeZhoSU1OQEDEMIK2OicLxCtNJFTzfad3G2Klo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DfKZ0IwF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DfKZ0IwF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32F8CC4CED3; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726507623; bh=5qUhOm/N1xmDx37BzF4Us12jj7jxEK7J2OvOQCs+KIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DfKZ0IwF1udZMyn5LKM4gMYAnIY4mM6dt4LOFY2RCTt3At5qS+hMZpPmgKDCuR/p6 k84EeefGYh/HaDUie//XokwSUGUPgJplID/uo9euiZW1bpXjEPGMJMftnmZmHIss13 NGzgJLo6KQyUV5ko+dndHApXfXU7KmSv64LgiBqbxnaoBhadi44NM2vH/tggB4Me/1 55Bm1TDP/1X4KVW7jjew5kJNpZSegNZgO0NETOjYBKSQelLBDnemWsKGtCnX6h1Knq GcQL+mYdp3IiG13RyqJ3BIRXo4MKzMozW0HKRTSvpWB2TYesLuo/WjGhQQzIC2360O EEA+lHyaVgd9Q== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1sqFVS-00000000234-3RXq; Mon, 16 Sep 2024 19:27:22 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Aniket Randive Subject: [PATCH 1/3] serial: qcom-geni: fix premature receiver enable Date: Mon, 16 Sep 2024 19:26:40 +0200 Message-ID: <20240916172642.7814-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240916172642.7814-1-johan+linaro@kernel.org> References: <20240916172642.7814-1-johan+linaro@kernel.org> 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" The receiver should no be enabled until the port is opened so drop the bogus call to start tx from the setup code which is shared with the console implementation. This was added for some confused implementation of hibernation support, but the receiver must not be started unconditionally as the port may not have been open when hibernating the system. Fixes: 35781d8356a2 ("tty: serial: qcom-geni-serial: Add support for Hibern= ation feature") Cc: stable@vger.kernel.org # 6.2 Cc: Aniket Randive Signed-off-by: Johan Hovold --- drivers/tty/serial/qcom_geni_serial.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qco= m_geni_serial.c index 6f0db310cf69..9ea6bd09e665 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1152,7 +1152,6 @@ static int qcom_geni_serial_port_setup(struct uart_po= rt *uport) false, true, true); geni_se_init(&port->se, UART_RX_WM, port->rx_fifo_depth - 2); geni_se_select_mode(&port->se, port->dev_data->mode); - qcom_geni_serial_start_rx(uport); port->setup =3D true; =20 return 0; --=20 2.44.2 From nobody Fri Nov 29 18:37:10 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89CDF15AAC8; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; cv=none; b=N+QALJEmLsNYUW5eNW3zUBzH5Z2Wa344e/PSfuou9KX8stPfgOXCWOQqCHYLcU/4aL3zfe+x63xenMHLvkTMjGplo5LkCzdkU0/YP4GeipHu2KssIWoJUVLzUnHu7xbhrZHLu/askWRg3pJvpN8n9BmPnALZiZVH5yx9Gc6tXkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; c=relaxed/simple; bh=2FOD8FiK/h3Ovv4JzXzrjDug1ahckongn7Uoo/tlsCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hczvPHjWXJhBCZoRSfdBZzo5I+sVztay5F91Bd8B6U8eXBretLeRwhenTJcgPi06i0R7pT45yF6eoTht0JC1iTNIrDD3maa5GyM4dn/gLbvXCdJPsgD5qa3vxEPMoB5cIOqWT1QqUK1TER5+7+XFPWK0/jXD6cXId5dq66qHjSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CCILYzyJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CCILYzyJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30F05C4CED2; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726507623; bh=2FOD8FiK/h3Ovv4JzXzrjDug1ahckongn7Uoo/tlsCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCILYzyJy0okcu+ucr1B9N9/NeNLkJOfwsqy1AG+ux/93td6XQJ91fLZn5/DvkxSF FpkE4ewwjbXG+Dkreo3v1Ax9Y24yPz9m6mpax6Vj7pUPnb4qGC7xO6cGNJj9L0wnzJ w/mMfnLmw0o566dgEROs62skvKhHogeMpPWwzkOg+33mmyIFpBrABiV7CTr2XqHz23 MyUHWu6tk2WCdfcJkisI96NK4qCE50qm1aADnEWvXUfoNkj759pW7rhS5RY9dWnciS y+JCrom25qx4sfhdXm63bmV+xBzefTyJsFZ7nQdA+eEJPvr1WGdFQ/eTu0lG1yZ8FI hYSYUrXRYxWOg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1sqFVS-00000000236-3osE; Mon, 16 Sep 2024 19:27:22 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/3] serial: qcom-geni: fix shutdown race Date: Mon, 16 Sep 2024 19:26:41 +0200 Message-ID: <20240916172642.7814-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240916172642.7814-1-johan+linaro@kernel.org> References: <20240916172642.7814-1-johan+linaro@kernel.org> 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" A commit adding back the stopping of tx on port shutdown failed to add back the locking which had also been removed by commit e83766334f96 ("tty: serial: qcom_geni_serial: No need to stop tx/rx on UART shutdown"). Holding the port lock is needed to serialise against the console code, which may update the interrupt enable register and access the port state. The call to stop rx that was added by the same commit is redundant as serial core will already have taken care of that and can thus be removed. Fixes: d8aca2f96813 ("tty: serial: qcom-geni-serial: stop operations in pro= gress at shutdown") Fixes: 947cc4ecc06c ("serial: qcom-geni: fix soft lockup on sw flow control= and suspend") Cc: stable@vger.kernel.org # 6.3 Cc: Bartosz Golaszewski Signed-off-by: Johan Hovold Reviewed-by: Bartosz Golaszewski --- drivers/tty/serial/qcom_geni_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qco= m_geni_serial.c index 9ea6bd09e665..88ad5a6e7de2 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1096,10 +1096,10 @@ static void qcom_geni_serial_shutdown(struct uart_p= ort *uport) { disable_irq(uport->irq); =20 + uart_port_lock_irq(uport); qcom_geni_serial_stop_tx(uport); - qcom_geni_serial_stop_rx(uport); - qcom_geni_serial_cancel_tx_cmd(uport); + uart_port_unlock_irq(uport); } =20 static void qcom_geni_serial_flush_buffer(struct uart_port *uport) --=20 2.44.2 From nobody Fri Nov 29 18:37:10 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89C83157A59; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; cv=none; b=dHWV3pUxx6IGCNHYmut/CFhafyGt7CY7EJhp+sRWPJ9qMQBi1UnE92vvjo4vk/tGESc+i+UYkaoljViNybcuTQgBjOoJ7fU61Z47ioNRW+R8vGLArV5NhhwCen1q+u5GMl1t1x5xXmfg4ZXm6qOzaf5TwQSc8n39T2pnNqII/pY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726507623; c=relaxed/simple; bh=wbyyvVbAwK0TTkdf+yzuQfBYJwErlMDyLPtz/JPez44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fDfFkqXPEUuFILXZREd9aU4YPh2lWl99PtX8/EAhGIoRuuf1Pz6CTdpT2XC84pSPwxuRJPi3DdPzHccoTkkfHktfQd9Yzgxln5fkDW8jRU1eyjeJqBLs3PWRGHawpMSVgeY9/nf3Qnjlk9ngA7nB26v81jBTUtDulOXnyc+cmDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gszUH7vQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gszUH7vQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25933C4CEC5; Mon, 16 Sep 2024 17:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726507623; bh=wbyyvVbAwK0TTkdf+yzuQfBYJwErlMDyLPtz/JPez44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gszUH7vQP6plBOSjalJjSiurW/X6SUQPWF3kSYXfLj30TsVpQ3z3Q7/9Vk/3vrc5F xsq7lzQomUKt3CGg/7hABYasWsNDdQTLw8VyXV+xkq6T+r0zhguAMR8cjO4IZWSQdk +0oLxzPWPbhJcfghdVyJOmayfETaheMqwAzeoCJPMpIDgD8jcy7sTXilsgJ0xdVIvQ cXSSrikfHWmTCwqJLMRGYXI20AHxPBoqYkUhfKfEaQ21W08HUtn3ICh1qjg8h8WjNb C9vMj50xwm2Rktwz91c7VkZys80EO8WcWhBKLPm60dWl1JqIROz0WUtPi7rMFRo6bH Vj7vx8bkg5LUw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1sqFVT-00000000238-02yb; Mon, 16 Sep 2024 19:27:23 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold Subject: [PATCH 3/3] serial: qcom-geni: fix receiver enable Date: Mon, 16 Sep 2024 19:26:42 +0200 Message-ID: <20240916172642.7814-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240916172642.7814-1-johan+linaro@kernel.org> References: <20240916172642.7814-1-johan+linaro@kernel.org> 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" The receiver should be enabled in the startup() callback and there is no need to stop it on every termios update. Since commit 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") the calls to manipulate the secondary interrupts, which were done without holding the port lock, can lead to the receiver being left disabled when set_termios() races with the console code (e.g. when init opens the tty during boot). Fixes: 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console = writes") Signed-off-by: Johan Hovold --- drivers/tty/serial/qcom_geni_serial.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qco= m_geni_serial.c index 88ad5a6e7de2..85c2742e6cc4 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1167,6 +1167,11 @@ static int qcom_geni_serial_startup(struct uart_port= *uport) if (ret) return ret; } + + uart_port_lock_irq(uport); + qcom_geni_serial_start_rx(uport); + uart_port_unlock_irq(uport); + enable_irq(uport->irq); =20 return 0; @@ -1252,7 +1257,6 @@ static void qcom_geni_serial_set_termios(struct uart_= port *uport, unsigned int avg_bw_core; unsigned long timeout; =20 - qcom_geni_serial_stop_rx(uport); /* baud rate */ baud =3D uart_get_baud_rate(uport, termios, old, 300, 4000000); =20 @@ -1268,7 +1272,7 @@ static void qcom_geni_serial_set_termios(struct uart_= port *uport, dev_err(port->se.dev, "Couldn't find suitable clock rate for %u\n", baud * sampling_rate); - goto out_restart_rx; + return; } =20 dev_dbg(port->se.dev, "desired_rate =3D %u, clk_rate =3D %lu, clk_div =3D= %u\n", @@ -1359,8 +1363,6 @@ static void qcom_geni_serial_set_termios(struct uart_= port *uport, writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN); writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG); writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG); -out_restart_rx: - qcom_geni_serial_start_rx(uport); } =20 #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE --=20 2.44.2