Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp509057pxb; Wed, 27 Jan 2021 13:23:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt7suprCGSpzGQlf3adPj/00CKExDxEA6mxHgyGrvy8wvWd8FvGhHs3OUdg8n0Qu5P9bqI X-Received: by 2002:a05:6402:1b11:: with SMTP id by17mr10556592edb.373.1611782580828; Wed, 27 Jan 2021 13:23:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611782580; cv=none; d=google.com; s=arc-20160816; b=lODJltYrVMgn+6psAxhGJql//eh1fIum97AHLnkp81d40C5KhTl8HKQGloeZ8HLLAd JH81vN9tcUxJ3XowI4uwz31K3PBp2rnMBaa+O1qcviq3OM0XZ1LtvoIlzAbY7cJPMB8z zSxz1LKSCPJvnjNtJdXaWYmaIL8q5idZXC6XxImiFDbyWXdRtedw2JUOWzJteUiYqolK 3v33qIlUmAsS6cnk3xMrtXIVWV94Hbm30l9FRYFfig3rNB0eVTC8IjmTSLg1wPwNVTuc q4yolk2O9jPYFxQJE2hfrOHPJNYC0a4GYwpSOqWqoxZyJNx9Ny7B5jW4sWYpjtqN+i+Q EQOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UXTjp2O+kLbB9CTCJxJt0SD+zZK5wsiYg7svDRD619A=; b=fKsFRfa8gLRIFKB2wTPIsMUX+PTKz2MilIrufUnHQcRXXTjagajuXR2GIbCZdnpxUj F7WAxWc0y+urD4hx1R6KEGE47eL8SERKzlKhpXjGXUz5Ka1NDcNcfpevWvJNRS/cEH1T X5/KxslmWNvByeVaUJOQw5wRlp7UB8yURMhM6nT55jXH80Ccb8pfwLxJGGwL676b4GZL LvR7Nd+IcTXKY0DhpjqvHMI8anOSTJGlnWW12/F7cF91N5VvjXEbKBVQfBBVFgdG1ujo XzLUYwLyfuPCS+OdPqro3cZGTkSDmG6K2a4HuNEoVt2Xlo1BN2eo9BaQIXifMvznJqbp jDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOn1TON+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si1670941eds.484.2021.01.27.13.22.36; Wed, 27 Jan 2021 13:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOn1TON+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234069AbhA0GGf (ORCPT + 99 others); Wed, 27 Jan 2021 01:06:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232382AbhA0Fe1 (ORCPT ); Wed, 27 Jan 2021 00:34:27 -0500 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C46CDC06174A for ; Tue, 26 Jan 2021 21:33:42 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id a109so622555otc.1 for ; Tue, 26 Jan 2021 21:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UXTjp2O+kLbB9CTCJxJt0SD+zZK5wsiYg7svDRD619A=; b=dOn1TON+07GhKGJIoyayMjmuy9BWh8V5ii5n4VTX82icYwL/TZwbySdeoTGe3zAzC7 oSuVT+QQQ33v+XleMivKtoG2pI8n2OuZ9WN0bVODaUZ1UVzMKaFDoNYW6SEGK0pCKGKQ oWxYyv3zdNrU3Ep7X6AREUC29Rlo8lcyt4qvfUGVJ+VMNTx5UuJgcjV0rAxgRI/6Bk/K 0i+FrH5GAbdXLc9mePC17FZ9ip41xi53D0APB/iDZlFNapeDRcpz5BD2WXJpdKPZBOIJ MnfwfXayWeimpxJ4hLheuNTqOC1Bq0ahgp4WJngILzzvK0tC/Jj3ClVY+bA4mPvdkw79 6Z2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UXTjp2O+kLbB9CTCJxJt0SD+zZK5wsiYg7svDRD619A=; b=juyS9ZcroRJzA9BU3mMFQKVg896gefybyrtIDkr2CoSgy/9LbtT0+KlOFeVZKzSphN fhqXw4IKwUAeZHWU3TIut0sFX1ZQq7CCfMQiJtq+pRExWTjfEFc2Dn4EykEeXLQmHhTh 8i3/R/DvQR53oiWSkkhSnp+vvIC+tJ8nOlCVerV+ChDffTWKgqWEWNtPe9e8WM4T9tX1 p/oew2AU3sx1RZUS3uJdsKpf+QAfvyDNh+ZVFJQw0N5/4wMr6/lhLreJcypkBzwFhWbh 1rIKDV3uwVKVFkULjmJKMOMfGpcbqdyJTmoYM9+kAVOm+XjhXentSmhmby07s620/2v2 NHig== X-Gm-Message-State: AOAM533g8/ZsXtlNBtUvE1IiNc3GUBb35G3dg19dC8HGMOtLPiZGVQ2x WtekXiKrSmd0x2cE7S2lLXAVaw== X-Received: by 2002:a9d:37a6:: with SMTP id x35mr6665900otb.275.1611725621367; Tue, 26 Jan 2021 21:33:41 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id y66sm260747oia.20.2021.01.26.21.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 21:33:40 -0800 (PST) Date: Tue, 26 Jan 2021 23:33:38 -0600 From: Bjorn Andersson To: Thara Gopinath Cc: agross@kernel.org, dan.j.williams@intel.com, vkoul@kernel.org, shawn.guo@linaro.org, srinivas.kandagatla@linaro.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] dma: qcom: bam_dma: Manage clocks when controlled_remotely is set Message-ID: References: <20210126211859.790892-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210126211859.790892-1-thara.gopinath@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 26 Jan 15:18 CST 2021, Thara Gopinath wrote: > When bam dma is "controlled remotely", thus far clocks were not controlled > from the Linux. In this scenario, Linux was disabling runtime pm in bam dma > driver and not doing any clock management in suspend/resume hooks. > > With introduction of crypto engine bam dma, the clock is a rpmh resource > that can be controlled from both Linux and TZ/remote side. Now bam dma > clock is getting enabled during probe even though the bam dma can be > "controlled remotely". But due to clocks not being handled properly, > bam_suspend generates a unbalanced clk_unprepare warning during system > suspend. > > To fix the above issue and to enable proper clock-management, this patch > enables runtim-pm and handles bam dma clocks in suspend/resume hooks if > the clock node is present irrespective of controlled_remotely property. > > Signed-off-by: Thara Gopinath Reviewed-by: Bjorn Andersson And from John on IRC: Tested-by: John Stultz Regards, Bjorn > --- > > v1->v2: > - As per Shawn's suggestion, use devm_clk_get_optional to get the > bam clock if the "controlled_remotely" property is set so that > the clock code takes care of setting the bam clock to NULL if > not specified by dt. > - Remove the check for "controlled_remotely" property in > bam_dma_resume now that clock enable / disable is based on > whether bamclk is NULL or not. > - Rebased to v5.11-rc5 > > drivers/dma/qcom/bam_dma.c | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c > index 88579857ca1d..c8a77b428b52 100644 > --- a/drivers/dma/qcom/bam_dma.c > +++ b/drivers/dma/qcom/bam_dma.c > @@ -1270,13 +1270,13 @@ static int bam_dma_probe(struct platform_device *pdev) > dev_err(bdev->dev, "num-ees unspecified in dt\n"); > } > > - bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); > - if (IS_ERR(bdev->bamclk)) { > - if (!bdev->controlled_remotely) > - return PTR_ERR(bdev->bamclk); > + if (bdev->controlled_remotely) > + bdev->bamclk = devm_clk_get_optional(bdev->dev, "bam_clk"); > + else > + bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); > > - bdev->bamclk = NULL; > - } > + if (IS_ERR(bdev->bamclk)) > + return PTR_ERR(bdev->bamclk); > > ret = clk_prepare_enable(bdev->bamclk); > if (ret) { > @@ -1350,7 +1350,7 @@ static int bam_dma_probe(struct platform_device *pdev) > if (ret) > goto err_unregister_dma; > > - if (bdev->controlled_remotely) { > + if (!bdev->bamclk) { > pm_runtime_disable(&pdev->dev); > return 0; > } > @@ -1438,10 +1438,10 @@ static int __maybe_unused bam_dma_suspend(struct device *dev) > { > struct bam_device *bdev = dev_get_drvdata(dev); > > - if (!bdev->controlled_remotely) > + if (bdev->bamclk) { > pm_runtime_force_suspend(dev); > - > - clk_unprepare(bdev->bamclk); > + clk_unprepare(bdev->bamclk); > + } > > return 0; > } > @@ -1451,12 +1451,13 @@ static int __maybe_unused bam_dma_resume(struct device *dev) > struct bam_device *bdev = dev_get_drvdata(dev); > int ret; > > - ret = clk_prepare(bdev->bamclk); > - if (ret) > - return ret; > + if (bdev->bamclk) { > + ret = clk_prepare(bdev->bamclk); > + if (ret) > + return ret; > > - if (!bdev->controlled_remotely) > pm_runtime_force_resume(dev); > + } > > return 0; > } > -- > 2.25.1 >