From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757269AbcH3C1T (ORCPT ); Mon, 29 Aug 2016 22:27:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34536 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757113AbcH3C1R (ORCPT ); Mon, 29 Aug 2016 22:27:17 -0400 Date: Tue, 30 Aug 2016 05:27:14 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Jason Wang , Alex Williamson , Cornelia Huck , virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [PATCH v2 1/2] vfio: report group noiommu status Message-ID: <1472523968-9540-2-git-send-email-mst@redhat.com> References: <1472523968-9540-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472523968-9540-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 30 Aug 2016 02:27:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using vfio, callers might want to know whether device is added to a regular group or an non-iommu group. Report this status from vfio_is_noiommu_group_dev. Signed-off-by: Michael S. Tsirkin --- include/linux/vfio.h | 2 ++ drivers/vfio/vfio.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 0ecae0b..584757b 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -51,6 +51,8 @@ extern int vfio_add_group_dev(struct device *dev, const struct vfio_device_ops *ops, void *device_data); +extern bool vfio_is_noiommu_group_dev(struct device *dev); + extern void *vfio_del_group_dev(struct device *dev); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index d1d70e0..22f279f 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -872,6 +872,18 @@ static bool vfio_dev_present(struct vfio_group *group, struct device *dev) } /* + * Is device part of a noiommu group? + * Note: must call vfio_add_group_dev first. + */ +bool vfio_is_noiommu_group_dev(struct device *dev) +{ + struct vfio_device *device = dev_get_drvdata(dev); + struct vfio_group *group = device->group; + + return group->noiommu; +} + +/* * Decrement the device reference count and wait for the device to be * removed. Open file descriptors for the device... */ void *vfio_del_group_dev(struct device *dev) -- MST