[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1413205825-6370-19-git-send-email-a.motakis@virtualopensystems.com>
Date: Mon, 13 Oct 2014 15:10:25 +0200
From: Antonios Motakis <a.motakis@...tualopensystems.com>
To: kvmarm@...ts.cs.columbia.edu, iommu@...ts.linux-foundation.org,
alex.williamson@...hat.com
Cc: will.deacon@....com, tech@...tualopensystems.com,
christoffer.dall@...aro.org, eric.auger@...aro.org,
kim.phillips@...escale.com, marc.zyngier@....com,
Antonios Motakis <a.motakis@...tualopensystems.com>,
kvm@...r.kernel.org (open list:VFIO DRIVER),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH v8 18/18] vfio/platform: implement IRQ masking/unmasking via an eventfd
With this patch the VFIO user will be able to set an eventfd that can be
used in order to mask and unmask IRQs of platform devices.
Signed-off-by: Antonios Motakis <a.motakis@...tualopensystems.com>
---
drivers/vfio/platform/vfio_platform_irq.c | 46 ++++++++++++++++++++++++---
drivers/vfio/platform/vfio_platform_private.h | 2 ++
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
index 7620a17..6abb387 100644
--- a/drivers/vfio/platform/vfio_platform_irq.c
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -45,6 +45,15 @@ static void vfio_platform_mask(struct vfio_platform_irq *irq_ctx)
spin_unlock_irqrestore(&irq_ctx->lock, flags);
}
+static int vfio_platform_mask_handler(void *opaque, void *unused)
+{
+ struct vfio_platform_irq *irq_ctx = opaque;
+
+ vfio_platform_mask(irq_ctx);
+
+ return 0;
+}
+
static int vfio_platform_set_irq_mask(struct vfio_platform_device *vdev,
unsigned index, unsigned start,
unsigned count, uint32_t flags, void *data)
@@ -52,8 +61,18 @@ static int vfio_platform_set_irq_mask(struct vfio_platform_device *vdev,
if (start != 0 || count != 1)
return -EINVAL;
- if (flags & VFIO_IRQ_SET_DATA_EVENTFD)
- return -EINVAL; /* not implemented yet */
+ if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
+ int32_t fd = *(int32_t *)data;
+
+ if (fd >= 0)
+ return virqfd_enable((void *) &vdev->irqs[index],
+ vfio_platform_mask_handler,
+ NULL, NULL,
+ &vdev->irqs[index].mask, fd);
+
+ virqfd_disable(&vdev->irqs[index].mask);
+ return 0;
+ }
if (flags & VFIO_IRQ_SET_DATA_NONE) {
vfio_platform_mask(&vdev->irqs[index]);
@@ -82,6 +101,15 @@ static void vfio_platform_unmask(struct vfio_platform_irq *irq_ctx)
spin_unlock_irqrestore(&irq_ctx->lock, flags);
}
+static int vfio_platform_unmask_handler(void *opaque, void *unused)
+{
+ struct vfio_platform_irq *irq_ctx = opaque;
+
+ vfio_platform_unmask(irq_ctx);
+
+ return 0;
+}
+
static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev,
unsigned index, unsigned start,
unsigned count, uint32_t flags, void *data)
@@ -89,8 +117,18 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev,
if (start != 0 || count != 1)
return -EINVAL;
- if (flags & VFIO_IRQ_SET_DATA_EVENTFD)
- return -EINVAL; /* not implemented yet */
+ if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
+ int32_t fd = *(int32_t *)data;
+
+ if (fd >= 0)
+ return virqfd_enable((void *) &vdev->irqs[index],
+ vfio_platform_unmask_handler,
+ NULL, NULL,
+ &vdev->irqs[index].unmask, fd);
+
+ virqfd_disable(&vdev->irqs[index].unmask);
+ return 0;
+ }
if (flags & VFIO_IRQ_SET_DATA_NONE) {
vfio_platform_unmask(&vdev->irqs[index]);
diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h
index 65e80e7..23ef038 100644
--- a/drivers/vfio/platform/vfio_platform_private.h
+++ b/drivers/vfio/platform/vfio_platform_private.h
@@ -32,6 +32,8 @@ struct vfio_platform_irq {
struct eventfd_ctx *trigger;
bool masked;
spinlock_t lock;
+ struct virqfd *unmask;
+ struct virqfd *mask;
};
struct vfio_platform_region {
--
2.1.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists