linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "serial: imx: remove unbalanced clk_prepare"
@ 2015-08-18 15:43 Fabio Estevam
  2015-08-18 23:33 ` Eduardo Valentin
  2015-09-26 20:14 ` Fabio Estevam
  0 siblings, 2 replies; 5+ messages in thread
From: Fabio Estevam @ 2015-08-18 15:43 UTC (permalink / raw)
  To: gregkh; +Cc: edubezval, Fabio Estevam, linux-arm-kernel, linux-serial, kernel

This reverts commit 9e7b399d6528eac33a6fbfceb2b92af209c3454d.

Commit ("9e7b399d6528ea") causes the following warning and sometimes
also hangs the system:

------------[ cut here ]------------
 WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
 DEBUG_LOCKS_WARN_ON(in_interrupt())
 Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
Backtrace: 
[<80012f08>] (dump_backtrace) from [<800130a4>] (show_stack+0x18/0x1c)
r6:00000364 r5:00000000 r4:00000000 r3:00000000
[<8001308c>] (show_stack) from [<807902b8>] (dump_stack+0x88/0xa4)
[<80790230>] (dump_stack) from [<8002a604>] (warn_slowpath_common+0x80/0xbc)
r5:807945c4 r4:80ab3b50
[<8002a584>] (warn_slowpath_common) from [<8002a6e4>] (warn_slowpath_fmt+0x38/0x40)
r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
[<8002a6b0>] (warn_slowpath_fmt) from [<807945c4>] (mutex_trylock+0x20c/0x22c)
r3:8095d0d8 r2:8095ab28
[<807943b8>] (mutex_trylock) from [<8054c3cc>] (clk_prepare_lock+0x14/0xf4)
r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
[<8054c3b8>] (clk_prepare_lock) from [<8054dbfc>] (clk_prepare+0x18/0x30)
r5:00000037 r4:be3f0c80
[<8054dbe4>] (clk_prepare) from [<8036a600>] (imx_console_write+0x30/0x244)
r4:812d0bc8 r3:8132b9a4

To reproduce the problem we only need to let the board idle for something
like 30 seconds.

Tested on a imx6q-sabresd.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/tty/serial/imx.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe3d41c..d0388a0 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1631,12 +1631,12 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
 	int locked = 1;
 	int retval;
 
-	retval = clk_prepare_enable(sport->clk_per);
+	retval = clk_enable(sport->clk_per);
 	if (retval)
 		return;
-	retval = clk_prepare_enable(sport->clk_ipg);
+	retval = clk_enable(sport->clk_ipg);
 	if (retval) {
-		clk_disable_unprepare(sport->clk_per);
+		clk_disable(sport->clk_per);
 		return;
 	}
 
@@ -1675,8 +1675,8 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
 	if (locked)
 		spin_unlock_irqrestore(&sport->port.lock, flags);
 
-	clk_disable_unprepare(sport->clk_ipg);
-	clk_disable_unprepare(sport->clk_per);
+	clk_disable(sport->clk_ipg);
+	clk_disable(sport->clk_per);
 }
 
 /*
@@ -1777,7 +1777,15 @@ imx_console_setup(struct console *co, char *options)
 
 	retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
 
-	clk_disable_unprepare(sport->clk_ipg);
+	clk_disable(sport->clk_ipg);
+	if (retval) {
+		clk_unprepare(sport->clk_ipg);
+		goto error_console;
+	}
+
+	retval = clk_prepare(sport->clk_per);
+	if (retval)
+		clk_disable_unprepare(sport->clk_ipg);
 
 error_console:
 	return retval;
-- 
1.9.1

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

* Re: [PATCH] Revert "serial: imx: remove unbalanced clk_prepare"
  2015-08-18 15:43 [PATCH] Revert "serial: imx: remove unbalanced clk_prepare" Fabio Estevam
@ 2015-08-18 23:33 ` Eduardo Valentin
  2015-08-20 11:13   ` Fabio Estevam
  2015-09-26 20:14 ` Fabio Estevam
  1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Valentin @ 2015-08-18 23:33 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: kernel, gregkh, linux-arm-kernel, linux-serial


[-- Attachment #1.1: Type: text/plain, Size: 3577 bytes --]

On Tue, Aug 18, 2015 at 12:43:12PM -0300, Fabio Estevam wrote:
> This reverts commit 9e7b399d6528eac33a6fbfceb2b92af209c3454d.
> 
> Commit ("9e7b399d6528ea") causes the following warning and sometimes
> also hangs the system:
> 
> ------------[ cut here ]------------
>  WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
>  DEBUG_LOCKS_WARN_ON(in_interrupt())
>  Modules linked in:
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
> Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> Backtrace: 
> [<80012f08>] (dump_backtrace) from [<800130a4>] (show_stack+0x18/0x1c)
> r6:00000364 r5:00000000 r4:00000000 r3:00000000
> [<8001308c>] (show_stack) from [<807902b8>] (dump_stack+0x88/0xa4)
> [<80790230>] (dump_stack) from [<8002a604>] (warn_slowpath_common+0x80/0xbc)
> r5:807945c4 r4:80ab3b50
> [<8002a584>] (warn_slowpath_common) from [<8002a6e4>] (warn_slowpath_fmt+0x38/0x40)
> r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
> [<8002a6b0>] (warn_slowpath_fmt) from [<807945c4>] (mutex_trylock+0x20c/0x22c)
> r3:8095d0d8 r2:8095ab28
> [<807943b8>] (mutex_trylock) from [<8054c3cc>] (clk_prepare_lock+0x14/0xf4)
> r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
> [<8054c3b8>] (clk_prepare_lock) from [<8054dbfc>] (clk_prepare+0x18/0x30)
> r5:00000037 r4:be3f0c80
> [<8054dbe4>] (clk_prepare) from [<8036a600>] (imx_console_write+0x30/0x244)
> r4:812d0bc8 r3:8132b9a4
> 
> To reproduce the problem we only need to let the board idle for something
> like 30 seconds.

hmmm.. I really did not see this one. Looking at the code looks like we
could be atomic in some of the uart console callbacks.

For this one:

Reviewed-by: Eduardo Valentin <edubezval@gmail.com>

Did you try the runtime pm patch on your end?

BR,

> 
> Tested on a imx6q-sabresd.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/tty/serial/imx.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index fe3d41c..d0388a0 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1631,12 +1631,12 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
>  	int locked = 1;
>  	int retval;
>  
> -	retval = clk_prepare_enable(sport->clk_per);
> +	retval = clk_enable(sport->clk_per);
>  	if (retval)
>  		return;
> -	retval = clk_prepare_enable(sport->clk_ipg);
> +	retval = clk_enable(sport->clk_ipg);
>  	if (retval) {
> -		clk_disable_unprepare(sport->clk_per);
> +		clk_disable(sport->clk_per);
>  		return;
>  	}
>  
> @@ -1675,8 +1675,8 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
>  	if (locked)
>  		spin_unlock_irqrestore(&sport->port.lock, flags);
>  
> -	clk_disable_unprepare(sport->clk_ipg);
> -	clk_disable_unprepare(sport->clk_per);
> +	clk_disable(sport->clk_ipg);
> +	clk_disable(sport->clk_per);
>  }
>  
>  /*
> @@ -1777,7 +1777,15 @@ imx_console_setup(struct console *co, char *options)
>  
>  	retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
>  
> -	clk_disable_unprepare(sport->clk_ipg);
> +	clk_disable(sport->clk_ipg);
> +	if (retval) {
> +		clk_unprepare(sport->clk_ipg);
> +		goto error_console;
> +	}
> +
> +	retval = clk_prepare(sport->clk_per);
> +	if (retval)
> +		clk_disable_unprepare(sport->clk_ipg);
>  
>  error_console:
>  	return retval;
> -- 
> 1.9.1
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
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] 5+ messages in thread

* Re: [PATCH] Revert "serial: imx: remove unbalanced clk_prepare"
  2015-08-18 23:33 ` Eduardo Valentin
@ 2015-08-20 11:13   ` Fabio Estevam
  0 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2015-08-20 11:13 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Fabio Estevam, Greg Kroah-Hartman,
	linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org, Sascha Hauer

On Tue, Aug 18, 2015 at 8:33 PM, Eduardo Valentin <edubezval@gmail.com> wrote:

> hmmm.. I really did not see this one. Looking at the code looks like we
> could be atomic in some of the uart console callbacks.
>
> For this one:
>
> Reviewed-by: Eduardo Valentin <edubezval@gmail.com>
>
> Did you try the runtime pm patch on your end?

I have only tested linux-next.

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

* Re: [PATCH] Revert "serial: imx: remove unbalanced clk_prepare"
  2015-08-18 15:43 [PATCH] Revert "serial: imx: remove unbalanced clk_prepare" Fabio Estevam
  2015-08-18 23:33 ` Eduardo Valentin
@ 2015-09-26 20:14 ` Fabio Estevam
  2015-09-28  8:15   ` Lucas Stach
  1 sibling, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2015-09-26 20:14 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Eduardo Valentin, Greg Kroah-Hartman,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Sascha Hauer

Hi Greg,

On Tue, Aug 18, 2015 at 12:43 PM, Fabio Estevam
<fabio.estevam@freescale.com> wrote:
> This reverts commit 9e7b399d6528eac33a6fbfceb2b92af209c3454d.
>
> Commit ("9e7b399d6528ea") causes the following warning and sometimes
> also hangs the system:
>
> ------------[ cut here ]------------
>  WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
>  DEBUG_LOCKS_WARN_ON(in_interrupt())
>  Modules linked in:
> CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
> Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> Backtrace:
> [<80012f08>] (dump_backtrace) from [<800130a4>] (show_stack+0x18/0x1c)
> r6:00000364 r5:00000000 r4:00000000 r3:00000000
> [<8001308c>] (show_stack) from [<807902b8>] (dump_stack+0x88/0xa4)
> [<80790230>] (dump_stack) from [<8002a604>] (warn_slowpath_common+0x80/0xbc)
> r5:807945c4 r4:80ab3b50
> [<8002a584>] (warn_slowpath_common) from [<8002a6e4>] (warn_slowpath_fmt+0x38/0x40)
> r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
> [<8002a6b0>] (warn_slowpath_fmt) from [<807945c4>] (mutex_trylock+0x20c/0x22c)
> r3:8095d0d8 r2:8095ab28
> [<807943b8>] (mutex_trylock) from [<8054c3cc>] (clk_prepare_lock+0x14/0xf4)
> r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
> [<8054c3b8>] (clk_prepare_lock) from [<8054dbfc>] (clk_prepare+0x18/0x30)
> r5:00000037 r4:be3f0c80
> [<8054dbe4>] (clk_prepare) from [<8036a600>] (imx_console_write+0x30/0x244)
> r4:812d0bc8 r3:8132b9a4
>
> To reproduce the problem we only need to let the board idle for something
> like 30 seconds.
>
> Tested on a imx6q-sabresd.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Could you please consider applying this one for 4.3-rc?

Thanks

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

* Re: [PATCH] Revert "serial: imx: remove unbalanced clk_prepare"
  2015-09-26 20:14 ` Fabio Estevam
@ 2015-09-28  8:15   ` Lucas Stach
  0 siblings, 0 replies; 5+ messages in thread
From: Lucas Stach @ 2015-09-28  8:15 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Fabio Estevam, Sascha Hauer, Greg Kroah-Hartman, Eduardo Valentin,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

Am Samstag, den 26.09.2015, 17:14 -0300 schrieb Fabio Estevam:
> Hi Greg,
> 
> On Tue, Aug 18, 2015 at 12:43 PM, Fabio Estevam
> <fabio.estevam@freescale.com> wrote:
> > This reverts commit 9e7b399d6528eac33a6fbfceb2b92af209c3454d.
> >
> > Commit ("9e7b399d6528ea") causes the following warning and sometimes
> > also hangs the system:
> >
> > ------------[ cut here ]------------
> >  WARNING: CPU: 0 PID: 0 at kernel/locking/mutex.c:868 mutex_trylock+0x20c/0x22c()
> >  DEBUG_LOCKS_WARN_ON(in_interrupt())
> >  Modules linked in:
> > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.2.0-rc7-next-20150818-00001-g14418a6 #4
> > Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> > Backtrace:
> > [<80012f08>] (dump_backtrace) from [<800130a4>] (show_stack+0x18/0x1c)
> > r6:00000364 r5:00000000 r4:00000000 r3:00000000
> > [<8001308c>] (show_stack) from [<807902b8>] (dump_stack+0x88/0xa4)
> > [<80790230>] (dump_stack) from [<8002a604>] (warn_slowpath_common+0x80/0xbc)
> > r5:807945c4 r4:80ab3b50
> > [<8002a584>] (warn_slowpath_common) from [<8002a6e4>] (warn_slowpath_fmt+0x38/0x40)
> > r8:00000000 r7:8131100c r6:8054c3cc r5:8131300c r4:80b0a570
> > [<8002a6b0>] (warn_slowpath_fmt) from [<807945c4>] (mutex_trylock+0x20c/0x22c)
> > r3:8095d0d8 r2:8095ab28
> > [<807943b8>] (mutex_trylock) from [<8054c3cc>] (clk_prepare_lock+0x14/0xf4)
> > r7:8131100c r6:be3f0c80 r5:00000037 r4:be3f0c80
> > [<8054c3b8>] (clk_prepare_lock) from [<8054dbfc>] (clk_prepare+0x18/0x30)
> > r5:00000037 r4:be3f0c80
> > [<8054dbe4>] (clk_prepare) from [<8036a600>] (imx_console_write+0x30/0x244)
> > r4:812d0bc8 r3:8132b9a4
> >
> > To reproduce the problem we only need to let the board idle for something
> > like 30 seconds.
> >
> > Tested on a imx6q-sabresd.
> >
> > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Could you please consider applying this one for 4.3-rc?
> 
To put a bit more wight behind this: without this revert i.MX6 with an
active serial console boards are not even able to boot into userspace.

Please apply this as a critical fix.

Regards,
Lucas
-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2015-09-28  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18 15:43 [PATCH] Revert "serial: imx: remove unbalanced clk_prepare" Fabio Estevam
2015-08-18 23:33 ` Eduardo Valentin
2015-08-20 11:13   ` Fabio Estevam
2015-09-26 20:14 ` Fabio Estevam
2015-09-28  8:15   ` Lucas Stach

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).