Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1730624imm; Wed, 23 May 2018 23:27:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8nN1nqC5yeolL9pzG65CEn9nxuklBXr/24S8xfZ00ADodDpVnKZaodp3nweIYHy2T6uLz X-Received: by 2002:a65:6354:: with SMTP id p20-v6mr4772937pgv.437.1527143246713; Wed, 23 May 2018 23:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527143246; cv=none; d=google.com; s=arc-20160816; b=x8TCyKcVFiiOdfCAWLRCC5io8UwfcpLeBbP5Cf0WG62zbU2R+1fDIymAPgAc3QQYA8 x9PS0c41syT1pQS/n7sNAZTchOT/FtVfMHpTcheEAQ6Z/oFJUYvOD6ZUBb7fX3NWxeiK cO5P0wvk52UDajZ2ogssszbKWiEqx5bolDm6YHaA7NIgv2OcF45PcFiXyVbwFMASy01n 3HPu4tD8EimkNLxyvoQHI0XheUrGvPLABVx+z0D/Ud3ydOaK1jenNnGRQz5ONQCWTot7 f0w8sWi2B1oB7DTJYhzn4bHzWamWlyygEGzOL3F/d6A5sytvTm/PreDX6KcL6qgeD5Yh /5Dg== 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=08eAEwxvn66dhs1VwxYggNckC2yl0k1LoGLPZPI9JJc=; b=k7fqNydQ3QSRUrz1b84LkNjxHYPevir60O2jkEcJQPm+NIJr4FPJxcJPT3VG/rSAM7 rmaxS6A3lLariXuFDNcvLRHlR+xdUSeDCm9P7Jh52eq3QPyKy0DlcZ3w7HkPjvhhYQkx RvJpaRrXMEFYDPWleEWmIQeuTv2weOQOayDHouDYR2zKhZNfNo4HafrrCbwyh45DHuMK Y9+yNyfNruXhawSpl8FUT5aWmRN3fwSxWf8Jr8OApztrhIKyrL0eeJ4SXVU/8c10Wdh3 NUgfc8Ha+ah6D3t2FcjamUjPxoHnzgwNPxKdRLLACSYdWPvgtBRLrknOFAAhPu9v1zn5 ngmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iuaHpldT; 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 f18-v6si1338623pge.581.2018.05.23.23.27.11; Wed, 23 May 2018 23:27:26 -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=iuaHpldT; 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 S1754955AbeEXGMD (ORCPT + 99 others); Thu, 24 May 2018 02:12:03 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:35410 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158AbeEXGMA (ORCPT ); Thu, 24 May 2018 02:12:00 -0400 Received: by mail-vk0-f68.google.com with SMTP id g72-v6so283173vke.2 for ; Wed, 23 May 2018 23:12:00 -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=08eAEwxvn66dhs1VwxYggNckC2yl0k1LoGLPZPI9JJc=; b=iuaHpldTexL0AOBF/0H+ZNc//+6qxOKML75csOZHYrdgK50BrFZgYS1bikRK6jC+Ax +fp3QXE00v4bKv4WFzr9T46y/C1Xh6GV46b/mk8Vd4IxdYkvSl0dkUNkBVj9xsCPZv8W aU8n4U+4Dr43TqwfrVOt0yEFNid9xHKk3kqZc= 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=08eAEwxvn66dhs1VwxYggNckC2yl0k1LoGLPZPI9JJc=; b=O4jpV6iBOd73p8FhJIEOAGVimr0Hjs16x8cGigG3qlUg6Vstl7hGr0Fyabj6kKHzGs v410PVq4QcGbW3nGFyl6y9s0UGrXokg6Z2GPSiVaDu7DQ6A2qw7Xw1g6BUayxviRV4oq 4JeR4ZOlZs6D6cNm/Qlz+aShep/vgffG/695Q6UD9MRn2CCGf+p1wAL70zL7qfzjU64S 4CTKHxTZN3Wq5zbGDi0Ui20IRQ213CRZJVIH4H3ChbrEggSXbtOkxKH1ZLXQGmB4psFb lcKAP5trTEZ9NZGgg9Ft71m4qe3z0qZbCc3hyU5iDvqfqpBcJY9fHHCPq6EXk6Q4lcWF Jmqg== X-Gm-Message-State: ALKqPwcURH9OL4Vv88bbzOHQwssM6cXdO7KrHiEDQeqPOB3gmKSpGTpD 7xsIAZ2DS/UvrAPu7gWT12Vx1MWTb8o= X-Received: by 2002:a1f:de04:: with SMTP id v4-v6mr3684802vkg.87.1527142319427; Wed, 23 May 2018 23:11:59 -0700 (PDT) Received: from mail-vk0-f54.google.com (mail-vk0-f54.google.com. [209.85.213.54]) by smtp.gmail.com with ESMTPSA id y23-v6sm3579385vky.26.2018.05.23.23.11.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 23:11:58 -0700 (PDT) Received: by mail-vk0-f54.google.com with SMTP id x191-v6so277161vke.10 for ; Wed, 23 May 2018 23:11:57 -0700 (PDT) X-Received: by 2002:a1f:c2c7:: with SMTP id s190-v6mr3726328vkf.86.1527142317424; Wed, 23 May 2018 23:11:57 -0700 (PDT) MIME-Version: 1.0 References: <20180515075859.17217-1-stanimir.varbanov@linaro.org> <20180515075859.17217-12-stanimir.varbanov@linaro.org> In-Reply-To: <20180515075859.17217-12-stanimir.varbanov@linaro.org> From: Tomasz Figa Date: Thu, 24 May 2018 15:11:46 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 11/29] venus: venc,vdec: adds clocks needed for venus 4xx 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:10 PM Stanimir Varbanov < stanimir.varbanov@linaro.org> wrote: > This extends the clocks number to support suspend and resume > on Venus version 4xx. > Signed-off-by: Stanimir Varbanov > --- > drivers/media/platform/qcom/venus/core.h | 4 +-- > drivers/media/platform/qcom/venus/vdec.c | 42 ++++++++++++++++++++++++++------ > drivers/media/platform/qcom/venus/venc.c | 42 ++++++++++++++++++++++++++------ > 3 files changed, 72 insertions(+), 16 deletions(-) > diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h > index 8d3e150800c9..b5b9a84e9155 100644 > --- a/drivers/media/platform/qcom/venus/core.h > +++ b/drivers/media/platform/qcom/venus/core.h > @@ -92,8 +92,8 @@ struct venus_core { > void __iomem *base; > int irq; > struct clk *clks[VIDC_CLKS_NUM_MAX]; > - struct clk *core0_clk; > - struct clk *core1_clk; > + struct clk *core0_clk, *core0_bus_clk; > + struct clk *core1_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/vdec.c b/drivers/media/platform/qcom/venus/vdec.c > index 261a51adeef2..c45452634e7e 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); > + } > + Rather than doing this conditional dance, wouldn't it make more sense to just list all the clocks in variant data struct and use clk_bulk_get()? > platform_set_drvdata(pdev, core); > vdev = video_device_alloc(); > @@ -1132,12 +1138,23 @@ static __maybe_unused int vdec_runtime_suspend(struct device *dev) > { > struct venus_core *core = dev_get_drvdata(dev); > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > - writel(0, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > + 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); > + > + 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); > + > + 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); Almost every step here differs between version. I'd suggest splitting this into separate functions for both versions. > return 0; > } > @@ -1147,12 +1164,23 @@ 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); > + 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 = clk_prepare_enable(core->core0_clk); > - writel(1, core->base + WRAPPER_VDEC_VCODEC_POWER_CONTROL); > + > + if (IS_V4(core)) > + ret |= clk_prepare_enable(core->core0_bus_clk); Please don't OR error codes. If both calls end up with different errors, the resulting value would be meaningless. > + > + 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); > return ret; > } Same for this function. I'd see separate function for each version. > diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c > index 947001170a77..bc8c2e7a8d2c 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); > + } > + Same as for corresponding function of vdec. > platform_set_drvdata(pdev, core); > vdev = video_device_alloc(); > @@ -1276,12 +1282,23 @@ static __maybe_unused int venc_runtime_suspend(struct device *dev) > { > struct venus_core *core = dev_get_drvdata(dev); > - if (core->res->hfi_version == HFI_VERSION_1XX) > + if (IS_V1(core)) > return 0; > - writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + if (IS_V3(core)) > + writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + else if (IS_V4(core)) > + writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); > + > + 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); > + > + if (IS_V3(core)) > + writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + else if (IS_V4(core)) > + writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); > return 0; > } Same as for vdec. > @@ -1291,12 +1308,23 @@ 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); > + if (IS_V3(core)) > + writel(0, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + else if (IS_V4(core)) > + writel(0, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); > + > ret = clk_prepare_enable(core->core1_clk); > - writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + > + if (IS_V4(core)) > + ret |= clk_prepare_enable(core->core1_bus_clk); > + > + if (IS_V3(core)) > + writel(1, core->base + WRAPPER_VENC_VCODEC_POWER_CONTROL); > + else if (IS_V4(core)) > + writel(1, core->base + WRAPPER_VCODEC1_MMCC_POWER_CONTROL); > return ret; > } Same as for vdec. Best regards, Tomasz