Skip to contentSkip to conversation

DVFS support for Venus

PATCH In review Rajendra Nayak 3 participants 10 messages Sep 1, 2020 – Oct 1, 2020

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v6 cover DVFS support for Venus

Rob, can you pick PATCH 1 since its already reviewed by you.
Stan, Patch 2 and 3 will need to be picked by you and they both have your ACKs Patch 4 and 5 will need to be merged via the qcom tree once we have them reviewed.

v6: No changes, rebased on 5.9-rc3

v5: Fixed the opp-tables (patch 4/5) to avoid -ERANGE from dev_pm_opp_set_rate

v4: Moved code from probe/remove/runtime_suspend into different pm_ops callbacks

v3: Renamed the optional power domain as cx

v2: Fixed up the labels of OPP nodes in patch 4
Included the bindings update patch as part of this series, a resend of https://lore.kernel.org/patchwork/patch/1241077/

These patches add DVFS support for Venus

Rajendra Nayak (5):
dt-bindings: media: venus: Add an optional power domain for perf
voting
media: venus: core: Fix error handling in probe
media: venus: core: Add support for opp tables/perf voting
arm64: dts: sdm845: Add OPP tables and power-domains for venus
arm64: dts: sc7180: Add OPP tables and power-domains for venus

 .../bindings/media/qcom,sc7180-venus.yaml          |  6 +-
 .../bindings/media/qcom,sdm845-venus-v2.yaml       |  6 +-
 arch/arm64/boot/dts/qcom/sc7180.dtsi               | 35 +++++++-
 arch/arm64/boot/dts/qcom/sdm845.dtsi               | 40 +++++++++-
 drivers/media/platform/qcom/venus/core.c           | 17 ++--
 drivers/media/platform/qcom/venus/core.h           |  5 ++
 drivers/media/platform/qcom/venus/pm_helpers.c     | 92 ++++++++++++++++++++--
 7 files changed, 183 insertions(+), 18 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH v6 1/5 dt-bindings: media: venus: Add an optional power domain for perf voting

Venus needs to vote for the performance state of a power domain (cx) to be able to support DVFS. This 'cx' power domain is controlled by rpmh and is a common power domain (scalable) not specific to venus alone. This is optional in the sense that, leaving this power domain out does not really impact the functionality but just makes the platform a little less power efficient.

---
 Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml    | 6 +++++-
 Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/media/qcom,sc7180-venus.yaml +5 -1
index 55f2d67..04e303b 100644
@@ -25,12 +25,16 @@ properties:
     maxItems: 1
 
   power-domains:
-    maxItems: 2
+    minItems: 2
+    maxItems: 3
 
   power-domain-names:
+    minItems: 2
+    maxItems: 3
     items:
       - const: venus
       - const: vcodec0
+      - const: cx
 
   clocks:
     maxItems: 5
Documentation/devicetree/bindings/media/qcom,sdm845-venus-v2.yaml +5 -1
index 157dff8..90013d4 100644
@@ -25,13 +25,17 @@ properties:
     maxItems: 1
 
   power-domains:
-    maxItems: 3
+    minItems: 3
+    maxItems: 4
 
   power-domain-names:
+    minItems: 3
+    maxItems: 4
     items:
       - const: venus
       - const: vcodec0
       - const: vcodec1
+      - const: cx
 
   clocks:
     maxItems: 7
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH v6 2/5 media: venus: core: Fix error handling in probe

In reply to Rajendra Nayak

Post a successful pm_ops->core_get, an error in probe should exit by doing a pm_ops->core_put which seems to be missing. So fix it.

---
 drivers/media/platform/qcom/venus/core.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/venus/core.c +10 -5
index 203c653..bfcaba3 100644
@@ -224,13 +224,15 @@ static int venus_probe(struct platform_device *pdev)
 
 	ret = dma_set_mask_and_coherent(dev, core->res->dma_mask);
 	if (ret)
-		return ret;
+		goto err_core_put;
 
 	if (!dev->dma_parms) {
 		dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms),
 					      GFP_KERNEL);
-		if (!dev->dma_parms)
-			return -ENOMEM;
+		if (!dev->dma_parms) {
+			ret = -ENOMEM;
+			goto err_core_put;
+		}
 	}
 	dma_set_max_seg_size(dev, DMA_BIT_MASK(32));
 
@@ -242,11 +244,11 @@ static int venus_probe(struct platform_device *pdev)
 					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 					"venus", core);
 	if (ret)
-		return ret;
+		goto err_core_put;
 
 	ret = hfi_create(core, &venus_core_ops);
 	if (ret)
-		return ret;
+		goto err_core_put;
 
 	pm_runtime_enable(dev);
 
@@ -302,6 +304,9 @@ static int venus_probe(struct platform_device *pdev)
 	pm_runtime_set_suspended(dev);
 	pm_runtime_disable(dev);
 	hfi_destroy(core);
+err_core_put:
+	if (core->pm_ops->core_put)
+		core->pm_ops->core_put(dev);
 	return ret;
 }
 
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

PATCH v6 3/5 media: venus: core: Add support for opp tables/perf voting

In reply to Rajendra Nayak

Add support to add OPP tables and perf voting on the OPP powerdomain. This is needed so venus votes on the corresponding performance state for the OPP powerdomain along with setting the core clock rate.

---
 drivers/media/platform/qcom/venus/core.c       |  2 +
 drivers/media/platform/qcom/venus/core.h       |  5 ++
 drivers/media/platform/qcom/venus/pm_helpers.c | 92 ++++++++++++++++++++++++--
 3 files changed, 92 insertions(+), 7 deletions(-)
drivers/media/platform/qcom/venus/core.c +2 -0
index bfcaba3..a3e98a5 100644
@@ -525,6 +525,7 @@ static const struct venus_resources sdm845_res_v2 = {
 	.vcodec_clks_num = 2,
 	.vcodec_pmdomains = { "venus", "vcodec0", "vcodec1" },
 	.vcodec_pmdomains_num = 3,
+	.opp_pmdomain = (const char *[]) { "cx", NULL },
 	.vcodec_num = 2,
 	.max_load = 3110400,	/* 4096x2160@90 */
 	.hfi_version = HFI_VERSION_4XX,
@@ -570,6 +571,7 @@ static const struct venus_resources sc7180_res = {
 	.vcodec_clks_num = 2,
 	.vcodec_pmdomains = { "venus", "vcodec0" },
 	.vcodec_pmdomains_num = 2,
+	.opp_pmdomain = (const char *[]) { "cx", NULL },
 	.vcodec_num = 1,
 	.hfi_version = HFI_VERSION_4XX,
 	.vmem_id = VIDC_RESOURCE_NONE,
drivers/media/platform/qcom/venus/core.h +5 -0
index 7118612..b0cc544 100644
@@ -62,6 +62,7 @@ struct venus_resources {
 	unsigned int vcodec_clks_num;
 	const char * const vcodec_pmdomains[VIDC_PMDOMAINS_NUM_MAX];
 	unsigned int vcodec_pmdomains_num;
+	const char **opp_pmdomain;
 	unsigned int vcodec_num;
 	enum hfi_version hfi_version;
 	u32 max_load;
@@ -145,8 +146,12 @@ struct venus_core {
 	struct clk *vcodec1_clks[VIDC_VCODEC_CLKS_NUM_MAX];
 	struct icc_path *video_path;
 	struct icc_path *cpucfg_path;
+	struct opp_table *opp_table;
+	bool has_opp_table;
 	struct device_link *pd_dl_venus;
 	struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX];
+	struct device_link *opp_dl_venus;
+	struct device *opp_pmdomain;
 	struct video_device *vdev_dec;
 	struct video_device *vdev_enc;
 	struct v4l2_device v4l2_dev;
drivers/media/platform/qcom/venus/pm_helpers.c +85 -7

163 lines not on this page · raw message

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH v6 4/5 arm64: dts: sdm845: Add OPP tables and power-domains for venus

In reply to Rajendra Nayak

Add the OPP tables in order to be able to vote on the performance state of a power-domain.

---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 40 ++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sdm845.dtsi +38 -2
index 2884577..86457d9b 100644
@@ -3639,8 +3639,10 @@
 			interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
 			power-domains = <&videocc VENUS_GDSC>,
 					<&videocc VCODEC0_GDSC>,
-					<&videocc VCODEC1_GDSC>;
-			power-domain-names = "venus", "vcodec0", "vcodec1";
+					<&videocc VCODEC1_GDSC>,
+					<&rpmhpd SDM845_CX>;
+			power-domain-names = "venus", "vcodec0", "vcodec1", "cx";
+			operating-points-v2 = <&venus_opp_table>;
 			clocks = <&videocc VIDEO_CC_VENUS_CTL_CORE_CLK>,
 				 <&videocc VIDEO_CC_VENUS_AHB_CLK>,
 				 <&videocc VIDEO_CC_VENUS_CTL_AXI_CLK>,
@@ -3662,6 +3664,40 @@
 			video-core1 {
 				compatible = "venus-encoder";
 			};
+
+			venus_opp_table: venus-opp-table {
+				compatible = "operating-points-v2";
+
+				opp-100000000 {
+					opp-hz = /bits/ 64 <100000000>;
+					required-opps = <&rpmhpd_opp_min_svs>;
+				};
+
+				opp-200000000 {
+					opp-hz = /bits/ 64 <200000000>;
+					required-opps = <&rpmhpd_opp_low_svs>;
+				};
+
+				opp-320000000 {
+					opp-hz = /bits/ 64 <320000000>;
+					required-opps = <&rpmhpd_opp_svs>;
+				};
+
+				opp-380000000 {
+					opp-hz = /bits/ 64 <380000000>;
+					required-opps = <&rpmhpd_opp_svs_l1>;
+				};
+
+				opp-444000000 {
+					opp-hz = /bits/ 64 <444000000>;
+					required-opps = <&rpmhpd_opp_nom>;
+				};
+
+				opp-533000097 {
+					opp-hz = /bits/ 64 <533000097>;
+					required-opps = <&rpmhpd_opp_turbo>;
+				};
+			};
 		};
 
 		videocc: clock-controller@ab00000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw

PATCH v6 5/5 arm64: dts: sc7180: Add OPP tables and power-domains for venus

In reply to Rajendra Nayak

Add the OPP tables in order to be able to vote on the performance state of a power-domain

---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sc7180.dtsi +33 -2
index d46b383..94a0ec4 100644
@@ -2691,8 +2691,10 @@
 			reg = <0 0x0aa00000 0 0xff000>;
 			interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
 			power-domains = <&videocc VENUS_GDSC>,
-					<&videocc VCODEC0_GDSC>;
-			power-domain-names = "venus", "vcodec0";
+					<&videocc VCODEC0_GDSC>,
+					<&rpmhpd SC7180_CX>;
+			power-domain-names = "venus", "vcodec0", "cx";
+			operating-points-v2 = <&venus_opp_table>;
 			clocks = <&videocc VIDEO_CC_VENUS_CTL_CORE_CLK>,
 				 <&videocc VIDEO_CC_VENUS_AHB_CLK>,
 				 <&videocc VIDEO_CC_VENUS_CTL_AXI_CLK>,
@@ -2713,6 +2715,35 @@
 			video-encoder {
 				compatible = "venus-encoder";
 			};
+
+			venus_opp_table: venus-opp-table {
+				compatible = "operating-points-v2";
+
+				opp-150000000 {
+					opp-hz = /bits/ 64 <150000000>;
+					required-opps = <&rpmhpd_opp_low_svs>;
+				};
+
+				opp-270000000 {
+					opp-hz = /bits/ 64 <270000000>;
+					required-opps = <&rpmhpd_opp_svs>;
+				};
+
+				opp-340000000 {
+					opp-hz = /bits/ 64 <340000000>;
+					required-opps = <&rpmhpd_opp_svs_l1>;
+				};
+
+				opp-434000000 {
+					opp-hz = /bits/ 64 <434000000>;
+					required-opps = <&rpmhpd_opp_nom>;
+				};
+
+				opp-500000097 {
+					opp-hz = /bits/ 64 <500000097>;
+					required-opps = <&rpmhpd_opp_turbo>;
+				};
+			};
 		};
 
 		videocc: clock-controller@ab00000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#6 lore raw
In reply to Rajendra Nayak
Quoted 2 lines · Rajendra Nayak

Rob, can you pick PATCH 1 since its already reviewed by you. Stan, Patch 2 and 3 will need to be picked by you and they both have your ACKs

Rob/Stan, any plans to get the patches merged for 5.10?

Quoted 35 lines

Patch 4 and 5 will need to be merged via the qcom tree once we have them reviewed.

v6: No changes, rebased on 5.9-rc3

v5: Fixed the opp-tables (patch 4/5) to avoid -ERANGE from dev_pm_opp_set_rate

v4: Moved code from probe/remove/runtime_suspend into different pm_ops callbacks

v3: Renamed the optional power domain as cx

v2: Fixed up the labels of OPP nodes in patch 4
Included the bindings update patch as part of this series, a resend of https://lore.kernel.org/patchwork/patch/1241077/

These patches add DVFS support for Venus

Rajendra Nayak (5):
dt-bindings: media: venus: Add an optional power domain for perf
voting
media: venus: core: Fix error handling in probe
media: venus: core: Add support for opp tables/perf voting
arm64: dts: sdm845: Add OPP tables and power-domains for venus
arm64: dts: sc7180: Add OPP tables and power-domains for venus

  .../bindings/media/qcom,sc7180-venus.yaml          |  6 +-
  .../bindings/media/qcom,sdm845-venus-v2.yaml       |  6 +-
  arch/arm64/boot/dts/qcom/sc7180.dtsi               | 35 +++++++-
  arch/arm64/boot/dts/qcom/sdm845.dtsi               | 40 +++++++++-
  drivers/media/platform/qcom/venus/core.c           | 17 ++--
  drivers/media/platform/qcom/venus/core.h           |  5 ++
  drivers/media/platform/qcom/venus/pm_helpers.c     | 92 ++++++++++++++++++++--
  7 files changed, 183 insertions(+), 18 deletions(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#7 lore raw

Hi,

Quoted 7 lines · Rajendra Nayak
Quoted 3 lines · Rajendra Nayak

Rob, can you pick PATCH 1 since its already reviewed by you. Stan, Patch 2 and 3 will need to be picked by you and they both have your ACKs

Rob/Stan, any plans to get the patches merged for 5.10?

2/5 and 3/5 are queued up for v5.10 through media tree.

Quoted 39 lines
Quoted 38 lines

Patch 4 and 5 will need to be merged via the qcom tree once we have them reviewed.

v6: No changes, rebased on 5.9-rc3

v5: Fixed the opp-tables (patch 4/5) to avoid -ERANGE from dev_pm_opp_set_rate

v4: Moved code from probe/remove/runtime_suspend into different pm_ops callbacks

v3: Renamed the optional power domain as cx

v2: Fixed up the labels of OPP nodes in patch 4 Included the bindings update patch as part of this series, a resend of https://lore.kernel.org/patchwork/patch/1241077/

These patches add DVFS support for Venus

Rajendra Nayak (5):
   dt-bindings: media: venus: Add an optional power domain for perf voting
   media: venus: core: Fix error handling in probe
   media: venus: core: Add support for opp tables/perf voting
   arm64: dts: sdm845: Add OPP tables and power-domains for venus
   arm64: dts: sc7180: Add OPP tables and power-domains for venus

  .../bindings/media/qcom,sc7180-venus.yaml          |  6 +- .../bindings/media/qcom,sdm845-venus-v2.yaml       |  6 +- arch/arm64/boot/dts/qcom/sc7180.dtsi               | 35 +++++++- arch/arm64/boot/dts/qcom/sdm845.dtsi               | 40 +++++++++- drivers/media/platform/qcom/venus/core.c           | 17 ++-- drivers/media/platform/qcom/venus/core.h           |  5 ++ drivers/media/platform/qcom/venus/pm_helpers.c     | 92
++++++++++++++++++++--

  7 files changed, 183 insertions(+), 18 deletions(-)
Signature · 2 lines
regards,
Stan
#8 lore raw

Hi,

Quoted 5 lines · Stanimir Varbanov

Hi,

Quoted 1 line · Rajendra Nayak
Quoted 8 lines
Quoted 6 lines · Rajendra Nayak
Quoted 3 lines

Rob, can you pick PATCH 1 since its already reviewed by you. Stan, Patch 2 and 3 will need to be picked by you and they both have your ACKs

Rob/Stan, any plans to get the patches merged for 5.10?

2/5 and 3/5 are queued up for v5.10 through media tree.

Normally I'd expect device tree bindings (patch #1) to go through the same tree as the driver changes. Does the media tree work differently? If you're expecting Rob Herring to land the device tree binding change, is he aware?

-Doug

#9 lore raw

Hi,

Quoted 14 lines · Doug Anderson

Hi,

Quoted 10 lines · Stanimir Varbanov

Hi,

Quoted 6 lines · Rajendra Nayak
Quoted 3 lines · Rajendra Nayak

Rob, can you pick PATCH 1 since its already reviewed by you. Stan, Patch 2 and 3 will need to be picked by you and they both have your ACKs

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Rob/Stan, any plans to get the patches merged for 5.10?

2/5 and 3/5 are queued up for v5.10 through media tree.

Normally I'd expect device tree bindings (patch #1) to go through the same tree as the driver changes. Does the media tree work differently? If you're expecting Rob Herring to land the device tree binding change, is he aware?

I sent pull request to Mauro with 1/5 included.
Thanks for spotting.

Quoted 4 lines

-Doug

Signature · 2 lines
regards,
Stan