Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp334237imu; Mon, 26 Nov 2018 11:32:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/WnH5sN9IywiHQZ9iOIgSOhpeo6ItxbKAUWjykygGYHkAnY5myD9/XJl4d346629tFWJJ1Z X-Received: by 2002:aa7:810c:: with SMTP id b12mr6497449pfi.44.1543260769527; Mon, 26 Nov 2018 11:32:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543260769; cv=none; d=google.com; s=arc-20160816; b=YIsDkbIR6Ns52EldEYVHNgKskxe/BkGnxtkS5TvdklyQmirE1MbrW7jYBMbC9l6+b7 b+I+Qnds1X3r2FFfp8wfC8uae7HSKPuzNkmK8q5tDHB4HqjTNLoAjQOVRHqiw+0aJ0tu /67gse1N5HZsWzvBLzhNOEcHDC37a4D/nPUIUIcr16bYw0wxiOv3ZX95SIBo4C83mSyw suUiN34k8cxNf7nSBPvBaUvGRlnYu9LJKzHqgJZdDxlifVIQ9Yq7brmQV2kqXh9MY9i7 mAzGq7R0GnvD7Uo/ZfAMo6+KOcwjIBBp/LCnxZF9pbusn/N4vk6h128pw+15UdsrzgYl FOlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xl/hQurlpDqQ0w1tO38n0O7BYad7AhQL3jVRsRdRXbs=; b=rRkV5rPEETL4sNp2cHDl6OKRUNGfPhmkVG1MFymkO+92W7ftfGevEFhW7uAOnvAAEa /6q9nw8l+fEI8PYiBT02paL4aQEwz4C8sRmmfcUvF7SGNI/nLDoto8WovDHxtmG1nd10 dLUlJ7cN+odocHbsPwswwHYerjGwJQsJqeS6uOSqoPTT1bApgHtv4dVZgY3X+qUM0T3r hyL3jFfONf9sbwRUCwoPqcn8CqVAg48w/zuo+XwSY5bAJwW+6DQt1ft3tGuzj/75vUxf 47DLNNsa2awi9z9H+F8sL/o8Yc55Wd6KUMiRJfgfoJINoBsDOh8tdFfLZ+GKSchZo1Pw XyDQ== 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 g7si1118498plt.212.2018.11.26.11.32.23; Mon, 26 Nov 2018 11:32:49 -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 S1727031AbeK0G0n (ORCPT + 99 others); Tue, 27 Nov 2018 01:26:43 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45968 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbeK0G0m (ORCPT ); Tue, 27 Nov 2018 01:26:42 -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 1DCC82381; Mon, 26 Nov 2018 11:31:35 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E1D333F5AF; Mon, 26 Nov 2018 11:31:34 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 6FDF31AE0839; Mon, 26 Nov 2018 19:31:52 +0000 (GMT) Date: Mon, 26 Nov 2018 19:31:52 +0000 From: Will Deacon To: Vivek Gautam Cc: Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , alex.williamson@redhat.com, Linux PM , sboyd@kernel.org, freedreno , "Rafael J. Wysocki" , open list , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , robh+dt , linux-arm-msm , Robin Murphy Subject: Re: [RESEND PATCH v17 2/5] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device Message-ID: <20181126193151.GC534@arm.com> References: <20181116112430.31248-1-vivek.gautam@codeaurora.org> <20181116112430.31248-3-vivek.gautam@codeaurora.org> <20181121173757.GA9801@arm.com> <20181123183555.GE21183@arm.com> <9064c01e-cef0-9306-078a-8d303cd6614b@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 04:56:42PM +0530, Vivek Gautam wrote: > On 11/26/2018 11:33 AM, Vivek Gautam wrote: > >On 11/24/2018 12:06 AM, Will Deacon wrote: > >>On Thu, Nov 22, 2018 at 05:32:24PM +0530, Vivek Gautam wrote: > >>>On Wed, Nov 21, 2018 at 11:09 PM Will Deacon > >>>wrote: > >>>>On Fri, Nov 16, 2018 at 04:54:27PM +0530, 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. > >>>>>Global locks are also initialized before enabling runtime pm as the > >>>>>runtime_resume() calls device_reset() which does tlb_sync_global() > >>>>>that ultimately requires locks to be initialized. > >>>>> > >>>>>Signed-off-by: Sricharan R > >>>>>[vivek: Cleanup pm runtime calls] > >>>>>Signed-off-by: Vivek Gautam > >>>>>Reviewed-by: Tomasz Figa > >>>>>Tested-by: Srinivas Kandagatla > >>>>>Reviewed-by: Robin Murphy > >>>>>--- > >>>>>? drivers/iommu/arm-smmu.c | 101 > >>>>>++++++++++++++++++++++++++++++++++++++++++----- > >>>>>? 1 file changed, 91 insertions(+), 10 deletions(-) > >>>>Given that you're doing the get/put in the TLBI ops unconditionally: > >>>> > >>>>>? static void arm_smmu_flush_iotlb_all(struct iommu_domain *domain) > >>>>>? { > >>>>>?????? struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); > >>>>>+???? struct arm_smmu_device *smmu = smmu_domain->smmu; > >>>>> > >>>>>-???? if (smmu_domain->tlb_ops) > >>>>>+???? if (smmu_domain->tlb_ops) { > >>>>>+???????????? arm_smmu_rpm_get(smmu); > >>>>>smmu_domain->tlb_ops->tlb_flush_all(smmu_domain); > >>>>>+???????????? arm_smmu_rpm_put(smmu); > >>>>>+???? } > >>>>>? } > >>>>> > >>>>>? static void arm_smmu_iotlb_sync(struct iommu_domain *domain) > >>>>>? { > >>>>>?????? struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); > >>>>>+???? struct arm_smmu_device *smmu = smmu_domain->smmu; > >>>>> > >>>>>-???? if (smmu_domain->tlb_ops) > >>>>>+???? if (smmu_domain->tlb_ops) { > >>>>>+???????????? arm_smmu_rpm_get(smmu); > >>>>>smmu_domain->tlb_ops->tlb_sync(smmu_domain); > >>>>>+???????????? arm_smmu_rpm_put(smmu); > >>>>>+???? } > >>>>Why do you need them around the map/unmap calls as well? > >>>We still have .tlb_add_flush path? > >>Ok, so we could add the ops around that as well. Right now, we've got > >>the runtime pm hooks crossing two parts of the API. > > > >Sure, will do that then, and remove the runtime pm hooks from map/unmap. > > I missed this earlier - > We are adding runtime pm hooks in the 'iommu_ops' callbacks and not really > to > 'tlb_ops'. So how the runtime pm hooks crossing the paths? > '.map/.unmap' iommu_ops don't call '.flush_iotlb_all' or '.iotlb_sync' > iommu_ops > anywhere. > > E.g., only callers to domain->ops->flush_iotlb_all() are: > iommu_dma_flush_iotlb_all(), or iommu_flush_tlb_all() which are not in > map/unmap paths. Yes, sorry, I got confused here and completely misled you. In which case, your original patch is ok because it intercepts the core IOMMU API via iommu_ops. Apologies. At that level, should we also annotate arm_smmu_iova_to_phys_hard() for the iova_to_phys() implementation? With that detail and clock bits sorted out, we should be able to get this queued at last. Will