Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3628140imm; Mon, 2 Jul 2018 02:37:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpepRIxLXQgXIjLh0ZpvOCtMGWP1C0RtKk/C/QrLA0acRF5WFlcNKkkYvkFuRLQdxKUDogXy X-Received: by 2002:a62:4f5b:: with SMTP id d88-v6mr20036057pfb.225.1530524238402; Mon, 02 Jul 2018 02:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530524238; cv=none; d=google.com; s=arc-20160816; b=Cj8WFyLt7uhNeMWGAaiPu+nsLLeQQ8xtkRV/xXaNuuFNI/bBxGQ8+gK+yQJ/rdUwA1 OXvBYSIH8kAP+Y7tAXiN7Xeqy/qs28qrcRNWwAT/By3vikYPFiDD950Ah9v+kRUdkooS g/eA1EOdgJx+WNLytDn7iSKeeLA3zaIBJwihyoSHzjvBtedliN9PCATG6oqE7cGr2akn uhNLqcDoK2EiemAlQ+3NGAt92oDswOL6PEc7bHwwi6YerDR/KIkkmP8Vvq6lwcsz8n0i tFBxq7sHWQIBRPjJBh0m9enH7jEH7pQtn2Wxax5O9jKpVwZsdI2WYWACvDhRieA+hLOw t5MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=EzbfFlLGL6r9jz1AON5q4rgDiAotjcsVfF9sgRBmedU=; b=kvdXdA3jGg0i/KPNeDBnqhyayk6rdsFhksYIr9GgYLe4IvvOUhLG27rqcmGyCtqyp/ PI6NNPOnzW0FdS7wxBwap3ZHZfD8RLt0xq/BPWJgTYEjLmeaiHa297HkN1TSrblVs8r5 1ObchhpEvQyvXNeXmcIWMeQpou3Qiot7ttebz2tb3M/CSlgG+zWzQonK7lgQHZa/Ko2Z RyB+K/VrS/bUhlZMHYzKBIsLXYELW15BN2nXeqobv4l7kkjrR2LqUqQR0vp+utsaXtjB dmb/BtQvWxoLdEgkiq/CjSwVkmoox2UyHQyRHIJCTTnBk6G9C9ydxQJnBF2FFB34EBbC 2ZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ahxezsse; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5-v6si15794935pls.53.2018.07.02.02.37.03; Mon, 02 Jul 2018 02:37:18 -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=@chromium.org header.s=google header.b=Ahxezsse; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933716AbeGBIsA (ORCPT + 99 others); Mon, 2 Jul 2018 04:48:00 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53884 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754302AbeGBIp4 (ORCPT ); Mon, 2 Jul 2018 04:45:56 -0400 Received: by mail-it0-f66.google.com with SMTP id a195-v6so11059767itd.3 for ; Mon, 02 Jul 2018 01:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EzbfFlLGL6r9jz1AON5q4rgDiAotjcsVfF9sgRBmedU=; b=AhxezsseKESV4lSPMP3VDEcNdL/q2sNqfv+KFVFY0dX3Ojbaws6D8ArGqluTIYNVGc LIWbSnsRicYBeWnKzPeCl7oS0o5P7fiV1dCykv9Apx7orp9cixij+8q9qAbjgpCr2eOb hEbGI5elr5V5gjMoHqP9l+PAIl45VUdNpnPPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EzbfFlLGL6r9jz1AON5q4rgDiAotjcsVfF9sgRBmedU=; b=a+RxLYMIcc1PFu7umOzDoqoJuEYs/C2xAMZJQVDuaAfhjUCeWN00yadC0HeQcl5H54 CTknIIMKEnAIID8ZKOkWS3x9EjV+QdwiSwA42sAZX/loowpbTHWW8Y2vKX1oRLpIwWM4 y3Tzt9TNtsZVrOmRp17v+jnv/KgkLdvMuxBPsOvF4iOqvOCJikJ07qwTGyafsTWfyiSF QzKW2neazn3Blq3Saa4teqC2CP+YZc9mUwHo4hux9oBhbdkH9L/PFRfLOcHz3Q3g6UoR uj+r9mamT62rToTxdlko2nFRT339k6WFME+OIOZ3/yfkyXkDR7Wym8fX2z/ABJFl2eV9 /I3Q== X-Gm-Message-State: APt69E37LTBpTnw1H3RVvFKyM9i2BJLyaNpd47e32umd5309bCEQA942 F772pvCs8xmugOxVCEicEKtAef9MBDc= X-Received: by 2002:a24:69cb:: with SMTP id e194-v6mr9866745itc.102.1530521155889; Mon, 02 Jul 2018 01:45:55 -0700 (PDT) Received: from mail-io0-f171.google.com (mail-io0-f171.google.com. [209.85.223.171]) by smtp.gmail.com with ESMTPSA id u127-v6sm6936927iod.54.2018.07.02.01.45.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 01:45:55 -0700 (PDT) Received: by mail-io0-f171.google.com with SMTP id d185-v6so14046354ioe.0 for ; Mon, 02 Jul 2018 01:45:54 -0700 (PDT) X-Received: by 2002:a6b:b342:: with SMTP id c63-v6mr19633438iof.204.1530521154609; Mon, 02 Jul 2018 01:45:54 -0700 (PDT) MIME-Version: 1.0 References: <20180627152725.9783-1-stanimir.varbanov@linaro.org> <20180627152725.9783-12-stanimir.varbanov@linaro.org> In-Reply-To: <20180627152725.9783-12-stanimir.varbanov@linaro.org> From: Alexandre Courbot Date: Mon, 2 Jul 2018 17:45:43 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 11/27] venus: core,helpers: add two more clocks found in Venus 4xx To: Stanimir Varbanov Cc: Mauro Carvalho Chehab , Hans Verkuil , Linux Media Mailing List , LKML , linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, Tomasz Figa Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 12:34 AM Stanimir Varbanov wrote: > > Add two more clocks for Venus 4xx in core structure and create > a new power enable function to handle it for 3xx/4xx versions. > > Signed-off-by: Stanimir Varbanov > --- > drivers/media/platform/qcom/venus/core.h | 4 +++ > drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++++++++++++++++++++ > drivers/media/platform/qcom/venus/helpers.h | 2 ++ > drivers/media/platform/qcom/venus/vdec.c | 44 ++++++++++++++++++++----- > drivers/media/platform/qcom/venus/venc.c | 44 ++++++++++++++++++++----- > 5 files changed, 129 insertions(+), 16 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h > index 8d3e150800c9..2bf8839784fa 100644 > --- a/drivers/media/platform/qcom/venus/core.h > +++ b/drivers/media/platform/qcom/venus/core.h > @@ -65,6 +65,8 @@ struct venus_format { > * @clks: an array of struct clk pointers > * @core0_clk: a struct clk pointer for core0 > * @core1_clk: a struct clk pointer for core1 > + * @core0_bus_clk: a struct clk pointer for core0 bus clock > + * @core1_bus_clk: a struct clk pointer for core1 bus clock > * @vdev_dec: a reference to video device structure for decoder instances > * @vdev_enc: a reference to video device structure for encoder instances > * @v4l2_dev: a holder for v4l2 device structure > @@ -94,6 +96,8 @@ struct venus_core { > struct clk *clks[VIDC_CLKS_NUM_MAX]; > struct clk *core0_clk; > struct clk *core1_clk; > + struct clk *core0_bus_clk; > + struct clk *core1_bus_clk; > struct video_device *vdev_dec; > struct video_device *vdev_enc; > struct v4l2_device v4l2_dev; > diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c > index d9065cc8a7d3..228084e72fb7 100644 > --- a/drivers/media/platform/qcom/venus/helpers.c > +++ b/drivers/media/platform/qcom/venus/helpers.c > @@ -13,6 +13,7 @@ > * > */ > #include > +#include > #include > #include > #include > @@ -24,6 +25,7 @@ > #include "core.h" > #include "helpers.h" > #include "hfi_helper.h" > +#include "hfi_venus_io.h" > > struct intbuf { > struct list_head list; > @@ -781,3 +783,52 @@ void venus_helper_init_instance(struct venus_inst *inst) > } > } > EXPORT_SYMBOL_GPL(venus_helper_init_instance); > + > +int venus_helper_power_enable(struct venus_core *core, u32 session_type, > + bool enable) > +{ > + void __iomem *ctrl, *stat; > + u32 val; > + int ret; > + > + if (!IS_V3(core) && !IS_V4(core)) > + return 0; > + > + if (IS_V3(core)) { > + if (session_type == VIDC_SESSION_TYPE_DEC) > + ctrl = core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL; > + else > + ctrl = core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL; > + if (enable) > + writel(0, ctrl); > + else > + writel(1, ctrl); > + > + return 0; > + } > + > + if (session_type == VIDC_SESSION_TYPE_DEC) { > + ctrl = core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL; > + stat = core->base + WRAPPER_VCODEC0_MMCC_POWER_STATUS; > + } else { > + ctrl = core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL; > + stat = core->base + WRAPPER_VCODEC1_MMCC_POWER_STATUS; > + } > + > + if (enable) { > + writel(0, ctrl); > + > + ret = readl_poll_timeout(stat, val, val & BIT(1), 1, 100); > + if (ret) > + return ret; > + } else { > + writel(1, ctrl); > + > + ret = readl_poll_timeout(stat, val, !(val & BIT(1)), 1, 100); > + if (ret) > + return ret; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(venus_helper_power_enable); > diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h > index 971392be5df5..0e64aa95624a 100644 > --- a/drivers/media/platform/qcom/venus/helpers.h > +++ b/drivers/media/platform/qcom/venus/helpers.h > @@ -43,4 +43,6 @@ int venus_helper_set_color_format(struct venus_inst *inst, u32 fmt); > void venus_helper_acquire_buf_ref(struct vb2_v4l2_buffer *vbuf); > void venus_helper_release_buf_ref(struct venus_inst *inst, unsigned int idx); > void venus_helper_init_instance(struct venus_inst *inst); > +int venus_helper_power_enable(struct venus_core *core, u32 session_type, > + bool enable); > #endif > diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c > index 261a51adeef2..3cf243ddcdb8 100644 > --- a/drivers/media/platform/qcom/venus/vdec.c > +++ b/drivers/media/platform/qcom/venus/vdec.c > @@ -1081,12 +1081,18 @@ static int vdec_probe(struct platform_device *pdev) > if (!core) > return -EPROBE_DEFER; > > - if (core->res->hfi_version == HFI_VERSION_3XX) { > + if (IS_V3(core) || IS_V4(core)) { > core->core0_clk = devm_clk_get(dev, "core"); > if (IS_ERR(core->core0_clk)) > return PTR_ERR(core->core0_clk); > } > > + if (IS_V4(core)) { > + core->core0_bus_clk = devm_clk_get(dev, "bus"); > + if (IS_ERR(core->core0_bus_clk)) > + return PTR_ERR(core->core0_bus_clk); > + } > + > platform_set_drvdata(pdev, core); > > vdev = video_device_alloc(); > @@ -1131,15 +1137,21 @@ static int vdec_remove(struct platform_device *pdev) > static __maybe_unused int vdec_runtime_suspend(struct device *dev) > { > struct venus_core *core = dev_get_drvdata(dev); > + int ret; > > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > > - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); > + > + if (IS_V4(core)) > + clk_disable_unprepare(core->core0_bus_clk); > + > clk_disable_unprepare(core->core0_clk); > - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > > - return 0; > + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); Is it safe to OR two potentially different error messages, at the risk of getting a third one that is different? If venus_helper_power_enable() fails, shouldn't we just exit early and signify that the suspend operation failed? > + > + return ret; > } > > static __maybe_unused int vdec_runtime_resume(struct device *dev) > @@ -1147,13 +1159,29 @@ static __maybe_unused int vdec_runtime_resume(struct device *dev) > struct venus_core *core = dev_get_drvdata(dev); > int ret; > > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > > - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, true); > + if (ret) > + return ret; ... similarly to what it done here, actually. > + > ret = clk_prepare_enable(core->core0_clk); > - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > + if (ret) > + goto err_power_disable; > + > + if (IS_V4(core)) > + ret = clk_prepare_enable(core->core0_bus_clk); > > + if (ret) > + goto err_unprepare_core0; > + > + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); > + > +err_unprepare_core0: > + clk_disable_unprepare(core->core0_clk); > +err_power_disable: > + venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); > return ret; > } > > diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c > index 947001170a77..2cd7b342b208 100644 > --- a/drivers/media/platform/qcom/venus/venc.c > +++ b/drivers/media/platform/qcom/venus/venc.c > @@ -1225,12 +1225,18 @@ static int venc_probe(struct platform_device *pdev) > if (!core) > return -EPROBE_DEFER; > > - if (core->res->hfi_version == HFI_VERSION_3XX) { > + if (IS_V3(core) || IS_V4(core)) { > core->core1_clk = devm_clk_get(dev, "core"); > if (IS_ERR(core->core1_clk)) > return PTR_ERR(core->core1_clk); > } > > + if (IS_V4(core)) { > + core->core1_bus_clk = devm_clk_get(dev, "bus"); > + if (IS_ERR(core->core1_bus_clk)) > + return PTR_ERR(core->core1_bus_clk); > + } > + > platform_set_drvdata(pdev, core); > > vdev = video_device_alloc(); > @@ -1275,15 +1281,21 @@ static int venc_remove(struct platform_device *pdev) > static __maybe_unused int venc_runtime_suspend(struct device *dev) > { > struct venus_core *core = dev_get_drvdata(dev); > + int ret; > > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > > - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); > + > + if (IS_V4(core)) > + clk_disable_unprepare(core->core1_bus_clk); > + > clk_disable_unprepare(core->core1_clk); > - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > > - return 0; > + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); Same question for this function. > + > + return ret; > } > > static __maybe_unused int venc_runtime_resume(struct device *dev) > @@ -1291,13 +1303,29 @@ static __maybe_unused int venc_runtime_resume(struct device *dev) > struct venus_core *core = dev_get_drvdata(dev); > int ret; > > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > > - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + ret = venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, true); > + if (ret) > + return ret; > + > ret = clk_prepare_enable(core->core1_clk); > - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + if (ret) > + goto err_power_disable; > + > + if (IS_V4(core)) > + ret = clk_prepare_enable(core->core1_bus_clk); > > + if (ret) > + goto err_unprepare_core1; > + > + return venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); > + > +err_unprepare_core1: > + clk_disable_unprepare(core->core1_clk); > +err_power_disable: > + venus_helper_power_enable(core, VIDC_SESSION_TYPE_ENC, false); > return ret; > } > > -- > 2.14.1 >