Skip to contentSkip to conversation

common/xyzModem.c: Fix delay timeout calculation

PATCH Superseded Andrew F. Davis 2 participants 3 messages Sep 20, 2016 – Sep 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 common/xyzModem.c: Fix delay timeout calculation

When waiting for input in CYGACC_COMM_IF_GETC_TIMEOUT we delay 2 seconds by incrementing and checking a counter variable every 20 uSeconds. The overhead in the loop calling tstc() thousands of times causes the timeout to be closer to 20 seconds. Delay longer per iteration to reduce overhead and bring the timeout back closer to the correct time.

---
 common/xyzModem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/xyzModem.c +2 -2
index 5656aac..390abdc 100644
@@ -73,9 +73,9 @@ CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
 {
 #define DELAY 20
   unsigned long counter = 0;
-  while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY))
+  while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT / DELAY))
     {
-      udelay (DELAY);
+      mdelay (DELAY);
       counter++;
     }
   if (tstc ())
Signature · 1 line
2.9.3
#1 lore raw

PATCH v2 1/1 common/xyzModem.c: Fix delay timeout calculation

Quoted 7 lines · Andrew F. Davis

When waiting for input in CYGACC_COMM_IF_GETC_TIMEOUT we delay 2 seconds by incrementing and checking a counter variable every 20 uSeconds. The overhead in the loop calling tstc() thousands of times causes the timeout to be closer to 20 seconds. Delay longer per iteration to reduce overhead and bring the timeout back closer to the correct time.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160923/788fc323/attachment.sig>
#2 lore raw

PATCH v2 1/1 common/xyzModem.c: Fix delay timeout calculation

Quoted 8 lines · Tom Rini
Quoted 6 lines · Andrew F. Davis

When waiting for input in CYGACC_COMM_IF_GETC_TIMEOUT we delay 2 seconds by incrementing and checking a counter variable every 20 uSeconds. The overhead in the loop calling tstc() thousands of times causes the timeout to be closer to 20 seconds. Delay longer per iteration to reduce overhead and bring the timeout back closer to the correct time.

Quoted 4 lines
Quoted 1 line

I was just informed that this may be breaking UART boot on a couple of our platforms, so this shouldn't be taken until I can get this figured out.

Thanks,
Andrew