From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Auger <eric.auger@linaro.org>,
eric.auger@st.com, qemu-devel@nongnu.org,
alex.williamson@redhat.com, peter.maydell@linaro.org,
agraf@suse.de
Cc: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org,
patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback
Date: Thu, 23 Apr 2015 11:58:30 +0200 [thread overview]
Message-ID: <5538C246.20304@redhat.com> (raw)
In-Reply-To: <5538BE19.6030009@linaro.org>
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.
next prev parent reply other threads:[~2015-04-23 9:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 8:49 [Qemu-devel] [PATCH 0/2] irq: add get_gsi callback Eric Auger
2015-04-23 8:49 ` [Qemu-devel] [PATCH 1/2] " Eric Auger
2015-04-23 8:49 ` [Qemu-devel] [PATCH 2/2] intc: arm_gic_kvm: set the " Eric Auger
2015-04-23 9:30 ` [Qemu-devel] [PATCH 0/2] irq: add " Paolo Bonzini
2015-04-23 9:40 ` Eric Auger
2015-04-23 9:58 ` Paolo Bonzini [this message]
2015-04-23 11:25 ` Eric Auger
2015-04-24 9:01 ` Eric Auger
2015-04-24 9:11 ` Paolo Bonzini
2015-04-24 9:18 ` Eric Auger
2015-04-24 9:29 ` Paolo Bonzini
2015-04-24 9:48 ` Eric Auger
2015-04-24 10:02 ` Paolo Bonzini
2015-04-24 11:59 ` Eric Auger
2015-04-24 12:04 ` Paolo Bonzini
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=5538C246.20304@redhat.com \
--to=pbonzini@redhat.com \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@linaro.org \
--cc=eric.auger@st.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).