[PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4

Renjiang Han posted 3 patches 3 weeks ago
[PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4
Posted by Renjiang Han 3 weeks ago
The POWER_CONTROL register addresses are not constant and can vary across
the variants. Also as per the HW recommendation, the GDSC mode switching
needs to be controlled from respective GDSC register and this is a uniform
approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API
which controls GDSC mode switching using its respective GDSC register.

In venus v4 variants, the vcodec gdsc gets enabled in SW mode by default
with new HW_CTRL_TRIGGER flag and there is no need to switch it to SW mode
again after enable, hence add check to avoid switching gdsc to SW mode
again after gdsc enable. Similarly add check to avoid switching GDSC to HW
mode before disabling the GDSC, so GDSC gets enabled in SW mode in the
next enable.

Signed-off-by: Renjiang Han <quic_renjiang@quicinc.com>
---
 drivers/media/platform/qcom/venus/pm_helpers.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index 33a5a659c0ada0ca97eebb5522c5f349f95c49c7..a2062b366d4aedba3eb5e4be456a005847eaec0b 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -412,7 +412,7 @@ static int vcodec_control_v4(struct venus_core *core, u32 coreid, bool enable)
 	u32 val;
 	int ret;
 
-	if (IS_V6(core))
+	if (IS_V6(core) || IS_V4(core))
 		return dev_pm_genpd_set_hwmode(core->pmdomains->pd_devs[coreid], !enable);
 	else if (coreid == VIDC_CORE_ID_1) {
 		ctrl = core->wrapper_base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL;
@@ -450,7 +450,7 @@ static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
 
 		vcodec_clks_disable(core, core->vcodec0_clks);
 
-		if (!IS_V6(core)) {
+		if (!IS_V6(core) && !IS_V4(core)) {
 			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, false);
 			if (ret)
 				return ret;
@@ -468,7 +468,7 @@ static int poweroff_coreid(struct venus_core *core, unsigned int coreid_mask)
 
 		vcodec_clks_disable(core, core->vcodec1_clks);
 
-		if (!IS_V6(core)) {
+		if (!IS_V6(core) && !IS_V4(core)) {
 			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, false);
 			if (ret)
 				return ret;
@@ -491,7 +491,7 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
 		if (ret < 0)
 			return ret;
 
-		if (!IS_V6(core)) {
+		if (!IS_V6(core) && !IS_V4(core)) {
 			ret = vcodec_control_v4(core, VIDC_CORE_ID_1, true);
 			if (ret)
 				return ret;
@@ -511,7 +511,7 @@ static int poweron_coreid(struct venus_core *core, unsigned int coreid_mask)
 		if (ret < 0)
 			return ret;
 
-		if (!IS_V6(core)) {
+		if (!IS_V6(core) && !IS_V4(core)) {
 			ret = vcodec_control_v4(core, VIDC_CORE_ID_2, true);
 			if (ret)
 				return ret;

-- 
2.34.1
Re: [PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4
Posted by Bryan O'Donoghue 3 weeks ago
On 15/01/2025 09:30, Renjiang Han wrote:
> The POWER_CONTROL register addresses are not constant and can vary across
> the variants. Also as per the HW recommendation, the GDSC mode switching
> needs to be controlled from respective GDSC register and this is a uniform
> approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API
> which controls GDSC mode switching using its respective GDSC register.

This paragraph is difficult to read and understand. Try something a bit 
more like "Use dev_pm_genpd_set_hwmode() API to control GDSC mode 
switching. Do that because of reason x, y z"

"We are making this change because of reason a, b, c"

Basically just try to state the facts as clearly and concisely as possible.

---
bod
Re: [PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4
Posted by Bjorn Andersson 2 weeks, 6 days ago
On Wed, Jan 15, 2025 at 12:02:31PM +0000, Bryan O'Donoghue wrote:
> On 15/01/2025 09:30, Renjiang Han wrote:
> > The POWER_CONTROL register addresses are not constant and can vary across
> > the variants. Also as per the HW recommendation, the GDSC mode switching
> > needs to be controlled from respective GDSC register and this is a uniform
> > approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API
> > which controls GDSC mode switching using its respective GDSC register.
> 
> This paragraph is difficult to read and understand. Try something a bit more
> like "Use dev_pm_genpd_set_hwmode() API to control GDSC mode switching. Do
> that because of reason x, y z"

No, follow https://docs.kernel.org/process/submitting-patches.html#describe-your-changes

It says "describe your problem, then describe your solution". "Use "
isn't a good start of any problem description that I can think of.

Regards,
Bjorn

> 
> "We are making this change because of reason a, b, c"
> 
> Basically just try to state the facts as clearly and concisely as possible.
> 
> ---
> bod
Re: [PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4
Posted by Bjorn Andersson 2 weeks, 6 days ago
On Wed, Jan 15, 2025 at 02:22:11PM -0600, Bjorn Andersson wrote:
> On Wed, Jan 15, 2025 at 12:02:31PM +0000, Bryan O'Donoghue wrote:
> > On 15/01/2025 09:30, Renjiang Han wrote:
> > > The POWER_CONTROL register addresses are not constant and can vary across
> > > the variants. Also as per the HW recommendation, the GDSC mode switching
> > > needs to be controlled from respective GDSC register and this is a uniform
> > > approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API
> > > which controls GDSC mode switching using its respective GDSC register.
> > 
> > This paragraph is difficult to read and understand. Try something a bit more
> > like "Use dev_pm_genpd_set_hwmode() API to control GDSC mode switching. Do
> > that because of reason x, y z"
> 
> No, follow https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
> 
> It says "describe your problem, then describe your solution". "Use "
> isn't a good start of any problem description that I can think of.
> 

But just to clarify, I have no concern with your request for
improvements to the description of the problem being addressed. 

Regards,
Bjorn
Re: [PATCH v3 2/3] venus: pm_helpers: Use dev_pm_genpd_set_hwmode to switch GDSC mode on V4
Posted by Renjiang Han 2 weeks, 5 days ago
On 1/16/2025 4:36 AM, Bjorn Andersson wrote:
> On Wed, Jan 15, 2025 at 02:22:11PM -0600, Bjorn Andersson wrote:
>> On Wed, Jan 15, 2025 at 12:02:31PM +0000, Bryan O'Donoghue wrote:
>>> On 15/01/2025 09:30, Renjiang Han wrote:
>>>> The POWER_CONTROL register addresses are not constant and can vary across
>>>> the variants. Also as per the HW recommendation, the GDSC mode switching
>>>> needs to be controlled from respective GDSC register and this is a uniform
>>>> approach across all the targets. Hence use dev_pm_genpd_set_hwmode() API
>>>> which controls GDSC mode switching using its respective GDSC register.
>>> This paragraph is difficult to read and understand. Try something a bit more
>>> like "Use dev_pm_genpd_set_hwmode() API to control GDSC mode switching. Do
>>> that because of reason x, y z"
>> No, follow https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
>>
>> It says "describe your problem, then describe your solution". "Use "
>> isn't a good start of any problem description that I can think of.
>>
> But just to clarify, I have no concern with your request for
> improvements to the description of the problem being addressed.
>
> Regards,
> Bjorn
Thanks Bjorn and Bryan. I'll update this message.

-- 
Best Regards,
Renjiang