public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andreas Reichel <Andreas.Reichel@tngtech.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] watchdog: Fix Watchdog Reset while in U-Boot Prompt
Date: Mon, 19 Sep 2016 13:59:44 +0200	[thread overview]
Message-ID: <20160919115944.GA20369@tng> (raw)
In-Reply-To: <CAPnjgZ3RppUB1y9D2J0CKY2TMsNCTn2Jfyb3R7tu07X7OAKhbg@mail.gmail.com>

Hi Tom,

is my patch going to be applied or is the problem resolved
otherwhise?

Kind regards
    Andreas

On Mo, Sep 05, 2016 at 07:04:53 -0600, Simon Glass wrote:
> +Tom, in case this should go into the release.
> 
> On 1 August 2016 at 05:49, Andreas J. Reichel
> <Andreas.Reichel@tngtech.com> wrote:
> > This patch fixes unwanted watchdog resets while the user enters
> > a command at the U-Boot prompt.
> >
> > As found on the CM-FX6 board from Compulab, when having enabled the
> > watchdog, a missing WATCHDOG_RESET call in _serial_tstc() in
> > (/drivers/serial/serial-uclass.c) causes this and alike boards to
> > reset when the watchdog's timeout has elapsed while waiting at the
> > U-Boot prompt.
> >
> > Despite the user could press several keys within the watchdog
> > timeout limit, the while loop in cli_readline.c, line 261, does only
> > call WATCHDOG_RESET if first == 1, which gets set to 0 in the 1st
> > loop iteration. This leads to a watchdog timeout no matter if the
> > user presses keys or not.
> >
> > The problem is solved with a call to WATCHDOG_RESET in _serial_tstc,
> > defined in drivers/serial/serial-uclass.c.
> >
> > Since the macro WATCHDOG_RESET expands to {} if watchdog support
> > isn't configured, there's no need to surround it by #ifdef in this
> > case.
> >
> >  * Symptom:
> >    U-Boot resets after watchdog times out when in commandline prompt
> >    and watchdog is enabled.
> >
> >  * Reasoning:
> >    When U-Boot shows the commandline prompt, the following function
> >    call stack is executed while waiting for a keypress:
> >
> >    common/main.c:
> >                     main_loop          => common/cli.c: cli_loop() =>
> >    common/cli_hush.c:
> >                     parse_file_outer   => parse_stream_outer       =>
> >                     parse_stream       => b_getch(i)               =>
> >                     i->get(i)          => file_get                 =>
> >                     get_user_input     => cmdedit_read_input       =>
> >                     uboot_cli_readline =>
> >    common/cli_readline.c:
> >                     cli_readline       => cli_readline_into_buffer =>
> >                     cread_line         => getcmd_getch (== getc)   =>
> >    commonn/console.c:
> >                     fgetc              => console_tstc
> >
> >    - in console_tstc line 181:
> >    If dev->tstc(dev) returns 0, the global tstcdev variable doesn't
> >    get set. This is the case if no character is in the serial buffer.
> >
> >    - in fgetc(int file), line 297:
> >    Program flow keeps looping because tstcdev does not get set.
> >    Therefore WATCHDOG_RESET is not called, as mx_serial_tstc from
> >    drivers/serial/serial_mxc.c does not call it.
> >
> >    - Initialization calls drv_system_init in stdio.c, which sets
> >    dev.tstc = stdio_serial_tstc. Thus, dev->tstc(dev) calls serial_tstc()
> >    which in turn calls _serial_tstc().
> >
> >    Hence, _serial_tstc() needs to call WATCHDOG_RESET() to periodically
> >    reset the watchdog while cli_readline waits for user input.
> >
> > Signed-off-by: Christian Storm <christian.storm@tngtech.com>
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > Signed-off-by: Andreas J. Reichel <Andreas.Reichel@tngtech.com>
> > ---
> >
> > Changes in v2:
> >  - Move WATCHDOG_RESET() call from common/console.c to
> >    drivers/serial/serial-uclass.c.
> >
> >  drivers/serial/serial-uclass.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> > index 0ce5c44..72cf808 100644
> > --- a/drivers/serial/serial-uclass.c
> > +++ b/drivers/serial/serial-uclass.c
> > @@ -155,6 +155,7 @@ static int _serial_tstc(struct udevice *dev)
> >  {
> >         struct dm_serial_ops *ops = serial_get_ops(dev);
> >
> > +       WATCHDOG_RESET();
> >         if (ops->pending)
> >                 return ops->pending(dev, true);
> 
> Great explanation, thank you.
> 
> Acked-by: Simon Glass <sjg@chromium.org>
> 
> >
> > --
> > 2.8.2
> >

-- 
Andreas Reichel 
Dipl.-Phys. (Univ.) 
Software Consultant

Andreas.Reichel at tngtech.com 
+49-174-3180074

TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterf?hring
Gesch?ftsf?hrer: Henrik Klagges, Christoph Stock, Dr. Robert Dahlke
Sitz: Unterf?hring * Amtsgericht M?nchen * HRB 135082

  reply	other threads:[~2016-09-19 11:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 10:56 [U-Boot] [PATCH PATCH v1] watchdog: Fix Watchdog Reset while in U-Boot Prompt Andreas J. Reichel
2016-08-01  1:01 ` Simon Glass
2016-08-01 11:49   ` [U-Boot] [PATCH v2] " Andreas J. Reichel
2016-09-06  1:04     ` Simon Glass
2016-09-19 11:59       ` Andreas Reichel [this message]
2016-10-15  1:45         ` Tom Rini
2016-08-01 13:32   ` [U-Boot] [PATCH v2 0/1] Fix U-Boot Prompt on CM-FX6 with enabled watchdog Andreas J. Reichel
2016-10-18 22:47 ` [U-Boot] [U-Boot, v1] watchdog: Fix Watchdog Reset while in U-Boot Prompt Tom Rini

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=20160919115944.GA20369@tng \
    --to=andreas.reichel@tngtech.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox