Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2612763imi; Mon, 25 Jul 2022 03:33:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vmznkfvwOpkHHFtCrp2xOpHeqWuE/4ofs1r8r9orPlakNOy63t5u0YrhGXQtzmDboxR65D X-Received: by 2002:a17:907:1623:b0:72b:64e3:878a with SMTP id hb35-20020a170907162300b0072b64e3878amr9895954ejc.185.1658745231037; Mon, 25 Jul 2022 03:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658745231; cv=none; d=google.com; s=arc-20160816; b=IUijR3Vxz4YYaEeFqOY3Bnee/KxaZbalpf/tP2/C7O4VEett771ab4BLcCDAshRxW3 /UBbNO4oEbbm08+4gvNc94/RY1VBbBwTfd9yFXowZN1/sfvC/KsiPwZYyO6VSMWr8gdw sw6k0rLwltlNjHqRyisMNMipXT+0krByno2JUSoiHtpYTbkw6kg95PycG+B/SYyt9DPN GqVG/AAStjM0je/sDacN1H8BJwa7EBxq6V/mXEdFlIENUyZ+qLVBu0vRrlHUuXPtqkXT +V3S6wiTnHPcI3YgbBebqqfYQe+Zi8MGqLFYNK2yRrEplkLKMAxp+jKjcU4uZUqk08RS HbwA== 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=v2LQRBnmwKzbxq9TpDW//lfz4j5V2ZACjDp+h73RRZk=; b=a1DZW1amvSFDpB0ba/uqqwxpo/nIIOV4KyfQmDWP2hTXkbgqD1M6WHjSIblUiXm6Wl XZBbfnbknrcF9Mf7Oa1YdjU8+MpG1zXIZo7JejMUKPStlJyL4PMp0ZgCjbZzfzWL9rnk MUMJAFVj2hU3fdHF6reIwl2qbJqDd3yafWBehCixH1Sr5VANTqtpyOAX2vh4L8FQEv4C DegmidxHx18O3T+qd0uCwEKMRSd7/oV5J/vSpWg4h28vrdckkE0mhlHrJvRwux8cI+RX VB3V6RiWd1MMbjeQ3jRioy7SJDfNjId2lxpb97KlMkAUvkeAKshpDaf4njdnhoy2Dz0H +j7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C1BomNv+; 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 f2-20020a1709062c4200b0072fb44407fdsi6677767ejh.962.2022.07.25.03.33.26; Mon, 25 Jul 2022 03:33:51 -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=C1BomNv+; 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 S233220AbiGYKWP (ORCPT + 99 others); Mon, 25 Jul 2022 06:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbiGYKWL (ORCPT ); Mon, 25 Jul 2022 06:22:11 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F7CB84C for ; Mon, 25 Jul 2022 03:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658744530; x=1690280530; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=wAXUudd2bYpf3nYYKav//ZqBy0T3UuLekipqsksLhYI=; b=C1BomNv+A8WJyUXri5zr5E7MpLWib0orDjp+PFkq63wcjeQB3TyC9q8j QWKlww5+iC1r0v02jTqk3Y/0TRIh/lKOjcv6mophdpH+cqVhDwGRTV9v9 eTRapJHZOhQlTA6/6o70r3a2gHl15GsvIyVU83pulURzPrdCEwb81nQK/ rY/0CM5gHsJ3/u2NZ5o3GQM7hYcTJx260Pof+Bh25vJ6pxJVl03zNnylJ /GVm4LXKcpyQDGT2Q+BVvYvy0NU4Mu40E+eWh/GOW01BZOs2zWqreYeua Ciwkf9njScFy1xGoimYqbRDtjPW/sllvldryKBTXxHSdSeZswYA/LTOap A==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="349362690" X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="349362690" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 03:22:09 -0700 X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="658130002" Received: from liangk-mobl.ccr.corp.intel.com (HELO [10.255.30.67]) ([10.255.30.67]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 03:22:06 -0700 Message-ID: Date: Mon, 25 Jul 2022 18:22:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.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" , Zhangfei Gao , "Zhu, Tony" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v10 08/12] iommu/sva: Refactoring iommu_sva_bind/unbind_device() Content-Language: en-US To: "Tian, Kevin" , Jason Gunthorpe References: <20220705050710.2887204-1-baolu.lu@linux.intel.com> <20220705050710.2887204-9-baolu.lu@linux.intel.com> <20220723142650.GH79279@nvidia.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=-4.9 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 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/7/25 15:50, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Sunday, July 24, 2022 9:48 PM >>> >>> The API is really refcounting the PASID: >>> >>>> +struct iommu_sva *iommu_sva_bind_device(struct device *dev, >>>> + struct mm_struct *mm); >>>> +void iommu_sva_unbind_device(struct iommu_sva *handle); >>> >>> So what you need to do is store that 'iommu_sva' in the group's PASID >>> xarray. >>> >>> The bind logic would be >>> >>> sva = xa_load(group->pasid, mm->pasid) >>> if (sva) >>> refcount_inc(sva->users) >>> return sva >>> sva = kalloc >>> sva->domain = domain >>> xa_store(group->pasid, sva); >> >> Thanks for the suggestion. It makes a lot of sense to me. >> >> Furthermore, I'd like to separate the generic data from the caller- >> specific things because the group->pasid_array should also be able to >> serve other usages. Hence, the attach/detach_device_pasid interfaces >> might be changed like below: >> >> /* Collection of per-pasid IOMMU data */ >> struct group_pasid { >> struct iommu_domain *domain; >> void *priv; >> }; >> > > Is there any reason why pasid refcnt is sva specific and needs to be > in a priv field? I am going to store the iommu_sva data which represents the bind relationship between device and domain. Best regards, baolu