Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp753828pxb; Thu, 21 Jan 2021 20:40:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVto5IbApJw8QYcC3vNJJwVb2e7MHHUdT6DFdrqHB1a9cZ7P5v1qelxTWpdZ+AKhm62qMz X-Received: by 2002:a17:906:4d8f:: with SMTP id s15mr1760188eju.389.1611290447345; Thu, 21 Jan 2021 20:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611290447; cv=none; d=google.com; s=arc-20160816; b=mbM9QmIXQmxK+sTfhvGEGtB8/MCqGbFDQpO8vBax0ctwKA86xFI2kfpZYEZelI5yXj hPZhoD0FGHlIIlghWD3w+d0P8HmyULH1DZtJI4Ukd3FbdqYYUJlkRlUauSrhHz/mxsAU WJ7Omvhe4IgLGK0OEjUjQcPqACLbMzFc/YrCdNkzAZuSl4BIXOnK4D3v00l9nccFFjvF Xn6gkzKdl2BGWmmWTmUtOf4d+Eh6TZCYCz/lJkBJoTFOsjGBiGHYoi0E+qA3/tKugj0K 3V8toF6rXR0rz3ajhEmwfAlVXxzHhhvuMy3YocfG6d8rLecnEGTMcLNXNGL9AmT5jsE/ kkJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GKuYChxcbat6wOowZ/luWuFDp05RLb0vBoPsH1W9HLw=; b=XDHv6m2v+3otktAD9GTtZwQFxOPleL+fmKS93zTMGG0bvMkskpQ8dNIel/CEjo2TeS +FMly0/HzoSoDokncSud/uU9eQ+jeXWrhf4Rf+sH0Wk4TPuSE+VtOh+ZqGyiTFbqP4iT LWqBRpy6aI06Fb6YE43Yaa6+8P8NY0SYe/VrQ28EzibfTDwd/nv42mLLpnsW+nxdkdY1 OlZ+hleN4rkLlfxxIxiv37/uOz/T9xwy54tXfDfvo8cfLFaX8SdBfhP3KWv+o6ruhm7U LJStJlTDODYDqYVNFgw33OhUcRR6DLNK/H1uT5X54onw+whuGPfr/6luHRUGXl51pHLP BqGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fWX1fVnS; 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 p5si3069632edt.50.2021.01.21.20.40.23; Thu, 21 Jan 2021 20:40:47 -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=fWX1fVnS; 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 S1726268AbhAVCxf (ORCPT + 99 others); Thu, 21 Jan 2021 21:53:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726680AbhAVCxd (ORCPT ); Thu, 21 Jan 2021 21:53:33 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4058BC0613D6 for ; Thu, 21 Jan 2021 18:52:53 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id e17so3207357qto.3 for ; Thu, 21 Jan 2021 18:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GKuYChxcbat6wOowZ/luWuFDp05RLb0vBoPsH1W9HLw=; b=fWX1fVnSDfRBs4lvhqIkcuFxJczn4RVcy8W7l7m57JkcWR8brGBrkwyok3ZO5XV3YL 3RccD753tIuCIC0P4G1d7mBywZOi/pwihdwRctYeiqSLrd9jVCS+qK9fGTIdbkuLYYCS wmiRwQx4lOEVr6f1M1UMbUV7pdeeceHIKQBdN+13ziDRMeW3A+V/Dx/Fs0WlmOo7SdLo JJYv89XgNZzOZo2HQPNOQZOF04qMh+bCZS9313D0PLJfkSbDKkfKJr/RoCKSqWdreMaW 1LXNrQAk6BdJryD72zjbT/O3Uq3Mxe1tWCyoUdVrWzcQIJsXi0z5WjEdMRtU8cQhWeLM a4yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GKuYChxcbat6wOowZ/luWuFDp05RLb0vBoPsH1W9HLw=; b=dR8Hw3TE10LLxvUq3xx8AQSY3L/NusVKIZLAX6soN7fLj+lSVVt4Ha01KeS8XnEGJ8 B3KbRzmqfHMBrVfhQkGvCVLKAoxHwDAmDlnb9WDE2sYrPGQY9EaiFr4YSUyKDm4bGzzs p+rZMNEUvz88fjOILBMeJRWLQsWXGETs/q+c3rqE1kHDUNC1iZgGRrcZgKdgFwfT26rH goscDxCVUTwuzbhAGO2KGRmgLdXETtWfMXLvxWpXBj4y/2WNcn2mk70La4a2HlBTi7K0 7/PRUgAgLP1KzmY1yBcwHlt++aqf04g+WUAO7ZHKdJkUW/MJbdUTy7vUXgUyPuNsoEg2 dO7Q== X-Gm-Message-State: AOAM532lrQWBSYseQLYb4HO9Ea0/xxMV9Y5uA0T0CyfmBGag474sCSPU mACDW4ZErOjdPtyTuR8SDUXXCQ== X-Received: by 2002:ac8:718d:: with SMTP id w13mr2513193qto.361.1611283972393; Thu, 21 Jan 2021 18:52:52 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id n62sm5414409qkn.125.2021.01.21.18.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 18:52:51 -0800 (PST) From: Thara Gopinath To: agross@kernel.org, bjorn.andersson@linaro.org, dan.j.williams@intel.com, vkoul@kernel.org Cc: shawn.guo@linaro.org, srinivas.kandagatla@linaro.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers: dma: qcom: bam_dma: Manage clocks when controlled_remotely is set Date: Thu, 21 Jan 2021 21:52:51 -0500 Message-Id: <20210122025251.3501362-1-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/dma/qcom/bam_dma.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c index 88579857ca1d..b3a34be63e99 100644 --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -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,14 @@ 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); + if (!bdev->controlled_remotely) + pm_runtime_force_resume(dev); + } return 0; } -- 2.25.1