From patchwork Tue Aug 30 02:27:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 9304719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 178E2607F0 for ; Tue, 30 Aug 2016 02:27:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0297928A4F for ; Tue, 30 Aug 2016 02:27:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EABE128A7A; Tue, 30 Aug 2016 02:27:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9046D28A4F for ; Tue, 30 Aug 2016 02:27:48 +0000 (UTC) Received: from localhost ([::1]:46582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beYmB-0003eb-IQ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Aug 2016 22:27:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beYli-0003cG-Js for qemu-devel@nongnu.org; Mon, 29 Aug 2016 22:27:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1beYlh-0006NA-Km for qemu-devel@nongnu.org; Mon, 29 Aug 2016 22:27:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1beYlh-0006Mx-F0 for qemu-devel@nongnu.org; Mon, 29 Aug 2016 22:27:17 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F08781555D; Tue, 30 Aug 2016 02:27:16 +0000 (UTC) Received: from redhat.com (vpn-60-237.rdu2.redhat.com [10.10.60.237]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u7U2REoX024948; Mon, 29 Aug 2016 22:27:14 -0400 Date: Tue, 30 Aug 2016 05:27:14 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org 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-Disposition: inline In-Reply-To: <1472523968-9540-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 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) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] vfio: report group noiommu status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Jason Wang , qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, Alex Williamson , Cornelia Huck Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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)