Skip to content

Commit

Permalink
FSP/RTC: Fix possible FSP R/R issue in rtc write path
Browse files Browse the repository at this point in the history
fsp_opal_rtc_write() checks FSP status before queueing message to FSP. But if
FSP R/R starts before getting response to queued message then we will continue
to return OPAL_BUSY_EVENT to host. In some extreme condition host may
experience hang. Once FSP is back we will repost message, get response from FSP
and return OPAL_SUCCES to host.

This patch caches new values and returns OPAL_SUCCESS if FSP R/R is happening.
And once FSP is back we will send cached value to FSP.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
Vasant Hegde authored and stewartsmith committed Jun 14, 2017
1 parent 447ccc4 commit f4757fb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions hw/fsp/fsp-rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ static int64_t fsp_rtc_send_write_request(uint32_t year_month_day,
{
struct fsp_msg *msg;
uint32_t w0, w1, w2;
struct tm tm;

assert(lock_held_by_me(&rtc_lock));
assert(rtc_write_request_state == RTC_WRITE_NO_REQUEST);
Expand All @@ -362,14 +361,7 @@ static int64_t fsp_rtc_send_write_request(uint32_t year_month_day,
}
prlog(PR_TRACE, " -> req at %p\n", msg);

if (fsp_in_rr()) {
datetime_to_tm(msg->data.words[0],
(u64) msg->data.words[1] << 32, &tm);
rtc_cache_update(&tm);
rtc_tod_cache_dirty = true;
fsp_freemsg(msg);
return OPAL_SUCCESS;
} else if (fsp_queue_msg(msg, fsp_rtc_req_complete)) {
if (fsp_queue_msg(msg, fsp_rtc_req_complete)) {
prlog(PR_TRACE, " -> queueing failed !\n");
fsp_freemsg(msg);
return OPAL_INTERNAL_ERROR;
Expand All @@ -384,13 +376,23 @@ static int64_t fsp_opal_rtc_write(uint32_t year_month_day,
uint64_t hour_minute_second_millisecond)
{
int rc;
struct tm tm;

lock(&rtc_lock);
if (rtc_tod_state == RTC_TOD_PERMANENT_ERROR) {
rc = OPAL_HARDWARE;
goto out;
}

if (fsp_in_rr()) {
datetime_to_tm(year_month_day,
hour_minute_second_millisecond, &tm);
rtc_cache_update(&tm);
rtc_tod_cache_dirty = true;
rc = OPAL_SUCCESS;
goto out;
}

if (rtc_write_request_state == RTC_WRITE_NO_REQUEST) {
prlog(PR_TRACE, "Sending new RTC write request\n");
rc = fsp_rtc_send_write_request(year_month_day,
Expand Down

0 comments on commit f4757fb

Please sign in to comment.