svn commit: r337503 - head/sys/powerpc/powernv
Breno Leitao
leitao at FreeBSD.org
Wed Aug 8 21:19:08 UTC 2018
Author: leitao
Date: Wed Aug 8 21:19:07 2018
New Revision: 337503
URL: https://svnweb.freebsd.org/changeset/base/337503
Log:
powerpc64/powernv: re-read RTC after polling
If OPAL_RTC_READ is busy and does not return the information on the first run,
as returning OPAL_BUSY_EVENT, the system will crash since ymd and hmsm variable
will contain junk values.
This is happening because we were not calling OPAL_RTC_READ again after
OPAL_POLL_EVENTS' return, which would finally replace the old/junk hmsm and ymd
values.
The code was also mixing OPAL_RTC_READ and OPAL_POLL_EVENTS return values.
This patch fix this logic and guarantee that we call OPAL_RTC_READ after
OPAL_POLL_EVENTS return, and guarantee the code will only proceed if
OPAL_RTC_READ returns OPAL_SUCCESS.
Reviewed by: jhibbits
Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D16617
Modified:
head/sys/powerpc/powernv/opal_dev.c
Modified: head/sys/powerpc/powernv/opal_dev.c
==============================================================================
--- head/sys/powerpc/powernv/opal_dev.c Wed Aug 8 20:30:12 2018 (r337502)
+++ head/sys/powerpc/powernv/opal_dev.c Wed Aug 8 21:19:07 2018 (r337503)
@@ -218,13 +218,12 @@ opal_gettime(device_t dev, struct timespec *ts)
uint32_t ymd;
uint64_t hmsm;
- do {
+ rv = opal_call(OPAL_RTC_READ, vtophys(&ymd), vtophys(&hmsm));
+ while (rv == OPAL_BUSY_EVENT) {
+ opal_call(OPAL_POLL_EVENTS, 0);
+ pause("opalrtc", 1);
rv = opal_call(OPAL_RTC_READ, vtophys(&ymd), vtophys(&hmsm));
- if (rv == OPAL_BUSY_EVENT) {
- rv = opal_call(OPAL_POLL_EVENTS, 0);
- pause("opalrtc", 1);
- }
- } while (rv == OPAL_BUSY_EVENT);
+ }
if (rv != OPAL_SUCCESS)
return (ENXIO);
More information about the svn-src-all
mailing list