All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Andreas Färber" <afaerber@suse.de>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
Date: Fri, 8 Jan 2021 16:10:40 +0200	[thread overview]
Message-ID: <20210108141040.GA1081858@ubuntu2004> (raw)
In-Reply-To: <02c664f5-8107-7757-2e20-c446a0458539@kernel.org>

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

WARNING: multiple messages have this Message-ID (diff)
From: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Andreas Färber" <afaerber@suse.de>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger
Date: Fri, 8 Jan 2021 16:10:40 +0200	[thread overview]
Message-ID: <20210108141040.GA1081858@ubuntu2004> (raw)
In-Reply-To: <02c664f5-8107-7757-2e20-c446a0458539@kernel.org>

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

  reply	other threads:[~2021-01-08 14:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-01-08 14:10         ` Cristian Ciocaltea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210108141040.GA1081858@ubuntu2004 \
    --to=cristian.ciocaltea@gmail.com \
    --cc=afaerber@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-actions@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.