rtc: pm8xxx: fix uefi offset lookup
Subsystems (4)
cover rtc: pm8xxx: fix uefi offset lookup
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the driver probes.
This series adds a 'qcom,uefi-rtc-info' boolean DT property to indicate that the RTC offset is stored in a Qualcomm specific UEFI variable so that the OS can determine whether to wait for it to become available.
I used such a property in v1 of the series adding support for the UEFI offset [1], but mistakenly convinced myself that it was not needed given that the efivars driver would need to remain built in. As Rob Clark noticed, this is however not sufficient and the driver can currently fail to look up the offset if the RTC driver is built in or if a dependency of the efivars driver is built as a module. [2]
As with the rest of this driver, hopefully all of this goes away (for future platforms) once Qualcomm fix their UEFI implementation so that the time service can be used directly.
Preferably the binding and driver fix can be merged for 6.15-rc by Alexandre, while Bjorn takes the DT changes through the branch which has the DT patches from v2 (which unfortunately missed 6.15 but may possibly be sent as hw enablement fixups). [3]
Johan
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
Johan Hovold (4):
dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
rtc: pm8xxx: fix uefi offset lookup
arm64: dts: qcom: sc8280xp-x13s: describe uefi rtc offset
arm64: dts: qcom: x1e80100: describe uefi rtc offset
.../bindings/rtc/qcom-pm8xxx-rtc.yaml | 6 ++++++ .../dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 ++ arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi | 1 + drivers/rtc/rtc-pm8xxx.c | 17 ++++++++++++----- 4 files changed, 21 insertions(+), 5 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/4 dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the RTC driver probes.
Add a 'qcom,uefi-rtc-info' boolean flag to indicate that the RTC offset is stored in a Qualcomm specific UEFI variable so that the OS can determine whether to wait for it to become available.
The UEFI variable is
882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo
and holds a 12-byte structure where the first four bytes is a GPS time offset in little-endian byte order.
--- Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml +6 -0
@@ -55,6 +55,12 @@ properties: description: RTC alarm is not owned by the OS + qcom,uefi-rtc-info: + type: boolean + description: + RTC offset is stored as a four-byte GPS time offset in a 12-byte UEFI + variable 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo + wakeup-source: true required:
Signature · 1 line
2.49.0
Re: [PATCH 1/4] dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
Quoted 18 lines · Johan Hovold
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the RTC driver probes.
Add a 'qcom,uefi-rtc-info' boolean flag to indicate that the RTC offset is stored in a Qualcomm specific UEFI variable so that the OS can determine whether to wait for it to become available.
The UEFI variable is
882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo
Quoted 9 lines
and holds a 12-byte structure where the first four bytes is a GPS time offset in little-endian byte order.
Signed-off-by Johan Hovold <[email protected]>--- Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
PATCH 2/4 rtc: pm8xxx: fix uefi offset lookup
In reply to Johan HovoldOn many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the driver probes.
Use the new 'qcom,uefi-rtc-info' property to determine whether to probe defer until the UEFI offset becomes available so that the offset can be used also when the RTC driver is built in or when a dependency of the UEFI variable driver is built as a module (e.g. the driver for the SCM interconnects).
--- drivers/rtc/rtc-pm8xxx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/rtc/rtc-pm8xxx.c +12 -5
@@ -576,13 +576,20 @@ static int pm8xxx_rtc_probe_offset(struct pm8xxx_rtc *rtc_dd) }/* Use UEFI storage as fallback if available */ -if (efivar_is_available ()) { - rc =pm8xxx_rtc_read_uefi_offset (rtc_dd); -if (rc ==0 ) - rtc_dd->use_uefi = true; + rtc_dd->use_uefi =of_property_read_bool (rtc_dd->dev->of_node, +"qcom,uefi-rtc-info" ); +if (!rtc_dd->use_uefi) +return 0 ; + +if (!efivar_is_available ()) { +if (IS_ENABLED (CONFIG_EFI )) +return -EPROBE_DEFER ; + +dev_warn (rtc_dd->dev,"efivars not available\n" ); + rtc_dd->use_uefi = false; } -return 0 ; +return pm8xxx_rtc_read_uefi_offset (rtc_dd); }static int pm8xxx_rtc_probe (struct platform_device *pdev)
Signature · 1 line
2.49.0
PATCH 3/4 arm64: dts: qcom: sc8280xp-x13s: describe uefi rtc offset
In reply to Johan HovoldOn many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the RTC driver probes.
Use the new 'qcom,uefi-rtc-info' property to indicate that the offset is stored in a UEFI variable so that the OS can determine whether to wait for it to become available.
--- arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +2 -0
@@ -1090,6 +1090,8 @@ &pmk8280_pon_resin { }; &pmk8280_rtc { + qcom,uefi-rtc-info; + status = "okay"; };
Signature · 1 line
2.49.0
PATCH 4/4 arm64: dts: qcom: x1e80100: describe uefi rtc offset
In reply to Johan HovoldOn many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the RTC driver probes.
Use the new 'qcom,uefi-rtc-info' property to indicate that the offset is stored in a UEFI variable so that the OS can determine whether to wait for it to become available.
--- arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi +1 -0
@@ -224,6 +224,7 @@ pmk8550_rtc: rtc@6100 { reg-names = "rtc", "alarm"; interrupts = <0x0 0x62 0x1 IRQ_TYPE_EDGE_RISING>; qcom,no-alarm; /* alarm owned by ADSP */ + qcom,uefi-rtc-info; }; pmk8550_sdam_2: nvram@7100 {
Signature · 1 line
2.49.0
Hi Alexandre and Bjorn,
Quoted 21 lines · Johan Hovold
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the driver probes.
This series adds a 'qcom,uefi-rtc-info' boolean DT property to indicate that the RTC offset is stored in a Qualcomm specific UEFI variable so that the OS can determine whether to wait for it to become available.
I used such a property in v1 of the series adding support for the UEFI offset [1], but mistakenly convinced myself that it was not needed given that the efivars driver would need to remain built in. As Rob Clark noticed, this is however not sufficient and the driver can currently fail to look up the offset if the RTC driver is built in or if a dependency of the efivars driver is built as a module. [2]
Quoted 8 lines
As with the rest of this driver, hopefully all of this goes away (for future platforms) once Qualcomm fix their UEFI implementation so that the time service can be used directly.
Preferably the binding and driver fix can be merged for 6.15-rc by Alexandre, while Bjorn takes the DT changes through the branch which has the DT patches from v2 (which unfortunately missed 6.15 but may possibly be sent as hw enablement fixups). [3]
It seems we won't have RTC support in 6.15, but could you please pick these up for 6.16 to make sure that the RTC works also when the driver is built in?
Quoted 9 lines
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/Johan Hovold (4):
dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
rtc: pm8xxx: fix uefi offset lookup
arm64: dts: qcom: sc8280xp-x13s: describe uefi rtc offset
arm64: dts: qcom: x1e80100: describe uefi rtc offset
Johan
Hi Alexandre,
Quoted 15 lines · Johan Hovold
Hi Alexandre and Bjorn,
Quoted 10 lines · Johan Hovold
This series adds a 'qcom,uefi-rtc-info' boolean DT property to indicate that the RTC offset is stored in a Qualcomm specific UEFI variable so that the OS can determine whether to wait for it to become available.
I used such a property in v1 of the series adding support for the UEFI offset [1], but mistakenly convinced myself that it was not needed given that the efivars driver would need to remain built in. As Rob Clark noticed, this is however not sufficient and the driver can currently fail to look up the offset if the RTC driver is built in or if a dependency of the efivars driver is built as a module. [2]
Quoted 8 lines
Quoted 4 lines
Preferably the binding and driver fix can be merged for 6.15-rc by Alexandre, while Bjorn takes the DT changes through the branch which has the DT patches from v2 (which unfortunately missed 6.15 but may possibly be sent as hw enablement fixups). [3]
It seems we won't have RTC support in 6.15, but could you please pick these up for 6.16 to make sure that the RTC works also when the driver is built in?
It's only been two weeks since my last last reminder about this series, but can you please pick up the binding and driver patches for 6.16?
Bjorn has already sent his DT changes for 6.16, but since these are fixes he should be able to get them in during the 6.16 cycle.
It would help a lot if the driver changes are in place then.
Quoted 9 lines
Quoted 9 lines
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/Johan Hovold (4):
dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
rtc: pm8xxx: fix uefi offset lookup
arm64: dts: qcom: sc8280xp-x13s: describe uefi rtc offset
arm64: dts: qcom: x1e80100: describe uefi rtc offset
Johan
Re: (subset) [PATCH 0/4] rtc: pm8xxx: fix uefi offset lookup
In reply to Johan HovoldQuoted 11 lines · Johan Hovold
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the driver probes.
[...]
Applied, thanks!
[1/4] dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset
https://git.kernel.org/abelloni/c/b23b91d56863 [2/4] rtc: pm8xxx: fix uefi offset lookup https://git.kernel.org/abelloni/c/ead453283279
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: (subset) [PATCH 0/4] rtc: pm8xxx: fix uefi offset lookup
In reply to Johan HovoldQuoted 11 lines · Johan Hovold
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the driver probes.
[...]
Applied, thanks!
[3/4] arm64: dts: qcom: sc8280xp-x13s: describe uefi rtc offset
commit: 869971de8221b97acb6aa4d7ff4fa67eb71adc87
[4/4] arm64: dts: qcom: x1e80100: describe uefi rtc offset
commit: e8d3dc45f2d3b0fea089e0e6e351d1287a5a2a29Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>