From: Renjiang Han <quic_renjiang@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Vikash Garodia <quic_vgarodia@quicinc.com>,
Dikshita Agarwal <quic_dikshita@quicinc.com>,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, <linux-media@vger.kernel.org>,
<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>
Subject: Re: [PATCH v8 1/3] media: venus: pm_helpers: use opp-table for the frequency
Date: Tue, 3 Jun 2025 10:31:13 +0800 [thread overview]
Message-ID: <b1293a1a-e3bf-4e05-835d-0e1908417e88@quicinc.com> (raw)
In-Reply-To: <pyaoow6swlbazljgvav2vghixmb7swd4nkahqvxnhd6gsde26f@myhtwp72qxz7>
On 5/31/2025 4:26 AM, Dmitry Baryshkov wrote:
> On Fri, May 30, 2025 at 09:32:13AM +0530, Renjiang Han wrote:
>> The frequency value in the opp-table in the device tree and the freq_tbl
>> in the driver are the same.
>>
>> Therefore, update pm_helpers.c to use the opp-table for frequency values
>> for the v4 core.
> You are kind of missing the linking between the first two sentences. "The
> tables are the same, so use the second one." You need to explain that
> some of the platforms (provide examples) use the same core, but
> different frequency tables. Using OPP tables allows us to abstract core
> description from the frequency data and use fallback compatibles.
OK. Thanks for your comment. I'll update this message in next version.
>
>> If getting data from the opp table fails, fall back to using the frequency
>> table.
>>
>> Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
>> Signed-off-by: Renjiang Han <quic_renjiang@quicinc.com>
>> ---
>> drivers/media/platform/qcom/venus/pm_helpers.c | 53 +++++++++++++++++++-------
>> 1 file changed, 39 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
>> index 409aa9bd0b5d099c993eedb03177ec5ed918b4a0..434dd66076e8faf7f3feac6c29152789f8d2f81b 100644
>> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
>> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
>> @@ -43,14 +43,20 @@ static int core_clks_enable(struct venus_core *core)
>> const struct venus_resources *res = core->res;
>> const struct freq_tbl *freq_tbl = core->res->freq_tbl;
>> unsigned int freq_tbl_size = core->res->freq_tbl_size;
>> + struct device *dev = core->dev;
>> + struct dev_pm_opp *opp;
>> unsigned long freq;
>> unsigned int i;
>> int ret;
>>
>> - if (!freq_tbl)
>> - return -EINVAL;
>> -
>> - freq = freq_tbl[freq_tbl_size - 1].freq;
>> + opp = dev_pm_opp_find_freq_ceil(dev, &freq);
>> + if (IS_ERR(opp)) {
>> + if (!freq_tbl)
>> + return -EINVAL;
>> + freq = freq_tbl[freq_tbl_size - 1].freq;
>> + } else {
>> + dev_pm_opp_put(opp);
>> + }
>>
>> for (i = 0; i < res->clks_num; i++) {
>> if (IS_V6(core)) {
>> @@ -631,12 +637,15 @@ min_loaded_core(struct venus_inst *inst, u32 *min_coreid, u32 *min_load, bool lo
>>
>> static int decide_core(struct venus_inst *inst)
>> {
>> + const struct freq_tbl *freq_tbl = inst->core->res->freq_tbl;
>> const u32 ptype = HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE;
>> struct venus_core *core = inst->core;
>> u32 min_coreid, min_load, cur_inst_load;
>> u32 min_lp_coreid, min_lp_load, cur_inst_lp_load;
>> struct hfi_videocores_usage_type cu;
>> - unsigned long max_freq;
>> + unsigned long max_freq = ULONG_MAX;
>> + struct device *dev = core->dev;
>> + struct dev_pm_opp *opp;
>> int ret = 0;
>>
>> if (legacy_binding) {
>> @@ -659,7 +668,11 @@ static int decide_core(struct venus_inst *inst)
>> cur_inst_lp_load *= inst->clk_data.low_power_freq;
>> /*TODO : divide this inst->load by work_route */
>>
>> - max_freq = core->res->freq_tbl[0].freq;
>> + opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
>> + if (IS_ERR(opp))
>> + max_freq = freq_tbl[0].freq;
>> + else
>> + dev_pm_opp_put(opp);
>>
>> min_loaded_core(inst, &min_coreid, &min_load, false);
>> min_loaded_core(inst, &min_lp_coreid, &min_lp_load, true);
>> @@ -1082,7 +1095,9 @@ static int load_scale_v4(struct venus_inst *inst)
>> unsigned int num_rows = core->res->freq_tbl_size;
>> struct device *dev = core->dev;
>> unsigned long freq = 0, freq_core1 = 0, freq_core2 = 0;
>> + unsigned long max_freq = ULONG_MAX;
>> unsigned long filled_len = 0;
>> + struct dev_pm_opp *opp;
>> int i, ret = 0;
>>
>> for (i = 0; i < inst->num_input_bufs; i++)
>> @@ -1108,19 +1123,29 @@ static int load_scale_v4(struct venus_inst *inst)
>>
>> freq = max(freq_core1, freq_core2);
>>
>> - if (freq > table[0].freq) {
>> - dev_dbg(dev, VDBGL "requested clock rate: %lu scaling clock rate : %lu\n",
>> - freq, table[0].freq);
>> + opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
>> + if (IS_ERR(opp))
>> + max_freq = table[0].freq;
>> + else
>> + dev_pm_opp_put(opp);
>>
>> - freq = table[0].freq;
>> + if (freq > max_freq) {
>> + dev_dbg(dev, VDBGL "requested clock rate: %lu scaling clock rate : %lu\n",
>> + freq, max_freq);
>> + freq = max_freq;
>> goto set_freq;
>> }
>>
>> - for (i = num_rows - 1 ; i >= 0; i--) {
>> - if (freq <= table[i].freq) {
>> - freq = table[i].freq;
>> - break;
>> + opp = dev_pm_opp_find_freq_ceil(dev, &freq);
>> + if (IS_ERR(opp)) {
>> + for (i = num_rows - 1 ; i >= 0; i--) {
>> + if (freq <= table[i].freq) {
>> + freq = table[i].freq;
>> + break;
>> + }
>> }
>> + } else {
>> + dev_pm_opp_put(opp);
>> }
>>
>> set_freq:
>>
>> --
>> 2.34.1
>>
--
Best Regards,
Renjiang
next prev parent reply other threads:[~2025-06-03 2:31 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 4:02 [PATCH v8 0/3] media: venus: enable venus on qcs615 Renjiang Han
2025-05-30 4:02 ` [PATCH v8 1/3] media: venus: pm_helpers: use opp-table for the frequency Renjiang Han
2025-05-30 20:26 ` Dmitry Baryshkov
2025-06-03 2:31 ` Renjiang Han [this message]
2025-05-31 11:11 ` Konrad Dybcio
2025-06-06 7:12 ` Renjiang Han
2025-05-30 4:02 ` [PATCH v8 2/3] arm64: dts: qcom: qcs615: add venus node to devicetree Renjiang Han
2025-05-30 10:51 ` Konrad Dybcio
2025-05-30 4:02 ` [PATCH v8 3/3] arm64: dts: qcom: qcs615-ride: enable venus node to initialize video codec Renjiang Han
2025-05-30 20:31 ` Dmitry Baryshkov
2025-05-31 0:07 ` Renjiang Han
2025-06-02 6:14 ` Dmitry Baryshkov
2025-05-30 12:52 ` [PATCH v8 0/3] media: venus: enable venus on qcs615 Rob Herring (Arm)
2025-05-30 20:27 ` Dmitry Baryshkov
2025-05-31 0:05 ` Renjiang Han
2025-06-02 6:16 ` Dmitry Baryshkov
2025-06-05 11:24 ` Renjiang Han
2025-06-05 11:46 ` Dmitry Baryshkov
2025-06-05 12:13 ` Krzysztof Kozlowski
2025-06-05 12:30 ` Dmitry Baryshkov
2025-06-05 12:33 ` Krzysztof Kozlowski
2025-06-05 12:40 ` Bryan O'Donoghue
2025-06-05 16:02 ` Dmitry Baryshkov
2025-06-05 16:39 ` Bryan O'Donoghue
2025-06-05 16:40 ` Dmitry Baryshkov
2025-06-05 17:12 ` Krzysztof Kozlowski
2025-06-05 17:13 ` Dmitry Baryshkov
2025-06-06 3:52 ` Renjiang Han
2025-06-06 7:51 ` Renjiang Han
2025-06-06 7:54 ` Krzysztof Kozlowski
2025-06-07 2:08 ` Dmitry Baryshkov
2025-06-05 12:34 ` Bryan O'Donoghue
2025-06-06 12:37 ` Renjiang Han
2025-06-06 12:44 ` Krzysztof Kozlowski
2025-06-06 12:51 ` Renjiang Han
2025-06-06 12:56 ` Krzysztof Kozlowski
2025-06-06 13:32 ` Renjiang Han
2025-06-06 14:53 ` Bryan O'Donoghue
2025-06-06 15:35 ` Vikash Garodia
2025-06-07 2:13 ` Dmitry Baryshkov
2025-06-07 2:31 ` Renjiang Han
2025-06-07 9:16 ` Bryan O'Donoghue
2025-06-07 10:32 ` Dmitry Baryshkov
2025-06-07 9:46 ` Krzysztof Kozlowski
2025-06-11 15:06 ` Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b1293a1a-e3bf-4e05-835d-0e1908417e88@quicinc.com \
--to=quic_renjiang@quicinc.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=quic_dikshita@quicinc.com \
--cc=quic_vgarodia@quicinc.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.