]> www.infradead.org Git - users/dwmw2/linux.git/commit
rtc: opal: Handle disabled TPO in opal_get_tpo_time()
authorVaibhav Jain <vaibhav@linux.vnet.ibm.com>
Fri, 19 May 2017 10:05:09 +0000 (15:35 +0530)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:27 +0000 (21:36 -0400)
commit7cb7ac4fb121af2a53f85cdf6d225d71e4106c26
tree3735ba4cd614e7eacb711d754982d08cd6f19bfb
parentc82ed2d4ded2d50e3ba5863fc7cbedc87283886e
rtc: opal: Handle disabled TPO in opal_get_tpo_time()

[ Upstream commit 6dc1cf6f932bb0ea4d8f5e913a0a401ecacd2f03 ]

On PowerNV platform when Timed-Power-On(TPO) is disabled, read of
stored TPO yields value with all date components set to '0' inside
opal_get_tpo_time(). The function opal_to_tm() then converts it to an
offset from year 1900 yielding alarm-time == "1900-00-01
00:00:00". This causes problems with __rtc_read_alarm() that
expecting an offset from "1970-00-01 00:00:00" and returned alarm-time
results in a -ve value for time64_t. Which ultimately results in this
error reported in kernel logs with a seemingly garbage value:

"rtc rtc0: invalid alarm value: -2-1--1041528741
2005511117:71582844:32"

We fix this by explicitly handling the case of all alarm date-time
components being '0' inside opal_get_tpo_time() and returning -ENOENT
in such a case. This signals generic rtc that no alarm is set and it
bails out from the alarm initialization flow without reporting the
above error.

Signed-off-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Reported-by: Steve Best <sbest@redhat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/rtc/rtc-opal.c