Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp96256lqt; Wed, 5 Jun 2024 19:07:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6+3CvZwn22d8Ic/hM0fxuFq6H+4pyTZg/+4f6uFAWBXH/Oj3GtdYUD1K94LRF4YiXaefKUXPvLF+G8hy205D+NS2VXGbbyi3Nazt5dw== X-Google-Smtp-Source: AGHT+IG6R5AGDgkpVo848HIYazrHC+gcLznGlBpN+zIFpDZiUrVeUrQpZWzwIWI74lnG9i+ZrYJ1 X-Received: by 2002:a17:90b:17c1:b0:2bd:edbe:4e1 with SMTP id 98e67ed59e1d1-2c27db61056mr4860991a91.31.1717639675638; Wed, 05 Jun 2024 19:07:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717639675; cv=pass; d=google.com; s=arc-20160816; b=FiOdxJy7SdZ4+OBdt6id+1Q1Vsr1Kc6q4JX85HXlmI775nTbH255v/9nWNvK+fjQo6 gctapFq2L1wymWiZdRPZTD/4PS2mi7gA/a993XFNQkin3GBDrSHJauORUeXjdLjJc0tz ve8foLHfHGEz2V68t1T9yXN94hwYcFg8PMwKGAMtav6NaYoGGgkAm5BLhJa9XwQsM+Gy eU8LSwsd7eXqunjk7IoVNPHvBC/8+V0C6FfST2n/QFA9myDK+fB0cDPvSbOMIuRgIo8G ijBJDW/I0l90ahL4El2BbyasNZ/VzCUmyjsehZrkJ0pvlFgNRh7SglRPFCERB3bad5CT xcIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=JYwWXqQi0PW5u/Fxy8/9m1ZVur3YHIXyO/jjnYnF8pE=; fh=nBgjHH8zp1vFX69aJLdYlgP555nTnI/jA+2imT6oIts=; b=z64IOHYB66kb1lakLw3Ekp5g81XZwI9SbV9mmzsh+rqCteXOAlvP/gjMvp/eU/90+B Nhai4TEH4FSWj8rzKu5oWTgaxj4bN/eRNSzaesbtRHSscYbUk+Vl5n2c9lnmwfhNg2Ej 0bvtoD1w2ilyCa9jWquTtxCPSXJL/R9QpelG73EkLnKsbcjhTE+TMJMnRXt6M6keVUkq BhoWzMygX/1LxFWVtTmM210kpvgROPXJ08WcLPQ/yxBqqK8i2G2FHtEYRPHxgQB5SgYQ jgGnmcOy61YkrsEHOnxh2KO8LCLvF5vBczwQoyMaX7TO2VIjRzXmDORnbX0tIA1rVKbr VUPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dcA5W7A8; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-203520-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c29c37c27dsi341606a91.90.2024.06.05.19.07.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 19:07:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203520-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dcA5W7A8; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-203520-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8123CB22840 for ; Thu, 6 Jun 2024 02:07:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B1F0175AB; Thu, 6 Jun 2024 02:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dcA5W7A8" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAF821401C for ; Thu, 6 Jun 2024 02:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717639620; cv=none; b=HLWy+WSa/8pL+s4zYn/NeoGi1LvaMp1quEZzrASQ8jMu7GHONbM8LOC9/9eYytXr3LLdQhLd7oX/8MfkIKe2EOxg+i2cmBXFGUOimbrsIiswfgO2v5kv/TnayAeOb2v8uCOxdPUlSjyP9CUEZbmaI74MbXRM+zD1evQqmdCh9p4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717639620; c=relaxed/simple; bh=O1pxJnfGlDL+o5WOmDo3d+UFg4FCJmMKJsHIxcmUatg=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=aNyILp5MFQJ+htIE/nvAr0guGPxjv29IekInncWIYhEZQZhV66T9h0lA3GzoWCjb6Ipt/VhYL27jC4wefm18H9zkX+nty+t9MJiLoIkQzpV0dgB1uRAN5JaltHjSuFZwi85RE/EXL+D89vKxEf9rGohXD5pP5kj23TrsJKhJ5ss= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dcA5W7A8; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717639619; x=1749175619; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=O1pxJnfGlDL+o5WOmDo3d+UFg4FCJmMKJsHIxcmUatg=; b=dcA5W7A8o4hBtZ8CaUXRUNXuPcPBibXJneb8sowSLchtDV0jBxWRbnBt 6Et/GH2VEAm30ctZ+RdjyIo2Ax/HX1Dd5HoEMiGyesVy5lixP/kcanj3+ YyK2d71v5tlCDGl7Hw4tupzbRwu+EANjuh7BbzYSYzG/wUE7IdaK7TBbO GwDifb5lBtU4ezcaivPLqvQHQ6/18FmmW6s4BwnURrR3Kt7ffQJt2RcVb FbyYKre9Euee2ARUyTZ8xTDWMhOkRcOAc7L01PnSSZ8/Koelp/zoKxP/j EIfxfrPO965ykB/h+ojyRmjO+hcsldYVONPYkqeJ2OyBtN/oMjMF5jDzg w==; X-CSE-ConnectionGUID: hOT/YcJkRNmhMlgWwWvsIQ== X-CSE-MsgGUID: YGv1TLAARBmvFHmk5uQxCQ== X-IronPort-AV: E=McAfee;i="6600,9927,11094"; a="14241616" X-IronPort-AV: E=Sophos;i="6.08,218,1712646000"; d="scan'208";a="14241616" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 19:06:59 -0700 X-CSE-ConnectionGUID: y0WgSW4NQBOS4MM9Agg9Iw== X-CSE-MsgGUID: RA+mTl0pQRWQMmAwcw88gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,218,1712646000"; d="scan'208";a="37813441" Received: from unknown (HELO [10.239.159.127]) ([10.239.159.127]) by fmviesa008.fm.intel.com with ESMTP; 05 Jun 2024 19:06:54 -0700 Message-ID: <75d0e879-a807-420e-bbf6-2ba4238329cf@linux.intel.com> Date: Thu, 6 Jun 2024 10:04:44 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/22] iommu: Add iommu_user_domain_alloc() interface To: Yi Liu , Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian References: <20240604015134.164206-1-baolu.lu@linux.intel.com> <20240604015134.164206-2-baolu.lu@linux.intel.com> <445fae9f-ea1e-4864-9f0e-f348c51146a1@intel.com> <91a42f46-060a-4430-a10a-7bfded67c4a9@linux.intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/5/24 2:23 PM, Yi Liu wrote: > On 2024/6/5 10:00, Baolu Lu wrote: >> On 6/4/24 4:03 PM, Yi Liu wrote: >>> On 2024/6/4 09:51, Lu Baolu wrote: >>>> Commit <909f4abd1097> ("iommu: Add new iommu op to create domains owned >>>> by userspace") added a dedicated iommu op to allocate a user domain. >>>> While IOMMUFD has already made use of this callback, other frameworks >>>> like vfio/type1 and vDPA still use the paging domain allocation >>>> interface. >>>> >>>> Add a new interface named iommu_user_domain_alloc(), which indicates >>>> the >>>> allocation of a domain for device DMA managed by user space driver. All >>>> device passthrough frameworks could use this interface for their domain >>>> allocation. >>>> >>>> Although it is expected that all iommu drivers could implement their >>>> own >>>> domain_alloc_user ops, most drivers haven't implemented it yet. >>>> Rollback >>>> to the paging domain allocation interface if the iommu driver hasn't >>>> implemented this op yet. >>>> >>>> Signed-off-by: Lu Baolu >>>> --- >>>>   include/linux/iommu.h |  6 ++++++ >>>>   drivers/iommu/iommu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ >>>>   2 files changed, 48 insertions(+) >>>> >>>> diff --git a/include/linux/iommu.h b/include/linux/iommu.h >>>> index 7bc8dff7cf6d..6648b2415474 100644 >>>> --- a/include/linux/iommu.h >>>> +++ b/include/linux/iommu.h >>>> @@ -780,6 +780,7 @@ extern bool iommu_present(const struct bus_type >>>> *bus); >>>>   extern bool device_iommu_capable(struct device *dev, enum >>>> iommu_cap cap); >>>>   extern bool iommu_group_has_isolated_msi(struct iommu_group *group); >>>>   extern struct iommu_domain *iommu_domain_alloc(const struct >>>> bus_type *bus); >>>> +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, >>>> u32 flags); >>>>   extern void iommu_domain_free(struct iommu_domain *domain); >>>>   extern int iommu_attach_device(struct iommu_domain *domain, >>>>                      struct device *dev); >>>> @@ -1086,6 +1087,11 @@ static inline struct iommu_domain >>>> *iommu_domain_alloc(const struct bus_type *bus >>>>       return NULL; >>>>   } >>>> +static inline struct iommu_domain *iommu_user_domain_alloc(struct >>>> device *dev, u32 flags) >>>> +{ >>>> +    return ERR_PTR(-ENODEV); >>>> +} >>>> + >>>>   static inline void iommu_domain_free(struct iommu_domain *domain) >>>>   { >>>>   } >>>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >>>> index 9df7cc75c1bc..f1416892ef8e 100644 >>>> --- a/drivers/iommu/iommu.c >>>> +++ b/drivers/iommu/iommu.c >>>> @@ -2032,6 +2032,48 @@ struct iommu_domain *iommu_domain_alloc(const >>>> struct bus_type *bus) >>>>   } >>>>   EXPORT_SYMBOL_GPL(iommu_domain_alloc); >>>> +/** >>>> + * iommu_user_domain_alloc() - Allocate a user domain >>>> + * @dev: device for which the domain is allocated >>>> + * @flags: iommufd_hwpt_alloc_flags defined in uapi/linux/iommufd.h >>>> + * >>>> + * Allocate a user domain which will be managed by a userspace >>>> driver. Return >>>> + * allocated domain if successful, or a ERR pointer for failure. >>> >>> do you want to mention that this is for paging domain allocation? >> >> You are worrying about its confusion with nesting domain allocation, >> right? > > yes. As I replied in last version, user_domain is a bit confusing since > nested domain is also a user_domain. That's why we introduced the > alloc_domain_user op. As I discussed with Jason in another reply, I will drop the iommu_user_domain_alloc() interface as it is currently iommfd-specific only and not generic for a common interface. Best regards, baolu