From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14052C761AF for ; Mon, 27 Mar 2023 09:41:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18A3710E563; Mon, 27 Mar 2023 09:41:27 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EC3010E390; Mon, 27 Mar 2023 09:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679910065; x=1711446065; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=plUlCrp6bygFf1uDNQYn5ATXNsu29vZxZWaihwKUYV8=; b=KOymvNvVZBCM3Be1Df+WSrbJ5QV1oGBYkSvlh8AIif1Z6MumZSWuN8/i k+JPP8WS/8PwTlK4W0lMhswOEpSmBGoG/6veQasInac2WBXEa3Pzd0Qoh XC1ug6dCSb8PBW12cINdkgTH5dmh5b8SwoTRVnMnXKFluVfK1tpmT3Dwr 3y5nGjPgZrpMBXX+k5WQqNFrM00unVUCMOSIlHeZcfFrE73Jj5rJpCg5G Ujxbw9oDKsaUSsJaT9hMzEPwwnqzThVCvKvAQNvywZ7Sj1KN36H0nkNKB 2KHD6UBOnPe/6o5FOwWGDelgYcIGEL+BYma91nahqJfbRyG/DdMGzxO0i w==; X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="426485432" X-IronPort-AV: E=Sophos;i="5.98,294,1673942400"; d="scan'208";a="426485432" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2023 02:41:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="660775829" X-IronPort-AV: E=Sophos;i="5.98,294,1673942400"; d="scan'208";a="660775829" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga006.jf.intel.com with ESMTP; 27 Mar 2023 02:41:05 -0700 From: Yi Liu To: alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com Date: Mon, 27 Mar 2023 02:40:41 -0700 Message-Id: <20230327094047.47215-19-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230327094047.47215-1-yi.l.liu@intel.com> References: <20230327094047.47215-1-yi.l.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-gfx] [PATCH v8 18/24] vfio: Determine noiommu in vfio_device registration X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mjrosato@linux.ibm.com, jasowang@redhat.com, xudong.hao@intel.com, peterx@redhat.com, terrence.xu@intel.com, chao.p.peng@linux.intel.com, linux-s390@vger.kernel.org, yi.l.liu@intel.com, kvm@vger.kernel.org, lulu@redhat.com, yanting.jiang@intel.com, joro@8bytes.org, nicolinc@nvidia.com, yan.y.zhao@intel.com, intel-gfx@lists.freedesktop.org, eric.auger@redhat.com, intel-gvt-dev@lists.freedesktop.org, yi.y.sun@linux.intel.com, cohuck@redhat.com, shameerali.kolothum.thodi@huawei.com, suravee.suthikulpanit@amd.com, robin.murphy@arm.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This adds a noiommu flag in vfio_device, hence caller of the vfio_device_is_noiommu() just refers to the flag for noiommu check. Signed-off-by: Yi Liu --- drivers/vfio/group.c | 2 +- drivers/vfio/vfio.h | 6 +++--- drivers/vfio/vfio_main.c | 2 ++ include/linux/vfio.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c index 8f09e4541c3a..b0a73d82662e 100644 --- a/drivers/vfio/group.c +++ b/drivers/vfio/group.c @@ -192,7 +192,7 @@ static int vfio_device_group_open(struct vfio_device_file *df) vfio_device_group_get_kvm_safe(device); df->iommufd = device->group->iommufd; - if (df->iommufd && vfio_device_is_noiommu(device)) { + if (df->iommufd && device->noiommu) { if (device->open_count == 0) { ret = vfio_iommufd_enable_noiommu_compat(device, df->iommufd); diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index b47b186573ac..41dfc9d5205a 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -108,10 +108,10 @@ bool vfio_device_has_container(struct vfio_device *device); int __init vfio_group_init(void); void vfio_group_cleanup(void); -static inline bool vfio_device_is_noiommu(struct vfio_device *vdev) +static inline void vfio_device_set_noiommu(struct vfio_device *device) { - return IS_ENABLED(CONFIG_VFIO_NOIOMMU) && - vdev->group->type == VFIO_NO_IOMMU; + device->noiommu = IS_ENABLED(CONFIG_VFIO_NOIOMMU) && + device->group->type == VFIO_NO_IOMMU; } #if IS_ENABLED(CONFIG_VFIO_CONTAINER) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index eb53b1f8c828..805c34c7b0ef 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -277,6 +277,8 @@ static int __vfio_register_dev(struct vfio_device *device, if (ret) return ret; + vfio_device_set_noiommu(device); + ret = device_add(&device->device); if (ret) goto err_out; diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 580cfc5728e8..5c06af04ed9e 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -62,6 +62,7 @@ struct vfio_device { struct iommufd_device *iommufd_device; bool iommufd_attached; #endif + bool noiommu; }; /** -- 2.34.1