Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6465519ybf; Thu, 5 Mar 2020 21:36:07 -0800 (PST) X-Google-Smtp-Source: ADFU+vsmwxY7wqBN0QMwq7Ta7fioPC/onPwG7Q5NumXrMMz3Jch3DvE4UkEWuBHSA/zehXCJq44/ X-Received: by 2002:a9d:191a:: with SMTP id j26mr1220273ota.278.1583472967384; Thu, 05 Mar 2020 21:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583472967; cv=none; d=google.com; s=arc-20160816; b=R0tS87N1MN4hkLwvS5HsKOVs2MlGYaTa4uTfjPrlCzUjZE6mYs7JorFKuN/FqPtxao MIt7OidiNDo4UDyipGHhngkobXGC2KpvVta7K0mdFyQ0Os9b6QIQLouXpW+0V+eQF8zU zjswHDDWs0Xot5pUCOnbvBs0SnJTK7sPAEXhbufzOw5AlJv4tEwfzNuLGnAg/99tJ9hw p3BCwe/AxSFRGdGDQoEoKSm4EJx0SzpLoyIq9eS6oJxl/B8SKfzArRUoR39FxS/DG1lM 8dvFVXuZhhPS0jzq/WPuUByYAlVJH9Dcp75tizi84yq/aln+UjPKzdvmeNUYJ2ceb824 6POg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=2jYDsm/fSKAHbwPlpeGl7LTzTtQ3CDvLIa1nOUh5E90=; b=Q6bvmdnfkWAi1DkVmUwHt7b561AfIA2xKlGwv674Fs22sIsz0KUGauIKcP0nvMZVff tQYqN9lMeBrdHkg0mXrpXpMKZItWvbGLjLz1DN+2K5/8VMS9k2RwUAuUHOqFYx+oYui8 OiG6c+NsUKdlPAAhmpDLLuD9DFG9ZPuyYQeA/nd7xnEKk6iwBymQb4sn0PeoLzsanB2e oFpnauwSGJVpAAYiwSlO7lVATvHlhjwYbgTj6z5chjl04XqpMqqqaFlNGnK4L9TExYZS 7DyLJNd9fvS2pWdhHLKpq9ND2AxMExZapO/X8dHnoC9ZDd9F5ZbX44zpFif4Vyu/V9GC S69w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u78si760743oia.266.2020.03.05.21.35.55; Thu, 05 Mar 2020 21:36:07 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbgCFFeW (ORCPT + 99 others); Fri, 6 Mar 2020 00:34:22 -0500 Received: from alexa-out-blr-01.qualcomm.com ([103.229.18.197]:37928 "EHLO alexa-out-blr-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgCFFeW (ORCPT ); Fri, 6 Mar 2020 00:34:22 -0500 Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by alexa-out-blr-01.qualcomm.com with ESMTP/TLS/AES256-SHA; 06 Mar 2020 11:02:49 +0530 Received: from c-mansur-linux.qualcomm.com ([10.204.90.208]) by ironmsg02-blr.qualcomm.com with ESMTP; 06 Mar 2020 11:02:40 +0530 Received: by c-mansur-linux.qualcomm.com (Postfix, from userid 461723) id B9DA52114D; Fri, 6 Mar 2020 11:02:39 +0530 (IST) From: Mansur Alisha Shaik To: linux-media@vger.kernel.org, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, mansur@codeaurora.org Subject: [PATCH] venus: avoid extra locking in driver Date: Fri, 6 Mar 2020 11:02:36 +0530 Message-Id: <1583472756-7611-1-git-send-email-mansur@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change will avoid extra locking in driver. Signed-off-by: Mansur Alisha Shaik --- drivers/media/platform/qcom/venus/core.c | 2 +- drivers/media/platform/qcom/venus/core.h | 2 +- drivers/media/platform/qcom/venus/helpers.c | 11 +++++++++-- drivers/media/platform/qcom/venus/pm_helpers.c | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c index 194b10b9..75d38b8 100644 --- a/drivers/media/platform/qcom/venus/core.c +++ b/drivers/media/platform/qcom/venus/core.c @@ -447,7 +447,7 @@ static const struct freq_tbl sdm845_freq_table[] = { { 244800, 100000000 }, /* 1920x1080@30 */ }; -static struct codec_freq_data sdm845_codec_freq_data[] = { +static const struct codec_freq_data sdm845_codec_freq_data[] = { { V4L2_PIX_FMT_H264, VIDC_SESSION_TYPE_ENC, 675, 10 }, { V4L2_PIX_FMT_HEVC, VIDC_SESSION_TYPE_ENC, 675, 10 }, { V4L2_PIX_FMT_VP8, VIDC_SESSION_TYPE_ENC, 675, 10 }, diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index ab7c360..8c8d0e9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -245,7 +245,7 @@ struct venus_buffer { struct clock_data { u32 core_id; unsigned long freq; - const struct codec_freq_data *codec_freq_data; + struct codec_freq_data codec_freq_data; }; #define to_venus_buffer(ptr) container_of(ptr, struct venus_buffer, vb) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index bcc6038..550c4ff 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -807,6 +807,7 @@ int venus_helper_init_codec_freq_data(struct venus_inst *inst) unsigned int i, data_size; u32 pixfmt; int ret = 0; + bool found = false; if (!IS_V4(inst->core)) return 0; @@ -816,16 +817,22 @@ int venus_helper_init_codec_freq_data(struct venus_inst *inst) pixfmt = inst->session_type == VIDC_SESSION_TYPE_DEC ? inst->fmt_out->pixfmt : inst->fmt_cap->pixfmt; + memset(&inst->clk_data.codec_freq_data, 0, + sizeof(inst->clk_data.codec_freq_data)); + for (i = 0; i < data_size; i++) { if (data[i].pixfmt == pixfmt && data[i].session_type == inst->session_type) { - inst->clk_data.codec_freq_data = &data[i]; + inst->clk_data.codec_freq_data = data[i]; + found = true; break; } } - if (!inst->clk_data.codec_freq_data) + if (!found) { + dev_err(inst->core->dev, "cannot find codec freq data\n"); ret = -EINVAL; + } return ret; } diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index abf9315..240845e 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -496,7 +496,7 @@ min_loaded_core(struct venus_inst *inst, u32 *min_coreid, u32 *min_load) list_for_each_entry(inst_pos, &core->instances, list) { if (inst_pos == inst) continue; - vpp_freq = inst_pos->clk_data.codec_freq_data->vpp_freq; + vpp_freq = inst_pos->clk_data.codec_freq_data.vpp_freq; coreid = inst_pos->clk_data.core_id; mbs_per_sec = load_per_instance(inst_pos); @@ -545,7 +545,7 @@ static int decide_core(struct venus_inst *inst) return 0; inst_load = load_per_instance(inst); - inst_load *= inst->clk_data.codec_freq_data->vpp_freq; + inst_load *= inst->clk_data.codec_freq_data.vpp_freq; max_freq = core->res->freq_tbl[0].freq; min_loaded_core(inst, &min_coreid, &min_load); @@ -848,10 +848,10 @@ static unsigned long calculate_inst_freq(struct venus_inst *inst, mbs_per_sec = load_per_instance(inst) / fps; - vpp_freq = mbs_per_sec * inst->clk_data.codec_freq_data->vpp_freq; + 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; + vsp_freq = mbs_per_sec * inst->clk_data.codec_freq_data.vsp_freq; /* 10 / 7 is overhead factor */ if (inst->session_type == VIDC_SESSION_TYPE_ENC) -- 2.7.4