Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1047869imm; Fri, 1 Jun 2018 14:22:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIhMsDwLR+XOAWSge1QfpnfJSbG54J4mMoaKDBsoLhuGB3bZAZKVf/A4D/I58EVSqkHculx X-Received: by 2002:a63:7f4f:: with SMTP id p15-v6mr10101466pgn.312.1527888127209; Fri, 01 Jun 2018 14:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527888127; cv=none; d=google.com; s=arc-20160816; b=DMZIRgMyOKDoVXe7J5HAR5GIWGWSnOpRetWlcL04XF+uyYZumCesmiS+lJHQYBGZoV JdxNgyu0uHO2V3OyfXgP8h8JL5pXVIFCeyMKuKtc+A9LZtC0p0a/YvABZJCP8g1UxzDO YU4Lx7cE/Fj+GpNDf9/agc9d5ag82VpG2N1SEX71ixOyVtuVQEbVPXPN47QyAi09i59Z /igto4AZuUSMtT/THV3eINliKgVJ15XUCz74Wcp5mxv5KBH4rNJrWXmToSVc9L3v2+sX A+6tWY5miYK7lRAu9QxB5ULL4xHWMiNZi09ICv9zmnp5fupKlUwOmU8d+0YuQUgOEEbY U5/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=QUYE7e5fsqvTlDIFw/jzm0e1Xroes4OeG/mWcbm3A5Y=; b=X9tRlMmSq+83nM6R8BDHSX4f8dD95nkzOCMYxwlq7AvnDwrKVBrdfujKZNvVfo1dIf oeNZW7Sy1BXgLvEoVdYJG/ngFyeNIjaJ7TNoYBoogsHO7UwIMrCjxZrrH5ztIgRDqO42 7/PyjAdkhCpgn+A+RI4HKx65SbxsstYyWR7Z4Oe82Wy7Um2mQpiYJqGvZIIoiWrgXNKP YZxtSQbUAMNL980Cr3duA0Sox4sgxVg1GhDWsrjblE6XY0TY0FA4Wy+Ns8iDouq6sC8P ycd1pBGIzAjG8wCUa47PlVip+WdidCEymXEU0S1sKeOtnwzxx3IoG/2MY/jfK0/6mVjd csgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=oDHdbuiW; dkim=pass header.i=@codeaurora.org header.s=default header.b=Me5QtDC1; 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 q137-v6si2090162pfc.164.2018.06.01.14.21.52; Fri, 01 Jun 2018 14:22:07 -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=@codeaurora.org header.s=default header.b=oDHdbuiW; dkim=pass header.i=@codeaurora.org header.s=default header.b=Me5QtDC1; 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 S1750929AbeFAVVZ (ORCPT + 99 others); Fri, 1 Jun 2018 17:21:25 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37086 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724AbeFAVVW (ORCPT ); Fri, 1 Jun 2018 17:21:22 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 15967606FA; Fri, 1 Jun 2018 21:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527888082; bh=2OFTiflZ16xF4Wa0EE/eA3f8+UjD5+Jx6ue8wZcDXH0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oDHdbuiWjEXkLulcc+EIetIOHWZ2uoxrXOSqy130oilnCEoVdZF/tPSJn8/Ibg00G 31EhUiOOERiWlnogJyFTe4gIAHBiCmXQcdS/rPqguQJXTsvBGeVPkZlV0R5nJvGuv9 IJkRSHQMnnjcwpKhQv8K+gqKvMmCVXpU9braaDiw= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E625C6044B; Fri, 1 Jun 2018 21:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527888081; bh=2OFTiflZ16xF4Wa0EE/eA3f8+UjD5+Jx6ue8wZcDXH0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Me5QtDC1OCV+1lOD5HqxDjN0dyE5h84BJUp8j8n/2BNLCrCW/OBUixRjpfF/C3loX 4sACDNKx1o9rv4ShXpjIh2l5hwhjYf7fk8TdrX3u35pp0dPsWNsp5ZUArsUWzj76EK igDTjWOiDpyOfZrnmDBz3vRBIZ71ThhPerC9eGss= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E625C6044B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org Date: Fri, 1 Jun 2018 15:21:17 -0600 From: Jordan Crouse To: Vikash Garodia Cc: hverkuil@xs4all.nl, mchehab@kernel.org, robh@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, bjorn.andersson@linaro.org, stanimir.varbanov@linaro.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, acourbot@chromium.org Subject: Re: [PATCH v2 2/5] media: venus: add a routine to set venus state Message-ID: <20180601212117.GD11565@jcrouse-lnx.qualcomm.com> Mail-Followup-To: Vikash Garodia , hverkuil@xs4all.nl, mchehab@kernel.org, robh@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org, bjorn.andersson@linaro.org, stanimir.varbanov@linaro.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, acourbot@chromium.org References: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> <1527884768-22392-3-git-send-email-vgarodia@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527884768-22392-3-git-send-email-vgarodia@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 02, 2018 at 01:56:05AM +0530, Vikash Garodia wrote: > Add a new routine which abstracts the TZ call to > set the video hardware state. > > Signed-off-by: Vikash Garodia > --- > drivers/media/platform/qcom/venus/core.h | 5 +++++ > drivers/media/platform/qcom/venus/firmware.c | 28 +++++++++++++++++++++++++++ > drivers/media/platform/qcom/venus/firmware.h | 1 + > drivers/media/platform/qcom/venus/hfi_venus.c | 13 ++++--------- > 4 files changed, 38 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h > index 85e66e2..e7bfb63 100644 > --- a/drivers/media/platform/qcom/venus/core.h > +++ b/drivers/media/platform/qcom/venus/core.h > @@ -35,6 +35,11 @@ struct reg_val { > u32 value; > }; > > +enum tzbsp_video_state { > + TZBSP_VIDEO_SUSPEND = 0, > + TZBSP_VIDEO_RESUME You should put a comma after the last item to reduce future patch sizes. > +}; > + > struct venus_resources { > u64 dma_mask; > const struct freq_tbl *freq_tbl; > diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c > index 7d89b5a..b4664ed 100644 > --- a/drivers/media/platform/qcom/venus/firmware.c > +++ b/drivers/media/platform/qcom/venus/firmware.c > @@ -53,6 +53,34 @@ static void venus_reset_hw(struct venus_core *core) > /* Bring Arm9 out of reset */ > writel_relaxed(0, reg_base + WRAPPER_A9SS_SW_RESET); > } > + > +int venus_set_hw_state(enum tzbsp_video_state state, struct venus_core *core) > +{ > + int ret; > + struct device *dev = core->dev; If you get rid of the log message as you should, you don't need this. > + void __iomem *reg_base = core->base; > + > + switch (state) { > + case TZBSP_VIDEO_SUSPEND: > + if (qcom_scm_is_available()) > + ret = qcom_scm_set_remote_state(TZBSP_VIDEO_SUSPEND, 0); > + else > + writel_relaxed(1, reg_base + WRAPPER_A9SS_SW_RESET); You can just use core->base here and not bother making a local variable for it. > + break; > + case TZBSP_VIDEO_RESUME: > + if (qcom_scm_is_available()) > + ret = qcom_scm_set_remote_state(TZBSP_VIDEO_RESUME, 0); > + else > + venus_reset_hw(core); > + break; > + default: > + dev_err(dev, "invalid state\n"); state is a enum - you are highly unlikely to be calling it in your own code with a random value. It is smart to have the default, but you don't need the log message - that is just wasted space in the binary. > + break; > + } There are three paths in the switch statement that could end up with 'ret' being uninitialized here. Set it to 0 when you declare it. > + return ret; > +} > +EXPORT_SYMBOL_GPL(venus_set_hw_state); > + > int venus_boot(struct device *dev, const char *fwname) > { > const struct firmware *mdt; > diff --git a/drivers/media/platform/qcom/venus/firmware.h b/drivers/media/platform/qcom/venus/firmware.h > index 428efb5..1336729 100644 > --- a/drivers/media/platform/qcom/venus/firmware.h > +++ b/drivers/media/platform/qcom/venus/firmware.h > @@ -18,5 +18,6 @@ > > int venus_boot(struct device *dev, const char *fwname); > int venus_shutdown(struct device *dev); > +int venus_set_hw_state(enum tzbsp_video_state, struct venus_core *core); > > #endif > diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c > index f61d34b..797a9f5 100644 > --- a/drivers/media/platform/qcom/venus/hfi_venus.c > +++ b/drivers/media/platform/qcom/venus/hfi_venus.c > @@ -19,7 +19,6 @@ > #include > #include > #include > -#include > #include > > #include "core.h" > @@ -27,6 +26,7 @@ > #include "hfi_msgs.h" > #include "hfi_venus.h" > #include "hfi_venus_io.h" > +#include "firmware.h" > > #define HFI_MASK_QHDR_TX_TYPE 0xff000000 > #define HFI_MASK_QHDR_RX_TYPE 0x00ff0000 > @@ -55,11 +55,6 @@ > #define IFACEQ_VAR_LARGE_PKT_SIZE 512 > #define IFACEQ_VAR_HUGE_PKT_SIZE (1024 * 12) > > -enum tzbsp_video_state { > - TZBSP_VIDEO_STATE_SUSPEND = 0, > - TZBSP_VIDEO_STATE_RESUME > -}; > - > struct hfi_queue_table_header { > u32 version; > u32 size; > @@ -574,7 +569,7 @@ static int venus_power_off(struct venus_hfi_device *hdev) > if (!hdev->power_enabled) > return 0; > > - ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0); > + ret = venus_set_hw_state(TZBSP_VIDEO_SUSPEND, hdev->core); > if (ret) > return ret; > > @@ -594,7 +589,7 @@ static int venus_power_on(struct venus_hfi_device *hdev) > if (hdev->power_enabled) > return 0; > > - ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0); > + ret = venus_set_hw_state(TZBSP_VIDEO_RESUME, hdev->core); > if (ret) > goto err; > > @@ -607,7 +602,7 @@ static int venus_power_on(struct venus_hfi_device *hdev) > return 0; > > err_suspend: > - qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0); > + venus_set_hw_state(TZBSP_VIDEO_SUSPEND, hdev->core); > err: > hdev->power_enabled = false; > return ret; -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project