Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1745451pxy; Mon, 2 Aug 2021 09:14:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqogtEPAbuLpe++WY3HAInDtMe+lMg5LV1wAi/sJMnJ88Fc3qmCYAyTS/q1Ie4sCiVdVF0 X-Received: by 2002:a17:906:8281:: with SMTP id h1mr16562860ejx.352.1627920843247; Mon, 02 Aug 2021 09:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627920843; cv=none; d=google.com; s=arc-20160816; b=pwLBbFbIpPuiGUDpJaGPzNKWE9+cu1/lo5pPam8Ml7RQ76DE2FbNpi1IFnpPLB9/va sry/MY3QPlBwAoc3gIqrAeCPXA0G4C2yvZH2rtaPT2mXDKTo4a5a/uvSM8+ei3jT7QzX UF6dz0IHyJvHnI9hQL+Eh23FsjZ02kjeUDHmdsOmjQhmvDBVLbKGQTi+XzcHZRsew069 55v7A5amtfO52c2bIc43HpBcr32L25m3VmuTcIeiM5DuhUobkzcsIIHyN0KEmGSLqyCL oNJLisvq9x+BcZXpZjUl38qRhBueGbCGEksbuED0ZvRccihEoSk3XPpy/5SDmxsPseXL bpHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oV4oT54r1DAM6Y+Ba4dcRHOADrla97GOzZ7uRllZl5k=; b=c6yRMMi45XKIxF5F8Zh/18EeYyp2Y8X9LzhCF5Y6IY3psCiajJc4EmQEIr+zbrJ+ck SC3X9I8AwCSTBXYONyf6kr5kvhLtX4zZa/5VgyQcoho+vTkYHI87ATAchPEozibiW7kp dnwgltvrUgQZHhXmCs+nknUFuFw9uQ7kmNyfchIpmFDtjE5Wq3jvanxk0t8ot5DKgayt Nhx2Zf0lIt/pVRuVNzxlSFH9Fdga9GiWRopXoCg/7KgqYc1I801RXwRjpYfJjP49p7rR x/C9SWO9/Sf2V7V1F6Po9aKXjbw723Copa1Df3hvc33vhRh3/nkQ3m+rMDBbS0SRZbZO vCeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FB6RhytU; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx21si9747225ejb.677.2021.08.02.09.13.39; Mon, 02 Aug 2021 09:14:03 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=FB6RhytU; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232190AbhHBQMW (ORCPT + 99 others); Mon, 2 Aug 2021 12:12:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbhHBQMV (ORCPT ); Mon, 2 Aug 2021 12:12:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E9EA60F9C; Mon, 2 Aug 2021 16:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627920732; bh=b2Ng61RAPlMVP2k8p8ptM8+ZLyJnqh59TBkLJy5ROis=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FB6RhytU9h1IMIKzRWu6GmLzfCEBjk6A6rHDieSWy6K/7PP1AFgKx9dq2kwTHFCzd 96MaL/uwcP5Fa2sUBheTQ6kHqmxsFUaNqmPubydLZvP96CB2xWespEO0qCy4S4bf1s 64Wn5fBpxIwpst/c9+Uue/GKmDdOf7CbaeqxCeCc7U1ZWCmNcD8Ukah0f1QYNfSNMH pmVu5gX6k4DPHSTUAAbIfNp97VAE7oHns/Gz1vxI3UGZRR3x4pvo/i/vVyluLojbRb 44MjxhWYGFkSZkPEruKKiiwocVA2+J5Yct+2FsADX+6Y9o4Ld+VfGByp9IedbE3py5 LmcCM5PZdGYVA== Date: Mon, 2 Aug 2021 17:12:06 +0100 From: Will Deacon To: Sai Prakash Ranjan Cc: Robin Murphy , Joerg Roedel , Rajendra Nayak , Taniya Das , srimuc , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, robdclark@chromium.org Subject: Re: [PATCH] iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks Message-ID: <20210802161206.GA29168@willie-the-truck> References: <20210727093322.13202-1-saiprakash.ranjan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727093322.13202-1-saiprakash.ranjan@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 03:03:22PM +0530, Sai Prakash Ranjan wrote: > Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk > of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in > such cases, we would need to drop the XO clock vote in unprepare call and > this unprepare callback for XO is in RPMh (Resource Power Manager-Hardened) > clock driver which controls RPMh managed clock resources for new QTI SoCs > and is a blocking call. > > Given we cannot have a sleeping calls such as clk_bulk_prepare() and > clk_bulk_unprepare() in arm-smmu runtime pm callbacks since the iommu > operations like map and unmap can be in atomic context and are in fast > path, add this prepare and unprepare call to drop the XO vote only for > system pm callbacks since it is not a fast path and we expect the system > to enter deep sleep states with system pm as opposed to runtime pm. > > This is a similar sequence of clock requests (prepare,enable and > disable,unprepare) in arm-smmu probe and remove. > > Signed-off-by: Sai Prakash Ranjan > Co-developed-by: Rajendra Nayak > Signed-off-by: Rajendra Nayak > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) [+Rob] How does this work with that funny GPU which writes to the SMMU registers directly? Does the SMMU need to remain independently clocked for that to work or is it all in the same clock domain? > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index d3c6f54110a5..9561ba4c5d39 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -2277,6 +2277,13 @@ static int __maybe_unused arm_smmu_runtime_suspend(struct device *dev) > > static int __maybe_unused arm_smmu_pm_resume(struct device *dev) > { > + int ret; > + struct arm_smmu_device *smmu = dev_get_drvdata(dev); > + > + ret = clk_bulk_prepare(smmu->num_clks, smmu->clks); > + if (ret) > + return ret; > + > if (pm_runtime_suspended(dev)) > return 0; If we subsequently fail to enable the clks in arm_smmu_runtime_resume() should we unprepare them again? Will > @@ -2285,10 +2292,19 @@ static int __maybe_unused arm_smmu_pm_resume(struct device *dev) > > static int __maybe_unused arm_smmu_pm_suspend(struct device *dev) > { > + int ret = 0; > + struct arm_smmu_device *smmu = dev_get_drvdata(dev); > + > if (pm_runtime_suspended(dev)) > - return 0; > + goto clk_unprepare; > > - return arm_smmu_runtime_suspend(dev); > + ret = arm_smmu_runtime_suspend(dev); > + if (ret) > + return ret; > + > +clk_unprepare: > + clk_bulk_unprepare(smmu->num_clks, smmu->clks); > + return ret; > } > > static const struct dev_pm_ops arm_smmu_pm_ops = { > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation >