Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1060006iob; Thu, 12 May 2022 10:12:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQAq1aWobuBBBwn2pPxmeS9nE9sOBkHXpyE3dLcoEhi+m+MvW6IcbdDsWCEmqI8g0L33vk X-Received: by 2002:a17:906:c14d:b0:6fd:dd02:7f81 with SMTP id dp13-20020a170906c14d00b006fddd027f81mr838695ejc.722.1652375527501; Thu, 12 May 2022 10:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652375527; cv=none; d=google.com; s=arc-20160816; b=nscH9AU+7mGNCs6frAahjFx+wBLyWmL2CzR5M8IveYEuUkXGWcHLMR1OH4DPNnxVEg 9RMJnopQNjJggRwDGWmvMEMfZfcHFepuw7fvxCow2d6UHhEw3mDMXqsZJNCcIR167agJ TVRiQvFAg0jJV4Te8r2idozBvKsktK9kz98gvI08GeWfh0b/LsNV4sE5ITo+okFwnhDb TirXmDo3FNeS8ap3OslrmvUnkYS5fj3G8pk2Egkz1kLjR2stwj+nm5ZoYbQQ5BF4CEws NmZysChiu5G6eIbTyrxhxT5VpmkhUmCMeJ0B45rEf6SZs9jDcBpmiPGNPvmME7yG2CKh pF1A== 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=efsh0uFhOmfXuxYUIJCJiPXg0Qyy8hA9I7vTZKgvJew=; b=yPCC6RW5bBwBJDlENJeVBdc0J9xjom1sVXEAW6olu5jgRRYTYS8L35f8Hh/Lgwui1k LZwBXI+VHIqKjf6BnaRm/Y0LWrCD7XkajjJGAMbdH/yScZRxjJA+gPXjBNr6LGHm8e0o KMRpDClRcBm6l1bG0LlxySf2TIoq4RyiS/k8vGmkAa3AZ/Fm8c3Ao+mrcny1AhKz+Q7l rzMZSiK0on8osqZMRH6odf7dCKYu4WuSjKHlgi5HDcDK69nEetUtrokxlZp/XrjZNroq 7kEQBOPgk5cT6n+tQ3LC/o1bEYknyWWrPXiTis0fI1tDT/WnLsZcFp8751gBhQjoRl+G XyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EnqUiSp3; 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 he36-20020a1709073da400b006fa7f01d3a0si7057514ejc.206.2022.05.12.10.11.29; Thu, 12 May 2022 10:12:07 -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=EnqUiSp3; 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 S1350635AbiELHBd (ORCPT + 99 others); Thu, 12 May 2022 03:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350640AbiELHBb (ORCPT ); Thu, 12 May 2022 03:01:31 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20AB36B44 for ; Thu, 12 May 2022 00:01:28 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id i25-20020a9d6259000000b00605df9afea7so2066216otk.1 for ; Thu, 12 May 2022 00:01:28 -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=efsh0uFhOmfXuxYUIJCJiPXg0Qyy8hA9I7vTZKgvJew=; b=EnqUiSp3NRowBkDyrnH+e0w+NAXs45+xS/LbhwDZ3jHVK0hFAtydeud0D9yIZn5vHW h8HWixSpXklXLa+vK0fx3AbDZVfRsCuQ3uWTqZM5UIxf9StJFijoGeJ7Y9NtGuxszsXu kpIsxH5bfEK7ZaVLJvMeAWAa17bcyo8M/DirkCc2ghz86spx04iga5Sx0rcogQiDYQQK EOfOw72OCdN2Dw7gxALr9tRfBFCVfE8WB3Y9udtLVW8WmkPb7+c5AtLreavAU14sR3SC TZ3bR7XjoP4DP+D+JPhHYQsGcJN53ZIv1t4dk2aqF7ASmkfTgz5ABsz8Jo02qvjVqbb+ lCrw== 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=efsh0uFhOmfXuxYUIJCJiPXg0Qyy8hA9I7vTZKgvJew=; b=KswGn7EL6Rf9vfc/BR610gcNytNAPB9qGy5i4rFawwnaUty7+NTEn2FZ93YDVMtRag g4fMhAlYy6chGYSz2vCOG9Kmc2RoBJycm8Jx5sv9/Icku4PU2+d+Rxn5yiWJBR0Y3WlJ a5Pv29rYZR9/rZjqA+teaqzhdOp3UaLELXxNFqo8kLS8kqKxlAgLcJRZTxp3TVpp3NbU g/hGiVhpiAPy1AxRcvhUPKW6MrIVuJLRMzFKgpCNk14eeZD770NZdGN5vZQEIrJJadEa lVaqwYFGQNh1CPyvHoSDV+r6tuSYMMtzXFKltjPAyT6shqazzX61i1u8BThPZAlZbDz+ Lw0w== X-Gm-Message-State: AOAM531K/y8AHVXoMOpMmtGtrDs1xQoUX1zIrJkDxpzWYeD/bnXlH2oR qkHRVAXvWXntBM1ZrIaD0TsEnDPRtDGdB5nH X-Received: by 2002:a9d:7618:0:b0:605:a132:7d57 with SMTP id k24-20020a9d7618000000b00605a1327d57mr11353454otl.262.1652338887629; Thu, 12 May 2022 00:01:27 -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 102-20020a9d016f000000b0060603221272sm1633368otu.66.2022.05.12.00.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 00:01:26 -0700 (PDT) Date: Thu, 12 May 2022 08:00:59 +0100 From: Jean-Philippe Brucker To: Jason Gunthorpe Cc: "Tian, Kevin" , Baolu Lu , 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> <20220511120240.GY49344@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220511120240.GY49344@nvidia.com> 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 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 09:02:40AM -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 08:54:39AM +0100, Jean-Philippe Brucker wrote: > > > > > 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. > > Why would a driver need to keep additional tracking? > > > 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. > > It is not "missing" it is just renamed to blocking_domain->ops->set_dev_pasid() > > The implementation of that function would be identical to > detach_dev_pasid. attach(dev, pasid, sva_domain) detach(dev, pasid, sva_domain) versus set_dev_pasid(dev, pasid, sva_domain) set_dev_pasid(dev, pasid, blocking) we loose the information of the domain previously attached, and the SMMU driver has to retrieve it to find the ASID corresponding to the mm. Thanks, Jean