Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp618259iob; Thu, 12 May 2022 00:29:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwcffdJqE4yB8VjZwYZoPznaxisRnTTN1i7lOhmgwMJKenTVAiEG3/+14WDQABroDsRGzE X-Received: by 2002:a05:6402:d52:b0:425:dda4:b676 with SMTP id ec18-20020a0564020d5200b00425dda4b676mr33050204edb.277.1652340547068; Thu, 12 May 2022 00:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652340547; cv=none; d=google.com; s=arc-20160816; b=DEIk+kvSM71OgpOS0ctkRXDiM9xo/hPkjljQkmFwkwe0UWVQafPio5bLwwwu0ndec+ c6AWMJev6+Tpn21NkVrL/FvqEXeGDtNsdlWBYzsA2Eh4W3Y1ASVAT5eF6jAqaRWOMGeq t9PjdPjtF/ns/T/XAF6fLd+Mz0AMXzeIyR6DKevZ5wTRFTC9BoRAz8EOMsh+xjUM75dw M0+uu+I07PcDuXF/VUQIDSI//L8yzEIUGJDo2ZnzSo7MLi4Ku70pP+igMl4Y2GoK9e9K 4U9QSXDEL/urJRJaDC2A6j2uYLUPylWqCTZUKF617X/CsmICTCgq/Ix1Fczs1sCZUxRa 10EA== 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=KweIJykG00oW05XBxqWWAzokRH3GAEJNiRVQG76WXHc=; b=YvxFGU7AkqvN61RreSnUJejdiLBjk86dTCXvECL0zAIXQls8xPrLjZynRL00USHykK eG5VXju3Ga9Zv8gwN9xDj6H7fIUBMhNoT0qibxRSSXA5npl6QKwqfzXgicVjlGvPkbM7 +GcxoDGNcMsYU4SL8pedjTMU3Eo7xH3lCvq9KEHtoSrnAQnAWDZ9FkSDcqY5ABN86hbq b5N+/2y6txViYOzzH0BpWnjjvp0bU+84ibASF7PnnCy1GpJOzuiMfEjStVlJKn+10LCE KN5B4px17LOJT2M5CsrsGsu8V9m9oMonldQITK3tlujXqrTG2bGEvKCbm6T6mPjUd6ri QAvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VXnnD1ST; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j23-20020a170906831700b006e06d4769f3si2972813ejx.692.2022.05.12.00.28.41; Thu, 12 May 2022 00:29: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=@intel.com header.s=Intel header.b=VXnnD1ST; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350212AbiELGQp (ORCPT + 99 others); Thu, 12 May 2022 02:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234728AbiELGQn (ORCPT ); Thu, 12 May 2022 02:16:43 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83759398C for ; Wed, 11 May 2022 23:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652336202; x=1683872202; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=g6IIn5TcCQm3tWIL9ibzyttiUg0lLF5CJ9+P8r5+AbE=; b=VXnnD1STRCpb8fdPqzKN69502lC6sQpjpf9aLALQhAq5IEJZseIojGM6 QYPbZENLfjdixI47BANIKzf4qTfhimSyvqqqFSIcfJEkiEBzYVdkt3GdA Yij9JdaruAMiMVD9Ziy3lReoAupopqmItnqRuOIEwU1WROlL+LTjPcVoZ q5JEsFkHc9fgzivXefQEB0m9epMSAQEEJLeltqh/BaceI4dvhk6J544g0 CVnrOErdyqgcIAXR5lAuBaNxA3GeAKVko24uWJbbJwlXnfrz8YZ6NIpxB bbgf3coWagcw4VQCQORTHgTxK/N7Wv2DV4hqHLerPZ1myWuCV1Q/fUaWn g==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="356327881" X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="356327881" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2022 23:16:42 -0700 X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="594513911" 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; 11 May 2022 23:16:37 -0700 Message-ID: <0170bf39-5c1b-c4d5-631d-2afe98a5de61@linux.intel.com> Date: Thu, 12 May 2022 14:16:36 +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, 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: "Tian, Kevin" , 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> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 2022/5/12 13:44, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Thursday, May 12, 2022 1:17 PM >> >> 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. > > can we just have unbind(domain, device)? Yes. With this, we can remove bond. This could be done in below phase 2. > >> >> Anyway, I'd expect to achieve all these in two steps: >> >> - sva and iopf refactoring, only iommu internal changes; >> - sva interface refactoring, only interface changes. >> >> Does above work? >> >> Best regards, >> baolu Best regards, baolu