From: Cornelia Huck <cohuck@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Eric Auger <eric.auger@redhat.com>,
eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
alex.williamson@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] vfio-pci: Introduce vfio_register_event_notifier helper
Date: Thu, 17 Jan 2019 09:59:56 +0100 [thread overview]
Message-ID: <20190117095956.29cbd8ab.cohuck@redhat.com> (raw)
In-Reply-To: <faafbd89-9420-d0ae-5bed-409056ba86b6@ozlabs.ru>
On Thu, 17 Jan 2019 14:46:42 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> On 12/01/2019 03:58, Eric Auger wrote:
> > The code used to attach the eventfd handler for the ERR and
> > REQ irq indices can be factorized into a helper. In subsequent
> > patches we will extend this helper to support other irq indices.
> >
> > We test the notification is allowed outside of the helper:
> > respectively check vdev->pci_aer and VFIO_FEATURE_ENABLE_REQ.
> > Depending on the returned value we set vdev->pci_aer and
> > vdev->req_enabled. An error handle is introduced for future usage
> > although not strictly useful here.>
> > Signed-off-by: Eric Auger <eric.auger@redhat.com>
> > ---
> > hw/vfio/pci.c | 291 ++++++++++++++++++++++----------------------------
> > 1 file changed, 127 insertions(+), 164 deletions(-)
> >
> > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> > index c0cb1ec289..c589a4e666 100644
> > --- a/hw/vfio/pci.c
> > +++ b/hw/vfio/pci.c
> > @@ -105,6 +105,95 @@ static void vfio_intx_eoi(VFIODevice *vbasedev)
> > vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
> > }
> >
> > +/*
> > + * vfio_register_event_notifier - setup/tear down eventfd
> > + * notification and handling for IRQ indices that span over
> > + * a single IRQ
> > + *
> > + * @vdev: VFIO device handle
> > + * @index: IRQ index the eventfd/handler is associated to
> > + * @target_state: true means notifier needs to be set up
> > + * @handler to attach if @target_state is true
> > + * @errp error handle
> > + */
> > +static int vfio_register_event_notifier(VFIOPCIDevice *vdev,
> > + int index,
> > + bool target_state,
> > + void (*handler)(void *opaque),
> > + Error **errp)
> > +{
> > + struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info),
> > + .index = index };
> > + struct vfio_irq_set *irq_set;
> > + EventNotifier *notifier;
> > + int argsz, ret = 0;
> > + int32_t *pfd, fd;
> > +
> > + switch (index) {
>
> I'd pass the notifier as a parameter as well so index/handler/notifier
> would walk together.
I first had the same thought, but I actually like that everything is
together in this switch statement.
Alternatively, pack it together in an indexed array? But that gets a
bit awkward with the intx stuff.
>
>
> > + case VFIO_PCI_REQ_IRQ_INDEX:
> > + notifier = &vdev->req_notifier;
> > + break;
> > + case VFIO_PCI_ERR_IRQ_INDEX:
> > + notifier = &vdev->err_notifier;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
next prev parent reply other threads:[~2019-01-17 9:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 16:57 [Qemu-devel] [PATCH 0/2] vfio-pci: Introduce vfio_register_event_notifier() Eric Auger
2019-01-11 16:58 ` [Qemu-devel] [PATCH 1/2] vfio-pci: Introduce vfio_register_event_notifier helper Eric Auger
2019-01-15 12:03 ` Cornelia Huck
2019-01-15 13:00 ` Auger Eric
2019-01-17 3:46 ` Alexey Kardashevskiy
2019-01-17 8:59 ` Cornelia Huck [this message]
2019-01-17 9:16 ` Auger Eric
2019-01-18 4:14 ` Alexey Kardashevskiy
2019-01-18 9:08 ` Auger Eric
2019-01-18 9:33 ` Cornelia Huck
2019-01-11 16:58 ` [Qemu-devel] [PATCH 2/2] vfio-pci: Use vfio_register_event_notifier in vfio_intx_enable_kvm Eric Auger
2019-01-15 12:12 ` Cornelia Huck
2019-01-15 13:00 ` Auger Eric
2019-01-17 3:46 ` Alexey Kardashevskiy
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=20190117095956.29cbd8ab.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.