From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Sverdlin Date: Wed, 1 Aug 2018 02:15:07 +0200 Subject: [U-Boot] xyz-modem: Change getc timeout loop waiting In-Reply-To: <1479716331-94776-1-git-send-email-tomas.melin@vaisala.com> References: <1479716331-94776-1-git-send-email-tomas.melin@vaisala.com> Message-ID: <20180801021507.d9061b74b8068bb32edfac5a@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello! On Mon, 21 Nov 2016 10:18:51 +0200 Tomas Melin wrote: > This fixes the loop delay when using a hw watchdog. > > In case a watchdog is used that accesses CPU registers, > the defined delay of 20us in a tight loop will cause a > huge delay in the actual timeout seen. This is caused > by the fact that udelay will inheritantly call WATCHDOG_RESET. > Together with the omap wdt implementation, the seen timeout increases up to > around 30s. This makes the loop very slow and causes long > delays when using the modem. > > Instead, implement the 2 sec loop by using the timer interface to know > when to break out of the timeout loop. Watchdog kicking is taken care of > by getc(). > > Signed-off-by: Tomas Melin This commit breaks YMODEM SPL->U-Boot boot on Beagle Bone, transfer is aborted (because of timeout) after 497kb (u-boot.img is around 570kb). Reverting the commit repairs YMODEM boot. > --- > common/xyzModem.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/common/xyzModem.c b/common/xyzModem.c > index 5656aac..e0d87db 100644 > --- a/common/xyzModem.c > +++ b/common/xyzModem.c > @@ -71,12 +71,12 @@ typedef int cyg_int32; > static int > CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c) > { > -#define DELAY 20 > - unsigned long counter = 0; > - while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) > + > + ulong now = get_timer(0); > + while (!tstc ()) > { > - udelay (DELAY); > - counter++; > + if (get_timer(now) > xyzModem_CHAR_TIMEOUT) > + break; > } > if (tstc ()) > { -- Alexander Sverdlin.