summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/platform/vfio_platform_irq.c
diff options
context:
space:
mode:
authorAntonios Motakis2015-03-16 21:08:48 +0100
committerAlex Williamson2015-03-16 21:08:48 +0100
commit682704c41e6d2238c1fb5c6ab83eedadd876fa0e (patch)
treea8a87b3d65f9f13115a4d2424ea78d8d8389e698 /drivers/vfio/platform/vfio_platform_irq.c
parentvfio/platform: support MMAP of MMIO regions (diff)
downloadkernel-qcow2-linux-682704c41e6d2238c1fb5c6ab83eedadd876fa0e.tar.gz
kernel-qcow2-linux-682704c41e6d2238c1fb5c6ab83eedadd876fa0e.tar.xz
kernel-qcow2-linux-682704c41e6d2238c1fb5c6ab83eedadd876fa0e.zip
vfio/platform: return IRQ info
Return information for the interrupts exposed by the device. This patch extends VFIO_DEVICE_GET_INFO with the number of IRQs and enables VFIO_DEVICE_GET_IRQ_INFO. 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.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
new file mode 100644
index 000000000000..c6c3ec1b9f82
--- /dev/null
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -0,0 +1,51 @@
+/*
+ * VFIO platform devices interrupt handling
+ *
+ * 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/eventfd.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/vfio.h>
+#include <linux/irq.h>
+
+#include "vfio_platform_private.h"
+
+int vfio_platform_irq_init(struct vfio_platform_device *vdev)
+{
+ int cnt = 0, i;
+
+ while (vdev->get_irq(vdev, cnt) >= 0)
+ cnt++;
+
+ vdev->irqs = kcalloc(cnt, sizeof(struct vfio_platform_irq), GFP_KERNEL);
+ if (!vdev->irqs)
+ return -ENOMEM;
+
+ for (i = 0; i < cnt; i++) {
+ vdev->irqs[i].flags = 0;
+ vdev->irqs[i].count = 1;
+ }
+
+ vdev->num_irqs = cnt;
+
+ return 0;
+}
+
+void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev)
+{
+ vdev->num_irqs = 0;
+ kfree(vdev->irqs);
+}