From: Alex Williamson <alex.williamson@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jason Wang <jasowang@redhat.com>,
Andy Lutomirski <luto@kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Wei Liu <wei.liu2@citrix.com>,
David Woodhouse <dwmw2@infradead.org>,
virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org,
kvm@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
Baptiste Reynal <b.reynal@virtualopensystems.com>,
Julia Lawall <Julia.Lawall@lip6.fr>,
Dan Carpenter <dan.carpenter@oracle.com>,
linux-doc@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH RFC 2/3] vfio: report group noiommu status
Date: Mon, 18 Apr 2016 12:56:58 -0600 [thread overview]
Message-ID: <20160418125658.48ffd105@t450s.home> (raw)
In-Reply-To: <1460973374-32719-3-git-send-email-mst@redhat.com>
On Mon, 18 Apr 2016 12:58:20 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> 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 <mst@redhat.com>
> ---
What about making an interface to query this rather than playing games
with magic return values?
bool vfio_iommu_group_is_noiommu(struct iommu_group *group)
{
return iommu_group_get_iommudata(group) == &noiommu;
}
> 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 {
next prev parent reply other threads:[~2016-04-18 18:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 9:58 [Qemu-devel] [PATCH RFC 0/3] virtio-pci: iommu support Michael S. Tsirkin
2016-04-18 9:58 ` [Qemu-devel] [PATCH RFC 1/3] virtio: add features for IOMMU control Michael S. Tsirkin
2016-04-18 9:58 ` [Qemu-devel] [PATCH RFC 2/3] vfio: report group noiommu status Michael S. Tsirkin
2016-04-18 18:56 ` Alex Williamson [this message]
2016-04-18 9:58 ` [Qemu-devel] [PATCH RFC 3/3] vfio: add virtio pci quirk Michael S. Tsirkin
2016-04-18 20:00 ` Alex Williamson
2016-04-19 9:58 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160418125658.48ffd105@t450s.home \
--to=alex.williamson@redhat.com \
--cc=Julia.Lawall@lip6.fr \
--cc=b.reynal@virtualopensystems.com \
--cc=borntraeger@de.ibm.com \
--cc=corbet@lwn.net \
--cc=cornelia.huck@de.ibm.com \
--cc=dan.carpenter@oracle.com \
--cc=dwmw2@infradead.org \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=wei.liu2@citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).