Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4442142ybi; Mon, 15 Jul 2019 08:59:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGSAYlDF5zM/MC35Z7kIrfcdShRsLfwapRgF79OUVGlUEanZiM7X/Iz569y6ldXJuhNd4M X-Received: by 2002:a17:902:467:: with SMTP id 94mr28943835ple.131.1563206396497; Mon, 15 Jul 2019 08:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563206396; cv=none; d=google.com; s=arc-20160816; b=gHAaeabYHAibYwAdJ/hDjk29Wl3gCmhFU87f1+iSABKQS7QKGVONJ3Ov/nOFaAAv1s chZIm0pqIxLkXsNKsbnw1yYV+/mtSV70OpQh9ODSDVC1ZKgootjAjQTVrprEjyywBIYI bVC9WrhGLiuRN0FTLmbQOQQeULpQ1xpkLbuBAQVIKRtqaF47m8mdYFbNIPqnAb8Hp29c icBaMEgUIvAdWP9fdeG8QD9UMPziCfE7cn1c67yjA/Xsl+zugOR8GLZ+8FcfZo2a5Vvf sPyM08EbeUwYK+WZwYXbYGqz4NRcruQkmZN4xdngvLUV8Tva9B5UMi+qvD78/TYicIfb Sfjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=HjbeDhOV51A8sdpXnqafwlfJ9iwiNhonhrxyNQUI16E=; b=KPyI3WHmwBSv/hmEf5xDBn6CCU+NfWngwRy/1kNpC0/nHlITNFCu8xHsWV13AnSM5p 5FpZm8Li6pWFdVkTHht7uucyJf2pe0fxmUs+RsOV+ZlpAtz2lkL00FrXS7YEob59s1RC KGCJcfep390ZX0v+4t7QJAQjWHrNPU7L8DcxqeH+OmtiaOa6DiArBvotskVO0SNpH4N/ LpMhV8Jn7x2VNysdoFEcRKs/LogVYUydxgv4vHjbiRJigczUZTCplAZTd6bTojN4yVm3 BamIzZrMyKr5rApwWFDuef40GVObtkGZ25XVufUoQ+Rab0CHOL+o1GWjZp6FsChLYeiL 8OeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="N+eU86f/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si11672022pfi.34.2019.07.15.08.59.39; Mon, 15 Jul 2019 08:59:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="N+eU86f/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731008AbfGOP7F (ORCPT + 99 others); Mon, 15 Jul 2019 11:59:05 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42333 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730436AbfGOP7F (ORCPT ); Mon, 15 Jul 2019 11:59:05 -0400 Received: by mail-lj1-f195.google.com with SMTP id t28so16782659lje.9 for ; Mon, 15 Jul 2019 08:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HjbeDhOV51A8sdpXnqafwlfJ9iwiNhonhrxyNQUI16E=; b=N+eU86f/1K4jXpLed142Olwx09e8H8Iivx69wTDwzoqwqFbC8Pe3Y7pdRrF6bmBl1f JhdQC7tAw/WwyEYSmz5ltzaNJ2xL7+fD+UmUOm4E4KvTPROstgSY6AXe9Tm8qYYPrS2K c9J9vJzxL6CrmTWBVQwLKPD9vYqRpjkpgcdwY/4H4sO7/+cMGdHMI64j+DBSE+dvsFc5 xTJlfTlD5s0iyTDoz9gh5jLj5fLF4b2spjq3k7oowVEbmTqoKHcNx483USXg1drtBEFk buTzA7D5lMjlsRhVlWy3p5a+YlYB7pORyFDmytvW9qASNVxT/sQoj7DRdWrapqSeaqXn F8dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HjbeDhOV51A8sdpXnqafwlfJ9iwiNhonhrxyNQUI16E=; b=uCcSlrZQ+sRvEYYcUzSC+cKu4sANLCi6INBoJKr4mg2YVgGvj6BAJs2tKeRIv4NJuO jnReufDcKWduoNt/r9daploSjoiaHToHDdoW/K2d/aPLG1PDiiHQVvf7myxtad5rwbHd IK5nm+F2GYsoKlkZRC9PyUKs7aL9h8UI/upb6w/EJkBTBcdYilynmRRNMeQhtIRmJ7JB SpPYVYXSv477PhEaQDeA85y0hPRU37Y3pXVWLSQQ+Wv91dyYh30ZNzj6/pbScI6hcDPa XvvU3kDpxxyt1XlF1urv7F8BpEyaddzD4bE8+vvRA0gmMQWQN/U8vfNdRB52nngHP+bw TamA== X-Gm-Message-State: APjAAAVuIj246diEHzxK6137RN88xUGS7CLaeDeT4ID6mWvDVa8fAu8b 8XiGJtInNQyzgD7ok3nUU8ZKtg== X-Received: by 2002:a2e:3e01:: with SMTP id l1mr11682242lja.208.1563206342726; Mon, 15 Jul 2019 08:59:02 -0700 (PDT) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id f24sm2633350lfk.72.2019.07.15.08.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 08:59:01 -0700 (PDT) Subject: Re: [PATCH v4 3/4] media: venus: Update to bitrate based clock scaling To: Aniket Masule , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org References: <1562078787-516-1-git-send-email-amasule@codeaurora.org> <1562078787-516-4-git-send-email-amasule@codeaurora.org> From: Stanimir Varbanov Message-ID: <06248dce-2c01-279b-20be-4dfcafbd792f@linaro.org> Date: Mon, 15 Jul 2019 18:58:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1562078787-516-4-git-send-email-amasule@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > --- > 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