Received: by 10.223.185.116 with SMTP id b49csp401783wrg; Wed, 14 Feb 2018 00:29:45 -0800 (PST) X-Google-Smtp-Source: AH8x2243B0DBDdLn45zGjJVVJpIRk1PHFN79EEozYL3eEkAM4Xd1dH8flNQIpS8ajETOpLwpqPl8 X-Received: by 2002:a17:902:46a:: with SMTP id 97-v6mr3680235ple.96.1518596985642; Wed, 14 Feb 2018 00:29:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518596985; cv=none; d=google.com; s=arc-20160816; b=F9oQEhE65IzxZXqADKPucJzkRad3YPargS8OCSzdWsufwn41bFCkfrK/wbHYbWJP/2 EpxQsir3pDo84AgGKgLeJ1oV5wgJJselmI9rK2IBbTgr3hBSMBwhC9wam7gdJVwXYDZm mazCjSlo/egPvfo0COKJutDRPOHDaGzAIrBeAVbjzR2RYnrlFuNZ51D18jdvvqX2vOeH o4D5sWD2MmoSJVIzQt290KjuV7h7e86q0NXlFGphl/eo+wYMqP6plCnldn7QgVqk+ABE abC/7J3lcRkUp/VgKeemJk/KErhceHOPw4d8jLmvP4KM0MtB9P4LeBccKeI7F6M0wO23 0kbQ== 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:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=Z7WXxLiQrAYk95oyYihhc1b75LxlheeMe79HAAB7Wwc=; b=SOuUfBxUEZW9XwVB/Gxj0aX27WD/R3qU23RcOVzXLoKAwfAF6nSUDVjzjWH+a+WIfi 12Frbj3qUbBLZdCxMol32tr1ciZ9Ul1kRkJjjgBcVASnr8vwfO07pLV3AfCzan2l43e6 37z3D5M4c87P/7tppGXnRm2b1KR4ZBhCdbWEsOTddE1lcCd7dCSyp9RW97KCzi4BgxwD vezhwuvCdX1PzwKnKPDOM/mGZ1Vp8YyClunbHGN0AaS/a14P4tHQviRaH+2u09E/3OMS tEYMj8SP30aB/pE5uuwp1GObIPQwRZ/PWmeoX9Ts4MKRrcwJChQ7lYTnCnnrj5T/0lXN LBnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=G8nj5lNa; dkim=pass header.i=@codeaurora.org header.s=default header.b=X/Iskujo; 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 q11si7745629pgf.225.2018.02.14.00.29.30; Wed, 14 Feb 2018 00:29:45 -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=@codeaurora.org header.s=default header.b=G8nj5lNa; dkim=pass header.i=@codeaurora.org header.s=default header.b=X/Iskujo; 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 S1754639AbeBNI2w (ORCPT + 99 others); Wed, 14 Feb 2018 03:28:52 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35262 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754569AbeBNI2u (ORCPT ); Wed, 14 Feb 2018 03:28:50 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A028260F71; Wed, 14 Feb 2018 08:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518596929; bh=XMLALSBZnUe02SR8WfbrLH11Nb+wrPTWTckXcZgXVy4=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=G8nj5lNaN5G3hIFBoyS20+FrIBzA/dizB+3mCCv072PZh+hpjNhfxENONF+MWAqWQ gA6yz66kfWPVXg4qRbS9fvlIf+IRAst4g+gSgBZhkgKh+pePla8V0dnXE8kmSdcTvB sew/ncoXXaLEYdKbkvFd4P7RQC21Hab2WsIW2FU8= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail-qt0-f172.google.com (mail-qt0-f172.google.com [209.85.216.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B072260558; Wed, 14 Feb 2018 08:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518596928; bh=XMLALSBZnUe02SR8WfbrLH11Nb+wrPTWTckXcZgXVy4=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=X/IskujoGYN9Dr/2LrM2JmpD4oQbTESZ72UONbQbz0jiuuI8hYHwtU/fgQuieaQm/ 99JbRVQ5505GpJ+LlYl8sJH+rBsx/rMDSEkgjlyklQaWIRIL5hHh97IlPkc8pfAIYI 1ekxMPsBGDV3tixOhWNinittFY+83hx0kwXG/SyM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B072260558 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Received: by mail-qt0-f172.google.com with SMTP id f18so6764797qth.11; Wed, 14 Feb 2018 00:28:48 -0800 (PST) X-Gm-Message-State: APf1xPC3+/B3N1FPKUsssMPwoA0YxBDSW9qgGs+zlxm1Y2L3I7A03SZM jD2T7wduqy489oVVryWqsMt4uGKe5dywaVvbhNk= X-Received: by 10.200.1.199 with SMTP id b7mr6254041qtg.36.1518596927899; Wed, 14 Feb 2018 00:28:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.8.227 with HTTP; Wed, 14 Feb 2018 00:28:47 -0800 (PST) In-Reply-To: References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> From: Vivek Gautam Date: Wed, 14 Feb 2018 13:58:47 +0530 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: Tomasz Figa 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, open list , Linux PM , dri-devel , freedreno , David Airlie , Greg KH , Stephen Boyd , linux-arm-msm 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 Tomasz, On Tue, Feb 13, 2018 at 1:54 PM, 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)? Yes, I too noticed it while i was testing on a different platform, and was hitting a failure case. Will update at all places. > > 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? No, I don't think. Can manage with just a 'put' here. Will modify. best regards Vivek > > [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 -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation