From: Stanimir Varbanov <stanimir.varbanov@linaro.org>
To: Aniket Masule <amasule@codeaurora.org>, linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
vgarodia@codeaurora.org
Subject: Re: [PATCH v4 3/4] media: venus: Update to bitrate based clock scaling
Date: Mon, 15 Jul 2019 18:58:58 +0300 [thread overview]
Message-ID: <06248dce-2c01-279b-20be-4dfcafbd792f@linaro.org> (raw)
In-Reply-To: <1562078787-516-4-git-send-email-amasule@codeaurora.org>
Hi,
On 7/2/19 5:46 PM, Aniket Masule wrote:
> Introduced clock scaling using bitrate, preavious
> calculations consider only the cycles per mb.
> Also, clock scaling is now triggered before every
> buffer being queued to the device. This helps in
> deciding precise clock cycles required.
>
> Signed-off-by: Aniket Masule <amasule@codeaurora.org>
> ---
> drivers/media/platform/qcom/venus/helpers.c | 31 +++++++++++++++++++++++++----
> 1 file changed, 27 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 2c976e4..5726d86 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -399,17 +399,26 @@ static int scale_clocks(struct venus_inst *inst)
> return ret;
> }
>
> -static unsigned long calculate_vpp_freq(struct venus_inst *inst)
> +static unsigned long calculate_inst_freq(struct venus_inst *inst,
> + unsigned long filled_len)
> {
> - unsigned long vpp_freq = 0;
> + unsigned long vpp_freq = 0, vsp_freq = 0;
> + u64 fps = inst->fps;
> u32 mbs_per_sec;
>
> mbs_per_sec = load_per_instance(inst);
> vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq;
> /* 21 / 20 is overhead factor */
> vpp_freq += vpp_freq / 20;
> + vsp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vsp_freq;
>
> - return vpp_freq;
> + /* 10 / 7 is overhead factor */
> + if (inst->session_type == VIDC_SESSION_TYPE_ENC)
> + vsp_freq += (inst->controls.enc.bitrate * 10) / 7;
> + else
> + vsp_freq += ((fps * filled_len * 8) * 10) / 7;
> +
> + return max(vpp_freq, vsp_freq);
> }
>
> static int scale_clocks_v4(struct venus_inst *inst)
> @@ -417,13 +426,27 @@ static int scale_clocks_v4(struct venus_inst *inst)
> struct venus_core *core = inst->core;
> const struct freq_tbl *table = core->res->freq_tbl;
> unsigned int num_rows = core->res->freq_tbl_size;
> + struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
> struct clk *clk = core->clks[0];
> struct device *dev = core->dev;
> unsigned int i;
> unsigned long freq = 0, freq_core1 = 0, freq_core2 = 0;
> + unsigned long filled_len = 0;
> + struct venus_buffer *buf, *n;
> + struct vb2_buffer *vb;
> int ret;
>
> - freq = calculate_vpp_freq(inst);
> + mutex_lock(&inst->lock);
> + v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buf, n) {
> + vb = &buf->vb.vb2_buf;
> + filled_len = max(filled_len, vb2_get_plane_payload(vb, 0));
> + }
> + mutex_unlock(&inst->lock);
> +
> + if (inst->session_type == VIDC_SESSION_TYPE_DEC && !filled_len)
> + return 0;
> +
> + freq = calculate_inst_freq(inst, filled_len);
>
> if (freq > table[0].freq)
> dev_warn(dev, "HW is overloaded, needed: %lu max: %lu\n",
>
The original patch has a call to load_scale_clocks from
venus_helper_vb2_buf_queue, why it is not included here?
--
regards,
Stan
next prev parent reply other threads:[~2019-07-15 15:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 14:46 [PATCH v4 0/4] media: venus: Update clock scaling and core selection Aniket Masule
2019-07-02 14:46 ` [PATCH v4 1/4] media: venus: Add codec data table Aniket Masule
2019-07-02 14:46 ` [PATCH v4 2/4] media: venus: Update clock scaling Aniket Masule
2019-07-02 14:46 ` [PATCH v4 3/4] media: venus: Update to bitrate based " Aniket Masule
2019-07-15 15:58 ` Stanimir Varbanov [this message]
2019-07-16 4:46 ` amasule
2019-07-02 14:46 ` [PATCH v4 4/4] media: venus: Update core selection Aniket Masule
2019-07-15 16:00 ` Stanimir Varbanov
2019-07-16 4:48 ` amasule
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=06248dce-2c01-279b-20be-4dfcafbd792f@linaro.org \
--to=stanimir.varbanov@linaro.org \
--cc=amasule@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=vgarodia@codeaurora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).