Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1244708pxb; Fri, 22 Jan 2021 10:25:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsgNFv4ZSBnOaHgpbaVqXT3hdyGONTZhemyeufjy1boatMAS0hERIY97YR40jQaIiuYuFJ X-Received: by 2002:aa7:d148:: with SMTP id r8mr4212380edo.127.1611339916474; Fri, 22 Jan 2021 10:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611339916; cv=none; d=google.com; s=arc-20160816; b=LD28qqrmEIZK+EXkmRYiGUmfjuM/8u7/AjX21jne8cUre3rnDKZfiVRKKc1ewmgvQB jZ4dMrHNuytj7admxRUCHxPuv3a1GXMBEVA7vYlWUV6vhvJzcTOryAGImC34v1OeJU8v F2B9cCHihOSBGXfXWtX1KI2aKs/+YVTr65wJevCOBeu3cM3spD3R0OY7EkVOkZnQhY5M ndaWYnyQHR4Go6f3tVTIc4Doth7hsXkt+7PT0OAFp7ZkIASC+5pvb+Ea0glPQ/fi4SmK DGD0IH4Bc2TaehPdan6k49lLJG3DYKwmKdYXuPa7/V337RCSgjin8fcVgWeN6gMA+lZd QXPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=nJ5Mm7jDvt8rYYjqfuGcAKVlF1C7OcwWb/rDTKJ5d/Q=; b=LODvzLi1RZs1QVmVbFe8Q2np/P7oQTJcs6tglf33CGo/7eNxLhe/AT/e9R/H33fXVG Bn3I/IdHL7FMt9Y8cd8ZmQSJ2nRPpNPcG9xmd1+/f3o/f84rm4QoOtyoAw8sLe5oQFwp ER17ajGPkhsPL2dbcEZWyW+Os3EQUOOeCLDQvGo4irwL9tXoojDSa1o2sJucnfhzaeTv UfBV4iMHxvPF+0SsdiIQxGfNBFQLzHByds+yoKcIZMF5B/Vmu/UFQlnknEaYgFxchkgL rjJAB3LGa4r69h/Bl/VfRHlTJY2Fyp/maFpc3Tud1fZ6ADh1eZ5EWSwOlL0uagILnMUa z8BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcWMa2Fp; 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 l26si3352143ejc.315.2021.01.22.10.24.52; Fri, 22 Jan 2021 10:25:16 -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=wcWMa2Fp; 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 S1729785AbhAVSW7 (ORCPT + 99 others); Fri, 22 Jan 2021 13:22:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbhAVPow (ORCPT ); Fri, 22 Jan 2021 10:44:52 -0500 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC1CC061786 for ; Fri, 22 Jan 2021 07:44:12 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id r9so4349749qtp.11 for ; Fri, 22 Jan 2021 07:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nJ5Mm7jDvt8rYYjqfuGcAKVlF1C7OcwWb/rDTKJ5d/Q=; b=wcWMa2FpEYwa9IT1fn9c6WjOp7s8r0ejmanTOS4UW7OvflsrFUpCD6F4pcKzYPFC81 17nnqVC3NCknrcdEJcqD4nSWJOb+uY33GwliYT+O8wKc/5qi4Jc1FjAEwoeNzn1exNHs qIw/6/Z+T8FGuv24jzsa+eRU6XI4fCK8I1qUe7CfR1QNNxegep2k6Yc/DFJ+sga+gJwJ 7w87e3YSYF48VPfreqMzKl/dTsEI5IV5x5K8M2LHTHdRAa7D67JMah8uKz1k8Pj3Kwvr G9gue26Ip4oMikjTsZf541S5wI+4/icsGylvKMYDB9Zf5kfJLOy79t6PG43MtcxlV+dH Yddw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nJ5Mm7jDvt8rYYjqfuGcAKVlF1C7OcwWb/rDTKJ5d/Q=; b=dO6B8FQ7mOW7ptPsl+95hkEAG73stWbc4i+pJGxdRyHM3s+D8BPjHtidgAxgNGbTTd IjkrqVFlzMjLBzcSXQx9902YHze+fGdITEe68M9MSwy3xMkGiYUi/lf1gfbhXsJyyJrJ 2rrkmOgj7r3pHCJzBs4MnNGCjmKrRMtlzWf26Kdf3y2N0nnagyKWGQoPDe1o1SbKGWuM EwHZo867dpqCW691azRxzd0cwGFnhiaTOJ3ve5dzsaxM082BqvLu1bh0aGQj63xsxi5C oR3ChkBpEn58zGjx05aIOOMBou/NkrfJXNcB8A1ZkY/cuIE+aOJZoLjPcxTkNgn/tWk3 zYTw== X-Gm-Message-State: AOAM531Wmk9MKJQ0BQZDLQK1OMiTwF+Vx8FMupYPh+CJc4cRAZTMQkdo gTmacEQqQAXR9jWu2gwIxIXy2Y1OLNUOPA== X-Received: by 2002:aed:2be7:: with SMTP id e94mr4817414qtd.110.1611330250814; Fri, 22 Jan 2021 07:44:10 -0800 (PST) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id p75sm6616661qka.72.2021.01.22.07.44.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Jan 2021 07:44:10 -0800 (PST) Subject: Re: [PATCH] drivers: dma: qcom: bam_dma: Manage clocks when controlled_remotely is set To: Shawn Guo Cc: agross@kernel.org, bjorn.andersson@linaro.org, dan.j.williams@intel.com, vkoul@kernel.org, srinivas.kandagatla@linaro.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210122025251.3501362-1-thara.gopinath@linaro.org> <20210122051013.GE2479@dragon> From: Thara Gopinath Message-ID: Date: Fri, 22 Jan 2021 10:44:09 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210122051013.GE2479@dragon> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shawn, Thanks for the review On 1/22/21 12:10 AM, Shawn Guo wrote: > On Thu, Jan 21, 2021 at 09:52:51PM -0500, 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. > > Shouldn't the following probe code need some update? Now we have both > controlled_remotely and clocks handle for cryptobam node. For example, > if devm_clk_get() returns -EPROBE_DEFER, we do not want to continue with > bamclk forcing to be NULL, right? We still will have to set bdev->bamclk to NULL in certain scenarios. For eg slimbus bam dma is controlled-remotely and the clocks are handled by the remote s/w. Linux does not handle the clocks at all and there is no clock specified in the dt node.This is the norm for the devices that are also controlled by remote s/w. Crypto bam dma is a special case where the clock is actually a rpmh resource and hence can be independently handled from both remote side and Linux by voting. In this case, the dma is controlled remotely but clock can be turned off and on in Linux. Hence the need for this patch. Yes, the probe code needs updating to handle -EPROBE_DEFER (esp if the clock driver is built in as a module) I am not sure if the clock framework handles -EPROBE_DEFER properly either. So that might need updating too. This is a separate activity and not part of this patch. > > bdev->bamclk = devm_clk_get(bdev->dev, "bam_clk"); > if (IS_ERR(bdev->bamclk)) { > if (!bdev->controlled_remotely) > return PTR_ERR(bdev->bamclk); > > bdev->bamclk = NULL; > } > >> >> 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) > > Why do we still need controlled_remotely check here? Yes you are right. This should be removed.I will send v2. -- Warm Regards Thara