Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/macppc/dev do what cuda does - if we read garbage f...



details:   https://anonhg.NetBSD.org/src/rev/38244a5de7f3
branches:  trunk
changeset: 791117:38244a5de7f3
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Nov 05 11:08:20 2013 +0000

description:
do what cuda does - if we read garbage from the RTC try a few more times

diffstat:

 sys/arch/macppc/dev/pmu.c |  23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r b97111d22e0a -r 38244a5de7f3 sys/arch/macppc/dev/pmu.c
--- a/sys/arch/macppc/dev/pmu.c Tue Nov 05 07:42:48 2013 +0000
+++ b/sys/arch/macppc/dev/pmu.c Tue Nov 05 11:08:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmu.c,v 1.21 2011/07/01 18:41:52 dyoung Exp $ */
+/*     $NetBSD: pmu.c,v 1.22 2013/11/05 11:08:20 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.21 2011/07/01 18:41:52 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.22 2013/11/05 11:08:20 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -702,13 +702,26 @@
 {
        struct pmu_softc *sc = tch->cookie;
        uint32_t sec;
+       int count = 10;
+       int ok = FALSE;
        uint8_t resp[16];
 
        DPRINTF("pmu_todr_get\n");
-       pmu_send(sc, PMU_READ_RTC, 0, NULL, 16, resp);
+       while ((count > 0) && (!ok)) {
+               pmu_send(sc, PMU_READ_RTC, 0, NULL, 16, resp);
 
-       memcpy(&sec, &resp[1], 4);
-       tvp->tv_sec = sec - DIFF19041970;
+               memcpy(&sec, &resp[1], 4);
+               tvp->tv_sec = sec - DIFF19041970;
+               ok = (sec > DIFF19041970) && (sec < 0xf0000000);
+               if (!ok) aprint_error_dev(sc->sc_dev,
+                   "got garbage from rtc (%08x)\n", sec);
+               count--;
+       }
+       if (count == 0) {
+               aprint_error_dev(sc->sc_dev,
+                   "unable to get a sane time value\n");
+               tvp->tv_sec = 0;
+       }
        DPRINTF("tod: %" PRIo64 "\n", tvp->tv_sec);
        tvp->tv_usec = 0;
        return 0;



Home | Main Index | Thread Index | Old Index