2016-04-26 20:08:20

by Alex Williamson

[permalink] [raw]
Subject: Re: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer

On Fri, 18 Sep 2015 22:29:50 +0800
Feng Wu <[email protected]> wrote:

@@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct
vfio_pci_device *vdev,
> return ret;
> }
>
> + vdev->ctx[vector].producer.token = trigger;
> + vdev->ctx[vector].producer.irq = irq;
> + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
> + if (unlikely(ret))
> + dev_info(&pdev->dev,
> + "irq bypass producer (token %p) registeration fails: %d\n",
> + vdev->ctx[vector].producer.token, ret);
> +
> vdev->ctx[vector].trigger = trigger;
>
> return 0;

Digging back into the IRQ producer/consumer thing, I'm not sure how we
should be handling a failure here, but it turns out that what we have
is pretty sub-optimal. Any sort of testing on AMD hits this dev_info
because kvm_arch_irq_bypass_add_producer() returns -EINVAL without
kvm_x86_ops->update_pi_irte which is only implemented for vmx. Clearly
we don't want to spew confusing error messages for a feature that does
not exist.

The easiest option is to simply make this error silent, but should
registering a producer/consumer really fail due to a mismatch on the
other end or should the __connect sequence fail silently, which both
ends would know about (if they care) due to the add/del handshake
between them? Perhaps for now we simply need a stable suitable fix to
silence the dev_info above, but longer term, registration shouldn't
fail for mismatches like this. Thoughts? Thanks,

Alex


2016-04-27 01:32:37

by Wu, Feng

[permalink] [raw]
Subject: RE: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer



> -----Original Message-----
> From: Alex Williamson [mailto:[email protected]]
> Sent: Wednesday, April 27, 2016 4:08 AM
> To: Wu, Feng <[email protected]>
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> foundation.org; [email protected]
> Subject: Re: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer
>
> On Fri, 18 Sep 2015 22:29:50 +0800
> Feng Wu <[email protected]> wrote:
>
> @@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct
> vfio_pci_device *vdev,
> > return ret;
> > }
> >
> > + vdev->ctx[vector].producer.token = trigger;
> > + vdev->ctx[vector].producer.irq = irq;
> > + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
> > + if (unlikely(ret))
> > + dev_info(&pdev->dev,
> > + "irq bypass producer (token %p) registeration fails: %d\n",
> > + vdev->ctx[vector].producer.token, ret);
> > +
> > vdev->ctx[vector].trigger = trigger;
> >
> > return 0;
>
> Digging back into the IRQ producer/consumer thing, I'm not sure how we
> should be handling a failure here, but it turns out that what we have
> is pretty sub-optimal. Any sort of testing on AMD hits this dev_info
> because kvm_arch_irq_bypass_add_producer() returns -EINVAL without
> kvm_x86_ops->update_pi_irte which is only implemented for vmx. Clearly
> we don't want to spew confusing error messages for a feature that does
> not exist.
>
> The easiest option is to simply make this error silent, but should
> registering a producer/consumer really fail due to a mismatch on the
> other end or should the __connect sequence fail silently, which both
> ends would know about (if they care) due to the add/del handshake
> between them? Perhaps for now we simply need a stable suitable fix to
> silence the dev_info above, but longer term, registration shouldn't
> fail for mismatches like this. Thoughts? Thanks,

Can we just return 0 when kvm_x86_ops->update_pi_irte is NULL in
kvm_arch_irq_bypass_add_producer?

Thanks,
Feng

>
> Alex

2016-04-28 15:36:39

by Eric Auger

[permalink] [raw]
Subject: Re: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer

Hi Alex,
On 04/26/2016 10:08 PM, Alex Williamson wrote:
> On Fri, 18 Sep 2015 22:29:50 +0800
> Feng Wu <[email protected]> wrote:
>
> @@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct
> vfio_pci_device *vdev,
>> return ret;
>> }
>>
>> + vdev->ctx[vector].producer.token = trigger;
>> + vdev->ctx[vector].producer.irq = irq;
>> + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
>> + if (unlikely(ret))
>> + dev_info(&pdev->dev,
>> + "irq bypass producer (token %p) registeration fails: %d\n",
>> + vdev->ctx[vector].producer.token, ret);
>> +
>> vdev->ctx[vector].trigger = trigger;
>>
>> return 0;
>
> Digging back into the IRQ producer/consumer thing, I'm not sure how we
> should be handling a failure here, but it turns out that what we have
> is pretty sub-optimal. Any sort of testing on AMD hits this dev_info
> because kvm_arch_irq_bypass_add_producer() returns -EINVAL without
> kvm_x86_ops->update_pi_irte which is only implemented for vmx. Clearly
> we don't want to spew confusing error messages for a feature that does
> not exist.
>
> The easiest option is to simply make this error silent, but should
> registering a producer/consumer really fail due to a mismatch on the
> other end or should the __connect sequence fail silently, which both
> ends would know about (if they care) due to the add/del handshake
> between them? Perhaps for now we simply need a stable suitable fix to
> silence the dev_info above, but longer term, registration shouldn't
> fail for mismatches like this. Thoughts? Thanks,

Regarding the ARM IRQ forwarding use case, I think it is OK to fail
silently. We would fall back to the irqfd standard mechanism. Anyway
this series still is waiting for ARM new-vgic dependency to be resolved,
as discussed with Christoffer and Marc.

Best Regards

Eric
>
> Alex
>

2016-04-28 16:40:38

by Alex Williamson

[permalink] [raw]
Subject: Re: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer

On Wed, 27 Apr 2016 01:32:32 +0000
"Wu, Feng" <[email protected]> wrote:

> > -----Original Message-----
> > From: Alex Williamson [mailto:[email protected]]
> > Sent: Wednesday, April 27, 2016 4:08 AM
> > To: Wu, Feng <[email protected]>
> > Cc: [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected]
> > foundation.org; [email protected]
> > Subject: Re: [PATCH v9 12/18] vfio: Register/unregister irq_bypass_producer
> >
> > On Fri, 18 Sep 2015 22:29:50 +0800
> > Feng Wu <[email protected]> wrote:
> >
> > @@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct
> > vfio_pci_device *vdev,
> > > return ret;
> > > }
> > >
> > > + vdev->ctx[vector].producer.token = trigger;
> > > + vdev->ctx[vector].producer.irq = irq;
> > > + ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
> > > + if (unlikely(ret))
> > > + dev_info(&pdev->dev,
> > > + "irq bypass producer (token %p) registeration fails: %d\n",
> > > + vdev->ctx[vector].producer.token, ret);
> > > +
> > > vdev->ctx[vector].trigger = trigger;
> > >
> > > return 0;
> >
> > Digging back into the IRQ producer/consumer thing, I'm not sure how we
> > should be handling a failure here, but it turns out that what we have
> > is pretty sub-optimal. Any sort of testing on AMD hits this dev_info
> > because kvm_arch_irq_bypass_add_producer() returns -EINVAL without
> > kvm_x86_ops->update_pi_irte which is only implemented for vmx. Clearly
> > we don't want to spew confusing error messages for a feature that does
> > not exist.
> >
> > The easiest option is to simply make this error silent, but should
> > registering a producer/consumer really fail due to a mismatch on the
> > other end or should the __connect sequence fail silently, which both
> > ends would know about (if they care) due to the add/del handshake
> > between them? Perhaps for now we simply need a stable suitable fix to
> > silence the dev_info above, but longer term, registration shouldn't
> > fail for mismatches like this. Thoughts? Thanks,
>
> Can we just return 0 when kvm_x86_ops->update_pi_irte is NULL in
> kvm_arch_irq_bypass_add_producer?

Yeah, that may be the best way to go, only return error for actual
failures, not for simple lack of a bypass mechanism. This is
consistent with what update_pi_irte does when running on hardware
or configurations without PI. Thanks,

Alex