From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A56C4C4320A for ; Tue, 27 Jul 2021 10:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B96C60F46 for ; Tue, 27 Jul 2021 10:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236313AbhG0KdJ (ORCPT ); Tue, 27 Jul 2021 06:33:09 -0400 Received: from foss.arm.com ([217.140.110.172]:37352 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbhG0KdI (ORCPT ); Tue, 27 Jul 2021 06:33:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 079541FB; Tue, 27 Jul 2021 03:33:08 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50E263F70D; Tue, 27 Jul 2021 03:33:06 -0700 (PDT) Subject: Re: [PATCH] iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks From: Robin Murphy To: Sai Prakash Ranjan , Will Deacon , Joerg Roedel , Rajendra Nayak , Taniya Das , srimuc Cc: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20210727093322.13202-1-saiprakash.ranjan@codeaurora.org> <955a3034-f7e7-f8f9-4abd-b65efbfbb404@arm.com> Message-ID: Date: Tue, 27 Jul 2021 11:33:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <955a3034-f7e7-f8f9-4abd-b65efbfbb404@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-07-27 11:25, Robin Murphy wrote: > On 2021-07-27 10:33, 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. > > Nope. We call arm_smmu_rpm_get(), which may resume the device, from > atomic contexts. clk_prepare() may sleep. This doesn't work. Urgh, or maybe I skimmed the commit message too lightly *and* managed to totally misread the patch, sorry :( I'll wake up some more and try again later... Robin. >> 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(-) >> >> 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; >> @@ -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 = { >> > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu