From patchwork Sat Jan 9 07:21:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 359746 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1218895jai; Fri, 8 Jan 2021 23:23:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiOLezY8KJQPXYg7vRw8qgop0fblpltchYH9lIs4KC4LOPK/mkDDe/CV0m4RAoJhmePM2Y X-Received: by 2002:a05:6402:366:: with SMTP id s6mr7544675edw.44.1610177020430; Fri, 08 Jan 2021 23:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610177020; cv=none; d=google.com; s=arc-20160816; b=HW/eSTtV4klaWnv52ClxVAeY4eE629LakAazMOpgEwS1a2WBlmLp6VFuC+4vcMFXH4 ocAVjx3tH2/rDPJM/G0ePoe6fX5N+g4xdAco9WD2zAgNl1wdqo1IxZuyPeA+6M/H/lzf h1WLieL9eWPLiL/qdYXiwGyZbcpskZRwLPC0XrTPOoEYSrNDnOvgqZ/BHsf5lgPcF3XT /ygvxHWdTz9ZcTvMGyMhQL8+Cff+MdzDXRLOkQP4OSUgreiIVCLa+fF+PaPb+N2AUS4Y Wqm7dyWsi8GFNS9qKLjp9dxS2ualNl3GROho3LNoR6AqH83mdPSTn6eJSJQuQaRPt/rf OO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=oMPxP8SoOc9C3ojU0+ecvXLMtYQCURVMW/VkKHiEGY4=; b=hw+UU/rV+eWh29v+EG4r7TJHFQk8Rq8YshZTtKXZ99jNjRYQArX0QkBBCl1qfxGteY SeJNft2v/prPureNlyhzeS1xlWYXbbrH1e7ngbgJcXLU05kFrGzLCTkahtm+4rOvsELF GHRoJ0XVzwJE7RIP0Wrtjh0rbd/XpVJac9hhLDAunpXNhV+7PS6sCII1n8Mvfv/3KHwR 0Zy/E3Hj62J/XYn123khYuPURAOgLmiJ0hxPa3F9Vlb7i8pqqrmTNn9KubBzEHuETkI1 62+wAB3ffpdIVeWPQIfgdm9f0au6AdxKBes9QwE/hHWktCm8Gf1kOT1nPWYiCwFuQalg GQgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D3oeU1IU; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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. [23.128.96.18]) by mx.google.com with ESMTP id c11si4499781edu.341.2021.01.08.23.23.39; Fri, 08 Jan 2021 23:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D3oeU1IU; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726443AbhAIHWX (ORCPT + 15 others); Sat, 9 Jan 2021 02:22:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbhAIHWX (ORCPT ); Sat, 9 Jan 2021 02:22:23 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9D0C061573 for ; Fri, 8 Jan 2021 23:21:42 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ce23so17562261ejb.8 for ; Fri, 08 Jan 2021 23:21:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=oMPxP8SoOc9C3ojU0+ecvXLMtYQCURVMW/VkKHiEGY4=; b=D3oeU1IUw5BxYChFH5RBM7HmjqemG9yIWB6lQNXUDu/LEVX4AYOn0CEz0Tu+JlpRKA H2YAjUNChY8MYNUtmRJ3iNQNoGYFLTA1oI4P1Znwk5PIfAUwcn/H51JwaINe0B+zZS3z VAEsmp2RAzZfoQH/+gM/qON1rQpIeMC3sfaJZPnV27dlWalgGfs0uQl1CUR9XAU8Bhoz fLt+e1HtXqiCaZSL8CUSnbh+5gPucZo0y5O5pWPsJVvDpV6XyttfKg4VXC6b/hliS5lb m11Ov8r5+GXtZpkXW1gUHvLsodMSodEhFEq558uu3OBjw+XMYAkvzu++gJBS+otcXEVI AbZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oMPxP8SoOc9C3ojU0+ecvXLMtYQCURVMW/VkKHiEGY4=; b=WvRQZgrQYOhDIF5b+lB5tGdQkknXX9pnI8GLoae+5CO36yECHf6JQIK8eWlmOdt0XW igOUfLCNI0s0yBrtZP49s5/TUcgQeS7yQbHD2w3lylqKm2dCyUOy9MeEWZzalLRibn3M sdBK7hhVgVKC5g3mZaYR4LRX6/Fl9lt1kTkdMLdRGH6a11eCEdMnTzWAlx9kN/wFLSSI QrgdiVcLeW9YV+YlOACbJ741UIzoOe9kQdSL19yKlKvXgNDhrXaT9TMSuRhaXpc8Futd tAG/Y7Nod/jybb3jygk9rymQmdKrSqMFuOfyo/EvbJinWGKB+miXhTdOaBa0RUFqB6c1 gRRQ== X-Gm-Message-State: AOAM533Rm5jcmeyrI+Kd1+CcEpWj31G20mYDVfXrLuuQwchd5hmnf/4o lmg04rEJDYOGdvwZ8WhuMuWhTw== X-Received: by 2002:a17:906:b309:: with SMTP id n9mr4905950ejz.365.1610176901271; Fri, 08 Jan 2021 23:21:41 -0800 (PST) Received: from localhost.localdomain (hst-221-28.medicom.bg. [84.238.221.28]) by smtp.gmail.com with ESMTPSA id o10sm4293997eju.89.2021.01.08.23.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 23:21:40 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Dikshita Agarwal , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH] venus: pm_helpers: Control core power domain manually Date: Sat, 9 Jan 2021 09:21:30 +0200 Message-Id: <20210109072130.784-1-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Presently we use device_link to control core power domain. But this leads to issues because the genpd doesn't guarantee synchronous on/off for supplier devices. Switch to manually control by pmruntime calls. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 - .../media/platform/qcom/venus/pm_helpers.c | 36 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) -- 2.17.1 Tested-by: Fritz Koenig diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index dfc13b2f371f..74d9fd3d51cc 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -128,7 +128,6 @@ struct venus_core { struct icc_path *cpucfg_path; struct opp_table *opp_table; bool has_opp_table; - struct device_link *pd_dl_venus; struct device *pmdomains[VIDC_PMDOMAINS_NUM_MAX]; struct device_link *opp_dl_venus; struct device *opp_pmdomain; diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index 94219a3093cb..e0338932a720 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -774,13 +774,6 @@ static int vcodec_domains_get(struct device *dev) core->pmdomains[i] = pd; } - core->pd_dl_venus = device_link_add(dev, core->pmdomains[0], - DL_FLAG_PM_RUNTIME | - DL_FLAG_STATELESS | - DL_FLAG_RPM_ACTIVE); - if (!core->pd_dl_venus) - return -ENODEV; - skip_pmdomains: if (!core->has_opp_table) return 0; @@ -807,14 +800,12 @@ static int vcodec_domains_get(struct device *dev) opp_dl_add_err: dev_pm_opp_detach_genpd(core->opp_table); opp_attach_err: - if (core->pd_dl_venus) { - device_link_del(core->pd_dl_venus); - for (i = 0; i < res->vcodec_pmdomains_num; i++) { - if (IS_ERR_OR_NULL(core->pmdomains[i])) - continue; - dev_pm_domain_detach(core->pmdomains[i], true); - } + for (i = 0; i < res->vcodec_pmdomains_num; i++) { + if (IS_ERR_OR_NULL(core->pmdomains[i])) + continue; + dev_pm_domain_detach(core->pmdomains[i], true); } + return ret; } @@ -827,9 +818,6 @@ static void vcodec_domains_put(struct device *dev) if (!res->vcodec_pmdomains_num) goto skip_pmdomains; - if (core->pd_dl_venus) - device_link_del(core->pd_dl_venus); - for (i = 0; i < res->vcodec_pmdomains_num; i++) { if (IS_ERR_OR_NULL(core->pmdomains[i])) continue; @@ -917,16 +905,30 @@ static void core_put_v4(struct device *dev) static int core_power_v4(struct device *dev, int on) { struct venus_core *core = dev_get_drvdata(dev); + struct device *pmctrl = core->pmdomains[0]; int ret = 0; if (on == POWER_ON) { + if (pmctrl) { + ret = pm_runtime_get_sync(pmctrl); + if (ret < 0) { + pm_runtime_put_noidle(pmctrl); + return ret; + } + } + ret = core_clks_enable(core); + if (ret < 0 && pmctrl) + pm_runtime_put_sync(pmctrl); } else { /* Drop the performance state vote */ if (core->opp_pmdomain) dev_pm_opp_set_rate(dev, 0); core_clks_disable(core); + + if (pmctrl) + pm_runtime_put_sync(pmctrl); } return ret;