Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6637243iob; Wed, 11 May 2022 01:55:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWe/qH497AoS4neTP/b1NKRqoNx+W3yR3Xm8xmOP/Mk541cLxt5BJxiDR9eTtkwsILgsK7 X-Received: by 2002:a17:907:7810:b0:6e7:ef73:8326 with SMTP id la16-20020a170907781000b006e7ef738326mr22908507ejc.429.1652259352563; Wed, 11 May 2022 01:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652259352; cv=none; d=google.com; s=arc-20160816; b=N3ymL0kHb841Tao3QAyv6LtlVM9egnel2emMqT8gAnKYwRV/WdP7ntSzaPlquE6KDY +Qcgm+Be5xlAvsj/Psp1vfYQlGtJp9rh2i8hiL2/FjNzgBj4wc+Z2PZjGaJj2FtxPWg6 UTCJbglheJZWpJfL3KJkXzDu8f7PoXBH4YHLIKaJtgaPLUOddJyTc/r68ie31EmlOxT4 QLwHyO0s5FU+Lt46MckFW9jtOHUlklt0ZJP4g23ALsDZRQHZ2DWpXFkOujP2l2NlLh8P Wn63543bVceY30wvs/5cIA0w8ntaLGs3J8P7e1GFzuLtNpf5UUHW3EaqSQCchsc/3q72 k7DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=T+vt0ZVMpAStN8vtcO/W3H1y3FeI0bv62I6/uRsSEhc=; b=WymzkviarnHkziFWoIpM4QXGGpypsMx6wvEOYldAn7ZpDKlPWXN7XOxOiy/v+Il4Ab tMjOYP4Y0OODVz5xzuAk646iOq9ISNzDj6A6cTGOanxPS2Bsx2sJEmnY2eWGdI90enKe LMcRgQXNoI8YMN4RkNDgCE5cT74Gp73TUUS2YSdRONTseOX7/CqqWLqoSqLZVfGEflCw vR6vemxfkScK5CJeoCbQTH8jJuvurGaMAZc4qYmb4zSH8hLBp2lNWZBXQsonmUkO4WTT Z76na093tf8R/JfZDgDjufVUYEHdqJ+UQQzcYKqhgs/BfuxR8AZUEEVprFbDTQelN2v+ 7IqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eMxDIQet; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho15-20020a1709070e8f00b006f458fb419dsi2162410ejc.223.2022.05.11.01.55.28; Wed, 11 May 2022 01:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eMxDIQet; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239106AbiEKHzJ (ORCPT + 99 others); Wed, 11 May 2022 03:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232187AbiEKHzH (ORCPT ); Wed, 11 May 2022 03:55:07 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9D6590A4 for ; Wed, 11 May 2022 00:55:06 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id i27so2329098ejd.9 for ; Wed, 11 May 2022 00:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T+vt0ZVMpAStN8vtcO/W3H1y3FeI0bv62I6/uRsSEhc=; b=eMxDIQet9ahQhMdVrUMgQwkO/EsYnZNzv1UJDALKOX2rvcys5c3H8xAiH3t2OPUist k4fwOMS1K82o9wu0H71ne7MF1fN1pM8DeSYZAxfh+twlzgYbpgy1xUJMayjXiqfC2/AQ 3qFqRtxN0o4QogT5xFHTW/YwqwbQM3OfJJPILkI8wW348+Km7BHGDfak3ERAZWL6PiGx n7hd/6dDe++fqJ5eJjKPQ1LZgvzSD7vNfySoL3i0CLpaEoj7NHQlQ7A16n6LisC2o6d+ X+oBfXKYs7I63iQPWJGL0m3E6JsVafv2SPPCIxC8hi1NLit0KYzv6DItaL30wSX9bkYY Q9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=T+vt0ZVMpAStN8vtcO/W3H1y3FeI0bv62I6/uRsSEhc=; b=4Of4dYd0t9aDCRGSjIpT5xXVFABhR6mL9Mqpary5Q9DPzW57Hf/KCmaWFTlQwDtU1Z eO5hfqEjJ+AEoVkzcKZCqR5B10pVijyB149YHIgRw8FwAzER8nCIHWBaEldxs+FKMHUj QFvyP1AQ5d8ibZI8mCwElDbV7/OSyl4cdVath7YoUq3IQ2nFnUJRNPTFU/U46TGiUKiR UpWs0i9aYKVbR/x3WHe3t066C01Q3gWyOdnQoClnYxbDFag9+th2/RPYnN0RTi21dRe4 dJjdzBsCQ0Vehk/9/QEF0zU87jDixFQNzq6FUucp3/E06Z2l7wBeWvMJwQWh/iAgv1dV tbUw== X-Gm-Message-State: AOAM532K9Dcbvxv52NjNWqIJrvazeirk8KlXHBTrqMPfE/V8ULB+QpDS eJT5MNNxpjDkzN6xB05Q60tJyA== X-Received: by 2002:a17:907:971b:b0:6f4:3b8c:ae04 with SMTP id jg27-20020a170907971b00b006f43b8cae04mr23406515ejc.548.1652255704732; Wed, 11 May 2022 00:55:04 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id t17-20020a17090605d100b006f3ef214e50sm638962ejt.182.2022.05.11.00.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 00:55:04 -0700 (PDT) Date: Wed, 11 May 2022 08:54:39 +0100 From: Jean-Philippe Brucker To: "Tian, Kevin" Cc: Baolu Lu , Jason Gunthorpe , Joerg Roedel , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Robin Murphy , Jean-Philippe Brucker , "Jiang, Dave" , Vinod Koul , Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v6 03/12] iommu: Add attach/detach_dev_pasid domain ops Message-ID: References: <20220510061738.2761430-1-baolu.lu@linux.intel.com> <20220510061738.2761430-4-baolu.lu@linux.intel.com> <20220510140238.GD49344@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 11, 2022 at 04:09:14AM +0000, Tian, Kevin wrote: > > From: Baolu Lu > > Sent: Wednesday, May 11, 2022 10:32 AM > > > > On 2022/5/10 22:02, Jason Gunthorpe wrote: > > > On Tue, May 10, 2022 at 02:17:29PM +0800, Lu Baolu wrote: > > > > > >> This adds a pair of common domain ops for this purpose and adds > > helpers > > >> to attach/detach a domain to/from a {device, PASID}. > > > > > > I wonder if this should not have a detach op - after discussing with > > > Robin we can see that detach_dev is not used in updated > > > drivers. Instead attach_dev acts as 'set_domain' > > > > > > So, it would be more symmetrical if attaching a blocking_domain to the > > > PASID was the way to 'detach'. > > > > > > This could be made straightforward by following the sketch I showed to > > > have a static, global blocing_domain and providing a pointer to it in > > > struct iommu_ops > > > > > > Then 'detach pasid' is: > > > > > > iommu_ops->blocking_domain->ops->attach_dev_pasid(domain, dev, > > pasid); > > > > > > And we move away from the notion of 'detach' and in the direction that > > > everything continuously has a domain set. PASID would logically > > > default to blocking_domain, though we wouldn't track this anywhere. > > > > I am not sure whether we still need to keep the blocking domain concept > > when we are entering the new PASID world. Please allow me to wait and > > listen to more opinions. > > > > I'm with Jason on this direction. In concept after a PASID is detached it's > essentially blocked. Implementation-wise it doesn't prevent the iommu > driver from marking the PASID entry as non-present as doing in this > series instead of actually pointing to the empty page table of the block > domain. But api-wise it does make the entire semantics more consistent. This is all internal to IOMMU so I don't think we should be concerned about API consistency. I prefer a straighforward detach() operation because that way IOMMU drivers don't have to keep track of which domain is attached to which PASID. That code can be factored into the IOMMU core. In addition to clearing contexts, detach() also needs to invalidate TLBs, and for that the SMMU driver needs to know the old ASID (!= PASID) that was used by the context descriptor. We can certainly work around a missing detach() to implement this, but it will be convoluted. Thanks, Jean