All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4] Solve issue with serial rx buffer when MUX is deactivated
@ 2018-08-03 11:38 Patrick Delaunay
  2018-08-03 11:38 ` [U-Boot] [PATCH 1/4] stm32mp1: activate serial rx buffer Patrick Delaunay
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Patrick Delaunay @ 2018-08-03 11:38 UTC (permalink / raw)
  To: u-boot


When I activate CONFIG_SERIAL_RX_BUFFER on my board without CONSOLE_MUX,
I have a strange behavior in console: a new prompt is displayed
continuously

I check the call stack

cread_line (common/cli_readline.c)
=> getcmd_getch (common/cli_readline.c)
==> fgetc (common/console.c)
===> console_tstc (common/console.c)
====> stdio_devices[file]->get()
=====> _serial_getc() (drivers/serial/serial-uclass.c)
       and the data reads from rx buffer but it is garbage
       as tstc is not called

PS: I have no issue when CONSOLE_MUX is activated because in this
    case the tstc() is always called in fgetc loop.

My first solution to update the rx buffer management,
to avoid the issue:

static int _serial_getc(struct udevice *dev)
{
	struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
	char val;

	if (upriv->rd_ptr == upriv->wr_ptr)
		__serial_tstc(dev);

	if (upriv->rd_ptr == upriv->wr_ptr)
		return 0; /* error : no data to read */

	val = upriv->buf[upriv->rd_ptr++];
	upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;

	return val;
}

With this first patch, I see that that WATCHDOG is not reloaded
and the getc() error value 0x0 wasn't correctly handle in cli;
the issue is alway present and the behavior change (getc function
is no more blocking): the caller needs to handle the error and
reload the watchdog.

To summarize, I see several issues in the current U-Boot code:
- No protection on the rx buffer in _serial_getc():
  the current code assumed that tstc() is alway called but
  it is dangerous
- error for getc() (read value = 0x0) is not handled in cread_line()
- in console.c, tstc() is not called when CONSOLE_MUX is not activated

In this patchset I try to solve all these issues by separate patch
but perhaps only the first correction on the rx buffer is really mandatory.

On my board stm32mp1 ev1 the issue is solved.



Patrick Delaunay (4):
  stm32mp1: activate serial rx buffer
  serial: protect access to serial rx buffer
  console: unify fgetc function when console MUX is deactivated
  cli: handle getch error

 common/cli_readline.c             | 4 ++++
 common/console.c                  | 9 +++++----
 configs/stm32mp15_basic_defconfig | 1 +
 drivers/serial/serial-uclass.c    | 3 +++
 4 files changed, 13 insertions(+), 4 deletions(-)

-- 
2.7.4

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

end of thread, other threads:[~2018-09-11 12:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 11:38 [U-Boot] [PATCH 0/4] Solve issue with serial rx buffer when MUX is deactivated Patrick Delaunay
2018-08-03 11:38 ` [U-Boot] [PATCH 1/4] stm32mp1: activate serial rx buffer Patrick Delaunay
2018-09-11 12:24   ` [U-Boot] [U-Boot,1/4] " Tom Rini
2018-08-03 11:38 ` [U-Boot] [PATCH 2/4] serial: protect access to " Patrick Delaunay
2018-08-08  9:56   ` Simon Glass
2018-09-03 13:35     ` Patrick DELAUNAY
2018-09-03 14:03       ` Stefan
2018-09-04  7:56         ` Patrick DELAUNAY
2018-09-04 12:07           ` Stefan
2018-09-06  8:09             ` Patrick DELAUNAY
2018-09-11 12:24   ` [U-Boot] [U-Boot, " Tom Rini
2018-08-03 11:38 ` [U-Boot] [PATCH 3/4] console: unify fgetc function when console MUX is deactivated Patrick Delaunay
2018-08-08  9:55   ` Simon Glass
2018-09-03 14:56     ` Patrick DELAUNAY
2018-09-11 12:24   ` [U-Boot] [U-Boot, " Tom Rini
2018-08-03 11:38 ` [U-Boot] [PATCH 4/4] cli: handle getch error Patrick Delaunay
2018-09-11 12:24   ` [U-Boot] [U-Boot,4/4] " Tom Rini

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.