* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-23 9:58 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-23 9:58 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, christoffer.dall, patches
On 23/04/2015 11:40, Eric Auger wrote:
>> > Why can't you just use a GHashTable?
> You mean implementing this hash table in the interrupt controller?
No, in KVM. Basically the kvm-vgic interrupt controller registers its
qemu_irqs with kvm-all.c, passing the gsi number for KVM_IRQFD along
the way. Then VFIO device can pass the qemu_irq and ask for an irqfd
for that qemu_irq, instead of having to know the gsi number. kvm-all.c
acts as a mediator.
The notifier actually is not even necessary, because we already have
a very similar concept in QOM. But qdev_init_gpio_out_named always
passes a dummy "notifier":
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
const char *name, int n)
{
int i;
NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out");
assert(gpio_list->num_in == 0 || !name);
gpio_list->num_out += n;
for (i = 0; i < n; ++i) {
memset(&pins[i], 0, sizeof(*pins));
object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
(Object **)&pins[i],
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE,
&error_abort);
}
g_free(propname);
}
So you need to add a method to DeviceClass, with the same prototype
as object_property_allow_set_link, and set the default value to
object_property_allow_set_link in device_class_init. Then
qdev_init_gpio_out_named can do
DeviceClass *dc = DEVICE_GET_CLASS(dev);
...
object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
(Object **)&pins[i],
dc->gpio_set_hook,
OBJ_PROP_LINK_UNREF_ON_RELEASE,
&error_abort);
or something like that.
Alternatively, and probably better, add the argument to
qdev_init_gpio_out_named; there aren't many calls. Then
you can add the method only to SysbusDeviceClass rather than
to all devices, and you can change sysbus_init_irq like this:
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
{
SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
sdc->irq_set_hook);
}
Paolo
> The problem is my VFIO device currently has no link to the interrupt
> controller object. Besides it has a platform bus in between. Previously
> I devised a reset notifier called in the machine file to pass this link
> but Alex was not keen about this method. So the idea here is when the
> VFIO sysbus device qemuirq is getting connected, a notifier is called,
> VFIO device can retrieve the gsi of this qemu_irq and call KVM_IRQFD
> with that gsi.
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-23 9:58 ` [Qemu-devel] " Paolo Bonzini
@ 2015-04-23 11:25 ` Eric Auger
-1 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-23 11:25 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
Hi Paolo,
thanks for taking the time to explain. I will rewrite accordingly.
Best Regards
Eric
On 04/23/2015 11:58 AM, Paolo Bonzini wrote:
>
>
> On 23/04/2015 11:40, Eric Auger wrote:
>>>> Why can't you just use a GHashTable?
>> You mean implementing this hash table in the interrupt controller?
>
> No, in KVM. Basically the kvm-vgic interrupt controller registers its
> qemu_irqs with kvm-all.c, passing the gsi number for KVM_IRQFD along
> the way. Then VFIO device can pass the qemu_irq and ask for an irqfd
> for that qemu_irq, instead of having to know the gsi number. kvm-all.c
> acts as a mediator.
>
> The notifier actually is not even necessary, because we already have
> a very similar concept in QOM. But qdev_init_gpio_out_named always
> passes a dummy "notifier":
>
> void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
> const char *name, int n)
> {
> int i;
> NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
> char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out");
>
> assert(gpio_list->num_in == 0 || !name);
> gpio_list->num_out += n;
>
> for (i = 0; i < n; ++i) {
> memset(&pins[i], 0, sizeof(*pins));
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> object_property_allow_set_link,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
> }
> g_free(propname);
> }
>
> So you need to add a method to DeviceClass, with the same prototype
> as object_property_allow_set_link, and set the default value to
> object_property_allow_set_link in device_class_init. Then
> qdev_init_gpio_out_named can do
>
> DeviceClass *dc = DEVICE_GET_CLASS(dev);
> ...
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> dc->gpio_set_hook,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
>
> or something like that.
>
> Alternatively, and probably better, add the argument to
> qdev_init_gpio_out_named; there aren't many calls. Then
> you can add the method only to SysbusDeviceClass rather than
> to all devices, and you can change sysbus_init_irq like this:
>
> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
> {
> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
> sdc->irq_set_hook);
> }
>
>
> Paolo
>
>> The problem is my VFIO device currently has no link to the interrupt
>> controller object. Besides it has a platform bus in between. Previously
>> I devised a reset notifier called in the machine file to pass this link
>> but Alex was not keen about this method. So the idea here is when the
>> VFIO sysbus device qemuirq is getting connected, a notifier is called,
>> VFIO device can retrieve the gsi of this qemu_irq and call KVM_IRQFD
>> with that gsi.
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-23 11:25 ` Eric Auger
0 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-23 11:25 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, christoffer.dall, patches
Hi Paolo,
thanks for taking the time to explain. I will rewrite accordingly.
Best Regards
Eric
On 04/23/2015 11:58 AM, Paolo Bonzini wrote:
>
>
> On 23/04/2015 11:40, Eric Auger wrote:
>>>> Why can't you just use a GHashTable?
>> You mean implementing this hash table in the interrupt controller?
>
> No, in KVM. Basically the kvm-vgic interrupt controller registers its
> qemu_irqs with kvm-all.c, passing the gsi number for KVM_IRQFD along
> the way. Then VFIO device can pass the qemu_irq and ask for an irqfd
> for that qemu_irq, instead of having to know the gsi number. kvm-all.c
> acts as a mediator.
>
> The notifier actually is not even necessary, because we already have
> a very similar concept in QOM. But qdev_init_gpio_out_named always
> passes a dummy "notifier":
>
> void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
> const char *name, int n)
> {
> int i;
> NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
> char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out");
>
> assert(gpio_list->num_in == 0 || !name);
> gpio_list->num_out += n;
>
> for (i = 0; i < n; ++i) {
> memset(&pins[i], 0, sizeof(*pins));
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> object_property_allow_set_link,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
> }
> g_free(propname);
> }
>
> So you need to add a method to DeviceClass, with the same prototype
> as object_property_allow_set_link, and set the default value to
> object_property_allow_set_link in device_class_init. Then
> qdev_init_gpio_out_named can do
>
> DeviceClass *dc = DEVICE_GET_CLASS(dev);
> ...
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> dc->gpio_set_hook,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
>
> or something like that.
>
> Alternatively, and probably better, add the argument to
> qdev_init_gpio_out_named; there aren't many calls. Then
> you can add the method only to SysbusDeviceClass rather than
> to all devices, and you can change sysbus_init_irq like this:
>
> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
> {
> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
> sdc->irq_set_hook);
> }
>
>
> Paolo
>
>> The problem is my VFIO device currently has no link to the interrupt
>> controller object. Besides it has a platform bus in between. Previously
>> I devised a reset notifier called in the machine file to pass this link
>> but Alex was not keen about this method. So the idea here is when the
>> VFIO sysbus device qemuirq is getting connected, a notifier is called,
>> VFIO device can retrieve the gsi of this qemu_irq and call KVM_IRQFD
>> with that gsi.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-23 9:58 ` [Qemu-devel] " Paolo Bonzini
@ 2015-04-24 9:01 ` Eric Auger
-1 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:01 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/23/2015 11:58 AM, Paolo Bonzini wrote:
>
>
> On 23/04/2015 11:40, Eric Auger wrote:
>>>> Why can't you just use a GHashTable?
>> You mean implementing this hash table in the interrupt controller?
>
> No, in KVM. Basically the kvm-vgic interrupt controller registers its
> qemu_irqs with kvm-all.c, passing the gsi number for KVM_IRQFD along
> the way. Then VFIO device can pass the qemu_irq and ask for an irqfd
> for that qemu_irq, instead of having to know the gsi number. kvm-all.c
> acts as a mediator.
>
> The notifier actually is not even necessary, because we already have
> a very similar concept in QOM. But qdev_init_gpio_out_named always
> passes a dummy "notifier":
>
> void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
> const char *name, int n)
> {
> int i;
> NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
> char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out");
>
> assert(gpio_list->num_in == 0 || !name);
> gpio_list->num_out += n;
>
> for (i = 0; i < n; ++i) {
> memset(&pins[i], 0, sizeof(*pins));
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> object_property_allow_set_link,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
> }
> g_free(propname);
> }
>
> So you need to add a method to DeviceClass, with the same prototype
> as object_property_allow_set_link, and set the default value to
> object_property_allow_set_link in device_class_init. Then
> qdev_init_gpio_out_named can do
>
> DeviceClass *dc = DEVICE_GET_CLASS(dev);
> ...
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> dc->gpio_set_hook,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
>
> or something like that.
>
> Alternatively, and probably better, add the argument to
> qdev_init_gpio_out_named; there aren't many calls. Then
> you can add the method only to SysbusDeviceClass rather than
> to all devices, and you can change sysbus_init_irq like this:
>
> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
> {
> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
> sdc->irq_set_hook);
> }
Hi Paolo
I implemented this alternative but my concern is the check method is
called before the qemu_irq setting. So on this callback I cannot
retrieve the qemu_irq VFIOINTp struct container object needed to setup
irqfd hence does not work for me. I would need a post_check cb. Do you
think it it sensible to add another cb?
Thanks
Eric
>
>
> Paolo
>
>> The problem is my VFIO device currently has no link to the interrupt
>> controller object. Besides it has a platform bus in between. Previously
>> I devised a reset notifier called in the machine file to pass this link
>> but Alex was not keen about this method. So the idea here is when the
>> VFIO sysbus device qemuirq is getting connected, a notifier is called,
>> VFIO device can retrieve the gsi of this qemu_irq and call KVM_IRQFD
>> with that gsi.
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 9:01 ` Eric Auger
0 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:01 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, christoffer.dall, patches
On 04/23/2015 11:58 AM, Paolo Bonzini wrote:
>
>
> On 23/04/2015 11:40, Eric Auger wrote:
>>>> Why can't you just use a GHashTable?
>> You mean implementing this hash table in the interrupt controller?
>
> No, in KVM. Basically the kvm-vgic interrupt controller registers its
> qemu_irqs with kvm-all.c, passing the gsi number for KVM_IRQFD along
> the way. Then VFIO device can pass the qemu_irq and ask for an irqfd
> for that qemu_irq, instead of having to know the gsi number. kvm-all.c
> acts as a mediator.
>
> The notifier actually is not even necessary, because we already have
> a very similar concept in QOM. But qdev_init_gpio_out_named always
> passes a dummy "notifier":
>
> void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
> const char *name, int n)
> {
> int i;
> NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
> char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-out");
>
> assert(gpio_list->num_in == 0 || !name);
> gpio_list->num_out += n;
>
> for (i = 0; i < n; ++i) {
> memset(&pins[i], 0, sizeof(*pins));
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> object_property_allow_set_link,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
> }
> g_free(propname);
> }
>
> So you need to add a method to DeviceClass, with the same prototype
> as object_property_allow_set_link, and set the default value to
> object_property_allow_set_link in device_class_init. Then
> qdev_init_gpio_out_named can do
>
> DeviceClass *dc = DEVICE_GET_CLASS(dev);
> ...
> object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
> (Object **)&pins[i],
> dc->gpio_set_hook,
> OBJ_PROP_LINK_UNREF_ON_RELEASE,
> &error_abort);
>
> or something like that.
>
> Alternatively, and probably better, add the argument to
> qdev_init_gpio_out_named; there aren't many calls. Then
> you can add the method only to SysbusDeviceClass rather than
> to all devices, and you can change sysbus_init_irq like this:
>
> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
> {
> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
> sdc->irq_set_hook);
> }
Hi Paolo
I implemented this alternative but my concern is the check method is
called before the qemu_irq setting. So on this callback I cannot
retrieve the qemu_irq VFIOINTp struct container object needed to setup
irqfd hence does not work for me. I would need a post_check cb. Do you
think it it sensible to add another cb?
Thanks
Eric
>
>
> Paolo
>
>> The problem is my VFIO device currently has no link to the interrupt
>> controller object. Besides it has a platform bus in between. Previously
>> I devised a reset notifier called in the machine file to pass this link
>> but Alex was not keen about this method. So the idea here is when the
>> VFIO sysbus device qemuirq is getting connected, a notifier is called,
>> VFIO device can retrieve the gsi of this qemu_irq and call KVM_IRQFD
>> with that gsi.
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 9:01 ` [Qemu-devel] " Eric Auger
@ 2015-04-24 9:11 ` Paolo Bonzini
-1 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 9:11 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:01, Eric Auger wrote:
>> > void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
>> > {
>> > SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
>> > qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
>> > sdc->irq_set_hook);
>> > }
> Hi Paolo
>
> I implemented this alternative but my concern is the check method is
> called before the qemu_irq setting. So on this callback I cannot
> retrieve the qemu_irq VFIOINTp struct container object needed to setup
> irqfd hence does not work for me.
Isn't the qemu_irq passed as the third argument to the callback? I
thought this solution was fine because you weren't passing the "int n"
from sysbus_connect_irq to your notifier.
If you really cannot make it work, I guess your "sysbus: add
irq_routing_notifier" patch would be okay. I would only ask you to move
the function pointer from SysBusDevice to SysBusDeviceClass.
Thanks,
Paolo
> I would need a post_check cb. Do you
> think it it sensible to add another cb?
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 9:11 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 9:11 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:01, Eric Auger wrote:
>> > void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
>> > {
>> > SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
>> > qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
>> > sdc->irq_set_hook);
>> > }
> Hi Paolo
>
> I implemented this alternative but my concern is the check method is
> called before the qemu_irq setting. So on this callback I cannot
> retrieve the qemu_irq VFIOINTp struct container object needed to setup
> irqfd hence does not work for me.
Isn't the qemu_irq passed as the third argument to the callback? I
thought this solution was fine because you weren't passing the "int n"
from sysbus_connect_irq to your notifier.
If you really cannot make it work, I guess your "sysbus: add
irq_routing_notifier" patch would be okay. I would only ask you to move
the function pointer from SysBusDevice to SysBusDeviceClass.
Thanks,
Paolo
> I would need a post_check cb. Do you
> think it it sensible to add another cb?
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 9:11 ` [Qemu-devel] " Paolo Bonzini
@ 2015-04-24 9:18 ` Eric Auger
-1 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:18 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 11:11 AM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:01, Eric Auger wrote:
>>>> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
>>>> {
>>>> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
>>>> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
>>>> sdc->irq_set_hook);
>>>> }
>> Hi Paolo
>>
>> I implemented this alternative but my concern is the check method is
>> called before the qemu_irq setting. So on this callback I cannot
>> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>> irqfd hence does not work for me.
>
> Isn't the qemu_irq passed as the third argument to the callback? I
> thought this solution was fine because you weren't passing the "int n"
> from sysbus_connect_irq to your notifier.
Yes it is. But I need to access the EventNotifiers for trigger &
resample which were initialized before for eventfd trigger and stored in
the container object. Will study if I can restructure the code ...
Thanks
Eric
>
> If you really cannot make it work, I guess your "sysbus: add
> irq_routing_notifier" patch would be okay. I would only ask you to move
> the function pointer from SysBusDevice to SysBusDeviceClass.
>
> Thanks,
>
> Paolo
>
>> I would need a post_check cb. Do you
>> think it it sensible to add another cb?
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 9:18 ` Eric Auger
0 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:18 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 11:11 AM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:01, Eric Auger wrote:
>>>> void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p)
>>>> {
>>>> SysBusDeviceClass *sdc = SYSBUS_DEVICE_GET_CLASS(dev);
>>>> qdev_init_gpio_out_named(DEVICE(dev), p, SYSBUS_DEVICE_GPIO_IRQ, 1,
>>>> sdc->irq_set_hook);
>>>> }
>> Hi Paolo
>>
>> I implemented this alternative but my concern is the check method is
>> called before the qemu_irq setting. So on this callback I cannot
>> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>> irqfd hence does not work for me.
>
> Isn't the qemu_irq passed as the third argument to the callback? I
> thought this solution was fine because you weren't passing the "int n"
> from sysbus_connect_irq to your notifier.
Yes it is. But I need to access the EventNotifiers for trigger &
resample which were initialized before for eventfd trigger and stored in
the container object. Will study if I can restructure the code ...
Thanks
Eric
>
> If you really cannot make it work, I guess your "sysbus: add
> irq_routing_notifier" patch would be okay. I would only ask you to move
> the function pointer from SysBusDevice to SysBusDeviceClass.
>
> Thanks,
>
> Paolo
>
>> I would need a post_check cb. Do you
>> think it it sensible to add another cb?
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 9:18 ` [Qemu-devel] " Eric Auger
@ 2015-04-24 9:29 ` Paolo Bonzini
-1 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 9:29 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:18, Eric Auger wrote:
>>> >> I implemented this alternative but my concern is the check method is
>>> >> called before the qemu_irq setting. So on this callback I cannot
>>> >> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>>> >> irqfd hence does not work for me.
>> >
>> > Isn't the qemu_irq passed as the third argument to the callback? I
>> > thought this solution was fine because you weren't passing the "int n"
>> > from sysbus_connect_irq to your notifier.
> Yes it is. But I need to access the EventNotifiers for trigger &
> resample which were initialized before for eventfd trigger and stored in
> the container object. Will study if I can restructure the code ...
What did the notifier code look like with your patch?
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 9:29 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 9:29 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:18, Eric Auger wrote:
>>> >> I implemented this alternative but my concern is the check method is
>>> >> called before the qemu_irq setting. So on this callback I cannot
>>> >> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>>> >> irqfd hence does not work for me.
>> >
>> > Isn't the qemu_irq passed as the third argument to the callback? I
>> > thought this solution was fine because you weren't passing the "int n"
>> > from sysbus_connect_irq to your notifier.
> Yes it is. But I need to access the EventNotifiers for trigger &
> resample which were initialized before for eventfd trigger and stored in
> the container object. Will study if I can restructure the code ...
What did the notifier code look like with your patch?
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 9:29 ` [Qemu-devel] " Paolo Bonzini
@ 2015-04-24 9:48 ` Eric Auger
-1 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:48 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 11:29 AM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:18, Eric Auger wrote:
>>>>>> I implemented this alternative but my concern is the check method is
>>>>>> called before the qemu_irq setting. So on this callback I cannot
>>>>>> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>>>>>> irqfd hence does not work for me.
>>>>
>>>> Isn't the qemu_irq passed as the third argument to the callback? I
>>>> thought this solution was fine because you weren't passing the "int n"
>>>> from sysbus_connect_irq to your notifier.
>> Yes it is. But I need to access the EventNotifiers for trigger &
>> resample which were initialized before for eventfd trigger and stored in
>> the container object. Will study if I can restructure the code ...
>
> What did the notifier code look like with your patch?
Currently both notifiers are stored in the VFIOINTp struct. They are
initialized in vfio_init_intp. VFIO platform device holds a list of
VFIOINTp struct.
When the vfio_start_irqfd callback is called the qemuirq is not yet
initialized so I cannot retrieve the EventNotifiers by container_of.
I can allocate and initialize them in the callback but I need a place to
store them to close the eventfd.
Also at the moment I start irqfd I must take some actions to stop (user
side) eventfd trigger; this also urges me to get access to VFIOINTp
struct. Some extracted pieces below (under work).
Eric
typedef struct VFIOINTp {
QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
EventNotifier interrupt; /* eventfd triggered on interrupt */
EventNotifier unmask; /* eventfd for unmask on QEMU bypass */
qemu_irq qemuirq;
struct VFIOPlatformDevice *vdev; /* back pointer to device */
int state; /* inactive, pending, active */
uint8_t pin; /* index */
uint32_t flags; /* IRQ info flags */
bool kvm_accel; /* set when QEMU bypass through KVM enabled */
} VFIOINTp;
static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
struct vfio_irq_info info)
{
int ret;
VFIOPlatformDevice *vdev =
container_of(vbasedev, VFIOPlatformDevice, vbasedev);
SysBusDevice *sbdev = SYS_BUS_DEVICE(vdev);
VFIOINTp *intp;
intp = g_malloc0(sizeof(*intp));
intp->vdev = vdev;
intp->pin = info.index;
intp->flags = info.flags;
intp->state = VFIO_IRQ_INACTIVE;
intp->kvm_accel = false;
sysbus_init_irq(sbdev, &intp->qemuirq);
/* Get an eventfd for trigger */
ret = event_notifier_init(&intp->interrupt, 0);
if (ret) {
g_free(intp);
error_report("vfio: Error: trigger event_notifier_init failed ");
return NULL;
}
/* Get an eventfd for resample/unmask */
ret = event_notifier_init(&intp->unmask, 0);
if (ret) {
g_free(intp);
error_report("vfio: Error: resample event_notifier_init failed ");
return NULL;
}
static void vfio_start_irqfd(Object *obj, const char *name,
Object *child, Error ** err)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(obj);
qemu_irq irq = OBJECT_CHECK(struct IRQState, (child), TYPE_IRQ);
struct VFIOINTp *tmp, *intp = container_of(&irq, struct VFIOINTp,
qemuirq);
EventNotifier *interrupt, *unmask;
vfio_stop_vfio_signaling(intp);
interrupt = g_new(EventNotifier, 1);
unmask = g_new(EventNotifier, 1);
/* Get an eventfd for trigger */
ret = event_notifier_init(interrupt, 0);
if (ret) {
return NULL;
}
/* Get an eventfd for resample/unmask */
ret = event_notifier_init(unmask, 0);
if (ret) {
return NULL;
}
kvm_irqchip_add_qemuirq_irqfd_notifier(kvm_state,
interrupt,
unmask,
irq);
../..
}
>
> Paolo
>
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 9:48 ` Eric Auger
0 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 9:48 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 11:29 AM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:18, Eric Auger wrote:
>>>>>> I implemented this alternative but my concern is the check method is
>>>>>> called before the qemu_irq setting. So on this callback I cannot
>>>>>> retrieve the qemu_irq VFIOINTp struct container object needed to setup
>>>>>> irqfd hence does not work for me.
>>>>
>>>> Isn't the qemu_irq passed as the third argument to the callback? I
>>>> thought this solution was fine because you weren't passing the "int n"
>>>> from sysbus_connect_irq to your notifier.
>> Yes it is. But I need to access the EventNotifiers for trigger &
>> resample which were initialized before for eventfd trigger and stored in
>> the container object. Will study if I can restructure the code ...
>
> What did the notifier code look like with your patch?
Currently both notifiers are stored in the VFIOINTp struct. They are
initialized in vfio_init_intp. VFIO platform device holds a list of
VFIOINTp struct.
When the vfio_start_irqfd callback is called the qemuirq is not yet
initialized so I cannot retrieve the EventNotifiers by container_of.
I can allocate and initialize them in the callback but I need a place to
store them to close the eventfd.
Also at the moment I start irqfd I must take some actions to stop (user
side) eventfd trigger; this also urges me to get access to VFIOINTp
struct. Some extracted pieces below (under work).
Eric
typedef struct VFIOINTp {
QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
EventNotifier interrupt; /* eventfd triggered on interrupt */
EventNotifier unmask; /* eventfd for unmask on QEMU bypass */
qemu_irq qemuirq;
struct VFIOPlatformDevice *vdev; /* back pointer to device */
int state; /* inactive, pending, active */
uint8_t pin; /* index */
uint32_t flags; /* IRQ info flags */
bool kvm_accel; /* set when QEMU bypass through KVM enabled */
} VFIOINTp;
static VFIOINTp *vfio_init_intp(VFIODevice *vbasedev,
struct vfio_irq_info info)
{
int ret;
VFIOPlatformDevice *vdev =
container_of(vbasedev, VFIOPlatformDevice, vbasedev);
SysBusDevice *sbdev = SYS_BUS_DEVICE(vdev);
VFIOINTp *intp;
intp = g_malloc0(sizeof(*intp));
intp->vdev = vdev;
intp->pin = info.index;
intp->flags = info.flags;
intp->state = VFIO_IRQ_INACTIVE;
intp->kvm_accel = false;
sysbus_init_irq(sbdev, &intp->qemuirq);
/* Get an eventfd for trigger */
ret = event_notifier_init(&intp->interrupt, 0);
if (ret) {
g_free(intp);
error_report("vfio: Error: trigger event_notifier_init failed ");
return NULL;
}
/* Get an eventfd for resample/unmask */
ret = event_notifier_init(&intp->unmask, 0);
if (ret) {
g_free(intp);
error_report("vfio: Error: resample event_notifier_init failed ");
return NULL;
}
static void vfio_start_irqfd(Object *obj, const char *name,
Object *child, Error ** err)
{
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(obj);
qemu_irq irq = OBJECT_CHECK(struct IRQState, (child), TYPE_IRQ);
struct VFIOINTp *tmp, *intp = container_of(&irq, struct VFIOINTp,
qemuirq);
EventNotifier *interrupt, *unmask;
vfio_stop_vfio_signaling(intp);
interrupt = g_new(EventNotifier, 1);
unmask = g_new(EventNotifier, 1);
/* Get an eventfd for trigger */
ret = event_notifier_init(interrupt, 0);
if (ret) {
return NULL;
}
/* Get an eventfd for resample/unmask */
ret = event_notifier_init(unmask, 0);
if (ret) {
return NULL;
}
kvm_irqchip_add_qemuirq_irqfd_notifier(kvm_state,
interrupt,
unmask,
irq);
../..
}
>
> Paolo
>
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 9:48 ` [Qemu-devel] " Eric Auger
@ 2015-04-24 10:02 ` Paolo Bonzini
-1 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 10:02 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:48, Eric Auger wrote:
>> > What did the notifier code look like with your patch?
> Currently both notifiers are stored in the VFIOINTp struct. They are
> initialized in vfio_init_intp. VFIO platform device holds a list of
> VFIOINTp struct.
>
> When the vfio_start_irqfd callback is called the qemuirq is not yet
> initialized so I cannot retrieve the EventNotifiers by container_of.
Understood better now. I would pass the "Object **child" variable of
object_set_link_property to the callback then (in qom/object.c).
Then I would go for the other solution (the notifier, just adding the
callback to SysbusDeviceClass). But I still do not understand why you
didn't have exactly the same problem :) unless you were walking the list
to find the relevant VFIOINTp.
Paolo
> I can allocate and initialize them in the callback but I need a place to
> store them to close the eventfd.
>
> Also at the moment I start irqfd I must take some actions to stop (user
> side) eventfd trigger; this also urges me to get access to VFIOINTp
> struct. Some extracted pieces below (under work).
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 10:02 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 10:02 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 11:48, Eric Auger wrote:
>> > What did the notifier code look like with your patch?
> Currently both notifiers are stored in the VFIOINTp struct. They are
> initialized in vfio_init_intp. VFIO platform device holds a list of
> VFIOINTp struct.
>
> When the vfio_start_irqfd callback is called the qemuirq is not yet
> initialized so I cannot retrieve the EventNotifiers by container_of.
Understood better now. I would pass the "Object **child" variable of
object_set_link_property to the callback then (in qom/object.c).
Then I would go for the other solution (the notifier, just adding the
callback to SysbusDeviceClass). But I still do not understand why you
didn't have exactly the same problem :) unless you were walking the list
to find the relevant VFIOINTp.
Paolo
> I can allocate and initialize them in the callback but I need a place to
> store them to close the eventfd.
>
> Also at the moment I start irqfd I must take some actions to stop (user
> side) eventfd trigger; this also urges me to get access to VFIOINTp
> struct. Some extracted pieces below (under work).
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 10:02 ` [Qemu-devel] " Paolo Bonzini
@ 2015-04-24 11:59 ` Eric Auger
-1 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 11:59 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 12:02 PM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:48, Eric Auger wrote:
>>>> What did the notifier code look like with your patch?
>> Currently both notifiers are stored in the VFIOINTp struct. They are
>> initialized in vfio_init_intp. VFIO platform device holds a list of
>> VFIOINTp struct.
>>
>> When the vfio_start_irqfd callback is called the qemuirq is not yet
>> initialized so I cannot retrieve the EventNotifiers by container_of.
>
> Understood better now. I would pass the "Object **child" variable of
> object_set_link_property to the callback then (in qom/object.c).
>
> Then I would go for the other solution (the notifier, just adding the
> callback to SysbusDeviceClass). But I still do not understand why you
> didn't have exactly the same problem :) unless you were walking the list
> to find the relevant VFIOINTp.
Hi Paolo,
Yes I was walking the list ;-)
So is my understanding coherent: revert to first patch but moving
notifier in class
Thanks
Eric
>
> Paolo
>
>> I can allocate and initialize them in the callback but I need a place to
>> store them to close the eventfd.
>>
>> Also at the moment I start irqfd I must take some actions to stop (user
>> side) eventfd trigger; this also urges me to get access to VFIOINTp
>> struct. Some extracted pieces below (under work).
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 11:59 ` Eric Auger
0 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2015-04-24 11:59 UTC (permalink / raw)
To: Paolo Bonzini, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 04/24/2015 12:02 PM, Paolo Bonzini wrote:
>
>
> On 24/04/2015 11:48, Eric Auger wrote:
>>>> What did the notifier code look like with your patch?
>> Currently both notifiers are stored in the VFIOINTp struct. They are
>> initialized in vfio_init_intp. VFIO platform device holds a list of
>> VFIOINTp struct.
>>
>> When the vfio_start_irqfd callback is called the qemuirq is not yet
>> initialized so I cannot retrieve the EventNotifiers by container_of.
>
> Understood better now. I would pass the "Object **child" variable of
> object_set_link_property to the callback then (in qom/object.c).
>
> Then I would go for the other solution (the notifier, just adding the
> callback to SysbusDeviceClass). But I still do not understand why you
> didn't have exactly the same problem :) unless you were walking the list
> to find the relevant VFIOINTp.
Hi Paolo,
Yes I was walking the list ;-)
So is my understanding coherent: revert to first patch but moving
notifier in class
Thanks
Eric
>
> Paolo
>
>> I can allocate and initialize them in the callback but I need a place to
>> store them to close the eventfd.
>>
>> Also at the moment I start irqfd I must take some actions to stop (user
>> side) eventfd trigger; this also urges me to get access to VFIOINTp
>> struct. Some extracted pieces below (under work).
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] irq: add get_gsi callback
2015-04-24 11:59 ` [Qemu-devel] " Eric Auger
@ 2015-04-24 12:04 ` Paolo Bonzini
-1 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 12:04 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 13:59, Eric Auger wrote:
> > Then I would go for the other solution (the notifier, just adding the
> > callback to SysbusDeviceClass). But I still do not understand why you
> > didn't have exactly the same problem :) unless you were walking the list
> > to find the relevant VFIOINTp.
>
> Yes I was walking the list ;-)
>
> So is my understanding coherent: revert to first patch but moving
> notifier in class
Yes.
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
@ 2015-04-24 12:04 ` Paolo Bonzini
0 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2015-04-24 12:04 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, alex.williamson,
peter.maydell, agraf
Cc: kvmarm, patches
On 24/04/2015 13:59, Eric Auger wrote:
> > Then I would go for the other solution (the notifier, just adding the
> > callback to SysbusDeviceClass). But I still do not understand why you
> > didn't have exactly the same problem :) unless you were walking the list
> > to find the relevant VFIOINTp.
>
> Yes I was walking the list ;-)
>
> So is my understanding coherent: revert to first patch but moving
> notifier in class
Yes.
Paolo
^ permalink raw reply [flat|nested] 30+ messages in thread