Received: by 10.223.185.116 with SMTP id b49csp3600960wrg; Tue, 13 Feb 2018 04:59:14 -0800 (PST) X-Google-Smtp-Source: AH8x225WPBxpeKkyJFkMcFZ13vS8tc7bDHiAnjCUKRg5ZoYvH5ScWIDcKl+Nilcn8NZYbRMiy/Ru X-Received: by 10.98.62.147 with SMTP id y19mr1218632pfj.18.1518526754067; Tue, 13 Feb 2018 04:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518526754; cv=none; d=google.com; s=arc-20160816; b=jT+KuiHaBNrNCIQfq+Wt2zbOpeYn+0mHsENgX+yJNZer5W/2dLm/ufZPLCQ2jHCxC6 rBPifkvAFtcABVCJJbHxrurcg4ClYqoNGtMAQ60u/kAI72wldhlEKjeg0aYvmdz+yM0r bTj0bXpSCXfmik4BToI5ufJ9GODsofhZzKUQe1+fPqZikiI+9GuBBT0/iO/RQSm8yS0L zERLfBcWqvga6ezT8kPVsaDNEAWRNyqmphhKY3XOjO7Kz1PAaSQzaucdOBLoM5wBzmH4 WoMcW5RGTOz7kiQkOUCbGpkPJHsz56TWqhQUwFU0pheWHvOy7lvVSKmo3V7Otfb86SxW FRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=0Sl/pSBAmhogUaNvfn+MJGMPKl3rMKD53VODufVcwS8=; b=Sa0nhe/Eu7AKKPDDtejcZhsmNYXbVu71FuQDbVa0JjatTzQymBrpHJ1RROSfFMqdJg szAYFzArxkbBSpi1qWQm4XDQr8EYLRCMiRrlZzkkNHocDvF23rBpECBZi5Ci5m2q542Y 91hmTQMOHL4pHnRKdlwnBYzlOkUPkDBprWfOW0v7LwaiiXecsNRknmjwTq05NgqAKqDa JG8s79SwGiU8UcMg88BzzsVsSu16aLWELVtfQJVZcfKU6cCMORxT8Yi4pglruebe9Bz4 IXRAliqyH5CUrr2nGLm3Dp3kqFGuDxYFr61ucCPvVTEo8B0HXxe2XX9aOAJobjTxa7Iz IUXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1-v6si5625235pln.408.2018.02.13.04.58.59; Tue, 13 Feb 2018 04:59:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935354AbeBMM5N (ORCPT + 99 others); Tue, 13 Feb 2018 07:57:13 -0500 Received: from foss.arm.com ([217.140.101.70]:57054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935223AbeBMM5J (ORCPT ); Tue, 13 Feb 2018 07:57:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 157181529; Tue, 13 Feb 2018 04:57:09 -0800 (PST) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 982323F487; Tue, 13 Feb 2018 04:57:05 -0800 (PST) Subject: Re: [PATCH v7 3/6] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device To: Tomasz Figa , Vivek Gautam Cc: "list@263.net:IOMMU DRIVERS" , Joerg Roedel , joro@8bytes.org, Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Will Deacon , Rob Clark , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel , freedreno@lists.freedesktop.org, David Airlie , Greg KH , sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> From: Robin Murphy Message-ID: <906051dd-8898-ec6f-5ad4-3f37716292cf@arm.com> Date: Tue, 13 Feb 2018 12:57:04 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/02/18 08:24, Tomasz Figa wrote: > Hi Vivek, > > Thanks for the patch. Please see my comments inline. > > On Wed, Feb 7, 2018 at 7:31 PM, Vivek Gautam > wrote: >> From: Sricharan R >> >> The smmu device probe/remove and add/remove master device callbacks >> gets called when the smmu is not linked to its master, that is without >> the context of the master device. So calling runtime apis in those places >> separately. >> >> Signed-off-by: Sricharan R >> [vivek: Cleanup pm runtime calls] >> Signed-off-by: Vivek Gautam >> --- >> drivers/iommu/arm-smmu.c | 42 ++++++++++++++++++++++++++++++++++++++---- >> 1 file changed, 38 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c >> index 9e2f917e16c2..c024f69c1682 100644 >> --- a/drivers/iommu/arm-smmu.c >> +++ b/drivers/iommu/arm-smmu.c >> @@ -913,11 +913,15 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain) >> struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); >> struct arm_smmu_device *smmu = smmu_domain->smmu; >> struct arm_smmu_cfg *cfg = &smmu_domain->cfg; >> - int irq; >> + int ret, irq; >> >> if (!smmu || domain->type == IOMMU_DOMAIN_IDENTITY) >> return; >> >> + ret = pm_runtime_get_sync(smmu->dev); >> + if (ret) >> + return; > > pm_runtime_get_sync() will return 0 if the device was powered off, 1 > if it was already/still powered on or runtime PM is not compiled in, > or a negative value on error, so shouldn't the test be (ret < 0)? > > Moreover, I'm actually wondering if it makes any sense to power up the > hardware just to program it and power it down again. In a system where > the IOMMU is located within a power domain, it would cause the IOMMU > block to lose its state anyway. This is generally for the case where the SMMU internal state remains active, but the programming interface needs to be powered up in order to access it. > Actually, reflecting back on "[PATCH v7 2/6] iommu/arm-smmu: Add > pm_runtime/sleep ops", perhaps it would make more sense to just > control the clocks independently of runtime PM? Then, runtime PM could > be used for real power management, e.g. really powering the block up > and down, for further power saving. Unfortunately that ends up pretty much unmanageable, because there are numerous different SMMU microarchitectures with fundamentally different clock/power domain schemes (multiplied by individual SoC integration possibilities). Since this is fundamentally a generic architectural driver, adding explicit clock support would probably make the whole thing about 50% clock code, with complicated decision trees around every hardware access calculating which clocks are necessary for a given operation on a given system. That maintainability aspect is why we've already nacked such a fine-grained approach in the past. Robin.