Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1022927iob; Fri, 13 May 2022 20:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlM63/eWLXMS911m4mtibqrLwqgpG7g2t+aII0ILbjF9DSbIx85cLtE0u01e3oSBCx2HlO X-Received: by 2002:a5d:680f:0:b0:20a:d858:f703 with SMTP id w15-20020a5d680f000000b0020ad858f703mr6101966wru.414.1652497277539; Fri, 13 May 2022 20:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652497277; cv=none; d=google.com; s=arc-20160816; b=gRRysra36zXf/ngqE1cNPJeNkxy0ldIlOToJb9PLZTxTTLs0FkmBztdyyU4AzQqJJD NPxyr37FrPzuL904xtobaqDR2rNV5CiP7iAaQkOw/kI2+nuQ0JL5THnsUBQWumLQCQET xvd8W4WlFYzvLqlDiJ4dZAxBSVZYLVsLm6s/IVU5LxIytJXfhni5jBBnnNC+NhUBVKD1 lMk41a+75gdm44lA0PQweS5BA/+apGny1QarcwrOaZ0kWPjH22Xn1Q8Sw7pFancxH1Ve cnZg3diY3S2BiiNpK5KngRFbc/lMe5yT24iOYY8/vHKgNLKwBZPJxSvnt+17XYgqY4Xq Yg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=YoyMMzKf+wqmK67XMsZV4Jv7Z8rXneWGl16B9VYtrOQ=; b=bxLFg8Lb6qFkITEFmk8yYfXy+1e7BuWATY8zAegndwyWzvlfw9TJjr5ZmVN66eiQ11 HRvR4cux1tpmvN8bus09MKVFRBPxLnAjwp7uKiTL22YzCpfUJU6X12aGuAOZSVbQKfWB g1SyNEOyU5fR2xYxL/sl/9Xm3o74kBRgr486kdb2xQXtkU6ctW/CIh9MJBQhqcYBMhQf rGq1fTtaOHPAMzpYG7aVJgzE2c7X5uteAUaO6Ka8Jf5afdICBzH9HSCk6EMXGwkkMBE1 Wa1CokmT3k3Lgp/Fwa+An22y8VkYiL0gcEPbOQKnf611IY9A9W3kaH60qw25TptD5zwE mCEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="D0H5/tLr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k25-20020a05600c1c9900b00393f95cb984si8502635wms.123.2022.05.13.20.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="D0H5/tLr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 846E73A32D8; Fri, 13 May 2022 16:44:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353490AbiELL7v (ORCPT + 99 others); Thu, 12 May 2022 07:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239193AbiELL7t (ORCPT ); Thu, 12 May 2022 07:59:49 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF41217FCA for ; Thu, 12 May 2022 04:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652356787; x=1683892787; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=2xpqBipggE9efSrMnAk1RxaKgm4Z25yOtIHM0l1ipSE=; b=D0H5/tLr9KKVS0ruxCZKIYIMnIrKdAaeVJfuzVl9AbIlc1Hx0jbd0k87 3PJE3rNATfgzLWvHq/2BGFgRTccKz71gXhCnMC43Av5j4Pflwvo4nQ2Fl ZJ8Ns4CklSy48Qw9KSDXLGgX+yS6/SdCHWByL7nxmQZt5VgghI4n2MIgt 5SNziVIlVl1N/XFamqwiOrJNwpOD/ffU2Hy8WECx5GSMcIxhIeGd7ZM9W So9D+TgWQcbyrfhbJeQidpEjyvpZhOel6cpctEjeUx54Ti6wwTMSzK2wE LoboHGZm4EnN28s23D/04e7RtsL+4MANGmac9VPtSoE5wfS5qXve2jLQC Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="356404381" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="356404381" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 04:59:47 -0700 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="594633931" Received: from hezhu1-mobl1.ccr.corp.intel.com (HELO [10.255.29.168]) ([10.255.29.168]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 04:59:43 -0700 Message-ID: <1a78418a-8637-e8dd-d1de-5529f20058fd@linux.intel.com> Date: Thu, 12 May 2022 19:59:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Cc: baolu.lu@linux.intel.com, "Tian, Kevin" , 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 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces Content-Language: en-US To: Jason Gunthorpe References: <20220510061738.2761430-1-baolu.lu@linux.intel.com> <20220510061738.2761430-9-baolu.lu@linux.intel.com> <20220510152330.GG49344@nvidia.com> <749a7d62-3e6c-ef5c-beaf-6b7add495740@linux.intel.com> <20220511145319.GZ49344@nvidia.com> <05a68e1e-8e18-5914-ebe7-d7b1a4aaa2ec@linux.intel.com> <64954f2d-2274-410e-269c-84efc0635633@linux.intel.com> <20220512114844.GT49344@nvidia.com> From: Baolu Lu In-Reply-To: <20220512114844.GT49344@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 2022/5/12 19:48, Jason Gunthorpe wrote: > On Thu, May 12, 2022 at 01:17:08PM +0800, Baolu Lu wrote: >> On 2022/5/12 13:01, Tian, Kevin wrote: >>>> From: Baolu Lu >>>> Sent: Thursday, May 12, 2022 11:03 AM >>>> >>>> On 2022/5/11 22:53, Jason Gunthorpe wrote: >>>>>>> Also, given the current arrangement it might make sense to have a >>>>>>> struct iommu_domain_sva given that no driver is wrappering this in >>>>>>> something else. >>>>>> Fair enough. How about below wrapper? >>>>>> >>>>>> +struct iommu_sva_domain { >>>>>> + /* >>>>>> + * Common iommu domain header,*must* be put at the top >>>>>> + * of the structure. >>>>>> + */ >>>>>> + struct iommu_domain domain; >>>>>> + struct mm_struct *mm; >>>>>> + struct iommu_sva bond; >>>>>> +} >>>>>> >>>>>> The refcount is wrapped in bond. >>>>> I'm still not sure that bond is necessary >>>> >>>> "bond" is the sva handle that the device drivers get through calling >>>> iommu_sva_bind(). >>>> >>> >>> 'bond' was required before because we didn't have a domain to wrap >>> the page table at that time. >>> >>> Now we have a domain and it is 1:1 associated to bond. Probably >>> make sense now by just returning the domain as the sva handle >>> instead? >> >> It also includes the device information that the domain has been >> attached. So the sva_unbind() looks like this: >> >> /** >> * iommu_sva_unbind_device() - Remove a bond created with >> iommu_sva_bind_device >> * @handle: the handle returned by iommu_sva_bind_device() >> * >> * Put reference to a bond between device and address space. The device >> should >> * not be issuing any more transaction for this PASID. All outstanding page >> * requests for this PASID must have been flushed to the IOMMU. >> */ >> void iommu_sva_unbind_device(struct iommu_sva *handle) >> >> It's fine to replace the iommu_sva with iommu_sva_domain for sva handle, >> if we can include the device in the unbind() interface. > > Why would we have a special unbind for SVA? It's about SVA kAPI for device drivers. The existing kAPIs include: struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm, void *drvdata); void iommu_sva_unbind_device(struct iommu_sva *handle); u32 iommu_sva_get_pasid(struct iommu_sva *handle); > SVA should not different from normal domains it should use the normal > detach flow too. Best regards, baolu