Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp520609imm; Wed, 4 Jul 2018 01:01:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcx1en89VfRKCmpBQQlJkoOp/mKh3YCCGNQYfBTs7krCKcvBsLmKHGVRkm5QUsnVOhq2BOL X-Received: by 2002:a63:9d87:: with SMTP id i129-v6mr894165pgd.395.1530691286391; Wed, 04 Jul 2018 01:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530691286; cv=none; d=google.com; s=arc-20160816; b=GEf2jM1XeHlACrU0LSLZLSwR6TpY+mOoX5Lzc/zM81136G7yQTTUzxKHqWDz3I8TzX IHYiNg45DjNx+MHTAYjPcy8+yeTCbhPFHDPWxh1camhIHKcnIPXD50Q5uASbk8atyJqv fXMu5rejjoWXGXdgIdk0TeBAXvfcnEp7pGHS9dldSoHZDhzDcVa1d40dVvGFqB+QF6sm CXazMc6MucOJNV0WuJqgjcCnoPMgY+NDELOBHL9zSrKl4zOVjtCQDGNSg/Ug6MuE8uv6 rN+ran/iId3i4fr0Q7bcjsFird6+P1fHKXxoYKMalJ9mW8PrDM1BNC/XS/zGSKgZmeal BV7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=NOBEpobj/S8PJoPxUoiSwNCDwBBBi2983f6I941O5MA=; b=drvWtl/Ii7bBAPNYC4AC684z7/OBWfGqVdMXTyUGUKhPR7hL09cdCURjK5n200zM7c 2MCMyRW0eNuUypGvGIsXRK1vZYYbId3VPePoatXF9opqXEnVF9rtp894GlQWigxezPjX NjL3Er9A7QyQq3Yf+q/GPsuFUNIYFx0ug7eL6pEU91XVJKXFY5MbZOzKrI5GWK5fkG35 gFqb3DcrtS/OT6Pu2nIRihwo/SQN5rPOxBCHxiT3UyAtNLEIreDE26ycObUyoNL77fCn LS7AgXAP5mNpeOT1xEr+rlCVGNhyZY0aMmMw0Poqa4gna6pSJkKsaRqQBR+U8S/3310y H0Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jGZQFpSp; dkim=pass header.i=@codeaurora.org header.s=default header.b=jGZQFpSp; 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 e7-v6si2822635pgc.233.2018.07.04.01.01.12; Wed, 04 Jul 2018 01:01: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=@codeaurora.org header.s=default header.b=jGZQFpSp; dkim=pass header.i=@codeaurora.org header.s=default header.b=jGZQFpSp; 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 S933930AbeGDH7k (ORCPT + 99 others); Wed, 4 Jul 2018 03:59:40 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56500 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933862AbeGDH7f (ORCPT ); Wed, 4 Jul 2018 03:59:35 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C7AEC6037C; Wed, 4 Jul 2018 07:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530691174; bh=HDtz+4PL2kQlcliMnYtONdajrMFzt01m9GTNQLI4pOw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jGZQFpSpNUpkv8hXC9ULlFqK+kHw5Ds+ePbNNE7kdCvcGU/nVR0O7gXdJSDXKeWnz 3s1IZBxVpq4OHx5HgnUZX6bhPHyoijmom2osWuc90pcbe5pUMM4Z3LlesKbQzwfIhK 1GoqiJQ+QUhobAUjJkiHRI4FunVPKtm95PLrVjhc= 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 mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id EBD766037C; Wed, 4 Jul 2018 07:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530691174; bh=HDtz+4PL2kQlcliMnYtONdajrMFzt01m9GTNQLI4pOw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jGZQFpSpNUpkv8hXC9ULlFqK+kHw5Ds+ePbNNE7kdCvcGU/nVR0O7gXdJSDXKeWnz 3s1IZBxVpq4OHx5HgnUZX6bhPHyoijmom2osWuc90pcbe5pUMM4Z3LlesKbQzwfIhK 1GoqiJQ+QUhobAUjJkiHRI4FunVPKtm95PLrVjhc= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 04 Jul 2018 13:29:33 +0530 From: Vikash Garodia To: Tomasz Figa Cc: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Mark Rutland , andy.gross@linaro.org, bjorn.andersson@linaro.org, Stanimir Varbanov , Linux Media Mailing List , Linux Kernel Mailing List , linux-arm-msm , linux-soc@vger.kernel.org, devicetree@vger.kernel.org, Alexandre Courbot Subject: Re: [PATCH v2 2/5] media: venus: add a routine to set venus state In-Reply-To: References: <1527884768-22392-1-git-send-email-vgarodia@codeaurora.org> <1527884768-22392-3-git-send-email-vgarodia@codeaurora.org> <20180601212117.GD11565@jcrouse-lnx.qualcomm.com> Message-ID: X-Sender: vgarodia@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jordan, Tomasz, Thanks for your valuable review comments. On 2018-06-04 18:24, Tomasz Figa wrote: > Hi Jordan, Vikash, > > On Sat, Jun 2, 2018 at 6:21 AM Jordan Crouse > wrote: >> >> On Sat, Jun 02, 2018 at 01:56:05AM +0530, Vikash Garodia wrote: > [snip] >> > +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. Would prefer to keep the log for cases when enum is expanded while the switch does not handle it. >> > + 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. Ok. >> > + 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. Incase enum is expanded while the switch does not handle it, default will be useful. >> > + 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. > Does this actually compile? The compiler should detect that ret is > used uninitialized. Setting it to 0 at declaration time actually > prevents compiler from doing that and makes it impossible to catch > cases when the ret should actually be non-zero, e.g. the invalid enum > value case. It does compile while it gave me failure while doing the functional validation. I have fixed it in next series of patch. > Given that this function is supposed to substitute existing calls into > qcom_scm_set_remote_state(), why not just do something like this: > > if (qcom_scm_is_available()) > return qcom_scm_set_remote_state(state, 0); > > switch (state) { > case TZBSP_VIDEO_SUSPEND: > writel_relaxed(1, reg_base + WRAPPER_A9SS_SW_RESET); > break; > case TZBSP_VIDEO_RESUME: > venus_reset_hw(core); > break; > } > > return 0; This will not work as driver will write on the register irrespective of scm availability. > Best regards, > Tomasz