2023-04-11 13:48:00

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 0/3] Fix SA8155P RPMPDs

SA8155P has some kind of a faulty firmware that advertises power
domains that are actually absent (and trying to access them results
in a lockup and reboot).. This series tries to amend that.

v1 -> v2:
- Reuse 8150 indices for 8155
- As a consequence of /\, only update domains that differ in the DT

I did not pick up any tags, as things changed rather significantly.

Compile-tested only.

v1: https://lore.kernel.org/linux-arm-msm/[email protected]/

Signed-off-by: Konrad Dybcio <[email protected]>
---
Konrad Dybcio (3):
dt-bindings: power: qcom,rpmpd: Add SA8155P
soc: qcom: rpmhpd: Add SA8155P power domains
arm64: dts: qcom: Split out SA8155P and use correct RPMh power domains

.../devicetree/bindings/power/qcom,rpmpd.yaml | 1 +
arch/arm64/boot/dts/qcom/sa8155p-adp.dts | 2 +-
arch/arm64/boot/dts/qcom/sa8155p.dtsi | 40 ++++++++++++++++++++++
drivers/soc/qcom/rpmhpd.c | 16 +++++++++
include/dt-bindings/power/qcom-rpmpd.h | 9 +++++
5 files changed, 67 insertions(+), 1 deletion(-)
---
base-commit: 009795d283d1f9f043e5a4ff97d4140cde17e2d3
change-id: 20230411-topic-hanaau-459c6cbbf55c

Best regards,
--
Konrad Dybcio <[email protected]>


2023-04-11 13:48:44

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 1/3] dt-bindings: power: qcom,rpmpd: Add SA8155P

Add a compatible for SA8155P platforms and relevant defines to the
include file.

Signed-off-by: Konrad Dybcio <[email protected]>
---
Documentation/devicetree/bindings/power/qcom,rpmpd.yaml | 1 +
include/dt-bindings/power/qcom-rpmpd.h | 9 +++++++++
2 files changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
index afad3135ed67..f9c211a9a938 100644
--- a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
+++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
@@ -29,6 +29,7 @@ properties:
- qcom,qcm2290-rpmpd
- qcom,qcs404-rpmpd
- qcom,qdu1000-rpmhpd
+ - qcom,sa8155p-rpmhpd
- qcom,sa8540p-rpmhpd
- qcom,sa8775p-rpmhpd
- qcom,sdm660-rpmpd
diff --git a/include/dt-bindings/power/qcom-rpmpd.h b/include/dt-bindings/power/qcom-rpmpd.h
index 1bf8e87ecd7e..867b18e041ea 100644
--- a/include/dt-bindings/power/qcom-rpmpd.h
+++ b/include/dt-bindings/power/qcom-rpmpd.h
@@ -90,6 +90,15 @@
#define SM8150_MMCX 9
#define SM8150_MMCX_AO 10

+/* SA8155P is a special case, kept for backwards compatibility */
+#define SA8155P_CX SM8150_CX
+#define SA8155P_CX_AO SM8150_CX_AO
+#define SA8155P_EBI SM8150_EBI
+#define SA8155P_GFX SM8150_GFX
+#define SA8155P_MSS SM8150_MSS
+#define SA8155P_MX SM8150_MX
+#define SA8155P_MX_AO SM8150_MX_AO
+
/* SM8250 Power Domain Indexes */
#define SM8250_CX 0
#define SM8250_CX_AO 1

--
2.40.0

2023-04-11 13:48:59

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 3/3] arm64: dts: qcom: Split out SA8155P and use correct RPMh power domains

The RPMhPD setup on SA8155P is different compared to SM8150. Correct
it to ensure the platform will not try accessing forbidden/missing
RPMh entries at boot, as a bad vote will hang the machine.

Signed-off-by: Konrad Dybcio <[email protected]>
---
arch/arm64/boot/dts/qcom/sa8155p-adp.dts | 2 +-
arch/arm64/boot/dts/qcom/sa8155p.dtsi | 40 ++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sa8155p-adp.dts b/arch/arm64/boot/dts/qcom/sa8155p-adp.dts
index 339fea522509..15e1ae1c1a97 100644
--- a/arch/arm64/boot/dts/qcom/sa8155p-adp.dts
+++ b/arch/arm64/boot/dts/qcom/sa8155p-adp.dts
@@ -7,7 +7,7 @@

#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
#include <dt-bindings/gpio/gpio.h>
-#include "sm8150.dtsi"
+#include "sa8155p.dtsi"
#include "pmm8155au_1.dtsi"
#include "pmm8155au_2.dtsi"

diff --git a/arch/arm64/boot/dts/qcom/sa8155p.dtsi b/arch/arm64/boot/dts/qcom/sa8155p.dtsi
new file mode 100644
index 000000000000..ffb7ab695213
--- /dev/null
+++ b/arch/arm64/boot/dts/qcom/sa8155p.dtsi
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2023, Linaro Limited
+ *
+ * SA8155P is an automotive variant of SM8150, with some minor changes.
+ * Most notably, the RPMhPD setup differs: MMCX and LCX/LMX rails are gone,
+ * though the cmd-db doesn't reflect that and access attemps result in a bite.
+ */
+
+#include "sm8150.dtsi"
+
+&dispcc {
+ power-domains = <&rpmhpd SA8155P_CX>;
+};
+
+&mdss_dsi0 {
+ power-domains = <&rpmhpd SA8155P_CX>;
+};
+
+&mdss_dsi1 {
+ power-domains = <&rpmhpd SA8155P_CX>;
+};
+
+&mdss_mdp {
+ power-domains = <&rpmhpd SA8155P_CX>;
+};
+
+&remoteproc_slpi {
+ power-domains = <&rpmhpd SA8155P_CX>,
+ <&rpmhpd SA8155P_MX>;
+};
+
+&rpmhpd {
+ /*
+ * The bindings were crafted such that SA8155P PDs match their
+ * SM8150 counterparts to make it more maintainable and only
+ * necessitate adjusting entries that actually differ
+ */
+ compatible = "qcom,sa8155p-rpmhpd";
+};

--
2.40.0

2023-04-11 13:49:44

by Konrad Dybcio

[permalink] [raw]
Subject: [PATCH v2 2/3] soc: qcom: rpmhpd: Add SA8155P power domains

Add the power domains exposed by RPMh in the Qualcomm SA8155P platform.
Turns out they differ from SM8150.

Signed-off-by: Konrad Dybcio <[email protected]>
---
drivers/soc/qcom/rpmhpd.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
index f20e2a49a669..63c35a32065b 100644
--- a/drivers/soc/qcom/rpmhpd.c
+++ b/drivers/soc/qcom/rpmhpd.c
@@ -342,6 +342,21 @@ static const struct rpmhpd_desc sm8150_desc = {
.num_pds = ARRAY_SIZE(sm8150_rpmhpds),
};

+static struct rpmhpd *sa8155p_rpmhpds[] = {
+ [SA8155P_CX] = &cx_w_mx_parent,
+ [SA8155P_CX_AO] = &cx_ao_w_mx_parent,
+ [SA8155P_EBI] = &ebi,
+ [SA8155P_GFX] = &gfx,
+ [SA8155P_MSS] = &mss,
+ [SA8155P_MX] = &mx,
+ [SA8155P_MX_AO] = &mx_ao,
+};
+
+static const struct rpmhpd_desc sa8155p_desc = {
+ .rpmhpds = sa8155p_rpmhpds,
+ .num_pds = ARRAY_SIZE(sa8155p_rpmhpds),
+};
+
/* SM8250 RPMH powerdomains */
static struct rpmhpd *sm8250_rpmhpds[] = {
[SM8250_CX] = &cx_w_mx_parent,
@@ -519,6 +534,7 @@ static const struct rpmhpd_desc sc8280xp_desc = {

static const struct of_device_id rpmhpd_match_table[] = {
{ .compatible = "qcom,qdu1000-rpmhpd", .data = &qdu1000_desc },
+ { .compatible = "qcom,sa8155p-rpmhpd", .data = &sa8155p_desc },
{ .compatible = "qcom,sa8540p-rpmhpd", .data = &sa8540p_desc },
{ .compatible = "qcom,sa8775p-rpmhpd", .data = &sa8775p_desc },
{ .compatible = "qcom,sc7180-rpmhpd", .data = &sc7180_desc },

--
2.40.0

2023-04-11 15:04:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Fix SA8155P RPMPDs

On Tue, Apr 11, 2023 at 3:47 PM Konrad Dybcio <[email protected]> wrote:
>
> SA8155P has some kind of a faulty firmware that advertises power
> domains that are actually absent (and trying to access them results
> in a lockup and reboot).. This series tries to amend that.
>
> v1 -> v2:
> - Reuse 8150 indices for 8155
> - As a consequence of /\, only update domains that differ in the DT
>
> I did not pick up any tags, as things changed rather significantly.
>
> Compile-tested only.
>
> v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> Konrad Dybcio (3):
> dt-bindings: power: qcom,rpmpd: Add SA8155P
> soc: qcom: rpmhpd: Add SA8155P power domains
> arm64: dts: qcom: Split out SA8155P and use correct RPMh power domains
>
> .../devicetree/bindings/power/qcom,rpmpd.yaml | 1 +
> arch/arm64/boot/dts/qcom/sa8155p-adp.dts | 2 +-
> arch/arm64/boot/dts/qcom/sa8155p.dtsi | 40 ++++++++++++++++++++++
> drivers/soc/qcom/rpmhpd.c | 16 +++++++++
> include/dt-bindings/power/qcom-rpmpd.h | 9 +++++
> 5 files changed, 67 insertions(+), 1 deletion(-)
> ---
> base-commit: 009795d283d1f9f043e5a4ff97d4140cde17e2d3
> change-id: 20230411-topic-hanaau-459c6cbbf55c
>
> Best regards,
> --
> Konrad Dybcio <[email protected]>
>

sa8155p-adp now works fine, thanks

Tested-by: Bartosz Golaszewski <[email protected]>

2023-04-11 17:40:32

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] dt-bindings: power: qcom,rpmpd: Add SA8155P

On 11/04/2023 15:47, Konrad Dybcio wrote:
> Add a compatible for SA8155P platforms and relevant defines to the
> include file.
>
> Signed-off-by: Konrad Dybcio <[email protected]>
> ---
> Documentation/devicetree/bindings/power/qcom,rpmpd.yaml | 1 +
> include/dt-bindings/power/qcom-rpmpd.h | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
> index afad3135ed67..f9c211a9a938 100644
> --- a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
> +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
> @@ -29,6 +29,7 @@ properties:
> - qcom,qcm2290-rpmpd
> - qcom,qcs404-rpmpd
> - qcom,qdu1000-rpmhpd
> + - qcom,sa8155p-rpmhpd
> - qcom,sa8540p-rpmhpd
> - qcom,sa8775p-rpmhpd
> - qcom,sdm660-rpmpd
> diff --git a/include/dt-bindings/power/qcom-rpmpd.h b/include/dt-bindings/power/qcom-rpmpd.h
> index 1bf8e87ecd7e..867b18e041ea 100644
> --- a/include/dt-bindings/power/qcom-rpmpd.h
> +++ b/include/dt-bindings/power/qcom-rpmpd.h
> @@ -90,6 +90,15 @@
> #define SM8150_MMCX 9
> #define SM8150_MMCX_AO 10
>
> +/* SA8155P is a special case, kept for backwards compatibility */

This is a new binding, thus I don't understand what is here backwards
compatible?

> +#define SA8155P_CX SM8150_CX
> +#define SA8155P_CX_AO SM8150_CX_AO
> +#define SA8155P_EBI SM8150_EBI
> +#define SA8155P_GFX SM8150_GFX
> +#define SA8155P_MSS SM8150_MSS
> +#define SA8155P_MX SM8150_MX
> +#define SA8155P_MX_AO SM8150_MX_AO
> +

Best regards,
Krzysztof

2023-04-11 18:05:22

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] dt-bindings: power: qcom,rpmpd: Add SA8155P



On 11.04.2023 19:37, Krzysztof Kozlowski wrote:
> On 11/04/2023 15:47, Konrad Dybcio wrote:
>> Add a compatible for SA8155P platforms and relevant defines to the
>> include file.
>>
>> Signed-off-by: Konrad Dybcio <[email protected]>
>> ---
>> Documentation/devicetree/bindings/power/qcom,rpmpd.yaml | 1 +
>> include/dt-bindings/power/qcom-rpmpd.h | 9 +++++++++
>> 2 files changed, 10 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
>> index afad3135ed67..f9c211a9a938 100644
>> --- a/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
>> +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.yaml
>> @@ -29,6 +29,7 @@ properties:
>> - qcom,qcm2290-rpmpd
>> - qcom,qcs404-rpmpd
>> - qcom,qdu1000-rpmhpd
>> + - qcom,sa8155p-rpmhpd
>> - qcom,sa8540p-rpmhpd
>> - qcom,sa8775p-rpmhpd
>> - qcom,sdm660-rpmpd
>> diff --git a/include/dt-bindings/power/qcom-rpmpd.h b/include/dt-bindings/power/qcom-rpmpd.h
>> index 1bf8e87ecd7e..867b18e041ea 100644
>> --- a/include/dt-bindings/power/qcom-rpmpd.h
>> +++ b/include/dt-bindings/power/qcom-rpmpd.h
>> @@ -90,6 +90,15 @@
>> #define SM8150_MMCX 9
>> #define SM8150_MMCX_AO 10
>>
>> +/* SA8155P is a special case, kept for backwards compatibility */
>
> This is a new binding, thus I don't understand what is here backwards
> compatible?
Check the DT structure, 8155-adp (so, de facto 8155) included
8150 before, but that was not exactly the correct approach..
It bit us after we accidentally discovered 8155 advertises MMCX,
LCX and LMX PDs in cmd-db but triggers a bite on access attempts..

By mimicking the indices to match the ones of 8150, we only have
to fix up the domains that were axed from 8155 (in comparison to
8150 which has the full fat setup).

Konrad
>
>> +#define SA8155P_CX SM8150_CX
>> +#define SA8155P_CX_AO SM8150_CX_AO
>> +#define SA8155P_EBI SM8150_EBI
>> +#define SA8155P_GFX SM8150_GFX
>> +#define SA8155P_MSS SM8150_MSS
>> +#define SA8155P_MX SM8150_MX
>> +#define SA8155P_MX_AO SM8150_MX_AO
>> +
>
> Best regards,
> Krzysztof
>

2023-04-12 07:27:12

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/3] dt-bindings: power: qcom,rpmpd: Add SA8155P

On 11/04/2023 20:03, Konrad Dybcio wrote:
>>> - qcom,sdm660-rpmpd
>>> diff --git a/include/dt-bindings/power/qcom-rpmpd.h b/include/dt-bindings/power/qcom-rpmpd.h
>>> index 1bf8e87ecd7e..867b18e041ea 100644
>>> --- a/include/dt-bindings/power/qcom-rpmpd.h
>>> +++ b/include/dt-bindings/power/qcom-rpmpd.h
>>> @@ -90,6 +90,15 @@
>>> #define SM8150_MMCX 9
>>> #define SM8150_MMCX_AO 10
>>>
>>> +/* SA8155P is a special case, kept for backwards compatibility */
>>
>> This is a new binding, thus I don't understand what is here backwards
>> compatible?
> Check the DT structure, 8155-adp (so, de facto 8155) included
> 8150 before, but that was not exactly the correct approach..
> It bit us after we accidentally discovered 8155 advertises MMCX,
> LCX and LMX PDs in cmd-db but triggers a bite on access attempts..
>
> By mimicking the indices to match the ones of 8150, we only have
> to fix up the domains that were axed from 8155 (in comparison to
> 8150 which has the full fat setup).

>
> Konrad
>>
>>> +#define SA8155P_CX SM8150_CX
>>> +#define SA8155P_CX_AO SM8150_CX_AO

The DTS diff (the patch here) does not show it, I would need to check
the context by opening other DTS in linux-next. Therefore it would be
great if commit msg explained this.

BTW, using here directly numbers matching SM8150 values, would also be
backwards compatible...

Acked-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2023-05-25 05:27:29

by Bjorn Andersson

[permalink] [raw]
Subject: Re: (subset) [PATCH v2 0/3] Fix SA8155P RPMPDs

On Tue, 11 Apr 2023 15:47:14 +0200, Konrad Dybcio wrote:
> SA8155P has some kind of a faulty firmware that advertises power
> domains that are actually absent (and trying to access them results
> in a lockup and reboot).. This series tries to amend that.
>
> v1 -> v2:
> - Reuse 8150 indices for 8155
> - As a consequence of /\, only update domains that differ in the DT
>
> [...]

Applied, thanks!

[2/3] soc: qcom: rpmhpd: Add SA8155P power domains
commit: 4a08af2f22ba3c2fb26287dc27fa07bf298acb34

Best regards,
--
Bjorn Andersson <[email protected]>