From patchwork Thu Mar 9 08:09:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 66655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp162645wrd; Thu, 9 Mar 2023 00:11:18 -0800 (PST) X-Google-Smtp-Source: AK7set+t/8lSWDW7/ei5Xv+FU5ndVA10E/myeYVVbIA+3YuEUs9wLedFG6WKR7+3NnoZmmekEV5u X-Received: by 2002:a17:902:bb90:b0:19e:524f:272f with SMTP id m16-20020a170902bb9000b0019e524f272fmr17550778pls.42.1678349478300; Thu, 09 Mar 2023 00:11:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678349478; cv=none; d=google.com; s=arc-20160816; b=LtRwQ7NOFqzDW+vsYr8Dfh8iyKNeZCfjX7pZOiObM5P8aQmF8HLnTf9z9F3Ey8XRtH bwRi/j5B5pF+xWAUkVjEsdLny0oD6ocO3AJZRKIsa4CEeKIXyW/UEQ8D4cXK5Lflzkyc RH9HU2xrWkyN1uLwmS8ZlsPJFT/nfUXX8YymS1D60cy7hzZtDq3eDueIui4AtHzuwYWU NE3KRp85SyCcQxTj/zIdsUHLMS26y4QmwmGZF8Q+aQyBa/d6Q1wHEr1DFTQZ2UhPH1X/ Hi49VRjlXnhS8mpcS2mDAPEis1FWRw+qnCUOpOP8QBcO1wr+aTIOJo6KBLSio4dY6zAo sqaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jibbQrLk5cXwZxu1xj/MficgJ0Ecvw7jN47sd94NZcg=; b=tMzuwA1c4u1gHZWiScI9GtV7oIRzLe3NSMvJr6gl67GPtKby4dyFg2XzPlSpemlbJ/ rxnwrAG+YLwTzeowBdhBh/3/RM34IxWNbLxcvyWxlJMqvkbxAKUVaUes6rDPX3/wfMjF Sd3XgNKkOpvZzwlQV0hD4JLEJv4q4kgH1Sxx6CItglL3lOHXPBY3F9031gDlXQJigv4U nv6WN4Y6Sdz+eYDrUrMpYP+Dlpt+Wh4/4/XqiCCc20s8pwxoU3c8Q8GAq3FNFfecqmSS rCRPc+wmiQ9X4WODoAQ3MFTdzYJ8zW0nwv8ChFiFR7E/n9udwR9YedYlUrZdYeSEHC9Q j6Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Zwu/Un9e"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kd13-20020a17090313cd00b0019aa6c46413si16128860plb.345.2023.03.09.00.11.05; Thu, 09 Mar 2023 00:11:18 -0800 (PST) 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="Zwu/Un9e"; 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 S230195AbjCIIJ7 (ORCPT + 99 others); Thu, 9 Mar 2023 03:09:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbjCIIJe (ORCPT ); Thu, 9 Mar 2023 03:09:34 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 332B26B97A; Thu, 9 Mar 2023 00:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678349373; x=1709885373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aeM9wYEQtVfENpenMofCYElwE3QfNhdny2a0DT1ZPjw=; b=Zwu/Un9eZ/PU9ql5o9aoUcsQrGOU2lQUX4OU4NGXPYb5Qf/OEjsM8gIT vRydaVvDQoZmJnDq+a3qOCscM9WlJHQiNgarLVKtrQ6liNCaktMTfXW2/ 7w1pFNjZb3bb4ZiwghcKHB3aOZvGZmHucHVKr/aEDhz8ssf9skL48VZM8 U9xxR8j1HBYCDphiWbA2XMzMUekzn48sXq/4SRXgrs/2JYDTr3vWaa3GV DMqkvu8EWtMLcbHgUKpxVXhVejzE3Vb7ln0oMIpt59kq4kQAaMb3A+eXW 57E4grSXykZNlGvlbBwQ9tFvEbMSiUzZaN4rErQogc2f3nr/o3qziehKu w==; X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="364023033" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="364023033" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2023 00:09:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10643"; a="787471362" X-IronPort-AV: E=Sophos;i="5.98,245,1673942400"; d="scan'208";a="787471362" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2023 00:09:23 -0800 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 03/12] iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation Date: Thu, 9 Mar 2023 00:09:01 -0800 Message-Id: <20230309080910.607396-4-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309080910.607396-1-yi.l.liu@intel.com> References: <20230309080910.607396-1-yi.l.liu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759876982657598750?= X-GMAIL-MSGID: =?utf-8?q?1759876982657598750?= This converts IOMMUFD to use iommu_domain_alloc_user() for iommu_domain creation. Suggested-by: Jason Gunthorpe Co-developed-by: Nicolin Chen Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu Reviewed-by: Lu Baolu --- drivers/iommu/iommufd/hw_pagetable.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 13bdab4c801b..84b4a11e62f8 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -5,6 +5,7 @@ #include #include +#include "../iommu-priv.h" #include "iommufd_private.h" void iommufd_hw_pagetable_destroy(struct iommufd_object *obj) @@ -55,6 +56,7 @@ struct iommufd_hw_pagetable * iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, struct iommufd_device *idev, bool immediate_attach) { + const struct iommu_ops *ops = dev_iommu_ops(idev->dev); struct iommufd_hw_pagetable *hwpt; int rc; @@ -69,7 +71,10 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, refcount_inc(&ioas->obj.users); hwpt->ioas = ioas; - hwpt->domain = iommu_domain_alloc(idev->dev->bus); + if (ops->domain_alloc_user) + hwpt->domain = ops->domain_alloc_user(idev->dev, NULL, NULL); + else + hwpt->domain = iommu_domain_alloc(idev->dev->bus); if (!hwpt->domain) { rc = -ENOMEM; goto out_abort;