Received: by 10.223.185.116 with SMTP id b49csp3939465wrg; Tue, 13 Feb 2018 10:04:25 -0800 (PST) X-Google-Smtp-Source: AH8x225tnVR4h0uyrwBdkfwsi5WyRKjAmu3jpJscL9ghFeyVBXw+G8RoowUmnTw1oQa//OEKIrIC X-Received: by 10.99.126.17 with SMTP id z17mr1649926pgc.218.1518545065687; Tue, 13 Feb 2018 10:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518545065; cv=none; d=google.com; s=arc-20160816; b=is2QLsdtf2cDEojRt+YVznRvGFdpstOwjRuKRT27yU8waZ3EsdYJ9NuKa2+dWCu+sm 8sgVPMrlSB4SWzZwQmmQAxsoY8D4n/cF8pIt3NipyYPDBdpc6QT4DuITPURdvuKML1Nk R4MAhib07UbBI7qw8UdI7vm7akBRylUMc95tuDQEC8Kru/4seuFysUp+h0Y4YODkMxH0 tH1I5u6qIpn613LaguOXjkZysh6dDH97Pq+s8PqYUqtFosfT7rdSuLvsY7X4Fq4f/oKM oW2L9v9yX/ZDLUW91jZfXRoogt1iW/iTm7XykcXYp9SQAEfnhJKPpkRHVzFC7PixxZ9x O4rw== 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=x4BraxUMb8M0aPxzDJs1j+/aaJH/Z/34RnRbU6qyoig=; b=QFV0P/DDnxPP9V/EffePHysvrE1jbJRzKYnt4MKcZe7qXGmNDblvkR+6aKRjIVdFJ9 iVWF+NASnA/2CSjZpNxB4ha7loRvGOIwFJIgSoAZMRYYfrOT3x+TMFcZXhO0tO6aopgn 8iDW+w521UWKCtsiaicx/e+Oqn/l7uXTUvSIkaaWEVUJ+XEN8lNEB4vNoORPVv14TrJP AyrCXcbA/wMSHxiCmvd6au+pTgFADYY/zZYc48umAXM0l0uJoIQaqeQtxqdC58MfaF75 MdC9qtKANmCeR4PIYdx1OqAqpdMdRk5iah/LxEfrmlxrCFZSXINp8/BA5PgBNno5F2YC Wg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dOv1+3t/; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f21-v6si2555321plj.194.2018.02.13.10.04.10; Tue, 13 Feb 2018 10:04:25 -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=@gmail.com header.s=20161025 header.b=dOv1+3t/; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965421AbeBMSDT (ORCPT + 99 others); Tue, 13 Feb 2018 13:03:19 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34147 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965158AbeBMSDQ (ORCPT ); Tue, 13 Feb 2018 13:03:16 -0500 Received: by mail-io0-f195.google.com with SMTP id e7so7992736ioj.1; Tue, 13 Feb 2018 10:03:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=x4BraxUMb8M0aPxzDJs1j+/aaJH/Z/34RnRbU6qyoig=; b=dOv1+3t//GEiHupOg9xCvCXTTvgluUr5H7EeJWZOJTFNQFuuoDxB1ORnzCLaKw3gQL UZuOuwpzv4YwmhVo7PuVahc6ysIt44kUFDFljJoL0hf46pX3as4FbIzpCki9/hHh3RHH eSRTElBJVoNhHe8Kk0p8WyhRZbR4fcuYCofZMVTblwzcn5l55zlnRzeCFMbXK1dNdtXb +U931fqbr1cbg66pO486t2PuNT30CIJ+RUuA0QHsFQx2IHTin0Dagc2ZuxD7LCT2V10p hkjMgJyXtNHBUY/c71MtgNR30K2VbAsnz4n3zYPSocyjSlK1QJ6EcdxcpHQr+Y+kpDcF pK7w== 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=x4BraxUMb8M0aPxzDJs1j+/aaJH/Z/34RnRbU6qyoig=; b=nZ5xZjb6A7rpvYfiqz3rb/f5IpfVMaEsdgnjrXQCdqXZ6ZYGJuDRLD5OuX6jMRCl2H GS1oRRnnVdGUMhfnRbS8JvSB2g97bWGD2OGOTjYBbvte6hEhobMOTvLgRq1lJM2HBVbs TC2IS7qOUVIPv8Wuh4lOjan+NMW4Qti0rS7+SIKFK4aRnt/74DAp4HX7vl64N/CvEtje OG2r1j1ujh/Mv80rInkjb0qUZLAHy4hJBrRtHsGrNpvJ3Ssl4CyAcbr69xtLQzQxW98H Ha2RlePmveR6HaQS0J8Ii/aqPVLshkfHIRJmSS51j0Lmmaaggt25ihBzdnH9U/zJphaH axSQ== X-Gm-Message-State: APf1xPB1uT+h9XWsxbN/XydoeRj4l7SnvkefPbp7Mri3CG7jTetmmWPb IQFkR0yaya6t+QaJBNNySt/bNrZi/oblCFSm1VTAOl5o X-Received: by 10.107.78.5 with SMTP id c5mr2439801iob.120.1518544994897; Tue, 13 Feb 2018 10:03:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.111.93 with HTTP; Tue, 13 Feb 2018 10:03:13 -0800 (PST) In-Reply-To: References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-7-git-send-email-vivek.gautam@codeaurora.org> From: Rob Clark Date: Tue, 13 Feb 2018 13:03:13 -0500 Message-ID: Subject: Re: [PATCH v7 6/6] drm/msm: iommu: Replace runtime calls with runtime suppliers To: Tomasz Figa Cc: Vivek Gautam , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Robin Murphy , Will Deacon , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, Linux Kernel Mailing List , linux-pm@vger.kernel.org, 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 4:10 AM, 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: >> While handling the concerned iommu, there should not be a >> need to power control the drm devices from iommu interface. >> If these drm devices need to be powered around this time, >> the respective drivers should take care of this. >> >> Replace the pm_runtime_get/put_sync() with >> pm_runtime_get/put_suppliers() calls, to power-up >> the connected iommu through the device link interface. >> In case the device link is not setup these get/put_suppliers() >> calls will be a no-op, and the iommu driver should take care of >> powering on its devices accordingly. >> >> Signed-off-by: Vivek Gautam >> --- >> drivers/gpu/drm/msm/msm_iommu.c | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c >> index b23d33622f37..1ab629bbee69 100644 >> --- a/drivers/gpu/drm/msm/msm_iommu.c >> +++ b/drivers/gpu/drm/msm/msm_iommu.c >> @@ -40,9 +40,9 @@ static int msm_iommu_attach(struct msm_mmu *mmu, const char * const *names, >> struct msm_iommu *iommu = to_msm_iommu(mmu); >> int ret; >> >> - pm_runtime_get_sync(mmu->dev); >> + pm_runtime_get_suppliers(mmu->dev); >> ret = iommu_attach_device(iommu->domain, mmu->dev); >> - pm_runtime_put_sync(mmu->dev); >> + pm_runtime_put_suppliers(mmu->dev); > > For me, it looks like a wrong place to handle runtime PM of IOMMU > here. iommu_attach_device() calls into IOMMU driver's attach_device() > callback and that's where necessary runtime PM gets should happen, if > any. In other words, driver A (MSM DRM driver) shouldn't be dealing > with power state of device controlled by driver B (ARM SMMU). Note that we end up having to do the same, because of iommu_unmap() while DRM driver is powered off.. it might be cleaner if it was all self contained in the iommu driver, but that would make it so other drivers couldn't call iommu_unmap() from an irq handler, which is apparently something that some of them want to do.. So I'm happy with the pm_runtime_get/put_suppliers() approach as a reasonable compromise. (Perhaps specifically, attach/detach this could move inside the iommu driver, but we still need to get/put_suppliers() for unmap(), so meh) BR, -R > This is also important for the reasons I stated in my comments to > "[PATCH v7 1/6] base: power: runtime: Export > pm_runtime_get/put_suppliers". Quoting for everyone's convenience: > >>> There are however cases in which the consumer wants to power-on >>> the supplier, but not itself. >>> E.g., A Graphics or multimedia driver wants to power-on the SMMU >>> to unmap a buffer and finish the TLB operations without powering >>> on itself. >> >>This sounds strange to me. If the SMMU is powered down, wouldn't the >>TLB lose its contents as well (and so no flushing needed)? >> >>Other than that, what kind of hardware operations would be needed >>besides just updating the page tables from the CPU? >> > > In other words, the SMMU driver can deal with hardware state based on > return value of pm_runtime_get_sync() or pm_runtime_get_if_in_use() > and decide whether some operations are necessary or not, e.g. > - a state restore is necessary if the domain was powered off, but we > are bringing the master on, > - a flush may not be required when (un)mapping with the domain powered off, > - etc. > > Best regards, > Tomasz