Received: by 10.223.185.116 with SMTP id b49csp399488wrg; Wed, 14 Feb 2018 00:26:45 -0800 (PST) X-Google-Smtp-Source: AH8x224twPcn2iRbBxH7Q8jye5V1aOdb0IUn5llrLWnhISc/c0clBEeBOFhxRG0Z55k47SK9+iG9 X-Received: by 10.99.154.73 with SMTP id e9mr3196222pgo.26.1518596805134; Wed, 14 Feb 2018 00:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518596805; cv=none; d=google.com; s=arc-20160816; b=kejt9/4ruVp2nIVsCL1HygEGiYCjsPEmOBGVMdrRvhiBd+5/dMFwG1aMGOHkzz6ckA k2u0zLhkpucHjeyWWQDoBIjlxB+kq3mtCrDOqUzRmKhUwQIrSKcjvZidHXLWPMhhe8+G DzCC3lANOlJmSNuP1/5M2zarGe/YRDEIkaCAu6GbfNl5lV7yINAwcsZY9SlSF/QFbRZ6 PPSXZ9r8iVSU/Jc+bm2lTw3vuhcZQphj+w5ed+IJoDKUgIgY10qH5ig+XE0J/+W6ogrz VZXn6B4G+U2AJBL0g2evne8PPmm1MGNB3eh5+b7ZPvWtKcaCz8EepaeRS5Mm285mJdxI 2dTQ== 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=H+Z9mAhbGZFEbqFAJAtiRK2nNMw5PoUS/Auqtc7zY7Q=; b=0rsAIWuMKaYV0tXhT58vd2X0+VaEW6q87EaPHw62CLZN1SDg4VhZJOlq9T+VBOutHL GBbYTgZMGIxeWwmNTRoInYF9JyklBSQsj6vHglHfEIznzqmCCYb4zZjIHcX+K7iSHKmE e48CU9opQpVeovhXPaguv6ISztP88Mn0qWciUBswy4owJTgmiBbKVyt4IUaDWP4ISNwL t0T7ViUK89FdPpWyD6ELHi5IFdsh18iudkzpTYEEMtedkpdvQaBdJu8tmtj1qcH7j1/4 /C3TzS7RZZP5035wtVHnVpBrH5UQhN7Vz1iUkfRoCiiGBciHHghOKz5cp6yNIbtKH1oB yD3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HHuiM9Ut; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ar8KbmWF; 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 n9si4579830pge.307.2018.02.14.00.26.30; Wed, 14 Feb 2018 00:26: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=HHuiM9Ut; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ar8KbmWF; 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 S1754680AbeBNIYp (ORCPT + 99 others); Wed, 14 Feb 2018 03:24:45 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34538 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754556AbeBNIYm (ORCPT ); Wed, 14 Feb 2018 03:24:42 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E6D9E60558; Wed, 14 Feb 2018 08:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518596682; bh=cnMNfngo1TF5PyX/QSXOsKzY6XcSYSjATLtW+4oufsY=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=HHuiM9UthlJaYboRfhuGUQxn53r9jhRxFSs5Nxb4CYaPTLO5KKsbdMQXPIYx0XP6H cHD1IDM6LapB/Qf4v3SYUDo7Z2YJriVeo2u4YoMdHqeSuPB4xA83tbac6altJU6nz0 NxXfdVJxInlyTKGPeyM7GAYTYWMA8h+Xnuq52Pt8= 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-f182.google.com (mail-qt0-f182.google.com [209.85.216.182]) (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 8CD8F60558; Wed, 14 Feb 2018 08:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518596680; bh=cnMNfngo1TF5PyX/QSXOsKzY6XcSYSjATLtW+4oufsY=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Ar8KbmWFFtAKLk3rli+SAo4GnQ/op1GAA+deBDyWtLieDyCDF/Ksk3wwAQ+SuIGvX Wk6tKO650PH797Vzp51n8X4RZZNEzlKL4wmONDeTuxWqb0CvO8cBCwa7Eg1P6jxNRI f/bhH6Ce1kpx5OTHtANWTWIIbWPa5It8lC+dGvoc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8CD8F60558 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-f182.google.com with SMTP id k25so777631qtj.9; Wed, 14 Feb 2018 00:24:40 -0800 (PST) X-Gm-Message-State: APf1xPBElgT+/0d8mhaRPoW47ZmJKloD5v7MefDRKVr8gHj+7siGuJb7 /Jp5Afmv6X4hgzVDkrGbxzE46xmgYqt2tiPRNfQ= X-Received: by 10.200.11.132 with SMTP id h4mr1735418qti.82.1518596679719; Wed, 14 Feb 2018 00:24:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.8.227 with HTTP; Wed, 14 Feb 2018 00:24:39 -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> <906051dd-8898-ec6f-5ad4-3f37716292cf@arm.com> From: Vivek Gautam Date: Wed, 14 Feb 2018 13:54:39 +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: Robin Murphy , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Will Deacon , Rob Clark , 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 On Tue, Feb 13, 2018 at 7:22 PM, Tomasz Figa wrote: > On Tue, Feb 13, 2018 at 9:57 PM, Robin Murphy wrote: >> 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. > > That's true for Qualcomm SMMU, but I think that would be different for > existing users of the driver? > >> >>> 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. > > Hmm, I think we are talking about different things here. My suggestion > would not add much more code to the driver than this patch does, calls > to arm_smmu_enable_clocks() instead of pm_runtime_get_sync() and > arm_smmu_disable_clocks() instead of pm_runtime_put(). The > implementation of both functions would be a simple call to clk_bulk_ > API (possibly even no need to put this into functions, just call > directly). Well, things are not so straight on msm. The IP clocks on msm are usually powered by (or i should rather say, controlled by) the same power domain that provides the VDD supply to iommu block. This is the behavior on msm8996 atleast that we are testing on right now. On later SoCs too things don't change drastically. So, you can't have the block in low power state until you program the register space and then power on the block to let it do its magic. Clocks and power domains are linked, and that's why we add them to the pm callbacks. This approach also looks generic to me since the platforms will either have such a link or they will not have. But, in either case you will have power and clocks available at the time when you need them. Thanks & regards Vivek > > Best regards, > Tomasz > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation