<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/rtc/rtc-opal.c, branch v4.16-rc6</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>rtc-opal: Fix handling of firmware error codes, prevent busy loops</title>
<updated>2018-01-27T10:15:59+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2016-08-02T01:50:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5b8b58063029f02da573120ef4dc9079822e3cda'/>
<id>5b8b58063029f02da573120ef4dc9079822e3cda</id>
<content type='text'>
According to the OPAL docs:
  skiboot-5.2.5/doc/opal-api/opal-rtc-read-3.txt
  skiboot-5.2.5/doc/opal-api/opal-rtc-write-4.txt

OPAL_HARDWARE may be returned from OPAL_RTC_READ or OPAL_RTC_WRITE and
this indicates either a transient or permanent error.

Prior to this patch, Linux was not dealing with OPAL_HARDWARE being a
permanent error particularly well, in that you could end up in a busy
loop.

This was not too hard to trigger on an AMI BMC based OpenPOWER machine
doing a continuous "ipmitool mc reset cold" to the BMC, the result of
that being that we'd get stuck in an infinite loop in
opal_get_rtc_time().

We now retry a few times before returning the error higher up the
stack.

Fixes: 16b1d26e77b1 ("rtc/tpo: Driver to support rtc and wakeup on PowerNV platform")
Cc: stable@vger.kernel.org # v3.19+
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
According to the OPAL docs:
  skiboot-5.2.5/doc/opal-api/opal-rtc-read-3.txt
  skiboot-5.2.5/doc/opal-api/opal-rtc-write-4.txt

OPAL_HARDWARE may be returned from OPAL_RTC_READ or OPAL_RTC_WRITE and
this indicates either a transient or permanent error.

Prior to this patch, Linux was not dealing with OPAL_HARDWARE being a
permanent error particularly well, in that you could end up in a busy
loop.

This was not too hard to trigger on an AMI BMC based OpenPOWER machine
doing a continuous "ipmitool mc reset cold" to the BMC, the result of
that being that we'd get stuck in an infinite loop in
opal_get_rtc_time().

We now retry a few times before returning the error higher up the
stack.

Fixes: 16b1d26e77b1 ("rtc/tpo: Driver to support rtc and wakeup on PowerNV platform")
Cc: stable@vger.kernel.org # v3.19+
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: opal: Implement rtc_class_ops.alarm_irq_enable callback</title>
<updated>2017-06-24T05:48:30+00:00</updated>
<author>
<name>Vaibhav Jain</name>
<email>vaibhav@linux.vnet.ibm.com</email>
</author>
<published>2017-05-31T13:09:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0ec7769a98b00866e37740328d65cba6594d178d'/>
<id>0ec7769a98b00866e37740328d65cba6594d178d</id>
<content type='text'>
Provide an implementation of the callback
rtc_class_ops.alarm_irq_enable for rtc-opal driver. This callback is
called when the wake alarm is disabled via the command:

'echo 0 &gt; /sys/class/rtc/rtc0/wakealarm'

Without this the Timed-Power-On(TPO) config remains set even when its
disabled by the above command and FSP will still force machine
boot at previously configured alarm time.

The callback is implemented as function opal_tpo_alarm_irq_enable()
which calls opal_set_tpo_time() with alarm.enabled == 0. A branch is
added to opal_set_tpo_time() to handle this case by passing y_m_d ==
h_m_s_ms == 0 to opal as arguments for opal_tpo_write() call.

Signed-off-by: Vaibhav Jain &lt;vaibhav@linux.vnet.ibm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Provide an implementation of the callback
rtc_class_ops.alarm_irq_enable for rtc-opal driver. This callback is
called when the wake alarm is disabled via the command:

'echo 0 &gt; /sys/class/rtc/rtc0/wakealarm'

Without this the Timed-Power-On(TPO) config remains set even when its
disabled by the above command and FSP will still force machine
boot at previously configured alarm time.

The callback is implemented as function opal_tpo_alarm_irq_enable()
which calls opal_set_tpo_time() with alarm.enabled == 0. A branch is
added to opal_set_tpo_time() to handle this case by passing y_m_d ==
h_m_s_ms == 0 to opal as arguments for opal_tpo_write() call.

Signed-off-by: Vaibhav Jain &lt;vaibhav@linux.vnet.ibm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: opal: Handle disabled TPO in opal_get_tpo_time()</title>
<updated>2017-05-31T10:57:37+00:00</updated>
<author>
<name>Vaibhav Jain</name>
<email>vaibhav@linux.vnet.ibm.com</email>
</author>
<published>2017-05-19T10:05:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6dc1cf6f932bb0ea4d8f5e913a0a401ecacd2f03'/>
<id>6dc1cf6f932bb0ea4d8f5e913a0a401ecacd2f03</id>
<content type='text'>
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 &lt;vaibhav@linux.vnet.ibm.com&gt;
Reported-by: Steve Best &lt;sbest@redhat.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;vaibhav@linux.vnet.ibm.com&gt;
Reported-by: Steve Best &lt;sbest@redhat.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>powerpc/opal: Add inline function to get rc from an ASYNC_COMP opal_msg</title>
<updated>2016-06-29T07:33:18+00:00</updated>
<author>
<name>Suraj Jitindar Singh</name>
<email>sjitindarsingh@gmail.com</email>
</author>
<published>2016-06-29T03:38:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d0226d315dba5e401a124b394a1af5e35e082b08'/>
<id>d0226d315dba5e401a124b394a1af5e35e082b08</id>
<content type='text'>
An opal_msg of type OPAL_MSG_ASYNC_COMP contains the return code in the
params[1] struct member. However this isn't intuitive or obvious when
reading the code and requires that a user look at the skiboot
documentation or opal-api.h to verify this.

Add an inline function to get the return code from an opal_msg and update
call sites accordingly.

Signed-off-by: Suraj Jitindar Singh &lt;sjitindarsingh@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
An opal_msg of type OPAL_MSG_ASYNC_COMP contains the return code in the
params[1] struct member. However this isn't intuitive or obvious when
reading the code and requires that a user look at the skiboot
documentation or opal-api.h to verify this.

Add an inline function to get the return code from an opal_msg and update
call sites accordingly.

Signed-off-by: Suraj Jitindar Singh &lt;sjitindarsingh@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>powerpc: Remove broken GregorianDay()</title>
<updated>2015-12-16T01:54:04+00:00</updated>
<author>
<name>Daniel Axtens</name>
<email>dja@axtens.net</email>
</author>
<published>2015-12-15T07:09:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=00b912b0c88e690b1662067497182454357b18b0'/>
<id>00b912b0c88e690b1662067497182454357b18b0</id>
<content type='text'>
GregorianDay() is supposed to calculate the day of the week
(tm-&gt;tm_wday) for a given day/month/year. In that calcuation it
indexed into an array called MonthOffset using tm-&gt;tm_mon-1. However
tm_mon is zero-based, not one-based, so this is off-by-one. It also
means that every January, GregoiranDay() will access element -1 of
the MonthOffset array.

It also doesn't appear to be a correct algorithm either: see in
contrast kernel/time/timeconv.c's time_to_tm function.

It's been broken forever, which suggests no-one in userland uses
this. It looks like no-one in the kernel uses tm-&gt;tm_wday either
(see e.g. drivers/rtc/rtc-ds1305.c:319).

tm-&gt;tm_wday is conventionally set to -1 when not available in
hardware so we can simply set it to -1 and drop the function.
(There are over a dozen other drivers in drivers/rtc that do
this.)

Found using UBSAN.

Cc: Andrey Ryabinin &lt;aryabinin@virtuozzo.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt; # as an example of what UBSan finds.
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: rtc-linux@googlegroups.com
Signed-off-by: Daniel Axtens &lt;dja@axtens.net&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
GregorianDay() is supposed to calculate the day of the week
(tm-&gt;tm_wday) for a given day/month/year. In that calcuation it
indexed into an array called MonthOffset using tm-&gt;tm_mon-1. However
tm_mon is zero-based, not one-based, so this is off-by-one. It also
means that every January, GregoiranDay() will access element -1 of
the MonthOffset array.

It also doesn't appear to be a correct algorithm either: see in
contrast kernel/time/timeconv.c's time_to_tm function.

It's been broken forever, which suggests no-one in userland uses
this. It looks like no-one in the kernel uses tm-&gt;tm_wday either
(see e.g. drivers/rtc/rtc-ds1305.c:319).

tm-&gt;tm_wday is conventionally set to -1 when not available in
hardware so we can simply set it to -1 and drop the function.
(There are over a dozen other drivers in drivers/rtc that do
this.)

Found using UBSAN.

Cc: Andrey Ryabinin &lt;aryabinin@virtuozzo.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt; # as an example of what UBSan finds.
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: rtc-linux@googlegroups.com
Signed-off-by: Daniel Axtens &lt;dja@axtens.net&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: opal: enable support for the stardard "wakeup-source" property</title>
<updated>2015-11-08T13:12:30+00:00</updated>
<author>
<name>Sudeep Holla</name>
<email>Sudeep.Holla@arm.com</email>
</author>
<published>2015-10-21T10:10:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=347e40f0302c7e817e64256284b9e69a8b2711d2'/>
<id>347e40f0302c7e817e64256284b9e69a8b2711d2</id>
<content type='text'>
Though the opal rtc driver should and will continue to support the legacy
"has-tpo" property to enable RTC as the wakeup source, we need to add
support for the new standard property "wakeup-source"

This patch adds support for "wakeup-source" property in addition to the
existing "has-tpo" property.

Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: rtc-linux@googlegroups.com
Signed-off-by: Sudeep Holla &lt;sudeep.holla@arm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Though the opal rtc driver should and will continue to support the legacy
"has-tpo" property to enable RTC as the wakeup source, we need to add
support for the new standard property "wakeup-source"

This patch adds support for "wakeup-source" property in addition to the
existing "has-tpo" property.

Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: rtc-linux@googlegroups.com
Signed-off-by: Sudeep Holla &lt;sudeep.holla@arm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: opal: fix type of token</title>
<updated>2015-11-08T13:12:24+00:00</updated>
<author>
<name>Andrzej Hajda</name>
<email>a.hajda@samsung.com</email>
</author>
<published>2015-09-21T13:33:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c35300941656508d37315625d276c5a104823505'/>
<id>c35300941656508d37315625d276c5a104823505</id>
<content type='text'>
The variable can take signed values.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda &lt;a.hajda@samsung.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The variable can take signed values.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda &lt;a.hajda@samsung.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: opal: Enable alarms only when opal supports tpo</title>
<updated>2015-09-05T11:19:06+00:00</updated>
<author>
<name>Vaibhav Jain</name>
<email>vaibhav@linux.vnet.ibm.com</email>
</author>
<published>2015-07-14T07:58:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f4a2eecb3ff9f51b179b213e7cc3766f920f2dc5'/>
<id>f4a2eecb3ff9f51b179b213e7cc3766f920f2dc5</id>
<content type='text'>
rtc-opal driver provides support for rtc alarms via
timed-power-on(tpo). However some Power platforms like BML use a fake
rtc clock and don't support tpo. Such platforms are indicated by the
missing 'has-tpo' property in the device tree.

Current implementation however enables callback for
rtc_class_ops.read/set alarm irrespective of the tpo support from the
platform. This results in a failed opal call when kernel tries to read
an existing alarms via opal_get_tpo_time during rtc device registration.

This patch fixes this issue by setting opal_rtc_ops.read/set_alarm
callback pointers only when tpo is supported.

Acked-by: Michael Neuling &lt;mikey@neuling.org&gt;
Acked-by: Neelesh Gupta &lt;neelegup@linux.vnet.ibm.com&gt;
Signed-off-by: Vaibhav Jain &lt;vaibhav@linux.vnet.ibm.com&gt;
Acked-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
rtc-opal driver provides support for rtc alarms via
timed-power-on(tpo). However some Power platforms like BML use a fake
rtc clock and don't support tpo. Such platforms are indicated by the
missing 'has-tpo' property in the device tree.

Current implementation however enables callback for
rtc_class_ops.read/set alarm irrespective of the tpo support from the
platform. This results in a failed opal call when kernel tries to read
an existing alarms via opal_get_tpo_time during rtc device registration.

This patch fixes this issue by setting opal_rtc_ops.read/set_alarm
callback pointers only when tpo is supported.

Acked-by: Michael Neuling &lt;mikey@neuling.org&gt;
Acked-by: Neelesh Gupta &lt;neelegup@linux.vnet.ibm.com&gt;
Signed-off-by: Vaibhav Jain &lt;vaibhav@linux.vnet.ibm.com&gt;
Acked-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: Drop owner assignment from platform_driver</title>
<updated>2015-09-05T11:19:06+00:00</updated>
<author>
<name>Krzysztof Kozlowski</name>
<email>k.kozlowski@samsung.com</email>
</author>
<published>2015-07-10T06:39:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=045c6fdd37a01d950c0f5ca64733b53b184fe91b'/>
<id>045c6fdd37a01d950c0f5ca64733b53b184fe91b</id>
<content type='text'>
platform_driver does not need to set an owner because
platform_driver_register() will set it.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
platform_driver does not need to set an owner because
platform_driver_register() will set it.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>rtc: use more standard kernel logging styles</title>
<updated>2015-04-17T13:04:02+00:00</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2015-04-16T19:46:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a737e835e5769ef22897179ed7f82b1fc50bfa58'/>
<id>a737e835e5769ef22897179ed7f82b1fc50bfa58</id>
<content type='text'>
Neaten the logging a bit by adding #define pr_fmt

Miscellanea:

o Remove __FILE__/__func__ uses
o Coalesce formats adding missing spaces
o Align arguments
o (rtc-cmos) Integrated 2 consecutive messages

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Joshua Kinard &lt;kumba@gentoo.org&gt;
Cc: Chanwoo Choi &lt;cw00.choi@samsung.com&gt;
Reviewed-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Tested-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Cc: Aaro Koskinen &lt;aaro.koskinen@iki.fi&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Neaten the logging a bit by adding #define pr_fmt

Miscellanea:

o Remove __FILE__/__func__ uses
o Coalesce formats adding missing spaces
o Align arguments
o (rtc-cmos) Integrated 2 consecutive messages

Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
Cc: Alessandro Zummo &lt;a.zummo@towertech.it&gt;
Cc: Joshua Kinard &lt;kumba@gentoo.org&gt;
Cc: Chanwoo Choi &lt;cw00.choi@samsung.com&gt;
Reviewed-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Tested-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Cc: Aaro Koskinen &lt;aaro.koskinen@iki.fi&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
