All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/15] UFS: Add OPP and interconnect support
@ 2023-07-20  5:40 Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 01/15] dt-bindings: ufs: common: add OPP table Manivannan Sadhasivam
                   ` (17 more replies)
  0 siblings, 18 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Hi,

This series adds OPP (Operating Points) support to UFSHCD driver and
interconnect support to Qcom UFS driver.

Motivation behind adding OPP support is to scale both clocks as well as
regulators/performance state dynamically. Currently, UFSHCD just scales
clock frequency during runtime with the help of "freq-table-hz" property
defined in devicetree. With the addition of OPP tables in devicetree (as
done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
both clocks and performance state of power domain which helps in power
saving.

For the addition of OPP support to UFSHCD, there are changes required to
the OPP framework and devfreq drivers which are also added in this series.

Finally, interconnect support is added to Qcom UFS driver for scaling the
interconnect path dynamically. This is required to avoid boot crash in
recent SoCs and also to save power during runtime. More information is
available in patch 13/13.

Credits
=======

This series is a continuation of previous work by Krzysztof Kozlowski [1]
and Brian Masney [2]. Ideally, this could've split into two series (OPP
and interconnect) but since there will be a dependency in the devicetree,
I decided to keep them in a single series.

Testing
=======

This series is tested on 96Boards RB3 (SDM845 SoC) and RB5 (SM8250 SoC)
development boards.

Merging Strategy
================

An immutable branch might be required between OPP and SCSI trees because of
the API dependency (devfreq too). And I leave it up to the maintainers to
decide.

Thanks,
Mani

[1] https://lore.kernel.org/all/20220513061347.46480-1-krzysztof.kozlowski@linaro.org/
[2] https://lore.kernel.org/all/20221117104957.254648-1-bmasney@redhat.com/

Changes in v2:

* Added more description to the bindings patch 2/15
* Fixed dev_pm_opp_put() usage in patch 10/15
* Added a new patch for adding enums for UFS lanes 14/15
* Changed the icc variables to mem_bw and cfg_bw and used
  the enums for gears and lanes in bw_table
* Collected review tags
* Added SCSI list and folks
* Removed duplicate patches

Krzysztof Kozlowski (2):
  dt-bindings: ufs: common: add OPP table
  arm64: dts: qcom: sdm845: Add OPP table support to UFSHC

Manivannan Sadhasivam (13):
  dt-bindings: opp: Increase maxItems for opp-hz property
  arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC
  arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  arm64: dts: qcom: sm8250: Add OPP table support to UFSHC
  OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  OPP: Introduce dev_pm_opp_get_freq_indexed() API
  PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed()
    APIs
  scsi: ufs: core: Add OPP support for scaling clocks and regulators
  scsi: ufs: host: Add support for parsing OPP
  arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC
  arm64: dts: qcom: sm8250: Add interconnect paths to UFSHC
  scsi: ufs: core: Add enums for UFS lanes
  scsi: ufs: qcom: Add support for scaling interconnects

 .../devicetree/bindings/opp/opp-v2-base.yaml  |   2 +-
 .../devicetree/bindings/ufs/ufs-common.yaml   |  34 +++-
 arch/arm64/boot/dts/qcom/sdm845.dtsi          |  47 ++++--
 arch/arm64/boot/dts/qcom/sm8250.dtsi          |  43 +++--
 drivers/devfreq/devfreq.c                     |  14 +-
 drivers/opp/core.c                            |  76 +++++++++
 drivers/ufs/core/ufshcd.c                     | 148 +++++++++++++-----
 drivers/ufs/host/ufs-qcom.c                   | 131 +++++++++++++++-
 drivers/ufs/host/ufs-qcom.h                   |   3 +
 drivers/ufs/host/ufshcd-pltfrm.c              | 120 +++++++++++++-
 include/linux/pm_opp.h                        |  26 +++
 include/ufs/ufshcd.h                          |   4 +
 include/ufs/unipro.h                          |   6 +
 13 files changed, 586 insertions(+), 68 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 01/15] dt-bindings: ufs: common: add OPP table
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property Manivannan Sadhasivam
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Rob Herring, Manivannan Sadhasivam

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Except scaling UFS and bus clocks, it's necessary to scale also the
voltages of regulators or power domain performance state levels.  Adding
Operating Performance Points table allows to adjust power domain
performance state, depending on the UFS clock speed.

OPPv2 deprecates previous property limited to clock scaling:
freq-table-hz.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 .../devicetree/bindings/ufs/ufs-common.yaml   | 34 +++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufs-common.yaml b/Documentation/devicetree/bindings/ufs/ufs-common.yaml
index 47a4e9e1a775..d7d2c8a136bb 100644
--- a/Documentation/devicetree/bindings/ufs/ufs-common.yaml
+++ b/Documentation/devicetree/bindings/ufs/ufs-common.yaml
@@ -20,11 +20,24 @@ properties:
       items:
         - description: Minimum frequency for given clock in Hz
         - description: Maximum frequency for given clock in Hz
+    deprecated: true
     description: |
+      Preferred is operating-points-v2.
+
       Array of <min max> operating frequencies in Hz stored in the same order
-      as the clocks property. If this property is not defined or a value in the
-      array is "0" then it is assumed that the frequency is set by the parent
-      clock or a fixed rate clock source.
+      as the clocks property. If either this property or operating-points-v2 is
+      not defined or a value in the array is "0" then it is assumed that the
+      frequency is set by the parent clock or a fixed rate clock source.
+
+  operating-points-v2:
+    description:
+      Preferred over freq-table-hz.
+      If present, each OPP must contain array of frequencies stored in the same
+      order for each clock.  If clock frequency in the array is "0" then it is
+      assumed that the frequency is set by the parent clock or a fixed rate
+      clock source.
+
+  opp-table: true
 
   interrupts:
     maxItems: 1
@@ -75,8 +88,23 @@ properties:
 
 dependencies:
   freq-table-hz: [ 'clocks' ]
+  operating-points-v2: [ 'clocks', 'clock-names' ]
 
 required:
   - interrupts
 
+allOf:
+  - if:
+      required:
+        - freq-table-hz
+    then:
+      properties:
+        operating-points-v2: false
+  - if:
+      required:
+        - operating-points-v2
+    then:
+      properties:
+        freq-table-hz: false
+
 additionalProperties: true
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 01/15] dt-bindings: ufs: common: add OPP table Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-24 15:51   ` Rob Herring
  2023-07-20  5:40 ` [PATCH v2 03/15] arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC Manivannan Sadhasivam
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Current limit of 16 will be exhausted by platforms specifying the frequency
for 9 clocks using opp-hz, like Qcom SDM845 SoC. For instance, specifying
the frequency for 9 clocks with 64bit specifier as below would consume
(9 * 2 = 18) items.

	opp-50000000 {
		opp-hz = /bits/ 64 <50000000>,
			 /bits/ 64 <0>,
			 /bits/ 64 <0>,
			 /bits/ 64 <37500000>,
			 /bits/ 64 <0>,
			 /bits/ 64 <0>,
			 /bits/ 64 <0>,
			 /bits/ 64 <0>,
			 /bits/ 64 <75000000>;
	};

So let's increase the limit to 32 which should be enough for most platforms
(hopefully).

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml
index 47e6f36b7637..e2f8f7af3cf4 100644
--- a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml
+++ b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml
@@ -56,7 +56,7 @@ patternProperties:
           need to be configured and that is left for the implementation
           specific binding.
         minItems: 1
-        maxItems: 16
+        maxItems: 32
         items:
           maxItems: 1
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 03/15] arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 01/15] dt-bindings: ufs: common: add OPP table Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk" Manivannan Sadhasivam
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

GCC and it's GDSCs are under the RPMh CX power domain. So let's add the
missing RPMh power domain to the GCC node.

Fixes: 6d4cf750d03a ("arm64: dts: sdm845: Add minimal dts/dtsi files for sdm845 SoC and MTP")
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Co-developed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 02a6ea0b8b2c..9ed74bf72d05 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -1207,6 +1207,7 @@ gcc: clock-controller@100000 {
 			#clock-cells = <1>;
 			#reset-cells = <1>;
 			#power-domain-cells = <1>;
+			power-domains = <&rpmhpd SDM845_CX>;
 		};
 
 		qfprom@784000 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (2 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 03/15] arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-21  7:18   ` Viresh Kumar
  2023-07-20  5:40 ` [PATCH v2 05/15] arm64: dts: qcom: sdm845: Add OPP table support to UFSHC Manivannan Sadhasivam
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Minimum frequency of the "ice_core_clk" should be 75MHz as specified in the
downstream vendor devicetree. So fix it!

https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.7.3.r1-09300-sdm845.0/arch/arm64/boot/dts/qcom/sdm845.dtsi

Fixes: 433f9a57298f ("arm64: dts: sdm845: add Inline Crypto Engine registers and clock")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 9ed74bf72d05..89520a9fe1e3 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2614,7 +2614,7 @@ ufs_mem_hc: ufshc@1d84000 {
 				<0 0>,
 				<0 0>,
 				<0 0>,
-				<0 300000000>;
+				<75000000 300000000>;
 
 			status = "disabled";
 		};
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 05/15] arm64: dts: qcom: sdm845: Add OPP table support to UFSHC
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (3 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk" Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 06/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

UFS host controller, when scaling gears, should choose appropriate
performance state of RPMh power domain controller along with clock
frequency. So let's add the OPP table support to specify both clock
frequency and RPMh performance states replacing the old "freq-table-hz"
property.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
[mani: Splitted pd change and used rpmhpd_opp_low_svs]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 41 +++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 89520a9fe1e3..e04a3cbb1017 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2605,18 +2605,39 @@ ufs_mem_hc: ufshc@1d84000 {
 				<&gcc GCC_UFS_PHY_RX_SYMBOL_0_CLK>,
 				<&gcc GCC_UFS_PHY_RX_SYMBOL_1_CLK>,
 				<&gcc GCC_UFS_PHY_ICE_CORE_CLK>;
-			freq-table-hz =
-				<50000000 200000000>,
-				<0 0>,
-				<0 0>,
-				<37500000 150000000>,
-				<0 0>,
-				<0 0>,
-				<0 0>,
-				<0 0>,
-				<75000000 300000000>;
 
+			operating-points-v2 = <&ufs_opp_table>;
 			status = "disabled";
+
+			ufs_opp_table: opp-table {
+				compatible = "operating-points-v2";
+
+				opp-50000000 {
+					opp-hz = /bits/ 64 <50000000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <37500000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <75000000>;
+					required-opps = <&rpmhpd_opp_low_svs>;
+				};
+
+				opp-200000000 {
+					opp-hz = /bits/ 64 <200000000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <150000000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <300000000>;
+					required-opps = <&rpmhpd_opp_nom>;
+				};
+			};
 		};
 
 		ufs_mem_phy: phy@1d87000 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 06/15] arm64: dts: qcom: sm8250: Add OPP table support to UFSHC
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (4 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 05/15] arm64: dts: qcom: sdm845: Add OPP table support to UFSHC Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 07/15] OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

UFS host controller, when scaling gears, should choose appropriate
performance state of RPMh power domain controller along with clock
frequency. So let's add the OPP table support to specify both clock
frequency and RPMh performance states replacing the old "freq-table-hz"
property.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 39 +++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 83ab6de459bc..72fd66db9c51 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2194,17 +2194,38 @@ ufs_mem_hc: ufshc@1d84000 {
 				<&gcc GCC_UFS_PHY_TX_SYMBOL_0_CLK>,
 				<&gcc GCC_UFS_PHY_RX_SYMBOL_0_CLK>,
 				<&gcc GCC_UFS_PHY_RX_SYMBOL_1_CLK>;
-			freq-table-hz =
-				<37500000 300000000>,
-				<0 0>,
-				<0 0>,
-				<37500000 300000000>,
-				<0 0>,
-				<0 0>,
-				<0 0>,
-				<0 0>;
+
+			operating-points-v2 = <&ufs_opp_table>;
 
 			status = "disabled";
+
+			ufs_opp_table: opp-table {
+				compatible = "operating-points-v2";
+
+				opp-37500000 {
+					opp-hz = /bits/ 64 <37500000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <37500000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>;
+					required-opps = <&rpmhpd_opp_low_svs>;
+				};
+
+				opp-300000000 {
+					opp-hz = /bits/ 64 <300000000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <300000000>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>,
+						 /bits/ 64 <0>;
+					required-opps = <&rpmhpd_opp_nom>;
+				};
+			};
 		};
 
 		ufs_mem_phy: phy@1d87000 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 07/15] OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (5 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 06/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API Manivannan Sadhasivam
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

In the case of devices with multiple clocks, drivers need to specify the
clock index for the OPP framework to find the OPP corresponding to the
floor/ceil of the supplied frequency. So let's introduce the two new APIs
accepting the clock index as an argument.

These APIs use the exising _find_key_ceil() helper by supplying the clock
index to it.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/opp/core.c     | 54 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/pm_opp.h | 18 ++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 3f46e499d615..a6d0b6b18e0e 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -658,6 +658,33 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil);
 
+/**
+ * dev_pm_opp_find_freq_ceil_indexed() - Search for a rounded ceil freq for the
+ *					 clock corresponding to the index
+ * @dev:	Device for which we do this operation
+ * @freq:	Start frequency
+ * @index:	Clock index
+ *
+ * Search for the matching ceil *available* OPP for the clock corresponding to
+ * the specified index from a starting freq for a device.
+ *
+ * Return: matching *opp and refreshes *freq accordingly, else returns
+ * ERR_PTR in case of error and should be handled using IS_ERR. Error return
+ * values can be:
+ * EINVAL:	for bad pointer
+ * ERANGE:	no match found for search
+ * ENODEV:	if device not found in list of registered devices
+ *
+ * The callers are required to call dev_pm_opp_put() for the returned OPP after
+ * use.
+ */
+struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev,
+					     unsigned long *freq, u32 index)
+{
+	return _find_key_ceil(dev, freq, index, true, _read_freq, NULL);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil_indexed);
+
 /**
  * dev_pm_opp_find_freq_floor() - Search for a rounded floor freq
  * @dev:	device for which we do this operation
@@ -683,6 +710,33 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor);
 
+/**
+ * dev_pm_opp_find_freq_floor_indexed() - Search for a rounded floor freq for the
+ *					  clock corresponding to the index
+ * @dev:	Device for which we do this operation
+ * @freq:	Start frequency
+ * @index:	Clock index
+ *
+ * Search for the matching floor *available* OPP for the clock corresponding to
+ * the specified index from a starting freq for a device.
+ *
+ * Return: matching *opp and refreshes *freq accordingly, else returns
+ * ERR_PTR in case of error and should be handled using IS_ERR. Error return
+ * values can be:
+ * EINVAL:	for bad pointer
+ * ERANGE:	no match found for search
+ * ENODEV:	if device not found in list of registered devices
+ *
+ * The callers are required to call dev_pm_opp_put() for the returned OPP after
+ * use.
+ */
+struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev,
+					      unsigned long *freq, u32 index)
+{
+	return _find_key_floor(dev, freq, index, true, _read_freq, NULL);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor_indexed);
+
 /**
  * dev_pm_opp_find_level_exact() - search for an exact level
  * @dev:		device for which we do this operation
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index dc1fb5890792..991f54da79b5 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -124,6 +124,9 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
 					      unsigned long *freq);
 
+struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev,
+					      unsigned long *freq, u32 index);
+
 struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
 					       unsigned int level);
 struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
@@ -132,6 +135,9 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
 					     unsigned long *freq);
 
+struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev,
+					     unsigned long *freq, u32 index);
+
 struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
 					   unsigned int *bw, int index);
 
@@ -271,12 +277,24 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
 	return ERR_PTR(-EOPNOTSUPP);
 }
 
+static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor_indexed(struct device *dev,
+					unsigned long *freq, u32 index)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
 					unsigned long *freq)
 {
 	return ERR_PTR(-EOPNOTSUPP);
 }
 
+static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil_indexed(struct device *dev,
+					unsigned long *freq, u32 index)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
 static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
 					unsigned int *bw, int index)
 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (6 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 07/15] OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-21  5:54   ` Dan Carpenter
  2023-07-20  5:40 ` [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

In the case of devices with multiple clocks, drivers need to specify the
frequency index for the OPP framework to get the specific frequency within
the required OPP. So let's introduce the dev_pm_opp_get_freq_indexed() API
accepting the frequency index as an argument.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/opp/core.c     | 22 ++++++++++++++++++++++
 include/linux/pm_opp.h |  8 ++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index a6d0b6b18e0e..66dc0d0cfaed 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -197,6 +197,28 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
 
+/**
+ * dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an
+ *				   available opp with specified index
+ * @opp: opp for which frequency has to be returned for
+ * @index: index of the frequency within the required opp
+ *
+ * Return: frequency in hertz corresponding to the opp with specified index,
+ * else return 0
+ */
+unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
+{
+	struct opp_table *opp_table = opp->opp_table;
+
+	if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) {
+		pr_err("%s: Invalid parameters\n", __func__);
+		return 0;
+	}
+
+	return opp->rates[index];
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq_indexed);
+
 /**
  * dev_pm_opp_get_level() - Gets the level corresponding to an available opp
  * @opp:	opp for which level value has to be returned for
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 991f54da79b5..97eb6159fb93 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -105,6 +105,8 @@ unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp);
 
 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
 
+unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index);
+
 unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp);
 
 unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp,
@@ -211,6 +213,12 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
 	return 0;
 }
 
+static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp,
+						      u32 index)
+{
+	return 0;
+}
+
 static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
 {
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (7 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-23 20:06   ` Chanwoo Choi
  2023-07-20  5:40 ` [PATCH v2 10/15] scsi: ufs: core: Add OPP support for scaling clocks and regulators Manivannan Sadhasivam
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Some devfreq consumers like UFS driver need to work with multiple clocks
through the OPP framework. For this reason, OPP framework exposes the
_indexed() APIs for finding the floor/ceil of the supplied frequency of
the indexed clock. So let's use them in the devfreq driver.

Currently, the clock index of 0 is used which works fine for multiple as
well as single clock.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/devfreq/devfreq.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index e36cbb920ec8..7686993d639f 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -88,7 +88,7 @@ static unsigned long find_available_min_freq(struct devfreq *devfreq)
 	struct dev_pm_opp *opp;
 	unsigned long min_freq = 0;
 
-	opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq);
+	opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &min_freq, 0);
 	if (IS_ERR(opp))
 		min_freq = 0;
 	else
@@ -102,7 +102,7 @@ static unsigned long find_available_max_freq(struct devfreq *devfreq)
 	struct dev_pm_opp *opp;
 	unsigned long max_freq = ULONG_MAX;
 
-	opp = dev_pm_opp_find_freq_floor(devfreq->dev.parent, &max_freq);
+	opp = dev_pm_opp_find_freq_floor_indexed(devfreq->dev.parent, &max_freq, 0);
 	if (IS_ERR(opp))
 		max_freq = 0;
 	else
@@ -196,7 +196,7 @@ static int set_freq_table(struct devfreq *devfreq)
 		return -ENOMEM;
 
 	for (i = 0, freq = 0; i < devfreq->max_state; i++, freq++) {
-		opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq);
+		opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &freq, 0);
 		if (IS_ERR(opp)) {
 			devm_kfree(devfreq->dev.parent, devfreq->freq_table);
 			return PTR_ERR(opp);
@@ -2034,18 +2034,18 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
 
 	if (flags & DEVFREQ_FLAG_LEAST_UPPER_BOUND) {
 		/* The freq is an upper bound. opp should be lower */
-		opp = dev_pm_opp_find_freq_floor(dev, freq);
+		opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
 
 		/* If not available, use the closest opp */
 		if (opp == ERR_PTR(-ERANGE))
-			opp = dev_pm_opp_find_freq_ceil(dev, freq);
+			opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
 	} else {
 		/* The freq is an lower bound. opp should be higher */
-		opp = dev_pm_opp_find_freq_ceil(dev, freq);
+		opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
 
 		/* If not available, use the closest opp */
 		if (opp == ERR_PTR(-ERANGE))
-			opp = dev_pm_opp_find_freq_floor(dev, freq);
+			opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
 	}
 
 	return opp;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 10/15] scsi: ufs: core: Add OPP support for scaling clocks and regulators
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (8 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP Manivannan Sadhasivam
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

UFS core is only scaling the clocks during devfreq scaling and
initialization. But for an optimum power saving, regulators should also
be scaled along with the clocks.

So let's use the OPP framework which supports scaling clocks, regulators,
and performance state using OPP table defined in devicetree. For
accomodating the OPP support, the existing APIs (ufshcd_scale_clks,
ufshcd_is_devfreq_scaling_required and ufshcd_devfreq_scale) are modified
to accept "freq" as an argument which in turn used by the OPP helpers.

The OPP support is added along with the old freq-table based clock scaling
so that the existing platforms work as expected.

Co-developed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/ufs/core/ufshcd.c | 144 +++++++++++++++++++++++++++++---------
 include/ufs/ufshcd.h      |   4 ++
 2 files changed, 115 insertions(+), 33 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 983fae84d9e8..6207afac729d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/pm_opp.h>
 #include <linux/regulator/consumer.h>
 #include <linux/sched/clock.h>
 #include <scsi/scsi_cmnd.h>
@@ -276,7 +277,8 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba);
 static void ufshcd_resume_clkscaling(struct ufs_hba *hba);
 static void ufshcd_suspend_clkscaling(struct ufs_hba *hba);
 static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba);
-static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up);
+static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq,
+			     bool scale_up);
 static irqreturn_t ufshcd_intr(int irq, void *__hba);
 static int ufshcd_change_power_mode(struct ufs_hba *hba,
 			     struct ufs_pa_layer_attr *pwr_mode);
@@ -1087,15 +1089,33 @@ static int ufshcd_set_clk_freq(struct ufs_hba *hba, bool scale_up)
 	return ret;
 }
 
+static int ufshcd_opp_set_rate(struct ufs_hba *hba, unsigned long freq)
+{
+	struct dev_pm_opp *opp;
+	int ret;
+
+	opp = dev_pm_opp_find_freq_floor_indexed(hba->dev,
+						 &freq, 0);
+	if (IS_ERR(opp))
+		return PTR_ERR(opp);
+
+	ret = dev_pm_opp_set_opp(hba->dev, opp);
+	dev_pm_opp_put(opp);
+
+	return ret;
+}
+
 /**
  * ufshcd_scale_clks - scale up or scale down UFS controller clocks
  * @hba: per adapter instance
+ * @freq: frequency to scale
  * @scale_up: True if scaling up and false if scaling down
  *
  * Returns 0 if successful
  * Returns < 0 for any other errors
  */
-static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up)
+static int ufshcd_scale_clks(struct ufs_hba *hba, unsigned long freq,
+			     bool scale_up)
 {
 	int ret = 0;
 	ktime_t start = ktime_get();
@@ -1104,13 +1124,21 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up)
 	if (ret)
 		goto out;
 
-	ret = ufshcd_set_clk_freq(hba, scale_up);
+	if (hba->use_pm_opp)
+		ret = ufshcd_opp_set_rate(hba, freq);
+	else
+		ret = ufshcd_set_clk_freq(hba, scale_up);
 	if (ret)
 		goto out;
 
 	ret = ufshcd_vops_clk_scale_notify(hba, scale_up, POST_CHANGE);
-	if (ret)
-		ufshcd_set_clk_freq(hba, !scale_up);
+	if (ret) {
+		if (hba->use_pm_opp)
+			ufshcd_opp_set_rate(hba,
+					    hba->devfreq->previous_freq);
+		else
+			ufshcd_set_clk_freq(hba, !scale_up);
+	}
 
 out:
 	trace_ufshcd_profile_clk_scaling(dev_name(hba->dev),
@@ -1122,12 +1150,13 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up)
 /**
  * ufshcd_is_devfreq_scaling_required - check if scaling is required or not
  * @hba: per adapter instance
+ * @freq: frequency to scale
  * @scale_up: True if scaling up and false if scaling down
  *
  * Returns true if scaling is required, false otherwise.
  */
 static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
-					       bool scale_up)
+					       unsigned long freq, bool scale_up)
 {
 	struct ufs_clk_info *clki;
 	struct list_head *head = &hba->clk_list_head;
@@ -1135,6 +1164,9 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba,
 	if (list_empty(head))
 		return false;
 
+	if (hba->use_pm_opp)
+		return freq != hba->clk_scaling.target_freq;
+
 	list_for_each_entry(clki, head, list) {
 		if (!IS_ERR_OR_NULL(clki->clk)) {
 			if (scale_up && clki->max_freq) {
@@ -1331,13 +1363,15 @@ static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err, bool sc
 /**
  * ufshcd_devfreq_scale - scale up/down UFS clocks and gear
  * @hba: per adapter instance
+ * @freq: frequency to scale
  * @scale_up: True for scaling up and false for scalin down
  *
  * Returns 0 for success,
  * Returns -EBUSY if scaling can't happen at this time
  * Returns non-zero for any other errors
  */
-static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
+static int ufshcd_devfreq_scale(struct ufs_hba *hba, unsigned long freq,
+				bool scale_up)
 {
 	int ret = 0;
 
@@ -1352,7 +1386,7 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
 			goto out_unprepare;
 	}
 
-	ret = ufshcd_scale_clks(hba, scale_up);
+	ret = ufshcd_scale_clks(hba, freq, scale_up);
 	if (ret) {
 		if (!scale_up)
 			ufshcd_scale_gear(hba, true);
@@ -1363,7 +1397,8 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
 	if (scale_up) {
 		ret = ufshcd_scale_gear(hba, true);
 		if (ret) {
-			ufshcd_scale_clks(hba, false);
+			ufshcd_scale_clks(hba, hba->devfreq->previous_freq,
+					  false);
 			goto out_unprepare;
 		}
 	}
@@ -1421,9 +1456,22 @@ static int ufshcd_devfreq_target(struct device *dev,
 	if (!ufshcd_is_clkscaling_supported(hba))
 		return -EINVAL;
 
-	clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, list);
-	/* Override with the closest supported frequency */
-	*freq = (unsigned long) clk_round_rate(clki->clk, *freq);
+	if (hba->use_pm_opp) {
+		struct dev_pm_opp *opp;
+
+		/* Get the recommended frequency from OPP framework */
+		opp = devfreq_recommended_opp(dev, freq, flags);
+		if (IS_ERR(opp))
+			return PTR_ERR(opp);
+
+		dev_pm_opp_put(opp);
+	} else {
+		/* Override with the closest supported frequency */
+		clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info,
+					list);
+		*freq =	(unsigned long) clk_round_rate(clki->clk, *freq);
+	}
+
 	spin_lock_irqsave(hba->host->host_lock, irq_flags);
 	if (ufshcd_eh_in_progress(hba)) {
 		spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
@@ -1438,12 +1486,17 @@ static int ufshcd_devfreq_target(struct device *dev,
 		goto out;
 	}
 
-	/* Decide based on the rounded-off frequency and update */
-	scale_up = *freq == clki->max_freq;
-	if (!scale_up)
+	/* Decide based on the target or rounded-off frequency and update */
+	if (hba->use_pm_opp)
+		scale_up = *freq > hba->clk_scaling.target_freq;
+	else
+		scale_up = *freq == clki->max_freq;
+
+	if (!hba->use_pm_opp && !scale_up)
 		*freq = clki->min_freq;
+
 	/* Update the frequency */
-	if (!ufshcd_is_devfreq_scaling_required(hba, scale_up)) {
+	if (!ufshcd_is_devfreq_scaling_required(hba, *freq, scale_up)) {
 		spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
 		ret = 0;
 		goto out; /* no state change required */
@@ -1451,7 +1504,9 @@ static int ufshcd_devfreq_target(struct device *dev,
 	spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
 
 	start = ktime_get();
-	ret = ufshcd_devfreq_scale(hba, scale_up);
+	ret = ufshcd_devfreq_scale(hba, *freq, scale_up);
+	if (!ret)
+		hba->clk_scaling.target_freq = *freq;
 
 	trace_ufshcd_profile_clk_scaling(dev_name(hba->dev),
 		(scale_up ? "up" : "down"),
@@ -1471,8 +1526,6 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
 	struct ufs_hba *hba = dev_get_drvdata(dev);
 	struct ufs_clk_scaling *scaling = &hba->clk_scaling;
 	unsigned long flags;
-	struct list_head *clk_list = &hba->clk_list_head;
-	struct ufs_clk_info *clki;
 	ktime_t curr_t;
 
 	if (!ufshcd_is_clkscaling_supported(hba))
@@ -1485,17 +1538,24 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
 	if (!scaling->window_start_t)
 		goto start_window;
 
-	clki = list_first_entry(clk_list, struct ufs_clk_info, list);
 	/*
 	 * If current frequency is 0, then the ondemand governor considers
 	 * there's no initial frequency set. And it always requests to set
 	 * to max. frequency.
 	 */
-	stat->current_frequency = clki->curr_freq;
+	if (hba->use_pm_opp) {
+		stat->current_frequency = hba->clk_scaling.target_freq;
+	} else {
+		struct list_head *clk_list = &hba->clk_list_head;
+		struct ufs_clk_info *clki;
+
+		clki = list_first_entry(clk_list, struct ufs_clk_info, list);
+		stat->current_frequency = clki->curr_freq;
+	}
+
 	if (scaling->is_busy_started)
 		scaling->tot_busy_t += ktime_us_delta(curr_t,
 				scaling->busy_start_t);
-
 	stat->total_time = ktime_us_delta(curr_t, scaling->window_start_t);
 	stat->busy_time = scaling->tot_busy_t;
 start_window:
@@ -1524,9 +1584,11 @@ static int ufshcd_devfreq_init(struct ufs_hba *hba)
 	if (list_empty(clk_list))
 		return 0;
 
-	clki = list_first_entry(clk_list, struct ufs_clk_info, list);
-	dev_pm_opp_add(hba->dev, clki->min_freq, 0);
-	dev_pm_opp_add(hba->dev, clki->max_freq, 0);
+	if (!hba->use_pm_opp) {
+		clki = list_first_entry(clk_list, struct ufs_clk_info, list);
+		dev_pm_opp_add(hba->dev, clki->min_freq, 0);
+		dev_pm_opp_add(hba->dev, clki->max_freq, 0);
+	}
 
 	ufshcd_vops_config_scaling_param(hba, &hba->vps->devfreq_profile,
 					 &hba->vps->ondemand_data);
@@ -1538,8 +1600,10 @@ static int ufshcd_devfreq_init(struct ufs_hba *hba)
 		ret = PTR_ERR(devfreq);
 		dev_err(hba->dev, "Unable to register with devfreq %d\n", ret);
 
-		dev_pm_opp_remove(hba->dev, clki->min_freq);
-		dev_pm_opp_remove(hba->dev, clki->max_freq);
+		if (!hba->use_pm_opp) {
+			dev_pm_opp_remove(hba->dev, clki->min_freq);
+			dev_pm_opp_remove(hba->dev, clki->max_freq);
+		}
 		return ret;
 	}
 
@@ -1551,7 +1615,6 @@ static int ufshcd_devfreq_init(struct ufs_hba *hba)
 static void ufshcd_devfreq_remove(struct ufs_hba *hba)
 {
 	struct list_head *clk_list = &hba->clk_list_head;
-	struct ufs_clk_info *clki;
 
 	if (!hba->devfreq)
 		return;
@@ -1559,9 +1622,13 @@ static void ufshcd_devfreq_remove(struct ufs_hba *hba)
 	devfreq_remove_device(hba->devfreq);
 	hba->devfreq = NULL;
 
-	clki = list_first_entry(clk_list, struct ufs_clk_info, list);
-	dev_pm_opp_remove(hba->dev, clki->min_freq);
-	dev_pm_opp_remove(hba->dev, clki->max_freq);
+	if (!hba->use_pm_opp) {
+		struct ufs_clk_info *clki;
+
+		clki = list_first_entry(clk_list, struct ufs_clk_info, list);
+		dev_pm_opp_remove(hba->dev, clki->min_freq);
+		dev_pm_opp_remove(hba->dev, clki->max_freq);
+	}
 }
 
 static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba)
@@ -1646,7 +1713,7 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
 		ufshcd_resume_clkscaling(hba);
 	} else {
 		ufshcd_suspend_clkscaling(hba);
-		err = ufshcd_devfreq_scale(hba, true);
+		err = ufshcd_devfreq_scale(hba, ULONG_MAX, true);
 		if (err)
 			dev_err(hba->dev, "%s: failed to scale clocks up %d\n",
 					__func__, err);
@@ -7666,7 +7733,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
 	hba->silence_err_logs = false;
 
 	/* scale up clocks to max frequency before full reinitialization */
-	ufshcd_scale_clks(hba, true);
+	ufshcd_scale_clks(hba, ULONG_MAX, true);
 
 	err = ufshcd_hba_enable(hba);
 
@@ -9185,6 +9252,17 @@ static int ufshcd_init_clocks(struct ufs_hba *hba)
 		dev_dbg(dev, "%s: clk: %s, rate: %lu\n", __func__,
 				clki->name, clk_get_rate(clki->clk));
 	}
+
+	/* Set Max. frequency for all clocks */
+	if (hba->use_pm_opp) {
+		ret = ufshcd_opp_set_rate(hba, ULONG_MAX);
+		if (ret) {
+			dev_err(hba->dev, "%s: failed to set OPP: %d", __func__,
+				ret);
+			goto out;
+		}
+	}
+
 out:
 	return ret;
 }
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 6dc11fa0ebb1..9f61b6d56d11 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -407,6 +407,7 @@ struct ufs_clk_gating {
  * @workq: workqueue to schedule devfreq suspend/resume work
  * @suspend_work: worker to suspend devfreq
  * @resume_work: worker to resume devfreq
+ * @target_freq: frequency requested by devfreq framework
  * @min_gear: lowest HS gear to scale down to
  * @is_enabled: tracks if scaling is currently enabled or not, controlled by
  *		clkscale_enable sysfs node
@@ -426,6 +427,7 @@ struct ufs_clk_scaling {
 	struct workqueue_struct *workq;
 	struct work_struct suspend_work;
 	struct work_struct resume_work;
+	unsigned long target_freq;
 	u32 min_gear;
 	bool is_enabled;
 	bool is_allowed;
@@ -870,6 +872,7 @@ enum ufshcd_mcq_opr {
  * @auto_bkops_enabled: to track whether bkops is enabled in device
  * @vreg_info: UFS device voltage regulator information
  * @clk_list_head: UFS host controller clocks list node head
+ * @use_pm_opp: Indicates whether OPP based scaling is used or not
  * @req_abort_count: number of times ufshcd_abort() has been called
  * @lanes_per_direction: number of lanes per data direction between the UFS
  *	controller and the UFS device.
@@ -1021,6 +1024,7 @@ struct ufs_hba {
 	bool auto_bkops_enabled;
 	struct ufs_vreg_info vreg_info;
 	struct list_head clk_list_head;
+	bool use_pm_opp;
 
 	/* Number of requests aborts */
 	int req_abort_count;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (9 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 10/15] scsi: ufs: core: Add OPP support for scaling clocks and regulators Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20 21:32   ` kernel test robot
  2023-07-20 23:26   ` kernel test robot
  2023-07-20  5:40 ` [PATCH v2 12/15] arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC Manivannan Sadhasivam
                   ` (6 subsequent siblings)
  17 siblings, 2 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

OPP framework can be used to scale the clocks along with other entities
such as regulators, performance state etc... So let's add support for
parsing OPP from devicetree. OPP support in devicetree is added through
the "operating-points-v2" property which accepts the OPP table defining
clock frequency, regulator voltage, power domain performance state etc...

Since the UFS controller requires multiple clocks to be controlled for
proper working, devm_pm_opp_set_config() has been used which supports
scaling multiple clocks through custom ufshcd_opp_config_clks() callback.

It should be noted that the OPP support is not compatible with the old
"freq-table-hz" property. So only one can be used at a time even though
the UFS core supports both.

Co-developed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/ufs/host/ufshcd-pltfrm.c | 116 +++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)

diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index 0b7430033047..068c22378c88 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -8,8 +8,10 @@
  *	Vinayak Holikatti <h.vinayak@samsung.com>
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_opp.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
 
@@ -17,6 +19,8 @@
 #include "ufshcd-pltfrm.h"
 #include <ufs/unipro.h>
 
+#include <trace/events/ufs.h>
+
 #define UFSHCD_DEFAULT_LANES_PER_DIRECTION		2
 
 static int ufshcd_parse_clock_info(struct ufs_hba *hba)
@@ -205,6 +209,112 @@ static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba)
 	}
 }
 
+static int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table,
+				  struct dev_pm_opp *opp, void *data,
+				  bool scaling_down)
+{
+	struct ufs_hba *hba = dev_get_drvdata(dev);
+	struct list_head *head = &hba->clk_list_head;
+	struct ufs_clk_info *clki;
+	unsigned long freq;
+	u8 idx = 0;
+	int ret;
+
+	list_for_each_entry(clki, head, list) {
+		if (!IS_ERR_OR_NULL(clki->clk)) {
+			freq = dev_pm_opp_get_freq_indexed(opp, idx++);
+
+			/* Do not set rate for clocks having frequency as 0 */
+			if (!freq)
+				continue;
+
+			ret = clk_set_rate(clki->clk, freq);
+			if (ret) {
+				dev_err(dev, "%s: %s clk set rate(%ldHz) failed, %d\n",
+					__func__, clki->name, freq, ret);
+				return ret;
+			}
+
+			trace_ufshcd_clk_scaling(dev_name(dev),
+				(scaling_down ? "scaled down" : "scaled up"),
+				clki->name, hba->clk_scaling.target_freq, freq);
+		}
+	}
+
+	return 0;
+}
+
+static int ufshcd_parse_operating_points(struct ufs_hba *hba)
+{
+	struct device *dev = hba->dev;
+	struct device_node *np = dev->of_node;
+	struct dev_pm_opp_config config = {};
+	struct ufs_clk_info *clki;
+	const char **clk_names;
+	int cnt, i, ret;
+
+	if (!of_find_property(np, "operating-points-v2", NULL))
+		return 0;
+
+	if (of_find_property(np, "freq-table-hz", NULL)) {
+		dev_err(dev, "%s: operating-points and freq-table-hz are incompatible\n",
+			 __func__);
+		return -EINVAL;
+	}
+
+	cnt = of_property_count_strings(np, "clock-names");
+	if (cnt <= 0) {
+		dev_err(dev, "%s: Missing clock-names\n",  __func__);
+		return -ENODEV;
+	}
+
+	/* OPP expects clk_names to be NULL terminated */
+	clk_names = devm_kcalloc(dev, cnt + 1, sizeof(*clk_names), GFP_KERNEL);
+	if (!clk_names)
+		return -ENOMEM;
+
+	/*
+	 * We still need to get reference to all clocks as the UFS core uses
+	 * them separately.
+	 */
+	for (i = 0; i < cnt; i++) {
+		ret = of_property_read_string_index(np, "clock-names", i,
+						    &clk_names[i]);
+		if (ret)
+			return ret;
+
+		clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL);
+		if (!clki)
+			return -ENOMEM;
+
+		clki->name = devm_kstrdup(dev, clk_names[i], GFP_KERNEL);
+		if (!clki->name)
+			return -ENOMEM;
+
+		if (!strcmp(clk_names[i], "ref_clk"))
+			clki->keep_link_active = true;
+
+		list_add_tail(&clki->list, &hba->clk_list_head);
+	}
+
+	config.clk_names = clk_names,
+	config.config_clks = ufshcd_opp_config_clks;
+
+	ret = devm_pm_opp_set_config(dev, &config);
+	if (ret)
+		return ret;
+
+	ret = devm_pm_opp_of_add_table(dev);
+	if (ret) {
+		dev_err(dev, "Failed to add OPP table: %d\n", ret);
+		return ret;
+	}
+
+	hba->use_pm_opp = true;
+
+	return 0;
+}
+
 /**
  * ufshcd_get_pwr_dev_param - get finally agreed attributes for
  *                            power mode change
@@ -371,6 +481,12 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
 
 	ufshcd_init_lanes_per_dir(hba);
 
+	err = ufshcd_parse_operating_points(hba);
+	if (err) {
+		dev_err(dev, "%s: OPP parse failed %d\n", __func__, err);
+		goto dealloc_host;
+	}
+
 	err = ufshcd_init(hba, mmio_base, irq);
 	if (err) {
 		dev_err(dev, "Initialization failed\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 12/15] arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (10 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 13/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

UFS host controller requires interconnect path configuration for proper
working. So let's specify them for SDM845 SoC.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index e04a3cbb1017..2ea6eb44953e 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -2607,6 +2607,11 @@ ufs_mem_hc: ufshc@1d84000 {
 				<&gcc GCC_UFS_PHY_ICE_CORE_CLK>;
 
 			operating-points-v2 = <&ufs_opp_table>;
+
+			interconnects = <&aggre1_noc MASTER_UFS_MEM 0 &mem_noc SLAVE_EBI1 0>,
+					<&gladiator_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_UFS_MEM_CFG 0>;
+			interconnect-names = "ufs-ddr", "cpu-ufs";
+
 			status = "disabled";
 
 			ufs_opp_table: opp-table {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 13/15] arm64: dts: qcom: sm8250: Add interconnect paths to UFSHC
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (11 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 12/15] arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:40 ` [PATCH v2 14/15] scsi: ufs: core: Add enums for UFS lanes Manivannan Sadhasivam
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

UFS host controller requires interconnect path configuration for proper
working. So let's specify them for SM8250 SoC.

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 72fd66db9c51..7a495ff7512f 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2197,6 +2197,10 @@ ufs_mem_hc: ufshc@1d84000 {
 
 			operating-points-v2 = <&ufs_opp_table>;
 
+			interconnects = <&aggre1_noc MASTER_UFS_MEM 0 &mc_virt SLAVE_EBI_CH0 0>,
+					<&gem_noc MASTER_AMPSS_M0 0 &config_noc SLAVE_UFS_MEM_CFG 0>;
+			interconnect-names = "ufs-ddr", "cpu-ufs";
+
 			status = "disabled";
 
 			ufs_opp_table: opp-table {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 14/15] scsi: ufs: core: Add enums for UFS lanes
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (12 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 13/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
@ 2023-07-20  5:40 ` Manivannan Sadhasivam
  2023-07-20  5:41 ` [PATCH v2 15/15] scsi: ufs: qcom: Add support for scaling interconnects Manivannan Sadhasivam
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:40 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Since there are enums available for UFS gears, let's add enums for lanes
as well to maintain uniformity.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/ufs/core/ufshcd.c        | 4 ++--
 drivers/ufs/host/ufshcd-pltfrm.c | 4 ++--
 include/ufs/unipro.h             | 6 ++++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 6207afac729d..4496a23eaa83 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4447,8 +4447,8 @@ static void ufshcd_init_pwr_info(struct ufs_hba *hba)
 {
 	hba->pwr_info.gear_rx = UFS_PWM_G1;
 	hba->pwr_info.gear_tx = UFS_PWM_G1;
-	hba->pwr_info.lane_rx = 1;
-	hba->pwr_info.lane_tx = 1;
+	hba->pwr_info.lane_rx = UFS_LANE_1;
+	hba->pwr_info.lane_tx = UFS_LANE_1;
 	hba->pwr_info.pwr_rx = SLOWAUTO_MODE;
 	hba->pwr_info.pwr_tx = SLOWAUTO_MODE;
 	hba->pwr_info.hs_rate = 0;
diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index 068c22378c88..8d20cbb552aa 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -415,8 +415,8 @@ EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
 void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
 {
 	*dev_param = (struct ufs_dev_params){
-		.tx_lanes = 2,
-		.rx_lanes = 2,
+		.tx_lanes = UFS_LANE_2,
+		.rx_lanes = UFS_LANE_2,
 		.hs_rx_gear = UFS_HS_G3,
 		.hs_tx_gear = UFS_HS_G3,
 		.pwm_rx_gear = UFS_PWM_G4,
diff --git a/include/ufs/unipro.h b/include/ufs/unipro.h
index dc9dd1d23f0f..256eb3a43f54 100644
--- a/include/ufs/unipro.h
+++ b/include/ufs/unipro.h
@@ -230,6 +230,12 @@ enum ufs_hs_gear_tag {
 	UFS_HS_G5		/* HS Gear 5 */
 };
 
+enum ufs_lanes {
+	UFS_LANE_DONT_CHANGE,	/* Don't change Lane */
+	UFS_LANE_1,		/* Lane 1 (default for reset) */
+	UFS_LANE_2,		/* Lane 2 */
+};
+
 enum ufs_unipro_ver {
 	UFS_UNIPRO_VER_RESERVED = 0,
 	UFS_UNIPRO_VER_1_40 = 1, /* UniPro version 1.40 */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v2 15/15] scsi: ufs: qcom: Add support for scaling interconnects
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (13 preceding siblings ...)
  2023-07-20  5:40 ` [PATCH v2 14/15] scsi: ufs: core: Add enums for UFS lanes Manivannan Sadhasivam
@ 2023-07-20  5:41 ` Manivannan Sadhasivam
  2023-07-20 16:44 ` [PATCH v2 00/15] UFS: Add OPP and interconnect support Bart Van Assche
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20  5:41 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel, Manivannan Sadhasivam

Qcom SoCs require scaling the interconnect paths for proper working of the
peripherals connected through interconnects. Even for accessing the UFS
controller, someone should setup the interconnect paths. So far, the
bootloaders used to setup the interconnect paths before booting linux as
they need to access the UFS storage for things like fetching boot firmware.
But with the advent of multi boot options, bootloader nowadays like in
SA8540p SoC do not setup the interconnect paths at all.

So trying to configure UFS in the absence of the interconnect path
configuration, results in boot crash.

To fix this issue and also to dynamically scale the interconnects (UFS-DDR
and CPU-UFS), interconnect API support is added to the Qcom UFS driver.
With this support, the interconnect paths are scaled dynamically based on
the gear configuration.

During the early stage of ufs_qcom_init(), ufs_qcom_icc_init() will setup
the paths to max bandwidth to allow configuring the UFS registers. Touching
the registers without configuring the icc paths would result in a crash.
However, we don't really need to set max vote for the icc paths as any
minimal vote would suffice. But the max value would allow initialization to
be done faster. After init, the bandwidth will get updated using
ufs_qcom_icc_update_bw() based on the gear and lane configuration.

The bandwidth values defined in ufs_qcom_bw_table struct are taken from
Qcom downstream vendor devicetree source and are calculated as per the
UFS3.1 Spec, Section 6.4.1, HS Gear Rates. So it is fixed across platforms.

Cc: Brian Masney <bmasney@redhat.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/ufs/host/ufs-qcom.c | 131 +++++++++++++++++++++++++++++++++++-
 drivers/ufs/host/ufs-qcom.h |   3 +
 2 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 8d6fd4c3324f..2ab09d65f1f4 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -7,6 +7,7 @@
 #include <linux/time.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/interconnect.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -46,6 +47,49 @@ enum {
 	TSTBUS_MAX,
 };
 
+#define QCOM_UFS_MAX_GEAR 4
+#define QCOM_UFS_MAX_LANE 2
+
+enum {
+	MODE_MIN,
+	MODE_PWM,
+	MODE_HS_RA,
+	MODE_HS_RB,
+	MODE_MAX,
+};
+
+struct __ufs_qcom_bw_table {
+	u32 mem_bw;
+	u32 cfg_bw;
+} ufs_qcom_bw_table[MODE_MAX + 1][QCOM_UFS_MAX_GEAR + 1][QCOM_UFS_MAX_LANE + 1] = {
+	[MODE_MIN][0][0]		   = { 0,		0 }, /* Bandwidth values in KB/s */
+	[MODE_PWM][UFS_PWM_G1][UFS_LANE_1] = { 922,		1000 },
+	[MODE_PWM][UFS_PWM_G2][UFS_LANE_1] = { 1844,		1000 },
+	[MODE_PWM][UFS_PWM_G3][UFS_LANE_1] = { 3688,		1000 },
+	[MODE_PWM][UFS_PWM_G4][UFS_LANE_1] = { 7376,		1000 },
+	[MODE_PWM][UFS_PWM_G1][UFS_LANE_2] = { 1844,		1000 },
+	[MODE_PWM][UFS_PWM_G2][UFS_LANE_2] = { 3688,		1000 },
+	[MODE_PWM][UFS_PWM_G3][UFS_LANE_2] = { 7376,		1000 },
+	[MODE_PWM][UFS_PWM_G4][UFS_LANE_2] = { 14752,		1000 },
+	[MODE_HS_RA][UFS_HS_G1][UFS_LANE_1] = { 127796,		1000 },
+	[MODE_HS_RA][UFS_HS_G2][UFS_LANE_1] = { 255591,		1000 },
+	[MODE_HS_RA][UFS_HS_G3][UFS_LANE_1] = { 1492582,	102400 },
+	[MODE_HS_RA][UFS_HS_G4][UFS_LANE_1] = { 2915200,	204800 },
+	[MODE_HS_RA][UFS_HS_G1][UFS_LANE_2] = { 255591,		1000 },
+	[MODE_HS_RA][UFS_HS_G2][UFS_LANE_2] = { 511181,		1000 },
+	[MODE_HS_RA][UFS_HS_G3][UFS_LANE_2] = { 1492582,	204800 },
+	[MODE_HS_RA][UFS_HS_G4][UFS_LANE_2] = { 2915200,	409600 },
+	[MODE_HS_RB][UFS_HS_G1][UFS_LANE_1] = { 149422,		1000 },
+	[MODE_HS_RB][UFS_HS_G2][UFS_LANE_1] = { 298189,		1000 },
+	[MODE_HS_RB][UFS_HS_G3][UFS_LANE_1] = { 1492582,	102400 },
+	[MODE_HS_RB][UFS_HS_G4][UFS_LANE_1] = { 2915200,	204800 },
+	[MODE_HS_RB][UFS_HS_G1][UFS_LANE_2] = { 298189,		1000 },
+	[MODE_HS_RB][UFS_HS_G2][UFS_LANE_2] = { 596378,		1000 },
+	[MODE_HS_RB][UFS_HS_G3][UFS_LANE_2] = { 1492582,	204800 },
+	[MODE_HS_RB][UFS_HS_G4][UFS_LANE_2] = { 2915200,	409600 },
+	[MODE_MAX][0][0]		    = { 7643136,	307200 },
+};
+
 static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
 
 static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
@@ -789,6 +833,51 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)
 	}
 }
 
+static int ufs_qcom_icc_set_bw(struct ufs_qcom_host *host, u32 mem_bw, u32 cfg_bw)
+{
+	struct device *dev = host->hba->dev;
+	int ret;
+
+	ret = icc_set_bw(host->icc_ddr, 0, mem_bw);
+	if (ret < 0) {
+		dev_err(dev, "failed to set bandwidth request: %d\n", ret);
+		return ret;
+	}
+
+	ret = icc_set_bw(host->icc_cpu, 0, cfg_bw);
+	if (ret < 0) {
+		dev_err(dev, "failed to set bandwidth request: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct __ufs_qcom_bw_table ufs_qcom_get_bw_table(struct ufs_qcom_host *host)
+{
+	struct ufs_pa_layer_attr *p = &host->dev_req_params;
+	int gear = max_t(u32, p->gear_rx, p->gear_tx);
+	int lane = max_t(u32, p->lane_rx, p->lane_tx);
+
+	if (ufshcd_is_hs_mode(p)) {
+		if (p->hs_rate == PA_HS_MODE_B)
+			return ufs_qcom_bw_table[MODE_HS_RB][gear][lane];
+		else
+			return ufs_qcom_bw_table[MODE_HS_RA][gear][lane];
+	} else {
+		return ufs_qcom_bw_table[MODE_PWM][gear][lane];
+	}
+}
+
+static int ufs_qcom_icc_update_bw(struct ufs_qcom_host *host)
+{
+	struct __ufs_qcom_bw_table bw_table;
+
+	bw_table = ufs_qcom_get_bw_table(host);
+
+	return ufs_qcom_icc_set_bw(host, bw_table.mem_bw, bw_table.cfg_bw);
+}
+
 static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
 				enum ufs_notify_change_status status,
 				struct ufs_pa_layer_attr *dev_max_params,
@@ -852,6 +941,8 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
 		memcpy(&host->dev_req_params,
 				dev_req_params, sizeof(*dev_req_params));
 
+		ufs_qcom_icc_update_bw(host);
+
 		/* disable the device ref clock if entered PWM mode */
 		if (ufshcd_is_hs_mode(&hba->pwr_info) &&
 			!ufshcd_is_hs_mode(dev_req_params))
@@ -981,7 +1072,9 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
 
 	switch (status) {
 	case PRE_CHANGE:
-		if (!on) {
+		if (on) {
+			ufs_qcom_icc_update_bw(host);
+		} else {
 			if (!ufs_qcom_is_link_active(hba)) {
 				/* disable device ref_clk */
 				ufs_qcom_dev_ref_clk_ctrl(host, false);
@@ -993,6 +1086,9 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
 			/* enable the device ref clock for HS mode*/
 			if (ufshcd_is_hs_mode(&hba->pwr_info))
 				ufs_qcom_dev_ref_clk_ctrl(host, true);
+		} else {
+			ufs_qcom_icc_set_bw(host, ufs_qcom_bw_table[MODE_MIN][0][0].mem_bw,
+					    ufs_qcom_bw_table[MODE_MIN][0][0].cfg_bw);
 		}
 		break;
 	}
@@ -1031,6 +1127,34 @@ static const struct reset_control_ops ufs_qcom_reset_ops = {
 	.deassert = ufs_qcom_reset_deassert,
 };
 
+static int ufs_qcom_icc_init(struct ufs_qcom_host *host)
+{
+	struct device *dev = host->hba->dev;
+	int ret;
+
+	host->icc_ddr = devm_of_icc_get(dev, "ufs-ddr");
+	if (IS_ERR(host->icc_ddr))
+		return dev_err_probe(dev, PTR_ERR(host->icc_ddr),
+				    "failed to acquire interconnect path\n");
+
+	host->icc_cpu = devm_of_icc_get(dev, "cpu-ufs");
+	if (IS_ERR(host->icc_cpu))
+		return dev_err_probe(dev, PTR_ERR(host->icc_cpu),
+				    "failed to acquire interconnect path\n");
+
+	/*
+	 * Set Maximum bandwidth vote before initializing the UFS controller and
+	 * device. Ideally, a minimal interconnect vote would suffice for the
+	 * initialization, but a max vote would allow faster initialization.
+	 */
+	ret = ufs_qcom_icc_set_bw(host, ufs_qcom_bw_table[MODE_MAX][0][0].mem_bw,
+				  ufs_qcom_bw_table[MODE_MAX][0][0].cfg_bw);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "failed to set bandwidth request\n");
+
+	return 0;
+}
+
 /**
  * ufs_qcom_init - bind phy with controller
  * @hba: host controller instance
@@ -1085,6 +1209,10 @@ static int ufs_qcom_init(struct ufs_hba *hba)
 		}
 	}
 
+	err = ufs_qcom_icc_init(host);
+	if (err)
+		goto out_variant_clear;
+
 	host->device_reset = devm_gpiod_get_optional(dev, "reset",
 						     GPIOD_OUT_HIGH);
 	if (IS_ERR(host->device_reset)) {
@@ -1282,6 +1410,7 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba,
 				    dev_req_params->pwr_rx,
 				    dev_req_params->hs_rate,
 				    false);
+		ufs_qcom_icc_update_bw(host);
 		ufshcd_uic_hibern8_exit(hba);
 	}
 
diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
index 6289ad5a42d0..dc27395ecba1 100644
--- a/drivers/ufs/host/ufs-qcom.h
+++ b/drivers/ufs/host/ufs-qcom.h
@@ -206,6 +206,9 @@ struct ufs_qcom_host {
 	struct clk *tx_l1_sync_clk;
 	bool is_lane_clks_enabled;
 
+	struct icc_path *icc_ddr;
+	struct icc_path *icc_cpu;
+
 #ifdef CONFIG_SCSI_UFS_CRYPTO
 	struct qcom_ice *ice;
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (14 preceding siblings ...)
  2023-07-20  5:41 ` [PATCH v2 15/15] scsi: ufs: qcom: Add support for scaling interconnects Manivannan Sadhasivam
@ 2023-07-20 16:44 ` Bart Van Assche
  2023-07-20 16:57   ` Manivannan Sadhasivam
  2023-07-21  9:42 ` Viresh Kumar
  2023-07-22  5:17 ` (subset) " Bjorn Andersson
  17 siblings, 1 reply; 34+ messages in thread
From: Bart Van Assche @ 2023-07-20 16:44 UTC (permalink / raw)
  To: Manivannan Sadhasivam, vireshk, nm, sboyd, myungjoo.ham,
	kyungmin.park, cw00.choi, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, linux-scsi, linux-pm, linux-arm-msm,
	devicetree, quic_asutoshd, quic_cang, quic_nitirawa,
	quic_narepall, quic_bhaskarv, quic_richardp, quic_nguyenb,
	quic_ziqichen, bmasney, krzysztof.kozlowski, linux-kernel

On 7/19/23 22:40, Manivannan Sadhasivam wrote:
> This series adds OPP (Operating Points) support to UFSHCD driver and
> interconnect support to Qcom UFS driver.
> 
> Motivation behind adding OPP support is to scale both clocks as well as
> regulators/performance state dynamically. Currently, UFSHCD just scales
> clock frequency during runtime with the help of "freq-table-hz" property
> defined in devicetree. With the addition of OPP tables in devicetree (as
> done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> both clocks and performance state of power domain which helps in power
> saving.
> 
> For the addition of OPP support to UFSHCD, there are changes required to
> the OPP framework and devfreq drivers which are also added in this series.
> 
> Finally, interconnect support is added to Qcom UFS driver for scaling the
> interconnect path dynamically. This is required to avoid boot crash in
> recent SoCs and also to save power during runtime. More information is
> available in patch 13/13.

How much power can OPP save? I'm asking this since I'm wondering whether
the power saved by OPP outweighs the complexity added by this patch series.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-20 16:44 ` [PATCH v2 00/15] UFS: Add OPP and interconnect support Bart Van Assche
@ 2023-07-20 16:57   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-20 16:57 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	linux-scsi, linux-pm, linux-arm-msm, devicetree, quic_asutoshd,
	quic_cang, quic_nitirawa, quic_narepall, quic_bhaskarv,
	quic_richardp, quic_nguyenb, quic_ziqichen, bmasney,
	krzysztof.kozlowski, linux-kernel

On Thu, Jul 20, 2023 at 09:44:38AM -0700, Bart Van Assche wrote:
> On 7/19/23 22:40, Manivannan Sadhasivam wrote:
> > This series adds OPP (Operating Points) support to UFSHCD driver and
> > interconnect support to Qcom UFS driver.
> > 
> > Motivation behind adding OPP support is to scale both clocks as well as
> > regulators/performance state dynamically. Currently, UFSHCD just scales
> > clock frequency during runtime with the help of "freq-table-hz" property
> > defined in devicetree. With the addition of OPP tables in devicetree (as
> > done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> > both clocks and performance state of power domain which helps in power
> > saving.
> > 
> > For the addition of OPP support to UFSHCD, there are changes required to
> > the OPP framework and devfreq drivers which are also added in this series.
> > 
> > Finally, interconnect support is added to Qcom UFS driver for scaling the
> > interconnect path dynamically. This is required to avoid boot crash in
> > recent SoCs and also to save power during runtime. More information is
> > available in patch 13/13.
> 
> How much power can OPP save? I'm asking this since I'm wondering whether
> the power saved by OPP outweighs the complexity added by this patch series.
> 

I haven't had a chance to do proper power measurements with this series due to
lack of access to tools. But it won't be optimal to run the clocks at high/low
frequencies without changing the associated regulator/power domain state.

Atleast on Qcom platforms, the clock frequencies are tied to RPMh (power
management entity) performance states for the peripherals. So both have to go
hand in hand. Till now, only UFS among the other peripherals is not doing it
right and hence this series.

- Mani

> Thanks,
> 
> Bart.

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP
  2023-07-20  5:40 ` [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP Manivannan Sadhasivam
@ 2023-07-20 21:32   ` kernel test robot
  2023-07-20 23:26   ` kernel test robot
  1 sibling, 0 replies; 34+ messages in thread
From: kernel test robot @ 2023-07-20 21:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, vireshk, nm, sboyd, myungjoo.ham,
	kyungmin.park, cw00.choi, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, jejb, martin.petersen
  Cc: oe-kbuild-all, alim.akhtar, avri.altman, bvanassche, linux-scsi,
	linux-pm, linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski

Hi Manivannan,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on mkp-scsi/for-next jejb-scsi/for-next linus/master v6.5-rc2 next-20230720]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam/dt-bindings-ufs-common-add-OPP-table/20230720-134720
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20230720054100.9940-12-manivannan.sadhasivam%40linaro.org
patch subject: [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP
config: i386-randconfig-m021-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210542.KoLHRbU6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210542.KoLHRbU6-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307210542.KoLHRbU6-lkp@intel.com/

All errors (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-nebula.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-norwood.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-npgtech.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-odroid.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pctv-sedna.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pine64.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pinnacle-color.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pinnacle-grey.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pixelview-002t.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pixelview-mk12.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pixelview-new.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pixelview.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-powercolor-real-angel.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-proteus-2309.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-purpletv.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-pv951.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-rc6-mce.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-real-audio-220-32-keys.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-reddo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-snapstream-firefly.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-streamzap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-su3000.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tanix-tx3mini.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tanix-tx5max.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tbs-nec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-technisat-ts35.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-technisat-usb2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-terratec-cinergy-xs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-terratec-slim-2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-terratec-slim.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tevii-nec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tivo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-total-media-in-hand-02.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-total-media-in-hand.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-trekstor.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-tt-1500.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-twinhan1027.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-vega-s9x.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-videomate-m1f.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-videomate-s350.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-videomate-tv-pvr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-videostrong-kii-pro.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-wetek-hub.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-wetek-play2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-winfast.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-x96max.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-xbox-360.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-xbox-dvd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/keymaps/rc-zx-irdec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/rc-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/hfcpci.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/hfcmulti.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/speedfax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/mISDNinfineon.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/w6692.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/netjet.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/mISDNipac.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/mISDNisar.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/mISDN_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/mISDN_dsp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/l1oip.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-bootrom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-spilib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-light.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-loopback.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/staging/greybus/gb-vibrator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rpmsg/rpmsg_char.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_simpleondemand.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/perf/cxl_pmu.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/pcmcia_rsrc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/yenta_socket.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/i82365.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/i82092.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwmon/asus_atk0110.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/greybus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/buffer/kfifo_buf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/siox/siox-bus-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/configfs/configfs_sample.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/bytestream-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/dma-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/inttype-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/record-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kobject-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kset-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kprobes/kprobe_example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kprobes/kretprobe_example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kmemleak/kmemleak-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/802/fddi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/nfc/nci/nci.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/nfc/nci/nci_spi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/atm/atm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/hsr/hsr.o
>> ERROR: modpost: "__tracepoint_ufshcd_clk_scaling" [drivers/ufs/host/ufshcd-pltfrm.ko] undefined!
>> ERROR: modpost: "__SCT__tp_func_ufshcd_clk_scaling" [drivers/ufs/host/ufshcd-pltfrm.ko] undefined!

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP
  2023-07-20  5:40 ` [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP Manivannan Sadhasivam
  2023-07-20 21:32   ` kernel test robot
@ 2023-07-20 23:26   ` kernel test robot
  1 sibling, 0 replies; 34+ messages in thread
From: kernel test robot @ 2023-07-20 23:26 UTC (permalink / raw)
  To: Manivannan Sadhasivam, vireshk, nm, sboyd, myungjoo.ham,
	kyungmin.park, cw00.choi, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, jejb, martin.petersen
  Cc: oe-kbuild-all, alim.akhtar, avri.altman, bvanassche, linux-scsi,
	linux-pm, linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski

Hi Manivannan,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on mkp-scsi/for-next jejb-scsi/for-next linus/master v6.5-rc2 next-20230720]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam/dt-bindings-ufs-common-add-OPP-table/20230720-134720
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20230720054100.9940-12-manivannan.sadhasivam%40linaro.org
patch subject: [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP
config: arm-randconfig-r046-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210720.G9ca0YYu-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210720.G9ca0YYu-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307210720.G9ca0YYu-lkp@intel.com/

All errors (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/rc-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/common/uvc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/platform/marvell/mcam-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/usb/dvb-usb/dvb-usb-dibusb-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/usb/dvb-usb/dvb-usb-dibusb-mc-common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/dvb-frontends/au8522_decoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-async.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-fwnode.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/hfcpci.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/hfcmulti.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/avmfritz.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/w6692.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/netjet.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/hardware/mISDN/mISDNipac.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/mISDN_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/mISDN_dsp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/isdn/mISDN/l1oip.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/mmc_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/pwrseq_simple.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/pwrseq_emmc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/sdio_uart.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/chrome/cros_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem_u-boot-env.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/parport/parport.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_util.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/maps/map_funcs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio_pruss.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/uio/uio_mf624.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/pcmcia_rsrc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pcmcia/i82092.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/greybus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iio/buffer/kfifo_buf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-aspeed.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-scom.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/802/fddi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/sch_netem.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/sch_plug.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/sch_mqprio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/sch_mqprio_lib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/sch_taprio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/cls_u32.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/cls_basic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/sched/cls_cgroup.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nf_conntrack.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nf_conntrack_netlink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nf_conntrack_broadcast.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nf_nat.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nf_tables.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nft_fib.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nft_chain_nat.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/nft_fwd_netdev.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_wrr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_wlc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_fo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_ovf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_lblc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_lblcr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/netfilter/ipvs/ip_vs_sh.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/netfilter/nf_defrag_ipv4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/netfilter/nf_reject_ipv4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/netfilter/iptable_nat.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/ipip.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/ip_vti.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/ah4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/esp4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/tunnel4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ipv4/udp_diag.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/xfrm/xfrm_algo.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/xfrm/xfrm_user.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_ar9331.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_brcm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_dsa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_gswip.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_hellcreek.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_ksz.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_lan9303.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_mtk.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_none.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_ocelot.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_ocelot_8021q.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_qca.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_rtl4_a.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_rtl8_4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_rzn1_a5psw.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_trailer.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/dsa/tag_xrs700x.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/mptcp/mptcp_crypto_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/mptcp/mptcp_token_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/kcm/kcm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/atm/atm.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/atm/lec.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/atm/mpoa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/ieee802154/ieee802154_socket.o
WARNING: modpost: missing MODULE_DESCRIPTION() in net/hsr/hsr.o
>> ERROR: modpost: "__traceiter_ufshcd_clk_scaling" [drivers/ufs/host/ufshcd-pltfrm.ko] undefined!
>> ERROR: modpost: "__tracepoint_ufshcd_clk_scaling" [drivers/ufs/host/ufshcd-pltfrm.ko] undefined!

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API
  2023-07-20  5:40 ` [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API Manivannan Sadhasivam
@ 2023-07-21  5:54   ` Dan Carpenter
  0 siblings, 0 replies; 34+ messages in thread
From: Dan Carpenter @ 2023-07-21  5:54 UTC (permalink / raw)
  To: oe-kbuild, Manivannan Sadhasivam, vireshk, nm, sboyd,
	myungjoo.ham, kyungmin.park, cw00.choi, andersson, konrad.dybcio,
	robh+dt, krzysztof.kozlowski+dt, conor+dt, jejb, martin.petersen
  Cc: lkp, oe-kbuild-all, alim.akhtar, avri.altman, bvanassche,
	linux-scsi, linux-pm, linux-arm-msm, devicetree, quic_asutoshd,
	quic_cang, quic_nitirawa, quic_narepall, quic_bhaskarv,
	quic_richardp, quic_nguyenb, quic_ziqichen, bmasney,
	krzysztof.kozlowski

Hi Manivannan,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam/dt-bindings-ufs-common-add-OPP-table/20230720-134720
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20230720054100.9940-9-manivannan.sadhasivam%40linaro.org
patch subject: [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API
config: i386-randconfig-m041-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210431.3S4SeXVw-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210431.3S4SeXVw-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202307210431.3S4SeXVw-lkp@intel.com/

New smatch warnings:
drivers/opp/core.c:213 dev_pm_opp_get_freq_indexed() warn: variable dereferenced before IS_ERR check 'opp' (see line 211)

Old smatch warnings:
drivers/opp/core.c:254 dev_pm_opp_get_required_pstate() warn: variable dereferenced before IS_ERR check 'opp' (see line 252)
drivers/opp/core.c:2458 _opp_attach_genpd() warn: passing zero to 'PTR_ERR'

vim +/opp +213 drivers/opp/core.c

a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  209  unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  210  {
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20 @211  	struct opp_table *opp_table = opp->opp_table;
                                                                                                              ^^^^^^^^^^^^^^^
Dereference

a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  212  
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20 @213  	if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) {
                                                                                                   ^^^
Checked too late

a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  214  		pr_err("%s: Invalid parameters\n", __func__);

This should be a dev_err(), btw.

a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  215  		return 0;
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  216  	}
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  217  
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  218  	return opp->rates[index];
a772c36cb3fb41 drivers/opp/core.c       Manivannan Sadhasivam 2023-07-20  219  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  2023-07-20  5:40 ` [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk" Manivannan Sadhasivam
@ 2023-07-21  7:18   ` Viresh Kumar
  2023-07-21 11:57     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 34+ messages in thread
From: Viresh Kumar @ 2023-07-21  7:18 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> Minimum frequency of the "ice_core_clk" should be 75MHz as specified in the
> downstream vendor devicetree. So fix it!
> 
> https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.7.3.r1-09300-sdm845.0/arch/arm64/boot/dts/qcom/sdm845.dtsi
> 
> Fixes: 433f9a57298f ("arm64: dts: sdm845: add Inline Crypto Engine registers and clock")
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> index 9ed74bf72d05..89520a9fe1e3 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> @@ -2614,7 +2614,7 @@ ufs_mem_hc: ufshc@1d84000 {
>  				<0 0>,
>  				<0 0>,
>  				<0 0>,
> -				<0 300000000>;
> +				<75000000 300000000>;
>  
>  			status = "disabled";
>  		};

Please keep new feature and fixes like this in separate series. This
could be merged directly in the currently ongoing kernel rc and
doesn't need to wait for this series.

Or at least keep the commit at the top, so another maintainer can
simply pick it.

-- 
viresh

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (15 preceding siblings ...)
  2023-07-20 16:44 ` [PATCH v2 00/15] UFS: Add OPP and interconnect support Bart Van Assche
@ 2023-07-21  9:42 ` Viresh Kumar
  2023-07-21 11:54   ` Manivannan Sadhasivam
  2023-07-22  5:17 ` (subset) " Bjorn Andersson
  17 siblings, 1 reply; 34+ messages in thread
From: Viresh Kumar @ 2023-07-21  9:42 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> Hi,
> 
> This series adds OPP (Operating Points) support to UFSHCD driver and
> interconnect support to Qcom UFS driver.
> 
> Motivation behind adding OPP support is to scale both clocks as well as
> regulators/performance state dynamically. Currently, UFSHCD just scales
> clock frequency during runtime with the help of "freq-table-hz" property
> defined in devicetree. With the addition of OPP tables in devicetree (as
> done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> both clocks and performance state of power domain which helps in power
> saving.
> 
> For the addition of OPP support to UFSHCD, there are changes required to
> the OPP framework and devfreq drivers which are also added in this series.
> 
> Finally, interconnect support is added to Qcom UFS driver for scaling the
> interconnect path dynamically. This is required to avoid boot crash in
> recent SoCs and also to save power during runtime. More information is
> available in patch 13/13.

Hi Mani,

I have picked the OPP related patches from here (apart from DT one)
and sent them separately in a series, along with few changes from me.
Also pushed them in my linux-next branch.

Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-21  9:42 ` Viresh Kumar
@ 2023-07-21 11:54   ` Manivannan Sadhasivam
  2023-07-24  7:52     ` Viresh Kumar
  0 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-21 11:54 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On Fri, Jul 21, 2023 at 03:12:06PM +0530, Viresh Kumar wrote:
> On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> > Hi,
> > 
> > This series adds OPP (Operating Points) support to UFSHCD driver and
> > interconnect support to Qcom UFS driver.
> > 
> > Motivation behind adding OPP support is to scale both clocks as well as
> > regulators/performance state dynamically. Currently, UFSHCD just scales
> > clock frequency during runtime with the help of "freq-table-hz" property
> > defined in devicetree. With the addition of OPP tables in devicetree (as
> > done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> > both clocks and performance state of power domain which helps in power
> > saving.
> > 
> > For the addition of OPP support to UFSHCD, there are changes required to
> > the OPP framework and devfreq drivers which are also added in this series.
> > 
> > Finally, interconnect support is added to Qcom UFS driver for scaling the
> > interconnect path dynamically. This is required to avoid boot crash in
> > recent SoCs and also to save power during runtime. More information is
> > available in patch 13/13.
> 
> Hi Mani,
> 
> I have picked the OPP related patches from here (apart from DT one)
> and sent them separately in a series, along with few changes from me.
> Also pushed them in my linux-next branch.
> 

Thanks Viresh! For patch 8/15, Kbuild bot has identified one potential null ptr
dereference issue. Could you please fix that in your branch?

You just need to remove the opp dereference in dev_pm_opp_get_freq_indexed()
before the IS_ERR_OR_NULL() check as below:

```
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 66dc0d0cfaed..683e6e61f80b 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -208,9 +208,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
  */
 unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
 {
-       struct opp_table *opp_table = opp->opp_table;
-
-       if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) {
+       if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) {
                pr_err("%s: Invalid parameters\n", __func__);
                return 0;
        }
```

- Mani

> Thanks.
> 
> -- 
> viresh

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  2023-07-21  7:18   ` Viresh Kumar
@ 2023-07-21 11:57     ` Manivannan Sadhasivam
  2023-07-22  3:15       ` Bjorn Andersson
  0 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-21 11:57 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On Fri, Jul 21, 2023 at 12:48:01PM +0530, Viresh Kumar wrote:
> On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> > Minimum frequency of the "ice_core_clk" should be 75MHz as specified in the
> > downstream vendor devicetree. So fix it!
> > 
> > https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.7.3.r1-09300-sdm845.0/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > 
> > Fixes: 433f9a57298f ("arm64: dts: sdm845: add Inline Crypto Engine registers and clock")
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > index 9ed74bf72d05..89520a9fe1e3 100644
> > --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > @@ -2614,7 +2614,7 @@ ufs_mem_hc: ufshc@1d84000 {
> >  				<0 0>,
> >  				<0 0>,
> >  				<0 0>,
> > -				<0 300000000>;
> > +				<75000000 300000000>;
> >  
> >  			status = "disabled";
> >  		};
> 
> Please keep new feature and fixes like this in separate series. This
> could be merged directly in the currently ongoing kernel rc and
> doesn't need to wait for this series.
> 
> Or at least keep the commit at the top, so another maintainer can
> simply pick it.
> 

That's what I did. This patch and previous patch are the fixes patches, so they
are posted on top of other dts patches to be merged separately if required.

- Mani

> -- 
> viresh

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  2023-07-21 11:57     ` Manivannan Sadhasivam
@ 2023-07-22  3:15       ` Bjorn Andersson
  2023-07-24  5:48         ` Manivannan Sadhasivam
  0 siblings, 1 reply; 34+ messages in thread
From: Bjorn Andersson @ 2023-07-22  3:15 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Viresh Kumar, vireshk, nm, sboyd, myungjoo.ham, kyungmin.park,
	cw00.choi, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On Fri, Jul 21, 2023 at 05:27:31PM +0530, Manivannan Sadhasivam wrote:
> On Fri, Jul 21, 2023 at 12:48:01PM +0530, Viresh Kumar wrote:
> > On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> > > Minimum frequency of the "ice_core_clk" should be 75MHz as specified in the
> > > downstream vendor devicetree. So fix it!
> > > 
> > > https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.7.3.r1-09300-sdm845.0/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > 
> > > Fixes: 433f9a57298f ("arm64: dts: sdm845: add Inline Crypto Engine registers and clock")
> > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > ---
> > >  arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > index 9ed74bf72d05..89520a9fe1e3 100644
> > > --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > @@ -2614,7 +2614,7 @@ ufs_mem_hc: ufshc@1d84000 {
> > >  				<0 0>,
> > >  				<0 0>,
> > >  				<0 0>,
> > > -				<0 300000000>;
> > > +				<75000000 300000000>;
> > >  
> > >  			status = "disabled";
> > >  		};
> > 
> > Please keep new feature and fixes like this in separate series. This
> > could be merged directly in the currently ongoing kernel rc and
> > doesn't need to wait for this series.
> > 
> > Or at least keep the commit at the top, so another maintainer can
> > simply pick it.
> > 
> 
> That's what I did. This patch and previous patch are the fixes patches, so they
> are posted on top of other dts patches to be merged separately if required.
> 

I agree with Viresh, this is patch 4 in a series where 1-2, 7- are new
things.

I can pick this from here, but I think it would have been better to send
this as 3-4 different series; 1 with DeviceTree fixes, 1 with driver
fixes, one that adds interconnect support and one that adds opp support
- the latter two with dts changes last...


And, the freq-table-hz -> opp transition in dts files must be merged
after the driver changes, so this will likely have to wait until 1
release after the driver changes.

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: (subset) [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
                   ` (16 preceding siblings ...)
  2023-07-21  9:42 ` Viresh Kumar
@ 2023-07-22  5:17 ` Bjorn Andersson
  17 siblings, 0 replies; 34+ messages in thread
From: Bjorn Andersson @ 2023-07-22  5:17 UTC (permalink / raw)
  To: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	konrad.dybcio, robh+dt, krzysztof.kozlowski+dt, conor+dt, jejb,
	martin.petersen, Manivannan Sadhasivam
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel


On Thu, 20 Jul 2023 11:10:45 +0530, Manivannan Sadhasivam wrote:
> This series adds OPP (Operating Points) support to UFSHCD driver and
> interconnect support to Qcom UFS driver.
> 
> Motivation behind adding OPP support is to scale both clocks as well as
> regulators/performance state dynamically. Currently, UFSHCD just scales
> clock frequency during runtime with the help of "freq-table-hz" property
> defined in devicetree. With the addition of OPP tables in devicetree (as
> done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> both clocks and performance state of power domain which helps in power
> saving.
> 
> [...]

Applied, thanks!

[03/15] arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC
        commit: 4b6ea15c0a1122422b44bf6c47a3c22fc8d46777
[04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
        commit: bbbef6e24bc4493602df68b052f6f48d48e3184a
[12/15] arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC
        commit: 84e2e371f4f911337604e8ba9281e950230d1189
[13/15] arm64: dts: qcom: sm8250: Add interconnect paths to UFSHC
        commit: aeea56072cc8cb0af2b35798aa7d72047f4c8ffa

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  2023-07-20  5:40 ` [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
@ 2023-07-23 20:06   ` Chanwoo Choi
  2023-07-24  5:46     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 34+ messages in thread
From: Chanwoo Choi @ 2023-07-23 20:06 UTC (permalink / raw)
  To: Manivannan Sadhasivam, vireshk, nm, sboyd, myungjoo.ham,
	kyungmin.park, cw00.choi, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, jejb, martin.petersen
  Cc: alim.akhtar, avri.altman, bvanassche, linux-scsi, linux-pm,
	linux-arm-msm, devicetree, quic_asutoshd, quic_cang,
	quic_nitirawa, quic_narepall, quic_bhaskarv, quic_richardp,
	quic_nguyenb, quic_ziqichen, bmasney, krzysztof.kozlowski,
	linux-kernel

Hi,

On 23. 7. 20. 14:40, Manivannan Sadhasivam wrote:
> Some devfreq consumers like UFS driver need to work with multiple clocks
> through the OPP framework. For this reason, OPP framework exposes the
> _indexed() APIs for finding the floor/ceil of the supplied frequency of
> the indexed clock. So let's use them in the devfreq driver.
> 
> Currently, the clock index of 0 is used which works fine for multiple as
> well as single clock.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  drivers/devfreq/devfreq.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index e36cbb920ec8..7686993d639f 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -88,7 +88,7 @@ static unsigned long find_available_min_freq(struct devfreq *devfreq)
>  	struct dev_pm_opp *opp;
>  	unsigned long min_freq = 0;
>  
> -	opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq);
> +	opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &min_freq, 0);

This patch changed the used function from dev_pm_opp_find_freq_ceil
to dev_pm_opp_find_freq_ceil_indexed even if there are no supporting of the multiple clocks
and then dev_pm_opp_find_freq_ceil is not removed from OPP.

I think that it is better to use dev_pm_opp_find_freq_ceil_indexed
when need to support multiple clocks with real case.

>  	if (IS_ERR(opp))
>  		min_freq = 0;
>  	else
> @@ -102,7 +102,7 @@ static unsigned long find_available_max_freq(struct devfreq *devfreq)
>  	struct dev_pm_opp *opp;
>  	unsigned long max_freq = ULONG_MAX;
>  
> -	opp = dev_pm_opp_find_freq_floor(devfreq->dev.parent, &max_freq);
> +	opp = dev_pm_opp_find_freq_floor_indexed(devfreq->dev.parent, &max_freq, 0);
>  	if (IS_ERR(opp))
>  		max_freq = 0;
>  	else
> @@ -196,7 +196,7 @@ static int set_freq_table(struct devfreq *devfreq)
>  		return -ENOMEM;
>  
>  	for (i = 0, freq = 0; i < devfreq->max_state; i++, freq++) {
> -		opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq);
> +		opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &freq, 0);
>  		if (IS_ERR(opp)) {
>  			devm_kfree(devfreq->dev.parent, devfreq->freq_table);
>  			return PTR_ERR(opp);
> @@ -2034,18 +2034,18 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
>  
>  	if (flags & DEVFREQ_FLAG_LEAST_UPPER_BOUND) {
>  		/* The freq is an upper bound. opp should be lower */
> -		opp = dev_pm_opp_find_freq_floor(dev, freq);
> +		opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
>  
>  		/* If not available, use the closest opp */
>  		if (opp == ERR_PTR(-ERANGE))
> -			opp = dev_pm_opp_find_freq_ceil(dev, freq);
> +			opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
>  	} else {
>  		/* The freq is an lower bound. opp should be higher */
> -		opp = dev_pm_opp_find_freq_ceil(dev, freq);
> +		opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
>  
>  		/* If not available, use the closest opp */
>  		if (opp == ERR_PTR(-ERANGE))
> -			opp = dev_pm_opp_find_freq_floor(dev, freq);
> +			opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
>  	}
>  
>  	return opp;

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  2023-07-23 20:06   ` Chanwoo Choi
@ 2023-07-24  5:46     ` Manivannan Sadhasivam
  2023-07-24 21:57       ` Chanwoo Choi
  0 siblings, 1 reply; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-24  5:46 UTC (permalink / raw)
  To: Chanwoo Choi
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On Mon, Jul 24, 2023 at 05:06:04AM +0900, Chanwoo Choi wrote:
> Hi,
> 
> On 23. 7. 20. 14:40, Manivannan Sadhasivam wrote:
> > Some devfreq consumers like UFS driver need to work with multiple clocks
> > through the OPP framework. For this reason, OPP framework exposes the
> > _indexed() APIs for finding the floor/ceil of the supplied frequency of
> > the indexed clock. So let's use them in the devfreq driver.
> > 
> > Currently, the clock index of 0 is used which works fine for multiple as
> > well as single clock.
> > 
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  drivers/devfreq/devfreq.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index e36cbb920ec8..7686993d639f 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -88,7 +88,7 @@ static unsigned long find_available_min_freq(struct devfreq *devfreq)
> >  	struct dev_pm_opp *opp;
> >  	unsigned long min_freq = 0;
> >  
> > -	opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq);
> > +	opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &min_freq, 0);
> 
> This patch changed the used function from dev_pm_opp_find_freq_ceil
> to dev_pm_opp_find_freq_ceil_indexed even if there are no supporting of the multiple clocks
> and then dev_pm_opp_find_freq_ceil is not removed from OPP.
> 
> I think that it is better to use dev_pm_opp_find_freq_ceil_indexed
> when need to support multiple clocks with real case.
> 

There is the user for dev_pm_opp_find_freq_ceil_indexed() which is the UFS
driver and since UFS is using devfreq, we need this change. I've added this info
in the commit message as well. What am I missing?

- Mani

> >  	if (IS_ERR(opp))
> >  		min_freq = 0;
> >  	else
> > @@ -102,7 +102,7 @@ static unsigned long find_available_max_freq(struct devfreq *devfreq)
> >  	struct dev_pm_opp *opp;
> >  	unsigned long max_freq = ULONG_MAX;
> >  
> > -	opp = dev_pm_opp_find_freq_floor(devfreq->dev.parent, &max_freq);
> > +	opp = dev_pm_opp_find_freq_floor_indexed(devfreq->dev.parent, &max_freq, 0);
> >  	if (IS_ERR(opp))
> >  		max_freq = 0;
> >  	else
> > @@ -196,7 +196,7 @@ static int set_freq_table(struct devfreq *devfreq)
> >  		return -ENOMEM;
> >  
> >  	for (i = 0, freq = 0; i < devfreq->max_state; i++, freq++) {
> > -		opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq);
> > +		opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &freq, 0);
> >  		if (IS_ERR(opp)) {
> >  			devm_kfree(devfreq->dev.parent, devfreq->freq_table);
> >  			return PTR_ERR(opp);
> > @@ -2034,18 +2034,18 @@ struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
> >  
> >  	if (flags & DEVFREQ_FLAG_LEAST_UPPER_BOUND) {
> >  		/* The freq is an upper bound. opp should be lower */
> > -		opp = dev_pm_opp_find_freq_floor(dev, freq);
> > +		opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
> >  
> >  		/* If not available, use the closest opp */
> >  		if (opp == ERR_PTR(-ERANGE))
> > -			opp = dev_pm_opp_find_freq_ceil(dev, freq);
> > +			opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
> >  	} else {
> >  		/* The freq is an lower bound. opp should be higher */
> > -		opp = dev_pm_opp_find_freq_ceil(dev, freq);
> > +		opp = dev_pm_opp_find_freq_ceil_indexed(dev, freq, 0);
> >  
> >  		/* If not available, use the closest opp */
> >  		if (opp == ERR_PTR(-ERANGE))
> > -			opp = dev_pm_opp_find_freq_floor(dev, freq);
> > +			opp = dev_pm_opp_find_freq_floor_indexed(dev, freq, 0);
> >  	}
> >  
> >  	return opp;
> 
> -- 
> Best Regards,
> Samsung Electronics
> Chanwoo Choi
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk"
  2023-07-22  3:15       ` Bjorn Andersson
@ 2023-07-24  5:48         ` Manivannan Sadhasivam
  0 siblings, 0 replies; 34+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-24  5:48 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Viresh Kumar, vireshk, nm, sboyd, myungjoo.ham, kyungmin.park,
	cw00.choi, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On Fri, Jul 21, 2023 at 08:15:36PM -0700, Bjorn Andersson wrote:
> On Fri, Jul 21, 2023 at 05:27:31PM +0530, Manivannan Sadhasivam wrote:
> > On Fri, Jul 21, 2023 at 12:48:01PM +0530, Viresh Kumar wrote:
> > > On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> > > > Minimum frequency of the "ice_core_clk" should be 75MHz as specified in the
> > > > downstream vendor devicetree. So fix it!
> > > > 
> > > > https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.7.3.r1-09300-sdm845.0/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > > 
> > > > Fixes: 433f9a57298f ("arm64: dts: sdm845: add Inline Crypto Engine registers and clock")
> > > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > > > ---
> > > >  arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > > index 9ed74bf72d05..89520a9fe1e3 100644
> > > > --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > > +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> > > > @@ -2614,7 +2614,7 @@ ufs_mem_hc: ufshc@1d84000 {
> > > >  				<0 0>,
> > > >  				<0 0>,
> > > >  				<0 0>,
> > > > -				<0 300000000>;
> > > > +				<75000000 300000000>;
> > > >  
> > > >  			status = "disabled";
> > > >  		};
> > > 
> > > Please keep new feature and fixes like this in separate series. This
> > > could be merged directly in the currently ongoing kernel rc and
> > > doesn't need to wait for this series.
> > > 
> > > Or at least keep the commit at the top, so another maintainer can
> > > simply pick it.
> > > 
> > 
> > That's what I did. This patch and previous patch are the fixes patches, so they
> > are posted on top of other dts patches to be merged separately if required.
> > 
> 
> I agree with Viresh, this is patch 4 in a series where 1-2, 7- are new
> things.
> 
> I can pick this from here, but I think it would have been better to send
> this as 3-4 different series; 1 with DeviceTree fixes, 1 with driver
> fixes, one that adds interconnect support and one that adds opp support
> - the latter two with dts changes last...
> 
> 
> And, the freq-table-hz -> opp transition in dts files must be merged
> after the driver changes, so this will likely have to wait until 1
> release after the driver changes.
> 

Hmm, Ok. Let me resend the series as you suggested (excluding the patches
already merged).

- Mani

> Regards,
> Bjorn

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/15] UFS: Add OPP and interconnect support
  2023-07-21 11:54   ` Manivannan Sadhasivam
@ 2023-07-24  7:52     ` Viresh Kumar
  0 siblings, 0 replies; 34+ messages in thread
From: Viresh Kumar @ 2023-07-24  7:52 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On 21-07-23, 17:24, Manivannan Sadhasivam wrote:
> On Fri, Jul 21, 2023 at 03:12:06PM +0530, Viresh Kumar wrote:
> > On 20-07-23, 11:10, Manivannan Sadhasivam wrote:
> > > Hi,
> > > 
> > > This series adds OPP (Operating Points) support to UFSHCD driver and
> > > interconnect support to Qcom UFS driver.
> > > 
> > > Motivation behind adding OPP support is to scale both clocks as well as
> > > regulators/performance state dynamically. Currently, UFSHCD just scales
> > > clock frequency during runtime with the help of "freq-table-hz" property
> > > defined in devicetree. With the addition of OPP tables in devicetree (as
> > > done for Qcom SDM845 and SM8250 SoCs in this series) UFSHCD can now scale
> > > both clocks and performance state of power domain which helps in power
> > > saving.
> > > 
> > > For the addition of OPP support to UFSHCD, there are changes required to
> > > the OPP framework and devfreq drivers which are also added in this series.
> > > 
> > > Finally, interconnect support is added to Qcom UFS driver for scaling the
> > > interconnect path dynamically. This is required to avoid boot crash in
> > > recent SoCs and also to save power during runtime. More information is
> > > available in patch 13/13.
> > 
> > Hi Mani,
> > 
> > I have picked the OPP related patches from here (apart from DT one)
> > and sent them separately in a series, along with few changes from me.
> > Also pushed them in my linux-next branch.
> > 
> 
> Thanks Viresh! For patch 8/15, Kbuild bot has identified one potential null ptr
> dereference issue. Could you please fix that in your branch?
> 
> You just need to remove the opp dereference in dev_pm_opp_get_freq_indexed()
> before the IS_ERR_OR_NULL() check as below:
> 
> ```
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 66dc0d0cfaed..683e6e61f80b 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -208,9 +208,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
>   */
>  unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index)
>  {
> -       struct opp_table *opp_table = opp->opp_table;
> -
> -       if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) {
> +       if (IS_ERR_OR_NULL(opp) || index >= opp->opp_table->clk_count) {
>                 pr_err("%s: Invalid parameters\n", __func__);
>                 return 0;
>         }

Fixed.

-- 
viresh

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property
  2023-07-20  5:40 ` [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property Manivannan Sadhasivam
@ 2023-07-24 15:51   ` Rob Herring
  2023-07-25  4:11     ` Viresh Kumar
  0 siblings, 1 reply; 34+ messages in thread
From: Rob Herring @ 2023-07-24 15:51 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: conor+dt, quic_richardp, quic_nguyenb, quic_nitirawa,
	linux-kernel, quic_ziqichen, linux-pm, nm, quic_bhaskarv,
	martin.petersen, devicetree, robh+dt, quic_asutoshd, alim.akhtar,
	vireshk, kyungmin.park, jejb, bvanassche, konrad.dybcio,
	krzysztof.kozlowski+dt, quic_cang, linux-arm-msm, myungjoo.ham,
	andersson, sboyd, linux-scsi, cw00.choi, krzysztof.kozlowski,
	avri.altman, bmasney, quic_narepall


On Thu, 20 Jul 2023 11:10:47 +0530, Manivannan Sadhasivam wrote:
> Current limit of 16 will be exhausted by platforms specifying the frequency
> for 9 clocks using opp-hz, like Qcom SDM845 SoC. For instance, specifying
> the frequency for 9 clocks with 64bit specifier as below would consume
> (9 * 2 = 18) items.
> 
> 	opp-50000000 {
> 		opp-hz = /bits/ 64 <50000000>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <37500000>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <0>,
> 			 /bits/ 64 <75000000>;
> 	};
> 
> So let's increase the limit to 32 which should be enough for most platforms
> (hopefully).
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> ---
>  Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Acked-by: Rob Herring <robh@kernel.org>


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs
  2023-07-24  5:46     ` Manivannan Sadhasivam
@ 2023-07-24 21:57       ` Chanwoo Choi
  0 siblings, 0 replies; 34+ messages in thread
From: Chanwoo Choi @ 2023-07-24 21:57 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: vireshk, nm, sboyd, myungjoo.ham, kyungmin.park, cw00.choi,
	andersson, konrad.dybcio, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, jejb, martin.petersen, alim.akhtar, avri.altman,
	bvanassche, linux-scsi, linux-pm, linux-arm-msm, devicetree,
	quic_asutoshd, quic_cang, quic_nitirawa, quic_narepall,
	quic_bhaskarv, quic_richardp, quic_nguyenb, quic_ziqichen,
	bmasney, krzysztof.kozlowski, linux-kernel

On 23. 7. 24. 14:46, Manivannan Sadhasivam wrote:
> On Mon, Jul 24, 2023 at 05:06:04AM +0900, Chanwoo Choi wrote:
>> Hi,
>>
>> On 23. 7. 20. 14:40, Manivannan Sadhasivam wrote:
>>> Some devfreq consumers like UFS driver need to work with multiple clocks
>>> through the OPP framework. For this reason, OPP framework exposes the
>>> _indexed() APIs for finding the floor/ceil of the supplied frequency of
>>> the indexed clock. So let's use them in the devfreq driver.
>>>
>>> Currently, the clock index of 0 is used which works fine for multiple as
>>> well as single clock.
>>>
>>> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>>> ---
>>>  drivers/devfreq/devfreq.c | 14 +++++++-------
>>>  1 file changed, 7 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>> index e36cbb920ec8..7686993d639f 100644
>>> --- a/drivers/devfreq/devfreq.c
>>> +++ b/drivers/devfreq/devfreq.c
>>> @@ -88,7 +88,7 @@ static unsigned long find_available_min_freq(struct devfreq *devfreq)
>>>  	struct dev_pm_opp *opp;
>>>  	unsigned long min_freq = 0;
>>>  
>>> -	opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq);
>>> +	opp = dev_pm_opp_find_freq_ceil_indexed(devfreq->dev.parent, &min_freq, 0);
>>
>> This patch changed the used function from dev_pm_opp_find_freq_ceil
>> to dev_pm_opp_find_freq_ceil_indexed even if there are no supporting of the multiple clocks
>> and then dev_pm_opp_find_freq_ceil is not removed from OPP.
>>
>> I think that it is better to use dev_pm_opp_find_freq_ceil_indexed
>> when need to support multiple clocks with real case.
>>
> 
> There is the user for dev_pm_opp_find_freq_ceil_indexed() which is the UFS
> driver and since UFS is using devfreq, we need this change. I've added this info
> in the commit message as well. What am I missing?


I found out the difference of them. 
- dev_pm_opp_find_freq_ceil() used the 'assert_single_clk' which check the count of clock.
                                                               

(snip)

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property
  2023-07-24 15:51   ` Rob Herring
@ 2023-07-25  4:11     ` Viresh Kumar
  0 siblings, 0 replies; 34+ messages in thread
From: Viresh Kumar @ 2023-07-25  4:11 UTC (permalink / raw)
  To: Rob Herring
  Cc: Manivannan Sadhasivam, conor+dt, quic_richardp, quic_nguyenb,
	quic_nitirawa, linux-kernel, quic_ziqichen, linux-pm, nm,
	quic_bhaskarv, martin.petersen, devicetree, robh+dt,
	quic_asutoshd, alim.akhtar, vireshk, kyungmin.park, jejb,
	bvanassche, konrad.dybcio, krzysztof.kozlowski+dt, quic_cang,
	linux-arm-msm, myungjoo.ham, andersson, sboyd, linux-scsi,
	cw00.choi, krzysztof.kozlowski, avri.altman, bmasney,
	quic_narepall

On 24-07-23, 09:51, Rob Herring wrote:
> 
> On Thu, 20 Jul 2023 11:10:47 +0530, Manivannan Sadhasivam wrote:
> > Current limit of 16 will be exhausted by platforms specifying the frequency
> > for 9 clocks using opp-hz, like Qcom SDM845 SoC. For instance, specifying
> > the frequency for 9 clocks with 64bit specifier as below would consume
> > (9 * 2 = 18) items.
> > 
> > 	opp-50000000 {
> > 		opp-hz = /bits/ 64 <50000000>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <37500000>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <0>,
> > 			 /bits/ 64 <75000000>;
> > 	};
> > 
> > So let's increase the limit to 32 which should be enough for most platforms
> > (hopefully).
> > 
> > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> > ---
> >  Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> Acked-by: Rob Herring <robh@kernel.org>

Applied. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-07-25  4:11 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20  5:40 [PATCH v2 00/15] UFS: Add OPP and interconnect support Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 01/15] dt-bindings: ufs: common: add OPP table Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 02/15] dt-bindings: opp: Increase maxItems for opp-hz property Manivannan Sadhasivam
2023-07-24 15:51   ` Rob Herring
2023-07-25  4:11     ` Viresh Kumar
2023-07-20  5:40 ` [PATCH v2 03/15] arm64: dts: qcom: sdm845: Add missing RPMh power domain to GCC Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 04/15] arm64: dts: qcom: sdm845: Fix the min frequency of "ice_core_clk" Manivannan Sadhasivam
2023-07-21  7:18   ` Viresh Kumar
2023-07-21 11:57     ` Manivannan Sadhasivam
2023-07-22  3:15       ` Bjorn Andersson
2023-07-24  5:48         ` Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 05/15] arm64: dts: qcom: sdm845: Add OPP table support to UFSHC Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 06/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 07/15] OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API Manivannan Sadhasivam
2023-07-21  5:54   ` Dan Carpenter
2023-07-20  5:40 ` [PATCH v2 09/15] PM / devfreq: Switch to dev_pm_opp_find_freq_{ceil/floor}_indexed() APIs Manivannan Sadhasivam
2023-07-23 20:06   ` Chanwoo Choi
2023-07-24  5:46     ` Manivannan Sadhasivam
2023-07-24 21:57       ` Chanwoo Choi
2023-07-20  5:40 ` [PATCH v2 10/15] scsi: ufs: core: Add OPP support for scaling clocks and regulators Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 11/15] scsi: ufs: host: Add support for parsing OPP Manivannan Sadhasivam
2023-07-20 21:32   ` kernel test robot
2023-07-20 23:26   ` kernel test robot
2023-07-20  5:40 ` [PATCH v2 12/15] arm64: dts: qcom: sdm845: Add interconnect paths to UFSHC Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 13/15] arm64: dts: qcom: sm8250: " Manivannan Sadhasivam
2023-07-20  5:40 ` [PATCH v2 14/15] scsi: ufs: core: Add enums for UFS lanes Manivannan Sadhasivam
2023-07-20  5:41 ` [PATCH v2 15/15] scsi: ufs: qcom: Add support for scaling interconnects Manivannan Sadhasivam
2023-07-20 16:44 ` [PATCH v2 00/15] UFS: Add OPP and interconnect support Bart Van Assche
2023-07-20 16:57   ` Manivannan Sadhasivam
2023-07-21  9:42 ` Viresh Kumar
2023-07-21 11:54   ` Manivannan Sadhasivam
2023-07-24  7:52     ` Viresh Kumar
2023-07-22  5:17 ` (subset) " Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.