Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp318850imm; Thu, 31 May 2018 00:36:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLz5gbsvJNhR2rGnvYHgTWk9dMlkqU8ACYcHQQ6V7TXZUWp6syUCEecfF8lV++STFxM19uH X-Received: by 2002:a63:7f15:: with SMTP id a21-v6mr4637156pgd.21.1527752190978; Thu, 31 May 2018 00:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527752190; cv=none; d=google.com; s=arc-20160816; b=RIs94dyOdgt+SAMZ9VxJIwZodCIohS1RBMj8PQhx3TCINdmTRFihPKNFKrk9HqF+jd q5KNh1ly+DdKrXgpaPJhghNaOHFH7a4xSMHMIhRZ1A7kBOZjbSrkFBoJRs7AeT2YwKdi EsaHrDNvdXIe/vmqxLhFC2goSql0J8bsHNX9OSgbobBWFqIdTuB18WXg3sDm0Njtno6D IUkzJ4jr8HGoeh/cEcnqb1IQDy3sDFbRggkFULP7F9YtYFqvdyBeG+dK4m5MTkBP9lt5 WPeqbzKneo8Lor8fRmeUt6Vg2nCkHfo0ftf4uHs+yFqLyKPH3iOKZx2GjHyqjUsCqR4/ hANQ== 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=PZdhaIm3ps+bPHc3nhpFRl5wz/QtehLeYfEwKmL1FhU=; b=OymRAmBZCc+uFLB7xhQncKY4lfa5wLs8OFQcXCO565Ek5C+MMeozdi5/XGefwHys6t ris1vvFSBHsNiXiuAgSn15YXWgMtPJUGqfZz466R5Kkqf3PdtDw2Fvib8s7+KQYowque WmKXlROmQSjc8QKJ+opjwBrg8lyEzVZ2YPqe9ulkkjaNqF9yQsBQ60mD3dYVv2BXIWZf Rlb+KgY4q/OrC9niImKu7Ttcv/MfYcMXs50V41Lwu+gDpOIJnBnvTnkI0xLEnElpNo+3 1rCKGomVac7N3JKCbzwXPd6APmlodztpz+nOHbWDyqy8Lb65gBTziZbj2ZDkvNRWPEZw Fskw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GoSuvnPQ; 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 q2-v6si36491210plh.136.2018.05.31.00.36.15; Thu, 31 May 2018 00:36:30 -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=GoSuvnPQ; 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 S1754021AbeEaHev (ORCPT + 99 others); Thu, 31 May 2018 03:34:51 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:46406 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753996AbeEaHeq (ORCPT ); Thu, 31 May 2018 03:34:46 -0400 Received: by mail-vk0-f68.google.com with SMTP id i190-v6so12741552vkd.13 for ; Thu, 31 May 2018 00:34:46 -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=PZdhaIm3ps+bPHc3nhpFRl5wz/QtehLeYfEwKmL1FhU=; b=GoSuvnPQvbXCWyu7RW/+z6Wc4YdgTqm7LfOGxFUCbQNzk123ZTSy52pW2BATRmWdMi RmCIUO9emRujj/+fnBljzPeayuNX2VocTXG8t8I7TwUzIsJhCNUtw5YRhSzM8Zc6a9ZU PK9W6YBHjwQbXxrTkW2wfuesW6mzRlM9gPIB4= 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=PZdhaIm3ps+bPHc3nhpFRl5wz/QtehLeYfEwKmL1FhU=; b=llP8+jE/2Uh2CLqnsHrD1Nko87Vqy27meaRutTiktn5EPBDgGJJF0Z/AZrn1R+WPIt dTQPSmFLgbkgsawWmlhDDklXqS3N85oouyb+PV/RkljR3WlGs/ETg7GRGG3344vGnGX6 ybYVZPerQEFIbaBOonfmlv2pivMcl0W4295jYNKrGLETEAAl/qaq1c6jXStGGLAVfCSS q5cSbU2K3kqiBsgno+vtFpVYmKNdpUDfj3FjwiNnNwQdR+3ijrRLnEYh3HUgF9Ht5n44 3VuqyLL36tdUFemvcroxjZbP6RA/MnEcYdSVlqWC/Vk9544vivK0BpTuzdBGtz0kyT31 w+FA== X-Gm-Message-State: ALKqPwdpgA/n2xcmxvQB3DtYIgvyaFKDANQQSSAfZYqCxq/84NEop4uD Zt+bVuaubQkRqlB4lEYduP73zqIY1Vo= X-Received: by 2002:a1f:784b:: with SMTP id t72-v6mr3462799vkc.33.1527752085415; Thu, 31 May 2018 00:34:45 -0700 (PDT) Received: from mail-vk0-f41.google.com (mail-vk0-f41.google.com. [209.85.213.41]) by smtp.gmail.com with ESMTPSA id r198-v6sm8044864vkr.35.2018.05.31.00.34.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 00:34:44 -0700 (PDT) Received: by mail-vk0-f41.google.com with SMTP id n134-v6so12736066vke.12 for ; Thu, 31 May 2018 00:34:44 -0700 (PDT) X-Received: by 2002:a1f:e686:: with SMTP id d128-v6mr3528441vkh.176.1527752083944; Thu, 31 May 2018 00:34:43 -0700 (PDT) MIME-Version: 1.0 References: <20180515075859.17217-1-stanimir.varbanov@linaro.org> <20180515075859.17217-14-stanimir.varbanov@linaro.org> In-Reply-To: <20180515075859.17217-14-stanimir.varbanov@linaro.org> From: Tomasz Figa Date: Thu, 31 May 2018 16:34:32 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 13/29] venus: helpers: make a commmon function for power_enable To: Stanimir Varbanov Cc: Mauro Carvalho Chehab , Hans Verkuil , Linux Media Mailing List , Linux Kernel Mailing List , linux-arm-msm , vgarodia@codeaurora.org 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 Hi Stanimir, On Tue, May 15, 2018 at 5:06 PM Stanimir Varbanov wrote: > > Make common function which will enable power when enabling/disabling > clocks and also covers Venus 3xx/4xx versions. > > Signed-off-by: Stanimir Varbanov > --- > drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++++++++++++++++++++ > drivers/media/platform/qcom/venus/helpers.h | 2 ++ > drivers/media/platform/qcom/venus/vdec.c | 25 ++++---------- > drivers/media/platform/qcom/venus/venc.c | 25 ++++---------- > 4 files changed, 67 insertions(+), 36 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c > index d9065cc8a7d3..2b21f6ed7502 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 -EINVAL; > + > + 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); nit: The value written is just !enable, but no strong preference. > + > + 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; > + } nit: The if/else could be just folded into code like below, but no strong preference: writel(!enable, ctrl); ret = readl_poll_timeout(stat, val, !!(val & BIT(1)) == enable, 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 3b38bd1241b0..2bd81de6328a 100644 > --- a/drivers/media/platform/qcom/venus/vdec.c > +++ b/drivers/media/platform/qcom/venus/vdec.c > @@ -1123,26 +1123,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 (IS_V1(core)) > return 0; > > - if (IS_V3(core)) > - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > - else if (IS_V4(core)) > - writel(0, core->base + WRAPPER_VCODEC0_MMCC_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); > > - if (IS_V3(core)) > - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > - else if (IS_V4(core)) > - writel(1, core->base + WRAPPER_VCODEC0_MMCC_POWER_CONTROL); > + ret |= venus_helper_power_enable(core, VIDC_SESSION_TYPE_DEC, false); If both calls return different error codes, the value of ret would become garbage. (Same for rest of the patch.) Best regards, Tomasz