From 1800c69b2437669573ee92ecc9da1c56afaaa747 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2024 10:53:42 -0800 Subject: [PATCH] 5.10-stable patches added patches: serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch --- ..._config-is-called-with-enabled-clock.patch | 104 ++++++++++++++++++ queue-5.10/series | 1 + 2 files changed, 105 insertions(+) create mode 100644 queue-5.10/serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch diff --git a/queue-5.10/serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch b/queue-5.10/serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch new file mode 100644 index 00000000000..a8ff5b0dd7f --- /dev/null +++ b/queue-5.10/serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch @@ -0,0 +1,104 @@ +From 7c45eaa813476bd195ac1227a64b52f9cf2e2030 Mon Sep 17 00:00:00 2001 +From: Christoph Niedermaier +Date: Tue, 26 Dec 2023 12:36:47 +0100 +Subject: serial: imx: Ensure that imx_uart_rs485_config() is called with enabled clock + +From: Christoph Niedermaier + +commit 7c45eaa813476bd195ac1227a64b52f9cf2e2030 upstream. + +There are register accesses in the function imx_uart_rs485_config(). The +clock must be enabled for these accesses. This was ensured by calling it +via the function uart_rs485_config() in the probe() function within the +range where the clock is enabled. With the commit 7c7f9bc986e6 ("serial: +Deassert Transmit Enable on probe in driver-specific way") it was removed +from the probe() function and is now only called through the function +uart_add_one_port() which is located at the end of the probe() function. +But the clock is already switched off in this area. To ensure that the +clock is enabled during register access, move the disabling of the clock +to the very end of the probe() function. To avoid leaking enabled clocks +on error also add an error path for exiting with disabling the clock. + +Fixes: 7c7f9bc986e6 ("serial: Deassert Transmit Enable on probe in driver-specific way") +Cc: stable +Signed-off-by: Christoph Niedermaier +Reviewed-by: Lukas Wunner +Link: https://lore.kernel.org/r/20231226113647.39376-1-cniedermaier@dh-electronics.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/imx.c | 23 ++++++++++++----------- + 1 file changed, 12 insertions(+), 11 deletions(-) + +--- a/drivers/tty/serial/imx.c ++++ b/drivers/tty/serial/imx.c +@@ -2358,10 +2358,8 @@ static int imx_uart_probe(struct platfor + sport->ufcr = readl(sport->port.membase + UFCR); + + ret = uart_get_rs485_mode(&sport->port); +- if (ret) { +- clk_disable_unprepare(sport->clk_ipg); +- return ret; +- } ++ if (ret) ++ goto err_clk; + + if (sport->port.rs485.flags & SER_RS485_ENABLED && + (!sport->have_rtscts && !sport->have_rtsgpio)) +@@ -2415,8 +2413,6 @@ static int imx_uart_probe(struct platfor + imx_uart_writel(sport, ucr3, UCR3); + } + +- clk_disable_unprepare(sport->clk_ipg); +- + hrtimer_init(&sport->trigger_start_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&sport->trigger_stop_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + sport->trigger_start_tx.function = imx_trigger_start_tx; +@@ -2432,7 +2428,7 @@ static int imx_uart_probe(struct platfor + if (ret) { + dev_err(&pdev->dev, "failed to request rx irq: %d\n", + ret); +- return ret; ++ goto err_clk; + } + + ret = devm_request_irq(&pdev->dev, txirq, imx_uart_txint, 0, +@@ -2440,7 +2436,7 @@ static int imx_uart_probe(struct platfor + if (ret) { + dev_err(&pdev->dev, "failed to request tx irq: %d\n", + ret); +- return ret; ++ goto err_clk; + } + + ret = devm_request_irq(&pdev->dev, rtsirq, imx_uart_rtsint, 0, +@@ -2448,14 +2444,14 @@ static int imx_uart_probe(struct platfor + if (ret) { + dev_err(&pdev->dev, "failed to request rts irq: %d\n", + ret); +- return ret; ++ goto err_clk; + } + } else { + ret = devm_request_irq(&pdev->dev, rxirq, imx_uart_int, 0, + dev_name(&pdev->dev), sport); + if (ret) { + dev_err(&pdev->dev, "failed to request irq: %d\n", ret); +- return ret; ++ goto err_clk; + } + } + +@@ -2463,7 +2459,12 @@ static int imx_uart_probe(struct platfor + + platform_set_drvdata(pdev, sport); + +- return uart_add_one_port(&imx_uart_uart_driver, &sport->port); ++ ret = uart_add_one_port(&imx_uart_uart_driver, &sport->port); ++ ++err_clk: ++ clk_disable_unprepare(sport->clk_ipg); ++ ++ return ret; + } + + static int imx_uart_remove(struct platform_device *pdev) diff --git a/queue-5.10/series b/queue-5.10/series index c9f7b436268..6e0b718c772 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -217,3 +217,4 @@ usb-chipidea-wait-controller-resume-finished-for-wakeup-irq.patch revert-usb-typec-class-fix-typec_altmode_put_partner-to-put-plugs.patch usb-typec-class-fix-typec_altmode_put_partner-to-put-plugs.patch usb-mon-fix-atomicity-violation-in-mon_bin_vma_fault.patch +serial-imx-ensure-that-imx_uart_rs485_config-is-called-with-enabled-clock.patch -- 2.47.3