From patchwork Mon Apr 18 09:58:20 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: 8869311 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29ECABF29F for ; Mon, 18 Apr 2016 09:59:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F81F200CC for ; Mon, 18 Apr 2016 09:59:53 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C858F2012D for ; Mon, 18 Apr 2016 09:59:51 +0000 (UTC) Received: from localhost ([::1]:34353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1as5yB-0000u7-6x for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Apr 2016 05:59:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1as5wu-0006t0-Cp for qemu-devel@nongnu.org; Mon, 18 Apr 2016 05:58:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1as5wr-0006Kp-7F for qemu-devel@nongnu.org; Mon, 18 Apr 2016 05:58:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1as5wr-0006KN-0A for qemu-devel@nongnu.org; Mon, 18 Apr 2016 05:58:29 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 3FB0881105; Mon, 18 Apr 2016 09:58:28 +0000 (UTC) Received: from redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u3I9wLBu025612; Mon, 18 Apr 2016 05:58:22 -0400 Date: Mon, 18 Apr 2016 12:58:20 +0300 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Message-ID: <1460973374-32719-3-git-send-email-mst@redhat.com> References: <1460973374-32719-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1460973374-32719-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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 RFC 2/3] 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: Julia Lawall , Wei Liu , kvm@vger.kernel.org, Jonathan Corbet , Jason Wang , linux-doc@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, Christian Borntraeger , Alex Williamson , Andy Lutomirski , Cornelia Huck , Baptiste Reynal , David Woodhouse , Dan Carpenter Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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_add_group_dev. Signed-off-by: Michael S. Tsirkin --- drivers/vfio/pci/vfio_pci.c | 2 +- drivers/vfio/platform/vfio_platform_common.c | 2 +- drivers/vfio/vfio.c | 5 ++++- Documentation/vfio.txt | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 712a849..d622a41 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -1119,7 +1119,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) spin_lock_init(&vdev->irqlock); ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev); - if (ret) { + if (ret < 0) { vfio_iommu_group_put(group, &pdev->dev); kfree(vdev); return ret; diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index e65b142..bf74e21 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -568,7 +568,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev, } ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev); - if (ret) { + if (ret < 0) { iommu_group_put(group); return ret; } diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 6fd6fa5..67db231 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -756,6 +756,7 @@ int vfio_add_group_dev(struct device *dev, struct iommu_group *iommu_group; struct vfio_group *group; struct vfio_device *device; + int noiommu; iommu_group = iommu_group_get(dev); if (!iommu_group) @@ -791,6 +792,8 @@ int vfio_add_group_dev(struct device *dev, return PTR_ERR(device); } + noiommu = group->noiommu; + /* * Drop all but the vfio_device reference. The vfio_device holds * a reference to the vfio_group, which holds a reference to the @@ -798,7 +801,7 @@ int vfio_add_group_dev(struct device *dev, */ vfio_group_put(group); - return 0; + return noiommu; } EXPORT_SYMBOL_GPL(vfio_add_group_dev); diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt index 1dd3fdd..d76be0f 100644 --- a/Documentation/vfio.txt +++ b/Documentation/vfio.txt @@ -259,7 +259,9 @@ extern void *vfio_del_group_dev(struct device *dev); vfio_add_group_dev() indicates to the core to begin tracking the specified iommu_group and register the specified dev as owned by -a VFIO bus driver. The driver provides an ops structure for callbacks +a VFIO bus driver. A negative return value indicates failure. +A positive return value indicates that an unsafe noiommu mode +is in use. The driver provides an ops structure for callbacks similar to a file operations structure: struct vfio_device_ops {