* [Qemu-devel] [PATCH] sysbus: add irq_routing_notifier
@ 2015-04-23 8:55 ` Eric Auger
0 siblings, 0 replies; 4+ messages in thread
From: Eric Auger @ 2015-04-23 8:55 UTC (permalink / raw)
To: eric.auger, eric.auger, qemu-devel, peter.maydell, agraf, pbonzini
Cc: alex.williamson, kvmarm, christoffer.dall, patches
Add a new irq_routing_notifier notifier and its setter. This
notifier is called on sysbus_connect_irq. The same notifier
is used for all interrupts.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
hw/core/sysbus.c | 9 +++++++++
include/hw/sysbus.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index b53c351..26579f1 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -110,6 +110,9 @@ qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n)
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
{
qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq);
+ if (dev->irq_routing_notifier) {
+ dev->irq_routing_notifier(dev, irq);
+ }
}
/* Check whether an MMIO region exists */
@@ -307,6 +310,12 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
return get_system_memory();
}
+void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
+ IRQRoutingNotifier notifier)
+{
+ dev->irq_routing_notifier = notifier;
+}
+
static void sysbus_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index d1f3f00..84166d9 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -13,6 +13,7 @@
#define SYSTEM_BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_SYSTEM_BUS)
typedef struct SysBusDevice SysBusDevice;
+typedef void (*IRQRoutingNotifier)(SysBusDevice *dev, qemu_irq irq);
#define TYPE_SYS_BUS_DEVICE "sys-bus-device"
#define SYS_BUS_DEVICE(obj) \
@@ -55,6 +56,8 @@ struct SysBusDevice {
} mmio[QDEV_MAX_MMIO];
int num_pio;
pio_addr_t pio[QDEV_MAX_PIO];
+
+ IRQRoutingNotifier irq_routing_notifier;
};
typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
@@ -100,4 +103,7 @@ static inline DeviceState *sysbus_try_create_simple(const char *name,
return sysbus_try_create_varargs(name, addr, irq, NULL);
}
+void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
+ IRQRoutingNotifier notifier);
+
#endif /* !HW_SYSBUS_H */
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] sysbus: add irq_routing_notifier
@ 2015-04-23 8:55 ` Eric Auger
0 siblings, 0 replies; 4+ messages in thread
From: Eric Auger @ 2015-04-23 8:55 UTC (permalink / raw)
To: eric.auger, eric.auger, qemu-devel, peter.maydell, agraf, pbonzini
Cc: alex.williamson, kvmarm, patches
Add a new irq_routing_notifier notifier and its setter. This
notifier is called on sysbus_connect_irq. The same notifier
is used for all interrupts.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
hw/core/sysbus.c | 9 +++++++++
include/hw/sysbus.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index b53c351..26579f1 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -110,6 +110,9 @@ qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n)
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
{
qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq);
+ if (dev->irq_routing_notifier) {
+ dev->irq_routing_notifier(dev, irq);
+ }
}
/* Check whether an MMIO region exists */
@@ -307,6 +310,12 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
return get_system_memory();
}
+void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
+ IRQRoutingNotifier notifier)
+{
+ dev->irq_routing_notifier = notifier;
+}
+
static void sysbus_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index d1f3f00..84166d9 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -13,6 +13,7 @@
#define SYSTEM_BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_SYSTEM_BUS)
typedef struct SysBusDevice SysBusDevice;
+typedef void (*IRQRoutingNotifier)(SysBusDevice *dev, qemu_irq irq);
#define TYPE_SYS_BUS_DEVICE "sys-bus-device"
#define SYS_BUS_DEVICE(obj) \
@@ -55,6 +56,8 @@ struct SysBusDevice {
} mmio[QDEV_MAX_MMIO];
int num_pio;
pio_addr_t pio[QDEV_MAX_PIO];
+
+ IRQRoutingNotifier irq_routing_notifier;
};
typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
@@ -100,4 +103,7 @@ static inline DeviceState *sysbus_try_create_simple(const char *name,
return sysbus_try_create_varargs(name, addr, irq, NULL);
}
+void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
+ IRQRoutingNotifier notifier);
+
#endif /* !HW_SYSBUS_H */
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] sysbus: add irq_routing_notifier
2015-04-23 8:55 ` Eric Auger
@ 2015-04-23 9:33 ` Paolo Bonzini
-1 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-04-23 9:33 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, peter.maydell, agraf
Cc: alex.williamson, kvmarm, christoffer.dall, patches
On 23/04/2015 10:55, Eric Auger wrote:
> Add a new irq_routing_notifier notifier and its setter. This
> notifier is called on sysbus_connect_irq. The same notifier
> is used for all interrupts.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
I'm sorry, same problem here. The question is: why? :)
I can sort of understand why you want this, but not completely. I also
have all sorts of questions on the code that aren't answered. For
example, why does the notifier not get the N argument?
I also cannot understand why this is not a layering violation. Maybe
it's not, but it's hard to say without seeing the user.
Paolo
> ---
> hw/core/sysbus.c | 9 +++++++++
> include/hw/sysbus.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index b53c351..26579f1 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -110,6 +110,9 @@ qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n)
> void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
> {
> qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq);
> + if (dev->irq_routing_notifier) {
> + dev->irq_routing_notifier(dev, irq);
> + }
> }
>
> /* Check whether an MMIO region exists */
> @@ -307,6 +310,12 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> return get_system_memory();
> }
>
> +void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
> + IRQRoutingNotifier notifier)
> +{
> + dev->irq_routing_notifier = notifier;
> +}
> +
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index d1f3f00..84166d9 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -13,6 +13,7 @@
> #define SYSTEM_BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_SYSTEM_BUS)
>
> typedef struct SysBusDevice SysBusDevice;
> +typedef void (*IRQRoutingNotifier)(SysBusDevice *dev, qemu_irq irq);
>
> #define TYPE_SYS_BUS_DEVICE "sys-bus-device"
> #define SYS_BUS_DEVICE(obj) \
> @@ -55,6 +56,8 @@ struct SysBusDevice {
> } mmio[QDEV_MAX_MMIO];
> int num_pio;
> pio_addr_t pio[QDEV_MAX_PIO];
> +
> + IRQRoutingNotifier irq_routing_notifier;
> };
>
> typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
> @@ -100,4 +103,7 @@ static inline DeviceState *sysbus_try_create_simple(const char *name,
> return sysbus_try_create_varargs(name, addr, irq, NULL);
> }
>
> +void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
> + IRQRoutingNotifier notifier);
> +
> #endif /* !HW_SYSBUS_H */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sysbus: add irq_routing_notifier
@ 2015-04-23 9:33 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-04-23 9:33 UTC (permalink / raw)
To: Eric Auger, eric.auger, qemu-devel, peter.maydell, agraf
Cc: alex.williamson, kvmarm, patches
On 23/04/2015 10:55, Eric Auger wrote:
> Add a new irq_routing_notifier notifier and its setter. This
> notifier is called on sysbus_connect_irq. The same notifier
> is used for all interrupts.
>
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
I'm sorry, same problem here. The question is: why? :)
I can sort of understand why you want this, but not completely. I also
have all sorts of questions on the code that aren't answered. For
example, why does the notifier not get the N argument?
I also cannot understand why this is not a layering violation. Maybe
it's not, but it's hard to say without seeing the user.
Paolo
> ---
> hw/core/sysbus.c | 9 +++++++++
> include/hw/sysbus.h | 6 ++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index b53c351..26579f1 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -110,6 +110,9 @@ qemu_irq sysbus_get_connected_irq(SysBusDevice *dev, int n)
> void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
> {
> qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq);
> + if (dev->irq_routing_notifier) {
> + dev->irq_routing_notifier(dev, irq);
> + }
> }
>
> /* Check whether an MMIO region exists */
> @@ -307,6 +310,12 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> return get_system_memory();
> }
>
> +void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
> + IRQRoutingNotifier notifier)
> +{
> + dev->irq_routing_notifier = notifier;
> +}
> +
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index d1f3f00..84166d9 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -13,6 +13,7 @@
> #define SYSTEM_BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_SYSTEM_BUS)
>
> typedef struct SysBusDevice SysBusDevice;
> +typedef void (*IRQRoutingNotifier)(SysBusDevice *dev, qemu_irq irq);
>
> #define TYPE_SYS_BUS_DEVICE "sys-bus-device"
> #define SYS_BUS_DEVICE(obj) \
> @@ -55,6 +56,8 @@ struct SysBusDevice {
> } mmio[QDEV_MAX_MMIO];
> int num_pio;
> pio_addr_t pio[QDEV_MAX_PIO];
> +
> + IRQRoutingNotifier irq_routing_notifier;
> };
>
> typedef int FindSysbusDeviceFunc(SysBusDevice *sbdev, void *opaque);
> @@ -100,4 +103,7 @@ static inline DeviceState *sysbus_try_create_simple(const char *name,
> return sysbus_try_create_varargs(name, addr, irq, NULL);
> }
>
> +void sysbus_set_irq_routing_notifier(SysBusDevice *dev,
> + IRQRoutingNotifier notifier);
> +
> #endif /* !HW_SYSBUS_H */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-23 9:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-23 8:55 [Qemu-devel] [PATCH] sysbus: add irq_routing_notifier Eric Auger
2015-04-23 8:55 ` Eric Auger
2015-04-23 9:33 ` [Qemu-devel] " Paolo Bonzini
2015-04-23 9:33 ` Paolo Bonzini
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.