From: Alex Williamson <alex.williamson@redhat.com>
To: Baptiste Reynal <b.reynal@virtualopensystems.com>
Cc: kvmarm@lists.cs.columbia.edu, iommu@lists.linux-fundation.org,
will.deacon@arm.com, tech@virtualopensystems.com,
christoffer.dall@linaro.org, eric.auger@linaro.org,
kim.phillips@freescale.com, marc.zyngier@arm.com,
Antonios Motakis <a.motakis@virtualopensystems.com>,
"open list:VFIO DRIVER" <kvm@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v12 10/18] vfio/platform: trigger an interrupt via eventfd
Date: Wed, 21 Jan 2015 16:26:19 -0700 [thread overview]
Message-ID: <1421882779.6130.454.camel@redhat.com> (raw)
In-Reply-To: <1421844606-24751-11-git-send-email-b.reynal@virtualopensystems.com>
On Wed, 2015-01-21 at 13:49 +0100, Baptiste Reynal wrote:
> From: Antonios Motakis <a.motakis@virtualopensystems.com>
>
> This patch allows to set an eventfd for a platform device's interrupt,
> and also to trigger the interrupt eventfd from userspace for testing.
> Level sensitive interrupts are marked as maskable and are handled in
> a later patch. Edge triggered interrupts are not advertised as maskable
> and are implemented here using a simple and efficient IRQ handler.
>
> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
> [Baptiste Reynal: fix masked interrupt initialization]
> Signed-off-by: Baptiste Reynal <b.reynal@virtualopensystems.com>
> ---
> drivers/vfio/platform/vfio_platform_irq.c | 98 ++++++++++++++++++++++++++-
> drivers/vfio/platform/vfio_platform_private.h | 2 +
> 2 files changed, 98 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
> index df5c919..4b1ee22 100644
> --- a/drivers/vfio/platform/vfio_platform_irq.c
> +++ b/drivers/vfio/platform/vfio_platform_irq.c
> @@ -39,12 +39,96 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev,
> return -EINVAL;
> }
>
> +static irqreturn_t vfio_irq_handler(int irq, void *dev_id)
> +{
> + struct vfio_platform_irq *irq_ctx = dev_id;
> +
> + eventfd_signal(irq_ctx->trigger, 1);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
> + int fd, irq_handler_t handler)
> +{
> + struct vfio_platform_irq *irq = &vdev->irqs[index];
> + struct eventfd_ctx *trigger;
> + int ret;
> +
> + if (irq->trigger) {
> + free_irq(irq->hwirq, irq);
> + kfree(irq->name);
> + eventfd_ctx_put(irq->trigger);
> + irq->trigger = NULL;
> + }
> +
> + if (fd < 0) /* Disable only */
> + return 0;
> +
> + irq->name = kasprintf(GFP_KERNEL, "vfio-irq[%d](%s)",
> + irq->hwirq, vdev->name);
> + if (!irq->name)
> + return -ENOMEM;
> +
> + trigger = eventfd_ctx_fdget(fd);
> + if (IS_ERR(trigger)) {
> + kfree(irq->name);
> + return PTR_ERR(trigger);
> + }
> +
> + irq->trigger = trigger;
> +
> + irq_set_status_flags(irq->hwirq, IRQ_NOAUTOEN);
> + ret = request_irq(irq->hwirq, handler, 0, irq->name, irq);
> + if (ret) {
> + kfree(irq->name);
> + eventfd_ctx_put(trigger);
> + irq->trigger = NULL;
> + return ret;
> + }
> +
> + if (!irq->masked)
> + enable_irq(irq->hwirq);
Unfortunately, irq->masked doesn't exist until the next patch. Thanks,
Alex
next prev parent reply other threads:[~2015-01-21 23:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1421844606-24751-1-git-send-email-b.reynal@virtualopensystems.com>
2015-01-21 12:49 ` [PATCH v12 01/18] vfio/platform: initial skeleton of VFIO support for platform devices Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 02/18] vfio: platform: probe to devices on the platform bus Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 03/18] vfio: platform: add the VFIO PLATFORM module to Kconfig Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 04/18] vfio/platform: return info for bound device Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 05/18] vfio/platform: return info for device memory mapped IO regions Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 06/18] vfio/platform: read and write support for the device fd Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 07/18] vfio/platform: support MMAP of MMIO regions Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 08/18] vfio/platform: return IRQ info Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 09/18] vfio/platform: initial interrupts support code Baptiste Reynal
2015-01-21 12:49 ` [PATCH v12 10/18] vfio/platform: trigger an interrupt via eventfd Baptiste Reynal
2015-01-21 23:26 ` Alex Williamson [this message]
2015-01-21 12:49 ` [PATCH v12 11/18] vfio/platform: support for level sensitive interrupts Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 12/18] vfio: add a vfio_ prefix to virqfd_enable and virqfd_disable and export Baptiste Reynal
2015-01-21 23:25 ` Alex Williamson
2015-01-21 12:50 ` [PATCH v12 13/18] vfio: virqfd: rename vfio_pci_virqfd_init and vfio_pci_virqfd_exit Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 14/18] vfio: add local lock for virqfd instead of depending on VFIO PCI Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 15/18] vfio: pass an opaque pointer on virqfd initialization Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 16/18] vfio: move eventfd support code for VFIO_PCI to a separate file Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 17/18] vfio: initialize the virqfd workqueue in VFIO generic code Baptiste Reynal
2015-01-21 12:50 ` [PATCH v12 18/18] vfio/platform: implement IRQ masking/unmasking via an eventfd Baptiste Reynal
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=1421882779.6130.454.camel@redhat.com \
--to=alex.williamson@redhat.com \
--cc=a.motakis@virtualopensystems.com \
--cc=b.reynal@virtualopensystems.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@linaro.org \
--cc=iommu@lists.linux-fundation.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
Powered by JetHome