summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/platform/vfio_platform_irq.c
diff options
context:
space:
mode:
authorAntonios Motakis2015-03-16 21:08:49 +0100
committerAlex Williamson2015-03-16 21:08:49 +0100
commit9a36321c8d3350c4f7befa02adf3ce4583287ad9 (patch)
tree7297fc06e32c1fd44a5abb893e8095cae3cb7e14 /drivers/vfio/platform/vfio_platform_irq.c
parentvfio/platform: return IRQ info (diff)
downloadkernel-qcow2-linux-9a36321c8d3350c4f7befa02adf3ce4583287ad9.tar.gz
kernel-qcow2-linux-9a36321c8d3350c4f7befa02adf3ce4583287ad9.tar.xz
kernel-qcow2-linux-9a36321c8d3350c4f7befa02adf3ce4583287ad9.zip
vfio/platform: initial interrupts support code
This patch is a skeleton for the VFIO_DEVICE_SET_IRQS IOCTL, around which most IRQ functionality is implemented in VFIO. Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com> Reviewed-by: Eric Auger <eric.auger@linaro.org> Tested-by: Eric Auger <eric.auger@linaro.org> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/platform/vfio_platform_irq.c')
-rw-r--r--drivers/vfio/platform/vfio_platform_irq.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
index c6c3ec1b9f82..df5c91936a68 100644
--- a/drivers/vfio/platform/vfio_platform_irq.c
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -23,6 +23,56 @@
#include "vfio_platform_private.h"
+static int vfio_platform_set_irq_mask(struct vfio_platform_device *vdev,
+ unsigned index, unsigned start,
+ unsigned count, uint32_t flags,
+ void *data)
+{
+ return -EINVAL;
+}
+
+static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev,
+ unsigned index, unsigned start,
+ unsigned count, uint32_t flags,
+ void *data)
+{
+ return -EINVAL;
+}
+
+static int vfio_platform_set_irq_trigger(struct vfio_platform_device *vdev,
+ unsigned index, unsigned start,
+ unsigned count, uint32_t flags,
+ void *data)
+{
+ return -EINVAL;
+}
+
+int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev,
+ uint32_t flags, unsigned index, unsigned start,
+ unsigned count, void *data)
+{
+ int (*func)(struct vfio_platform_device *vdev, unsigned index,
+ unsigned start, unsigned count, uint32_t flags,
+ void *data) = NULL;
+
+ switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) {
+ case VFIO_IRQ_SET_ACTION_MASK:
+ func = vfio_platform_set_irq_mask;
+ break;
+ case VFIO_IRQ_SET_ACTION_UNMASK:
+ func = vfio_platform_set_irq_unmask;
+ break;
+ case VFIO_IRQ_SET_ACTION_TRIGGER:
+ func = vfio_platform_set_irq_trigger;
+ break;
+ }
+
+ if (!func)
+ return -ENOTTY;
+
+ return func(vdev, index, start, count, flags, data);
+}
+
int vfio_platform_irq_init(struct vfio_platform_device *vdev)
{
int cnt = 0, i;
@@ -35,13 +85,22 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev)
return -ENOMEM;
for (i = 0; i < cnt; i++) {
+ int hwirq = vdev->get_irq(vdev, i);
+
+ if (hwirq < 0)
+ goto err;
+
vdev->irqs[i].flags = 0;
vdev->irqs[i].count = 1;
+ vdev->irqs[i].hwirq = hwirq;
}
vdev->num_irqs = cnt;
return 0;
+err:
+ kfree(vdev->irqs);
+ return -EINVAL;
}
void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev)