[Skiboot] [PATCH] FSP/RTC: Check for TOD state in fsp_opal_rtc_read
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Sun Mar 8 20:48:06 AEDT 2015
Check for TOD state before returning cached time in
fsp_opal_rtc_read. Also improve error handling.
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
hw/fsp/fsp-rtc.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/hw/fsp/fsp-rtc.c b/hw/fsp/fsp-rtc.c
index 955521b..cde1b37 100644
--- a/hw/fsp/fsp-rtc.c
+++ b/hw/fsp/fsp-rtc.c
@@ -278,19 +278,24 @@ static int64_t fsp_opal_rtc_read(uint32_t *year_month_day,
return OPAL_PARAMETER;
lock(&rtc_lock);
- /* During R/R of FSP, read cached TOD */
- if (fsp_in_reset) {
- rtc_cache_get_datetime(year_month_day,
- hour_minute_second_millisecond);
- rc = OPAL_SUCCESS;
- goto out;
- }
if (rtc_tod_state == RTC_TOD_PERMANENT_ERROR) {
rc = OPAL_HARDWARE;
goto out;
}
+ /* During R/R of FSP, read cached TOD */
+ if (fsp_in_reset) {
+ if (rtc_tod_state == RTC_TOD_VALID) {
+ rtc_cache_get_datetime(year_month_day,
+ hour_minute_second_millisecond);
+ rc = OPAL_SUCCESS;
+ } else {
+ rc = OPAL_INTERNAL_ERROR;
+ }
+ goto out;
+ }
+
/* If we don't have a read pending already, fire off a request and
* return */
if (rtc_read_request_state == RTC_READ_NO_REQUEST) {
@@ -320,10 +325,13 @@ static int64_t fsp_opal_rtc_read(uint32_t *year_month_day,
} else if (mftb() > read_req_tb + msecs_to_tb(rtc_read_timeout_ms)) {
prlog(PR_TRACE, "RTC read timed out\n");
- rtc_cache_get_datetime(year_month_day,
- hour_minute_second_millisecond);
- rc = OPAL_SUCCESS;
-
+ if (rtc_tod_state == RTC_TOD_VALID) {
+ rtc_cache_get_datetime(year_month_day,
+ hour_minute_second_millisecond);
+ rc = OPAL_SUCCESS;
+ } else {
+ rc = OPAL_INTERNAL_ERROR;
+ }
/* Otherwise, we're still waiting on the read to complete */
} else {
assert(rtc_read_request_state == RTC_READ_PENDING_REQUEST);
More information about the Skiboot
mailing list