From patchwork Thu Feb 9 04:31:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 54718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp122962wrn; Wed, 8 Feb 2023 20:35:55 -0800 (PST) X-Google-Smtp-Source: AK7set/C3qjk5WF7PrBtmB57AdL2ArcBciB9MTkiRzq4wuIL2wOohDmybphu93C1ZT1siZB2DyUh X-Received: by 2002:a17:902:db10:b0:199:2e77:fe16 with SMTP id m16-20020a170902db1000b001992e77fe16mr10957908plx.58.1675917355403; Wed, 08 Feb 2023 20:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675917355; cv=none; d=google.com; s=arc-20160816; b=ZajaULTajbTqV6vDRt6KYaki/eg3NevKQp85h46HSIK1I1XnF3yf9BJE9XRhy8zIpI oxBGNf+9f7rdNy0SzHaTmF/oi/qLh3asLZvLIeG3sAAUKYWME8YJw8k1FULxkZxF7tH/ DYwtHhE2kqEU5ooiQ7ngws9k/xoQD42jz6NgcBtPqiRqoMzwj0kIt0KxOiWeEX0XbxaB 34n1hFSR5gTUauha8a1kmfzkr76hJEoo76eyWZyJlVahgd5pzNFYCPwM7M2aMWTqk208 LspJQqa1UF9aTultJOH2545EieIstizBQSm/2MZLHSQHEbknnXtMt1W8JA1wcsh2mtGO Dmow== 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=7h+dLYb8Ynk3pnVBuHtPB4/jrj1pbUcdWyK/tMZgXgY=; b=fZk0T/mVsozyR6sxApI9twxBbXoKrDUxrIKiHWT/Eop0IhoyBTxpkKZrB9/A4GPFaI h0n0/4bE3gJGx5NC4Xgaf1CW8HiUo81wPhLz/lDoGSqDgk6gmhXdfF5tMkNL3/v/ZZ2P LjKJ740iPSjjgdP1q8zEx6WgY5ZxlMtTTT8xAG239afqObpRBeizXk4DaHZlOOOmripW KeRhNbKJZJ8GVvIuNi3L+RJmsTU982mapOinjA4OBb8HpLkb5UKr7KBgWa9fBJPEb2WH 7NUM4eCehXPi1RczSGkKcFly0msYyOYZjChPEoKv+0csM9gngQh7nPA3g1/GT6s8Htsn VErQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nT9GYdMV; 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 a5-20020a170902ecc500b001991e3b4f3asi761713plh.427.2023.02.08.20.35.34; Wed, 08 Feb 2023 20:35:55 -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=nT9GYdMV; 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 S230418AbjBIEfD (ORCPT + 99 others); Wed, 8 Feb 2023 23:35:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjBIEdt (ORCPT ); Wed, 8 Feb 2023 23:33:49 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53820457F1; Wed, 8 Feb 2023 20:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675917160; x=1707453160; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RfT4R/xTBwZsk8AEoHLAHBvK4hYBuXf+5pIwXQ6TqQw=; b=nT9GYdMVpkOL5y2Y74N2jEJ8RvrkFcJM1Y2qgEtjSH4Z0dHdbpJOjceE uBCHDNZp7kWrkCJevRc/hwELompD/r2oaWKpsYc4wIYRHciLZfsUu5TVV U555ilUofG6ccxY/WnU9wM010fTrbKH1+R03S/QPEdriThmjK3lAsX5T7 h3Rae6Dix1aMQG3IKgcDAPE+P+PYhUcReREmZcIfbdQRrqicSUCJKPLiY 3owLTeviEMmljGKwM6XHb3j99YHeOVgE5zYic3gL8fXTnuG8z78t2K9Sd KSMnNSafmVVc8j4eMAbfR3uv+PQkQHNSXExkUEhe/rxljzE+UOQqB5XSj A==; X-IronPort-AV: E=McAfee;i="6500,9779,10615"; a="331298694" X-IronPort-AV: E=Sophos;i="5.97,281,1669104000"; d="scan'208";a="331298694" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 20:32:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10615"; a="669447517" X-IronPort-AV: E=Sophos;i="5.97,281,1669104000"; d="scan'208";a="669447517" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by fmsmga007.fm.intel.com with ESMTP; 08 Feb 2023 20:32:08 -0800 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.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, baolu.lu@linux.intel.com Subject: [PATCH 06/17] iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation Date: Wed, 8 Feb 2023 20:31:42 -0800 Message-Id: <20230209043153.14964-7-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230209043153.14964-1-yi.l.liu@intel.com> References: <20230209043153.14964-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?1757326716523914679?= X-GMAIL-MSGID: =?utf-8?q?1757326716523914679?= This converts iommufd to use iommu_domain_alloc_user() for iommu_domain creation. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/hw_pagetable.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 43d473989a06..08d963ee38c7 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -30,6 +30,7 @@ struct iommufd_hw_pagetable * iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, struct device *dev) { + const struct iommu_ops *ops; struct iommufd_hw_pagetable *hwpt; int rc; @@ -37,7 +38,13 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, if (IS_ERR(hwpt)) return hwpt; - hwpt->domain = iommu_domain_alloc(dev->bus); + ops = dev_iommu_ops(dev); + if (!ops || !ops->domain_alloc_user) { + rc = -EOPNOTSUPP; + goto out_abort; + } + + hwpt->domain = ops->domain_alloc_user(dev, NULL, NULL); if (!hwpt->domain) { rc = -ENOMEM; goto out_abort;