All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-05 17:02 ` Cristian Ciocaltea
  0 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-05 17:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Andreas Färber,
	Manivannan Sadhasivam
  Cc: linux-serial, linux-arm-kernel, linux-actions, linux-kernel

Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
'owl_uart_ops' that enables OWL UART to be used for kernel debugging
over serial line.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
Changes in v2:
 - Reverted unnecessary changes per Andreas feedback
 - Optimized implementation for 'owl_uart_poll_get_char()'
   and 'owl_uart_poll_put_char()' callbacks

 drivers/tty/serial/owl-uart.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index c149f8c30007..54b24669ebc5 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -12,6 +12,7 @@
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -461,6 +462,26 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
 	}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static int owl_uart_poll_get_char(struct uart_port *port)
+{
+	if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
+		return NO_POLL_CHAR;
+
+	return owl_uart_read(port, OWL_UART_RXDAT);
+}
+
+static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
+		cpu_relax();
+
+	owl_uart_write(port, ch, OWL_UART_TXDAT);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
 static const struct uart_ops owl_uart_ops = {
 	.set_mctrl = owl_uart_set_mctrl,
 	.get_mctrl = owl_uart_get_mctrl,
@@ -476,6 +497,10 @@ static const struct uart_ops owl_uart_ops = {
 	.request_port = owl_uart_request_port,
 	.release_port = owl_uart_release_port,
 	.verify_port = owl_uart_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+	.poll_get_char = owl_uart_poll_get_char,
+	.poll_put_char = owl_uart_poll_put_char,
+#endif
 };
 
 #ifdef CONFIG_SERIAL_OWL_CONSOLE
-- 
2.30.0


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

* [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-05 17:02 ` Cristian Ciocaltea
  0 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-05 17:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Andreas Färber,
	Manivannan Sadhasivam
  Cc: linux-actions, linux-arm-kernel, linux-serial, linux-kernel

Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
'owl_uart_ops' that enables OWL UART to be used for kernel debugging
over serial line.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
Changes in v2:
 - Reverted unnecessary changes per Andreas feedback
 - Optimized implementation for 'owl_uart_poll_get_char()'
   and 'owl_uart_poll_put_char()' callbacks

 drivers/tty/serial/owl-uart.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index c149f8c30007..54b24669ebc5 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -12,6 +12,7 @@
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -461,6 +462,26 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
 	}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+
+static int owl_uart_poll_get_char(struct uart_port *port)
+{
+	if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
+		return NO_POLL_CHAR;
+
+	return owl_uart_read(port, OWL_UART_RXDAT);
+}
+
+static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
+		cpu_relax();
+
+	owl_uart_write(port, ch, OWL_UART_TXDAT);
+}
+
+#endif /* CONFIG_CONSOLE_POLL */
+
 static const struct uart_ops owl_uart_ops = {
 	.set_mctrl = owl_uart_set_mctrl,
 	.get_mctrl = owl_uart_get_mctrl,
@@ -476,6 +497,10 @@ static const struct uart_ops owl_uart_ops = {
 	.request_port = owl_uart_request_port,
 	.release_port = owl_uart_release_port,
 	.verify_port = owl_uart_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+	.poll_get_char = owl_uart_poll_get_char,
+	.poll_put_char = owl_uart_poll_put_char,
+#endif
 };
 
 #ifdef CONFIG_SERIAL_OWL_CONSOLE
-- 
2.30.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] 10+ messages in thread

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
  2021-01-05 17:02 ` Cristian Ciocaltea
@ 2021-01-07 15:20   ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2021-01-07 15:20 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: Jiri Slaby, Andreas Färber, Manivannan Sadhasivam,
	linux-serial, linux-arm-kernel, linux-actions, linux-kernel

On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> over serial line.
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> ---
> Changes in v2:
>  - Reverted unnecessary changes per Andreas feedback
>  - Optimized implementation for 'owl_uart_poll_get_char()'
>    and 'owl_uart_poll_put_char()' callbacks
> 
>  drivers/tty/serial/owl-uart.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
> index c149f8c30007..54b24669ebc5 100644
> --- a/drivers/tty/serial/owl-uart.c
> +++ b/drivers/tty/serial/owl-uart.c
> @@ -12,6 +12,7 @@
>  #include <linux/console.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/iopoll.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> @@ -461,6 +462,26 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
>  	}
>  }
>  
> +#ifdef CONFIG_CONSOLE_POLL
> +
> +static int owl_uart_poll_get_char(struct uart_port *port)
> +{
> +	if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
> +		return NO_POLL_CHAR;
> +
> +	return owl_uart_read(port, OWL_UART_RXDAT);
> +}
> +
> +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> +{
> +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> +		cpu_relax();

Unbounded loops?  What could possibly go wrong?

:(

Please don't do that in the kernel, put a max bound on this.

And are you _SURE_ that cpu_relax() is what you want to call here?

thanks,

greg k-h

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-07 15:20   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2021-01-07 15:20 UTC (permalink / raw)
  To: Cristian Ciocaltea
  Cc: linux-actions, linux-kernel, linux-serial, Manivannan Sadhasivam,
	Jiri Slaby, Andreas Färber, linux-arm-kernel

On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> over serial line.
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> ---
> Changes in v2:
>  - Reverted unnecessary changes per Andreas feedback
>  - Optimized implementation for 'owl_uart_poll_get_char()'
>    and 'owl_uart_poll_put_char()' callbacks
> 
>  drivers/tty/serial/owl-uart.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
> index c149f8c30007..54b24669ebc5 100644
> --- a/drivers/tty/serial/owl-uart.c
> +++ b/drivers/tty/serial/owl-uart.c
> @@ -12,6 +12,7 @@
>  #include <linux/console.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/iopoll.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> @@ -461,6 +462,26 @@ static void owl_uart_config_port(struct uart_port *port, int flags)
>  	}
>  }
>  
> +#ifdef CONFIG_CONSOLE_POLL
> +
> +static int owl_uart_poll_get_char(struct uart_port *port)
> +{
> +	if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)
> +		return NO_POLL_CHAR;
> +
> +	return owl_uart_read(port, OWL_UART_RXDAT);
> +}
> +
> +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> +{
> +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> +		cpu_relax();

Unbounded loops?  What could possibly go wrong?

:(

Please don't do that in the kernel, put a max bound on this.

And are you _SURE_ that cpu_relax() is what you want to call here?

thanks,

greg k-h

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
  2021-01-07 15:20   ` Greg Kroah-Hartman
@ 2021-01-07 18:16     ` Cristian Ciocaltea
  -1 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-07 18:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Andreas Färber, Manivannan Sadhasivam,
	linux-serial, linux-arm-kernel, linux-actions, linux-kernel

Hi Greg,

Thank you for the review!

On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> > Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> > 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> > over serial line.
> > 
> > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>

[...]

> > +
> > +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> > +{
> > +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> > +		cpu_relax();
> 
> Unbounded loops?  What could possibly go wrong?
> 
> :(
> 
> Please don't do that in the kernel, put a max bound on this.

I didn't realize the issue since I had encountered this pattern in many
other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.

> And are you _SURE_ that cpu_relax() is what you want to call here?

I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
if that would be a better approach.

Kind regards,
Cristi

> thanks,
> 
> greg k-h

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-07 18:16     ` Cristian Ciocaltea
  0 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-07 18:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-actions, linux-kernel, linux-serial, Manivannan Sadhasivam,
	Jiri Slaby, Andreas Färber, linux-arm-kernel

Hi Greg,

Thank you for the review!

On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> > Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> > 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> > over serial line.
> > 
> > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>

[...]

> > +
> > +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> > +{
> > +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> > +		cpu_relax();
> 
> Unbounded loops?  What could possibly go wrong?
> 
> :(
> 
> Please don't do that in the kernel, put a max bound on this.

I didn't realize the issue since I had encountered this pattern in many
other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.

> And are you _SURE_ that cpu_relax() is what you want to call here?

I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
if that would be a better approach.

Kind regards,
Cristi

> thanks,
> 
> greg k-h

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
  2021-01-07 18:16     ` Cristian Ciocaltea
@ 2021-01-08  7:58       ` Jiri Slaby
  -1 siblings, 0 replies; 10+ messages in thread
From: Jiri Slaby @ 2021-01-08  7:58 UTC (permalink / raw)
  To: Cristian Ciocaltea, Greg Kroah-Hartman
  Cc: Andreas Färber, Manivannan Sadhasivam, linux-serial,
	linux-arm-kernel, linux-actions, linux-kernel

On 07. 01. 21, 19:16, Cristian Ciocaltea wrote:
> Hi Greg,
> 
> Thank you for the review!
> 
> On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
>> On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
>>> Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
>>> 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
>>> over serial line.
>>>
>>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> 
> [...]
> 
>>> +
>>> +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
>>> +{
>>> +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
>>> +		cpu_relax();
>>
>> Unbounded loops?  What could possibly go wrong?
>>
>> :(
>>
>> Please don't do that in the kernel, put a max bound on this.
> 
> I didn't realize the issue since I had encountered this pattern in many
> other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.
> 
>> And are you _SURE_ that cpu_relax() is what you want to call here?
> 
> I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
> if that would be a better approach.

It might be better, yes. Either way, if you add a bound to the loop, you 
definitely need a more precise timing, so ndelay/udelay instead of 
cpu_relax.

thanks,
-- 
js

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-08  7:58       ` Jiri Slaby
  0 siblings, 0 replies; 10+ messages in thread
From: Jiri Slaby @ 2021-01-08  7:58 UTC (permalink / raw)
  To: Cristian Ciocaltea, Greg Kroah-Hartman
  Cc: linux-actions, linux-kernel, linux-serial, Manivannan Sadhasivam,
	Andreas Färber, linux-arm-kernel

On 07. 01. 21, 19:16, Cristian Ciocaltea wrote:
> Hi Greg,
> 
> Thank you for the review!
> 
> On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
>> On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
>>> Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
>>> 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
>>> over serial line.
>>>
>>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> 
> [...]
> 
>>> +
>>> +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
>>> +{
>>> +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
>>> +		cpu_relax();
>>
>> Unbounded loops?  What could possibly go wrong?
>>
>> :(
>>
>> Please don't do that in the kernel, put a max bound on this.
> 
> I didn't realize the issue since I had encountered this pattern in many
> other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.
> 
>> And are you _SURE_ that cpu_relax() is what you want to call here?
> 
> I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
> if that would be a better approach.

It might be better, yes. Either way, if you add a bound to the loop, you 
definitely need a more precise timing, so ndelay/udelay instead of 
cpu_relax.

thanks,
-- 
js

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
  2021-01-08  7:58       ` Jiri Slaby
@ 2021-01-08 14:10         ` Cristian Ciocaltea
  -1 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-08 14:10 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, Andreas Färber, Manivannan Sadhasivam,
	linux-serial, linux-arm-kernel, linux-actions, linux-kernel

On Fri, Jan 08, 2021 at 08:58:38AM +0100, Jiri Slaby wrote:
> On 07. 01. 21, 19:16, Cristian Ciocaltea wrote:
> > Hi Greg,
> > 
> > Thank you for the review!
> > 
> > On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
> > > On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> > > > Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> > > > 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> > > > over serial line.
> > > > 
> > > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> > 
> > [...]
> > 
> > > > +
> > > > +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> > > > +{
> > > > +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> > > > +		cpu_relax();
> > > 
> > > Unbounded loops?  What could possibly go wrong?
> > > 
> > > :(
> > > 
> > > Please don't do that in the kernel, put a max bound on this.
> > 
> > I didn't realize the issue since I had encountered this pattern in many
> > other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.
> > 
> > > And are you _SURE_ that cpu_relax() is what you want to call here?
> > 
> > I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
> > if that would be a better approach.
> 
> It might be better, yes. Either way, if you add a bound to the loop, you
> definitely need a more precise timing, so ndelay/udelay instead of
> cpu_relax.

I will use 1-5 us for the timing, but I'm not quite sure about the
overall timeout - 10 ms would suffice?

Thanks,
Cristi

> thanks,
> -- 
> js

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

* Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
@ 2021-01-08 14:10         ` Cristian Ciocaltea
  0 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2021-01-08 14:10 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-actions, linux-kernel, linux-serial,
	Manivannan Sadhasivam, Andreas Färber, linux-arm-kernel

On Fri, Jan 08, 2021 at 08:58:38AM +0100, Jiri Slaby wrote:
> On 07. 01. 21, 19:16, Cristian Ciocaltea wrote:
> > Hi Greg,
> > 
> > Thank you for the review!
> > 
> > On Thu, Jan 07, 2021 at 04:20:55PM +0100, Greg Kroah-Hartman wrote:
> > > On Tue, Jan 05, 2021 at 07:02:02PM +0200, Cristian Ciocaltea wrote:
> > > > Implement 'poll_put_char' and 'poll_get_char' callbacks in struct
> > > > 'owl_uart_ops' that enables OWL UART to be used for kernel debugging
> > > > over serial line.
> > > > 
> > > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
> > 
> > [...]
> > 
> > > > +
> > > > +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch)
> > > > +{
> > > > +	while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)
> > > > +		cpu_relax();
> > > 
> > > Unbounded loops?  What could possibly go wrong?
> > > 
> > > :(
> > > 
> > > Please don't do that in the kernel, put a max bound on this.
> > 
> > I didn't realize the issue since I had encountered this pattern in many
> > other serial drivers, as well: altera_uart, arc_uart, atmel_serial, etc.
> > 
> > > And are you _SURE_ that cpu_relax() is what you want to call here?
> > 
> > I'm thinking of replacing the loop with 'readl_poll_timeout_atomic()',
> > if that would be a better approach.
> 
> It might be better, yes. Either way, if you add a bound to the loop, you
> definitely need a more precise timing, so ndelay/udelay instead of
> cpu_relax.

I will use 1-5 us for the timing, but I'm not quite sure about the
overall timeout - 10 ms would suffice?

Thanks,
Cristi

> thanks,
> -- 
> js

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

end of thread, other threads:[~2021-01-08 14:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 17:02 [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger Cristian Ciocaltea
2021-01-05 17:02 ` Cristian Ciocaltea
2021-01-07 15:20 ` Greg Kroah-Hartman
2021-01-07 15:20   ` Greg Kroah-Hartman
2021-01-07 18:16   ` Cristian Ciocaltea
2021-01-07 18:16     ` Cristian Ciocaltea
2021-01-08  7:58     ` Jiri Slaby
2021-01-08  7:58       ` Jiri Slaby
2021-01-08 14:10       ` Cristian Ciocaltea
2021-01-08 14:10         ` Cristian Ciocaltea

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.