Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5089659rwb; Tue, 6 Sep 2022 18:46:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR58vw/39ViTFg34wmNC7oayMxPrQMn+IDYU4WDX8CC0Q4ROYSz8ior0Wpk+8Ynj/fqqIEJl X-Received: by 2002:a17:902:c213:b0:176:cdb9:c504 with SMTP id 19-20020a170902c21300b00176cdb9c504mr1419440pll.44.1662515176621; Tue, 06 Sep 2022 18:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662515176; cv=none; d=google.com; s=arc-20160816; b=xXI0u6KJU2DCrZRLgku31UxRl3GYx8w3hNgbB3d1/VH/egVGwClFRgipsYt+msYT0s JVPTlBjhoYkaY2IKMDSztOGmXsVx+u8Lyqn6Y7BjpZIZA+9NvGlogewVVgFqfPxrLkme TI9LEhshdTJV++jZvxflns2mCA8o+iJs02SnG2DC8U71VBXxaCwTSDo36Cd/R4zS1089 hzs5gEnhnDTeuQ/WYQwx+dXUHTQVNcmSEWn5E2bZgoCWMYKWsGD7XQrJWxGYExJvI5pR m5NraZkKRt+tosauBe8Fe8aUECpWzRKttiFpHqXRxREtCVL+mE/aFOWdo6EKh772QSTn 06Ig== 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:subject :from:content-language:references:to:cc:user-agent:mime-version:date :message-id:dkim-signature; bh=zChE8UEHtoNrTDqi7LFCFbohQDAZylleBGIQHcq6PH0=; b=rWTeBwke9MIOX5VU5HQl6z6RHFbI4wf6jgvfEHnhv3/FQVWx4zTXh1IxOn19Y8FUTw HSAzVBkp4NVpQb42arh37hs6zSNiphWZPjmkYti08Xjwf4Nz8lpLn+4buPLtJ2rK/fnR OLELugoMMEE4nsnAN6M8IUobioohH3TrP2h6go2H8OHJOkjsK1ITEHuMx3h7BpWOCd0M hZ0MxwsrUZDeT6LiflpmsgE13f6h+WqyIGPZSXr+HKVrRAuqBGgXx1+yf2YtSvaG2XLH upIgO0HkRJypfdhEv5okevQvOT9XmVTD1NgQ2TqD0LhrgqmVuqTbHRqPWlEky7qvNHIC kVjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AMUA9Pv+; 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 i1-20020a63e901000000b00434e46317d6si885891pgh.817.2022.09.06.18.45.57; Tue, 06 Sep 2022 18:46:16 -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=AMUA9Pv+; 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 S229733AbiIGB1k (ORCPT + 99 others); Tue, 6 Sep 2022 21:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiIGB1i (ORCPT ); Tue, 6 Sep 2022 21:27:38 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 106F211A32; Tue, 6 Sep 2022 18:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662514058; x=1694050058; h=message-id:date:mime-version:cc:to:references:from: subject:in-reply-to:content-transfer-encoding; bh=ZV1q+JgdPyql58iLRG4rBR7Tp9YEX2NHtfBPjMsBF2E=; b=AMUA9Pv+WSO6P8ndU0QMVF4Uys+zrhjiksCqk6SjEfJY8gj/9T5210oO vcg8nuW7vbvCyPyYPOrSp4WUcSM1UHpCvHk4gdWqXsF7NFTXamZHBUgN+ smrnqMNof3Lli/KZ76KnbH3UQ5PWuhaZ9DhnDcMRK5sRF5BGRC9o0VnQ8 z2HGVKhJvtzpCzarYS8OhCW5OGNkRLbq+GgNa8I5tnyyOt1zxYlC7L0Gf OZ+SuzBFL5XDzUqP17uiNjg1LANumuLjo44yVhNYRxRLhnLdFUDxBNVgi SHEc2HCPYEf3vKjqTWRnYtt7iCJ8SsCqD5zGDpkKw/zIskZTG1qqrQR7A Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="295486690" X-IronPort-AV: E=Sophos;i="5.93,295,1654585200"; d="scan'208";a="295486690" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 18:27:37 -0700 X-IronPort-AV: E=Sophos;i="5.93,295,1654585200"; d="scan'208";a="591491033" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.214.40]) ([10.254.214.40]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 18:27:32 -0700 Message-ID: <682d8922-200d-8c89-7142-83e7b3754b8d@linux.intel.com> Date: Wed, 7 Sep 2022 09:27:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Cc: baolu.lu@linux.intel.com, Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Bjorn Helgaas , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Dave Jiang , Fenghua Yu , Vinod Koul , Eric Auger , Liu Yi L , Jacob jun Pan , Zhangfei Gao , Zhu Tony , iommu@lists.linux.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org To: Jean-Philippe Brucker References: <20220906124458.46461-1-baolu.lu@linux.intel.com> <20220906124458.46461-10-baolu.lu@linux.intel.com> Content-Language: en-US From: Baolu Lu Subject: Re: [PATCH v13 09/13] iommu/sva: Refactoring iommu_sva_bind/unbind_device() In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 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 Hi Jean, On 2022/9/7 0:36, Jean-Philippe Brucker wrote: > On Tue, Sep 06, 2022 at 08:44:54PM +0800, Lu Baolu wrote: >> +/** >> + * iommu_sva_bind_device() - Bind a process address space to a device >> + * @dev: the device >> + * @mm: the mm to bind, caller must hold a reference to mm_users >> + * >> + * Create a bond between device and address space, allowing the device to access >> + * the mm using the returned PASID. If a bond already exists between @device and >> + * @mm, it is returned and an additional reference is taken. Caller must call >> + * iommu_sva_unbind_device() to release each reference. > This isn't true anymore. How about storing handle in the domain? Yes, agreed. How about making the comments like this: /** * iommu_sva_bind_device() - Bind a process address space to a device * @dev: the device * @mm: the mm to bind, caller must hold a reference to mm_users * * Create a bond between device and address space, allowing the device to * access the mm using the pasid returned by iommu_sva_get_pasid(). If a * bond already exists between @device and @mm, an additional internal * reference is taken. The reference will be released when the caller calls * iommu_sva_unbind_device(). Storing the handle in the domain looks odd. Conceptually an iommu domain represents a hardware page table and the SVA handle represents a relationship between device and the page table for a consumer. It's better to make them separated. In a separated series, probably we can discuss the possibility of removing handle from the driver APIs. Just simply return the sva domain instead. struct iommu_domain *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); void iommu_sva_unbind_device(struct device *dev, struct iommu_domain *domain); u32 iommu_sva_get_pasid(struct iommu_domain *domain); If you think it's appropriate, I can send out the code for discussion. > > (Maybe also drop my Reviewed-by tags since this has changed significantly, > I tend to ignore patches that have them) I am sorry that after your review, the SVA domain and attach/detach device pasid interfaces have undergone some changes. They mainly exist in the following patches. Can you please help to take a look. iommu/sva: Refactoring iommu_sva_bind/unbind_device() arm-smmu-v3/sva: Add SVA domain support iommu: Add IOMMU SVA domain support iommu: Add attach/detach_dev_pasid iommu interfaces Best regards, baolu