linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: imx: Fix clock imbalance
@ 2023-12-05  0:50 Marek Vasut
  2023-12-05 20:22 ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marek Vasut @ 2023-12-05  0:50 UTC (permalink / raw)
  To: linux-serial
  Cc: Marek Vasut, Ilpo Järvinen, Uwe Kleine-König,
	Fabio Estevam, Greg Kroah-Hartman, Jiri Slaby, NXP Linux Team,
	Pengutronix Kernel Team, Rob Herring, Sascha Hauer,
	Sergey Organov, Shawn Guo, Thomas Gleixner, Tom Rix,
	linux-arm-kernel

Disable and unprepare the clock on every exit from probe function
after the clock were prepared and enabled to avoid enable/disable
imbalance.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Rob Herring <robh@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sergey Organov <sorganov@gmail.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Rix <trix@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-serial@vger.kernel.org
---
 drivers/tty/serial/imx.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 52dd8a6b87603..1cce66e5d05d8 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2332,10 +2332,8 @@ static int imx_uart_probe(struct platform_device *pdev)
 	}
 
 	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))
@@ -2436,7 +2434,7 @@ static int imx_uart_probe(struct platform_device *pdev)
 		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,
@@ -2444,7 +2442,7 @@ static int imx_uart_probe(struct platform_device *pdev)
 		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,
@@ -2452,14 +2450,14 @@ static int imx_uart_probe(struct platform_device *pdev)
 		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;
 		}
 	}
 
@@ -2468,6 +2466,10 @@ static int imx_uart_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, sport);
 
 	return uart_add_one_port(&imx_uart_uart_driver, &sport->port);
+
+err_clk:
+	clk_disable_unprepare(sport->clk_ipg);
+	return ret;
 }
 
 static void imx_uart_remove(struct platform_device *pdev)
-- 
2.42.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] serial: imx: Fix clock imbalance
  2023-12-05  0:50 [PATCH] serial: imx: Fix clock imbalance Marek Vasut
@ 2023-12-05 20:22 ` Fabio Estevam
  2023-12-06 14:06 ` Christoph Niedermaier
  2023-12-06 14:29 ` Ahmad Fatoum
  2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2023-12-05 20:22 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-serial, Ilpo Järvinen, Uwe Kleine-König,
	Greg Kroah-Hartman, Jiri Slaby, NXP Linux Team,
	Pengutronix Kernel Team, Rob Herring, Sascha Hauer,
	Sergey Organov, Shawn Guo, Thomas Gleixner, Tom Rix,
	linux-arm-kernel

Hi Marek,

On Mon, Dec 4, 2023 at 9:51 PM Marek Vasut <marex@denx.de> wrote:
>
> Disable and unprepare the clock on every exit from probe function
> after the clock were prepared and enabled to avoid enable/disable
> imbalance.
>
> Signed-off-by: Marek Vasut <marex@denx.de>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] serial: imx: Fix clock imbalance
  2023-12-05  0:50 [PATCH] serial: imx: Fix clock imbalance Marek Vasut
  2023-12-05 20:22 ` Fabio Estevam
@ 2023-12-06 14:06 ` Christoph Niedermaier
  2023-12-06 14:29 ` Ahmad Fatoum
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Niedermaier @ 2023-12-06 14:06 UTC (permalink / raw)
  To: Marek Vasut, linux-serial@vger.kernel.org
  Cc: Ilpo Järvinen, Uwe Kleine-König, Fabio Estevam,
	Greg Kroah-Hartman, Jiri Slaby, NXP Linux Team,
	Pengutronix Kernel Team, Rob Herring, Sascha Hauer,
	Sergey Organov, Shawn Guo, Thomas Gleixner, Tom Rix,
	linux-arm-kernel@lists.infradead.org

From: linux-arm-kernel [mailto:linux-arm-kernel-bounces@lists.infradead.org] On Behalf Of Marek Vasut
Sent: Tuesday, December 5, 2023 1:51 AM
> Disable and unprepare the clock on every exit from probe function
> after the clock were prepared and enabled to avoid enable/disable
> imbalance.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Sergey Organov <sorganov@gmail.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tom Rix <trix@redhat.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-serial@vger.kernel.org
> ---
>  drivers/tty/serial/imx.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 52dd8a6b87603..1cce66e5d05d8 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2332,10 +2332,8 @@ static int imx_uart_probe(struct platform_device *pdev)
>         }
> 
>         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))
> @@ -2436,7 +2434,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>                 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,
> @@ -2444,7 +2442,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>                 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,
> @@ -2452,14 +2450,14 @@ static int imx_uart_probe(struct platform_device *pdev)
>                 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;
>                 }
>         }
> 
> @@ -2468,6 +2466,10 @@ static int imx_uart_probe(struct platform_device *pdev)
>         platform_set_drvdata(pdev, sport);
> 
>         return uart_add_one_port(&imx_uart_uart_driver, &sport->port);
> +
> +err_clk:
> +       clk_disable_unprepare(sport->clk_ipg);
> +       return ret;
>  }
> 
>  static void imx_uart_remove(struct platform_device *pdev)

Reviewed-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>

Regards
Christoph
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] serial: imx: Fix clock imbalance
  2023-12-05  0:50 [PATCH] serial: imx: Fix clock imbalance Marek Vasut
  2023-12-05 20:22 ` Fabio Estevam
  2023-12-06 14:06 ` Christoph Niedermaier
@ 2023-12-06 14:29 ` Ahmad Fatoum
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-12-06 14:29 UTC (permalink / raw)
  To: Marek Vasut, linux-serial
  Cc: Rob Herring, Jiri Slaby, Greg Kroah-Hartman, Sascha Hauer,
	Tom Rix, Shawn Guo, Sergey Organov, NXP Linux Team,
	Pengutronix Kernel Team, Uwe Kleine-König,
	Ilpo Järvinen, Thomas Gleixner, Fabio Estevam,
	linux-arm-kernel

Hello Marek,

On 05.12.23 01:50, Marek Vasut wrote:
> Disable and unprepare the clock on every exit from probe function
> after the clock were prepared and enabled to avoid enable/disable
> imbalance.

Why not switch the probe function to use devm_clk_get_enabled() instead?

Cheers,
Ahmad

> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Sergey Organov <sorganov@gmail.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tom Rix <trix@redhat.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-serial@vger.kernel.org
> ---
>  drivers/tty/serial/imx.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 52dd8a6b87603..1cce66e5d05d8 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2332,10 +2332,8 @@ static int imx_uart_probe(struct platform_device *pdev)
>  	}
>  
>  	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))
> @@ -2436,7 +2434,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>  		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,
> @@ -2444,7 +2442,7 @@ static int imx_uart_probe(struct platform_device *pdev)
>  		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,
> @@ -2452,14 +2450,14 @@ static int imx_uart_probe(struct platform_device *pdev)
>  		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;
>  		}
>  	}
>  
> @@ -2468,6 +2466,10 @@ static int imx_uart_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, sport);
>  
>  	return uart_add_one_port(&imx_uart_uart_driver, &sport->port);
> +
> +err_clk:
> +	clk_disable_unprepare(sport->clk_ipg);
> +	return ret;
>  }
>  
>  static void imx_uart_remove(struct platform_device *pdev)

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-06 14:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05  0:50 [PATCH] serial: imx: Fix clock imbalance Marek Vasut
2023-12-05 20:22 ` Fabio Estevam
2023-12-06 14:06 ` Christoph Niedermaier
2023-12-06 14:29 ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).