From: Alex Williamson <alex.williamson@redhat.com>
To: Eric Auger <eric.auger@linaro.org>
Cc: Antonios Motakis <a.motakis@virtualopensystems.com>,
kvmarm@lists.cs.columbia.edu, iommu@lists.linux-foundation.org,
will.deacon@arm.com, tech@virtualopensystems.com,
christoffer.dall@linaro.org, kim.phillips@freescale.com,
marc.zyngier@arm.com, open list <linux-kernel@vger.kernel.org>,
VFIO DRIVER <kvm@vger.kernel.org>
Subject: Re: [PATCH v9 01/19] vfio/platform: initial skeleton of VFIO support for platform devices
Date: Wed, 12 Nov 2014 09:49:45 -0700 [thread overview]
Message-ID: <1415810985.16601.361.camel@ul30vt.home> (raw)
In-Reply-To: <546330DE.5010002@linaro.org>
On Wed, 2014-11-12 at 11:05 +0100, Eric Auger wrote:
> Hi Antonios,
>
> On 10/27/2014 07:07 PM, Antonios Motakis wrote:
> > This patch forms the common skeleton code for platform devices support
> > with VFIO. This will include the core functionality of VFIO_PLATFORM,
> > however binding to the device and discovering the device resources will
> > be done with the help of a separate file where any Linux platform bus
> > specific code will reside.
> >
> > This will allow us to implement support for also discovering AMBA devices
> > and their resources, but still reuse a large part of the VFIO_PLATFORM
> > implementation.
> >
> > Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
> > ---
> > drivers/vfio/platform/vfio_platform_common.c | 126 ++++++++++++++++++++++++++
> > drivers/vfio/platform/vfio_platform_private.h | 36 ++++++++
> > 2 files changed, 162 insertions(+)
> > create mode 100644 drivers/vfio/platform/vfio_platform_common.c
> > create mode 100644 drivers/vfio/platform/vfio_platform_private.h
> >
> > diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
> > new file mode 100644
> > index 0000000..e0fdbc8
> > --- /dev/null
> > +++ b/drivers/vfio/platform/vfio_platform_common.c
> > @@ -0,0 +1,126 @@
> > +/*
> > + * Copyright (C) 2013 - Virtual Open Systems
> > + * Author: Antonios Motakis <a.motakis@virtualopensystems.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License, version 2, as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/device.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/iommu.h>
> > +#include <linux/module.h>
> > +#include <linux/mutex.h>
> > +#include <linux/notifier.h>
> > +#include <linux/pm_runtime.h>
> > +#include <linux/slab.h>
> > +#include <linux/types.h>
> > +#include <linux/uaccess.h>
> > +#include <linux/vfio.h>
> > +#include <linux/io.h>
> not sure at that state all the above includes are needed.
> > +
> > +#include "vfio_platform_private.h"
> > +
> > +static void vfio_platform_release(void *device_data)
> > +{
> > + module_put(THIS_MODULE);
> > +}
> > +
> > +static int vfio_platform_open(void *device_data)
> > +{
> > + if (!try_module_get(THIS_MODULE))
> > + return -ENODEV;
> > +
> > + return 0;
> > +}
> > +
> > +static long vfio_platform_ioctl(void *device_data,
> > + unsigned int cmd, unsigned long arg)
> a minor style comment/question that applies on all the series. Shouldn't
> subsequent argument lines rather be aligned with the first char after
> "(", as done in PCI code?
It's also my preferred style to indent to just after the open paren on
wrapped lines where possible, but I don't think there are hard rules in
CodingStyle or checkpatch that enforce this, so I often let it slide.
Thanks,
Alex
> > +{
> > + if (cmd == VFIO_DEVICE_GET_INFO)
> > + return -EINVAL;
> > +
> > + else if (cmd == VFIO_DEVICE_GET_REGION_INFO)
> > + return -EINVAL;
> > +
> > + else if (cmd == VFIO_DEVICE_GET_IRQ_INFO)
> > + return -EINVAL;
> > +
> > + else if (cmd == VFIO_DEVICE_SET_IRQS)
> > + return -EINVAL;
> > +
> > + else if (cmd == VFIO_DEVICE_RESET)
> > + return -EINVAL;
> > +
> > + return -ENOTTY;
> > +}
> > +
> > +static ssize_t vfio_platform_read(void *device_data, char __user *buf,
> > + size_t count, loff_t *ppos)
> > +{
> > + return -EINVAL;
> > +}
> > +
> > +static ssize_t vfio_platform_write(void *device_data, const char __user *buf,
> > + size_t count, loff_t *ppos)
> > +{
> > + return -EINVAL;
> > +}
> > +
> > +static int vfio_platform_mmap(void *device_data, struct vm_area_struct *vma)
> > +{
> > + return -EINVAL;
> > +}
> > +
> > +static const struct vfio_device_ops vfio_platform_ops = {
> > + .name = "vfio-platform",
> > + .open = vfio_platform_open,
> > + .release = vfio_platform_release,
> > + .ioctl = vfio_platform_ioctl,
> > + .read = vfio_platform_read,
> > + .write = vfio_platform_write,
> > + .mmap = vfio_platform_mmap,
> > +};
> > +
> > +int vfio_platform_probe_common(struct vfio_platform_device *vdev,
> > + struct device *dev)
> > +{
> > + struct iommu_group *group;
> > + int ret;
> > +
> > + if (!vdev)
> > + return -EINVAL;
> > +
> > + group = iommu_group_get(dev);
> > + if (!group) {
> > + pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
> > + return -EINVAL;
> > + }
> I saw the above check also is done at beginning of vfio_add_group_dev.
> Added value however is pr_err which is useful and PCI code does the
> check too.
>
> Eric
> > +
> > + ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
> > + if (ret) {
> > + iommu_group_put(group);
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
> > +
> > +struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
> > +{
> > + struct vfio_platform_device *vdev;
> > +
> > + vdev = vfio_del_group_dev(dev);
> > + if (vdev)
> > + iommu_group_put(dev->iommu_group);
> > +
> > + return vdev;
> > +}
> > +EXPORT_SYMBOL_GPL(vfio_platform_remove_common);
> > diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h
> > new file mode 100644
> > index 0000000..062b92d
> > --- /dev/null
> > +++ b/drivers/vfio/platform/vfio_platform_private.h
> > @@ -0,0 +1,36 @@
> > +/*
> > + * Copyright (C) 2013 - Virtual Open Systems
> > + * Author: Antonios Motakis <a.motakis@virtualopensystems.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License, version 2, as
> > + * published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#ifndef VFIO_PLATFORM_PRIVATE_H
> > +#define VFIO_PLATFORM_PRIVATE_H
> > +
> > +struct vfio_platform_device {
> > + /*
> > + * These fields should be filled by the bus specific binder
> > + */
> > + void *opaque;
> > + const char *name;
> > + uint32_t flags;
> > + /* callbacks to discover device resources */
> > + struct resource*
> > + (*get_resource)(struct vfio_platform_device *vdev, int i);
> > + int (*get_irq)(struct vfio_platform_device *vdev, int i);
> > +};
> > +
> > +extern int vfio_platform_probe_common(struct vfio_platform_device *vdev,
> > + struct device *dev);
> > +extern struct vfio_platform_device *vfio_platform_remove_common
> > + (struct device *dev);
> > +
> > +#endif /* VFIO_PLATFORM_PRIVATE_H */
> >
>
next prev parent reply other threads:[~2014-11-12 17:48 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1414433284-31719-1-git-send-email-a.motakis@virtualopensystems.com>
2014-10-27 18:07 ` Antonios Motakis
[not found] ` <546330DE.5010002@linaro.org>
2014-11-12 16:49 ` Alex Williamson [this message]
2014-11-20 14:10 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 02/19] vfio: platform: probe to devices on the platform bus Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 03/19] vfio: platform: add the VFIO PLATFORM module to Kconfig Antonios Motakis
2014-11-12 9:52 ` Hongbo Zhang
2014-11-12 9:57 ` Antonios Motakis
2014-11-13 8:05 ` Hongbo Zhang
2014-11-20 14:10 ` Antonios Motakis
[not found] ` <CAOhR-w2N3SF=3DTgFr22JfAKDXxzz0PASznJaRjK3oBrRTVcsw@mail.gmail.com>
[not found] ` <d3c4a63eaa294f1987a797a39eed4650@BN3PR0301MB1265.namprd03.prod.outlook.com>
2014-11-12 10:38 ` Hongbo Zhang
2014-11-12 11:00 ` Bharat.Bhushan
2014-11-12 11:17 ` Hongbo Zhang
2014-10-27 18:07 ` [PATCH v9 04/19] vfio: amba: VFIO support for AMBA devices Antonios Motakis
2014-10-31 18:40 ` Alex Williamson
2014-11-05 9:50 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 05/19] vfio: amba: add the VFIO for AMBA devices module to Kconfig Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 06/19] vfio/platform: return info for bound device Antonios Motakis
[not found] ` <5463373C.2010202@linaro.org>
2014-11-12 16:36 ` Alex Williamson
2014-11-20 14:10 ` Antonios Motakis
2014-11-20 14:26 ` Eric Auger
2014-10-27 18:07 ` [PATCH v9 07/19] vfio/platform: return info for device memory mapped IO regions Antonios Motakis
2014-10-31 18:58 ` Alex Williamson
2014-11-05 9:50 ` Antonios Motakis
[not found] ` <54633D5B.4040204@linaro.org>
2014-11-20 14:11 ` Antonios Motakis
2014-11-24 15:53 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 08/19] vfio/platform: read and write support for the device fd Antonios Motakis
[not found] ` <546380DD.8000802@linaro.org>
2014-11-20 14:11 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 09/19] vfio/platform: support MMAP of MMIO regions Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 10/19] vfio/platform: return IRQ info Antonios Motakis
2014-10-31 19:11 ` Alex Williamson
2014-11-05 10:04 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 11/19] vfio/platform: initial interrupts support code Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 12/19] vfio/platform: trigger an interrupt via eventfd Antonios Motakis
2014-10-31 19:36 ` Alex Williamson
2014-11-05 10:08 ` Antonios Motakis
[not found] ` <54636D25.6060009@linaro.org>
2014-11-20 14:11 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 13/19] vfio/platform: support for level sensitive interrupts Antonios Motakis
2014-10-31 19:36 ` Alex Williamson
2014-11-05 10:10 ` Antonios Motakis
2014-10-27 18:07 ` [PATCH v9 14/19] vfio: move eventfd support code for VFIO_PCI to a separate file Antonios Motakis
2014-10-27 19:16 ` Bjorn Helgaas
2014-10-31 16:03 ` Antonios Motakis
2014-10-27 18:08 ` [PATCH v9 15/19] vfio: add local lock in virqfd instead of depending on VFIO PCI Antonios Motakis
2014-10-31 19:43 ` Alex Williamson
2014-11-05 10:04 ` Antonios Motakis
2014-10-27 18:08 ` [PATCH v9 16/19] vfio: pass an opaque pointer on virqfd initialization Antonios Motakis
2014-10-27 18:08 ` [PATCH v9 17/19] vfio: virqfd: add vfio_ prefix to virqfd_enable and virqfd_disable Antonios Motakis
2014-10-27 20:12 ` Bjorn Helgaas
2014-10-31 16:06 ` Antonios Motakis
2014-10-27 18:08 ` [PATCH v9 18/19] vfio: initialize the virqfd workqueue in VFIO generic code Antonios Motakis
2014-10-27 18:08 ` [PATCH v9 19/19] vfio/platform: implement IRQ masking/unmasking via an eventfd Antonios Motakis
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=1415810985.16601.361.camel@ul30vt.home \
--to=alex.williamson@redhat.com \
--cc=a.motakis@virtualopensystems.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=kim.phillips@freescale.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=tech@virtualopensystems.com \
--cc=will.deacon@arm.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
all inboxes | Powered by JetHome®