Received: by 10.223.185.116 with SMTP id b49csp3310912wrg; Tue, 13 Feb 2018 00:26:14 -0800 (PST) X-Google-Smtp-Source: AH8x226R0OVLO6WjdDNJ97BA1AzsoMngUowRB/79mRNHa9Lj/hwIGOteKNTf7ajdg7JVv+YkgaW8 X-Received: by 10.99.172.2 with SMTP id v2mr388365pge.204.1518510374593; Tue, 13 Feb 2018 00:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518510374; cv=none; d=google.com; s=arc-20160816; b=wN434nGzxEy7IBIp4GPr8CG6tFol/ygKtN7T/dQG757Vdhkijh3smp2Y5Qn7p+2Fz9 ltpRQQ/UQEDLeMPXv+4PA62bsirPdmBzw9G6BxHJLSoiu/cEri04An+uIh4k7z/frG24 /q0DtUuBKLAifShp0rY8490b+O2/cAXZzaEIJmxyiIWMU9R7nwz5vm/N6NhKaDoKEDFU lPdaZ0ejc4o/LnaRPznlKrZsgMFmp30l5bMGtYumzkAwfMVIaWs89SqiIgJHhMxc/8FN jwVvzfVsNLZUoatakXmglvaSnzYK48qFX5Uuy91fiYeerEMxF31fVcWt57250L1eu0qj RcRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=3qImykOaVkEOo/IUvwo5zkUlsXQPmIDn/KImcx8EjYI=; b=jUkHJQnIBLdpWb122EOrqcNuZKcW/VNOyMqOfbm0luHt2AASpR/qeXRhOWZBUOayqs NJpsm3TgeUbnqp3WgYzNuOIlWDgjqE4rf4DEO5UIOMK34lDHIBu+vggf0RdZHdEsYIWL 0WYqakLF6sSdum0HFTlQkst5dJ0kRpaQjjkvz8JOpmbAC620fupK/osjazY7aJU1H1We SOgrANbJuLAIly7EzDSj4nQ8A8F8KCfHX/XHQylN2YYS5eQQc5gcBxJWuooEDA0mQHi3 0fKZ89xVoqfjgt/aHARdTzpdzdIximrHOpaftt4S+z+y8NmmLn7Xq7BKZEQ9OoyQl1OI N0jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CSrhdcjJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si6249160pgc.128.2018.02.13.00.25.58; Tue, 13 Feb 2018 00:26: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; dkim=pass header.i=@chromium.org header.s=google header.b=CSrhdcjJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933680AbeBMIZU (ORCPT + 99 others); Tue, 13 Feb 2018 03:25:20 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:41352 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933631AbeBMIZR (ORCPT ); Tue, 13 Feb 2018 03:25:17 -0500 Received: by mail-ua0-f196.google.com with SMTP id d4so6553199uak.8 for ; Tue, 13 Feb 2018 00:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3qImykOaVkEOo/IUvwo5zkUlsXQPmIDn/KImcx8EjYI=; b=CSrhdcjJIMhRoNnR9Jg4YXkD9d0yejdBlQvR1HEIM3F4RFWBLFTkouI6EXzIXfbnHO Ze2sNyzu/c/Dqlq1akXgc94UVE0H0kLf1m/JorWivr6aQ7e9fnIoGkubJI/idzFtK4Re etgPFbzSJVI5Mlmxyt9Zh59M1SBegKJ2aVrUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3qImykOaVkEOo/IUvwo5zkUlsXQPmIDn/KImcx8EjYI=; b=AKaDLdozvUJ0hM8ClUrOFpI7YJz8Q9a+fnozD9MLlefMQ+gpdhOrb6ycX5ZAtROEnX 8A+Kg1h0W/qrKmOGyf5bO+TMiuVsbAduOVgCzankgrVIaYHsU1nkg2TKF6Dh5+scZWUw xhgnb/TZBMsbLXAS6L/hoKSp5nPNOD5ApjOk0hXbcZh6By9S2yEgN2qDlV+KJbs8mIqB k4SuBgPhM416UVWghbKa9kPbj7aEZ8+O2a7oVkgqK3HxeuJD2k+TYCVvWI7z+LK8oZhj WQYw/exi3+XCyMqt2zf6IUd7JCy3hdEcYHq8WhhfbrKMwTBuBAVmevFV5NMPMRK2Rgo9 07tw== X-Gm-Message-State: APf1xPA2aCWOazsxJS44I7Z8B/GWedSDACHYxBpTOj7acp/u05Rwgn72 4hP9Dlw5oKnQwbXqvGdrGDIDQkXSCd4= X-Received: by 10.159.53.142 with SMTP id t14mr402965uad.58.1518510317090; Tue, 13 Feb 2018 00:25:17 -0800 (PST) Received: from mail-ua0-f179.google.com (mail-ua0-f179.google.com. [209.85.217.179]) by smtp.gmail.com with ESMTPSA id d15sm4415518uag.3.2018.02.13.00.25.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 00:25:15 -0800 (PST) Received: by mail-ua0-f179.google.com with SMTP id y17so9328435uaa.13 for ; Tue, 13 Feb 2018 00:25:14 -0800 (PST) X-Received: by 10.176.75.109 with SMTP id i45mr360333uaf.73.1518510313496; Tue, 13 Feb 2018 00:25:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.0.68 with HTTP; Tue, 13 Feb 2018 00:24:53 -0800 (PST) In-Reply-To: <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> From: Tomasz Figa Date: Tue, 13 Feb 2018 17:24:53 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 3/6] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device To: Vivek Gautam Cc: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Robin Murphy , Will Deacon , Rob Clark , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. +Generally similar comments for other places in this patch. > + > /* > * Disable the context bank and free the page tables before freeing > * it. > @@ -932,6 +936,8 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain) > > free_io_pgtable_ops(smmu_domain->pgtbl_ops); > __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx); > + > + pm_runtime_put_sync(smmu->dev); Is there any point in the put being sync here? [snip] > @@ -2131,6 +2152,14 @@ static int arm_smmu_device_probe(struct platform_device *pdev) > if (err) > return err; > > + platform_set_drvdata(pdev, smmu); > + > + pm_runtime_enable(dev); I suspect this may be a disaster for systems where IOMMUs are located inside power domains, because the driver doesn't take care of the IOMMU block losing its state on physical power down, as I mentioned in my comments above. Best regards, Tomasz