intc: change 'info irq' and 'info pic' to be target-agnostic
cover intc: change 'info irq' and 'info pic' to be target-agnostic
Hi,
This patchset aims at genericizing the 'info irq' and 'info pic' HMP commands, so that it is available on all machines and can display details about more than one interrupt controller per machine.
Patch 1 adds a new interface IntCtrl, which is used to:
- gather statistics for the 'info irq' command
- print some text when 'info pic' is called
Patches 2 to 4 implement IntCtrl interface on interrupt controllers which have ad-hock code to handle 'info irq'/'info pic' commands.
Patch 5 removes ad-hock code, and replaces it by a generic version. You can get details about multiple interrupt controllers per machine starting here.
Patch 6 makes 'info irq'/'info pic' commands available on all architectures. For example, Alpha clipper machine is now able to display details about the i8259 interrupt controller.
Hervé
Hervé Poussineau (6):
intc: add an interface to gather statistics/informations on interrupt
controllers
intc/i8259: implement IntCtrl interface intc/slavio_intctl: implement IntCtrl interface intc/lm32_pic: implement IntCtrl interface
intc: make HMP 'info irq' and 'info pic' commands use IntCtrl
interface instead of ad-hock code
intc: make HMP 'info irq' and 'info pic' commands available on all
targets
hmp-commands-info.hx | 17 +---------- hmp.c | 61 ++++++++++++++++++++++++++++++++++++++ hmp.h | 2 ++ hw/intc/Makefile.objs | 1 + hw/intc/i8259.c | 73 +++++++++++++++++++++++----------------------- hw/intc/intc.c | 41 ++++++++++++++++++++++++++ hw/intc/lm32_pic.c | 63 ++++++++++++++++++--------------------- hw/intc/slavio_intctl.c | 67 ++++++++++++++++++++++-------------------- hw/sparc/sun4m.c | 15 +--------- include/hw/i386/pc.h | 2 -- include/hw/intc/intc.h | 27 +++++++++++++++++ include/hw/lm32/lm32_pic.h | 3 -- include/hw/sparc/sun4m.h | 8 ----- monitor.c | 6 ---- 14 files changed, 234 insertions(+), 152 deletions(-) create mode 100644 hw/intc/intc.c create mode 100644 include/hw/intc/intc.h
Signature · 1 line
2.1.4
PATCH 1/6 intc: add an interface to gather statistics/informations on interrupt controllers
This interface will be used by HMP commands 'info irq' and 'info pic'.
--- hw/intc/Makefile.objs | 1 + hw/intc/intc.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/hw/intc/intc.h | 27 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 hw/intc/intc.c create mode 100644 include/hw/intc/intc.h
hw/intc/Makefile.objs +1 -0
@@ -17,6 +17,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_dist.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_redist.o common-obj-$(CONFIG_OPENPIC) += openpic.o +common-obj-y += intc.o obj-$(CONFIG_APIC) += apic.o apic_common.o obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o
hw/intc/intc.c new file +41 -0
41 lines not on this page · raw message
include/hw/intc/intc.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef INTC_H +#define INTC_H + +#include "qom/object.h" + +#define TYPE_INTCTRL "intctrl" + +#define INTCTRL_CLASS (klass) \ + OBJECT_CLASS_CHECK(IntCtrlClass, (klass), TYPE_INTCTRL) +#define INTCTRL_GET_CLASS (obj) \ + OBJECT_GET_CLASS(IntCtrlClass, (obj), TYPE_INTCTRL) +#define INTCTRL (obj) \ + INTERFACE_CHECK(IntCtrl, (obj), TYPE_INTCTRL) + +typedef struct IntCtrl { +Object parent; +}IntCtrl ; + +typedef struct IntCtrlClass { +InterfaceClass parent; + +bool (*get_statistics)(IntCtrl *obj,uint64_t **irq_counts, +unsigned int *nb_irqs); +void (*print_info)(IntCtrl *obj,Monitor *mon); +}IntCtrlClass ; + +#endif
Signature · 1 line
2.1.4
PATCH 2/6 intc/i8259: implement IntCtrl interface
In reply to Hervé Poussineau--- hw/intc/i8259.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
hw/intc/i8259.c +37 -0
@@ -29,6 +29,7 @@#include "qemu/timer.h" #include "qemu/log.h" #include "hw/isa/i8259_internal.h" +#include "hw/intc/intc.h" /* debug PIC */ //#define DEBUG_PIC
@@ -251,6 +252,35 @@ static void pic_reset(DeviceState *dev)pic_init_reset (s); } +static bool pic_get_statistics (IntCtrl *obj,uint64_t **irq_counts, +unsigned int *nb_irqs) +{ +PICCommonState *s =PIC_COMMON (obj); + +if (s->master) { +#ifdef DEBUG_IRQ_COUNT + *irq_counts = irq_count; + *nb_irqs =ARRAY_SIZE (irq_count); +#else +return false; +#endif + }else { + *irq_counts =NULL ; + *nb_irqs =0 ; + } +return true; +} + +static void pic_print_info (IntCtrl *obj,Monitor *mon) +{ +PICCommonState *s =PIC_COMMON (obj); +monitor_printf (mon,"pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " +"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , + s->master ?0 :1 , s->irr, s->imr, s->isr, s->priority_add, + s->irq_base, s->read_reg_select, s->elcr, + s->special_fully_nested_mode); +} +static void pic_ioport_write (void *opaque,hwaddr addr64,uint64_t val64,unsigned size) {
@@ -503,10 +533,13 @@ static void i8259_class_init(ObjectClass *klass, void *data) {PICClass *k =PIC_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); +IntCtrlClass *ic =INTCTRL_CLASS (klass); k->parent_realize = dc->realize; dc->realize = pic_realize; dc->reset = pic_reset; + ic->get_statistics = pic_get_statistics; + ic->print_info = pic_print_info; }static const TypeInfo i8259_info = {
@@ -515,6 +548,10 @@ static const TypeInfo i8259_info = { .parent = TYPE_PIC_COMMON, .class_init = i8259_class_init, .class_size = sizeof(PICClass), + .interfaces = (InterfaceInfo []) { + {TYPE_INTCTRL }, + { } + }, };static void pic_register_types (void )
Signature · 1 line
2.1.4
PATCH 3/6 intc/slavio_intctl: implement IntCtrl interface
In reply to Hervé Poussineau--- hw/intc/slavio_intctl.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
hw/intc/slavio_intctl.c +35 -0
@@ -26,6 +26,7 @@#include "hw/sparc/sun4m.h" #include "monitor/monitor.h" #include "hw/sysbus.h" +#include "hw/intc/intc.h" #include "trace.h" //#define DEBUG_IRQ_COUNT
@@ -418,6 +419,31 @@ static void slavio_intctl_reset(DeviceState *d)slavio_check_interrupts (s,0 ); } +#ifdef DEBUG_IRQ_COUNT +static bool slavio_intctl_get_statistics (IntCtrl *obj, +uint64_t **irq_counts, +unsigned int *nb_irqs) +{ +SLAVIO_INTCTLState *s =SLAVIO_INTCTL (obj); + *irq_counts = s->irq_count; + *nb_irqs =ARRAY_SIZE (s->irq_count); +return true; +} +#endif + +static void slavio_intctl_print_info (IntCtrl *obj,Monitor *mon) +{ +SLAVIO_INTCTLState *s =SLAVIO_INTCTL (obj); +int i; + +for (i =0 ; i <MAX_CPUS ; i++) { +monitor_printf (mon,"per-cpu %d: pending 0x%08x\n" , i, + s->slaves[i].intreg_pending); + } +monitor_printf (mon,"master: pending 0x%08x, disabled 0x%08x\n" , + s->intregm_pending, s->intregm_disabled); +} +static void slavio_intctl_init (Object *obj) {DeviceState *dev =DEVICE (obj);
@@ -449,9 +475,14 @@ static void slavio_intctl_init(Object *obj)static void slavio_intctl_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +IntCtrlClass *ic =INTCTRL_CLASS (klass); dc->reset = slavio_intctl_reset; dc->vmsd = &vmstate_intctl; +#ifdef DEBUG_IRQ_COUNT + ic->get_statistics = slavio_intctl_get_statistics; +#endif + ic->print_info = slavio_intctl_print_info; }static const TypeInfo slavio_intctl_info = {
@@ -460,6 +491,10 @@ static const TypeInfo slavio_intctl_info = { .instance_size = sizeof(SLAVIO_INTCTLState), .instance_init = slavio_intctl_init, .class_init = slavio_intctl_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_INTCTRL }, + { } + }, };static void slavio_intctl_register_types (void )
Signature · 1 line
2.1.4
PATCH 4/6 intc/lm32_pic: implement IntCtrl interface
In reply to Hervé PoussineauWe have to change the vmstate version due to changes in statistics counters.
--- hw/intc/lm32_pic.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
hw/intc/lm32_pic.c +28 -4
@@ -25,6 +25,7 @@#include "hw/sysbus.h" #include "trace.h" #include "hw/lm32/lm32_pic.h" +#include "hw/intc/intc.h" #define TYPE_LM32_PIC "lm32-pic"#define LM32_PIC (obj) OBJECT_CHECK(LM32PicState, (obj), TYPE_LM32_PIC)
@@ -38,7 +39,7 @@ struct LM32PicState {uint32_t irq_state;/* statistics */ -uint32_t stats_irq_count[32 ]; +uint64_t stats_irq_count[32 ]; };typedef struct LM32PicState LM32PicState ;
@@ -152,6 +153,22 @@ static void pic_reset(DeviceState *d) } } +static bool lm32_get_statistics (IntCtrl *obj,uint64_t **irq_counts, +unsigned int *nb_irqs) +{ +LM32PicState *s =LM32_PIC (obj); + *irq_counts = s->stats_irq_count; + *nb_irqs =ARRAY_SIZE (s->stats_irq_count); +return true; +} + +static void lm32_print_info (IntCtrl *obj,Monitor *mon) +{ +LM32PicState *s =LM32_PIC (obj); +monitor_printf (mon,"lm32-pic: im=%08x ip=%08x irq_state=%08x\n" , + s->im, s->ip, s->irq_state); +} +static void lm32_pic_init (Object *obj) {DeviceState *dev =DEVICE (obj);
@@ -166,13 +183,13 @@ static void lm32_pic_init(Object *obj)static const VMStateDescription vmstate_lm32_pic = { .name ="lm32-pic" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (VMStateField []) {VMSTATE_UINT32 (im, LM32PicState),VMSTATE_UINT32 (ip, LM32PicState),VMSTATE_UINT32 (irq_state, LM32PicState), -VMSTATE_UINT32_ARRAY (stats_irq_count, LM32PicState,32 ), +VMSTATE_UINT64_ARRAY (stats_irq_count, LM32PicState,32 ),VMSTATE_END_OF_LIST () } };
@@ -180,9 +197,12 @@ static const VMStateDescription vmstate_lm32_pic = {static void lm32_pic_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +IntCtrlClass *ic =INTCTRL_CLASS (klass); dc->reset = pic_reset; dc->vmsd = &vmstate_lm32_pic; + ic->get_statistics = lm32_get_statistics; + ic->print_info = lm32_print_info; }static const TypeInfo lm32_pic_info = {
@@ -191,6 +211,10 @@ static const TypeInfo lm32_pic_info = { .instance_size = sizeof(LM32PicState), .instance_init = lm32_pic_init, .class_init = lm32_pic_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_INTCTRL }, + { } + }, };static void lm32_pic_register_types (void )
Signature · 1 line
2.1.4
PATCH 6/6 intc: make HMP 'info irq' and 'info pic' commands available on all targets
In reply to Hervé Poussineau--- hmp-commands-info.hx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hmp-commands-info.hx +1 -4
@@ -172,8 +172,6 @@ STEXI Show the command line history. ETEXI -#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \ - defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64)) { .name = "irq", .args_type = "",
@@ -192,10 +190,9 @@ ETEXI .name = "pic", .args_type = "", .params = "", - .help = "show i8259 (PIC) state", + .help = "show PIC state", .cmd = hmp_info_pic, }, -#endif STEXI @item info pic
Signature · 1 line
2.1.4
PATCH 5/6 intc: make HMP 'info irq' and 'info pic' commands use IntCtrl interface instead of ad-hock code
In reply to Hervé Poussineau--- hmp-commands-info.hx | 12 --------- hmp.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ hmp.h | 2 ++ hw/intc/i8259.c | 36 --------------------------- hw/intc/lm32_pic.c | 31 ----------------------- hw/intc/slavio_intctl.c | 32 ------------------------ hw/sparc/sun4m.c | 15 +----------- include/hw/i386/pc.h | 2 -- include/hw/lm32/lm32_pic.h | 3 --- include/hw/sparc/sun4m.h | 8 ------ monitor.c | 6 ----- 11 files changed, 64 insertions(+), 144 deletions(-)
hmp-commands-info.hx +0 -12
@@ -179,13 +179,7 @@ ETEXI .args_type = "", .params = "", .help = "show the interrupts statistics (if available)", -#ifdef TARGET_SPARC - .cmd = sun4m_hmp_info_irq, -#elif defined(TARGET_LM32) - .cmd = lm32_hmp_info_irq, -#else .cmd = hmp_info_irq, -#endif }, STEXI
@@ -199,13 +193,7 @@ ETEXI .args_type = "", .params = "", .help = "show i8259 (PIC) state", -#ifdef TARGET_SPARC - .cmd = sun4m_hmp_info_pic, -#elif defined(TARGET_LM32) - .cmd = lm32_hmp_info_pic, -#else .cmd = hmp_info_pic, -#endif }, #endif
hmp.c +61 -0
73 lines not on this page · raw message
hmp.h +2 -0
@@ -36,6 +36,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict);void hmp_info_vnc (Monitor *mon,const QDict *qdict);void hmp_info_spice (Monitor *mon,const QDict *qdict);void hmp_info_balloon (Monitor *mon,const QDict *qdict); +void hmp_info_irq (Monitor *mon,const QDict *qdict); +void hmp_info_pic (Monitor *mon,const QDict *qdict);void hmp_info_pci (Monitor *mon,const QDict *qdict);void hmp_info_block_jobs (Monitor *mon,const QDict *qdict);void hmp_info_tpm (Monitor *mon,const QDict *qdict);
hw/intc/i8259.c +0 -36
@@ -461,42 +461,6 @@ static void pic_realize(DeviceState *dev, Error **errp) pc->parent_realize (dev, errp); } -void hmp_info_pic (Monitor *mon,const QDict *qdict) -{ -int i; -PICCommonState *s; - -if (!isa_pic) { -return ; - } -for (i =0 ; i <2 ; i++) { - s = i ==0 ?PIC_COMMON (isa_pic) : slave_pic; -monitor_printf (mon,"pic%d: irr=%02x imr=%02x isr=%02x hprio=%d " -"irq_base=%02x rr_sel=%d elcr=%02x fnm=%d\n" , - i, s->irr, s->imr, s->isr, s->priority_add, - s->irq_base, s->read_reg_select, s->elcr, - s->special_fully_nested_mode); - } -} - -void hmp_info_irq (Monitor *mon,const QDict *qdict) -{ -#ifndef DEBUG_IRQ_COUNT -monitor_printf (mon,"irq statistic code not compiled.\n" ); -#else -int i; -int64_t count; - -monitor_printf (mon,"IRQ statistics:\n" ); -for (i =0 ; i <16 ; i++) { - count = irq_count[i]; -if (count >0 ) { -monitor_printf (mon,"%2d: %" PRId64"\n" , i, count); - } - } -#endif -} -qemu_irq *i8259_init (ISABus *bus,qemu_irq parent_irq) {qemu_irq *irq_set;
hw/intc/lm32_pic.c +0 -31
@@ -43,35 +43,6 @@ struct LM32PicState { };typedef struct LM32PicState LM32PicState ; -static LM32PicState *pic; -void lm32_hmp_info_pic (Monitor *mon,const QDict *qdict) -{ -if (pic ==NULL ) { -return ; - } - -monitor_printf (mon,"lm32-pic: im=%08x ip=%08x irq_state=%08x\n" , - pic->im, pic->ip, pic->irq_state); -} - -void lm32_hmp_info_irq (Monitor *mon,const QDict *qdict) -{ -int i; -uint32_t count; - -if (pic ==NULL ) { -return ; - } - -monitor_printf (mon,"IRQ statistics:\n" ); -for (i =0 ; i <32 ; i++) { - count = pic->stats_irq_count[i]; -if (count >0 ) { -monitor_printf (mon,"%2d: %u\n" , i, count); - } - } -} -static void update_irq (LM32PicState *s) { s->ip |= s->irq_state;
@@ -177,8 +148,6 @@ static void lm32_pic_init(Object *obj)qdev_init_gpio_in (dev, irq_handler,32 );sysbus_init_irq (sbd, &s->parent_irq); - - pic = s; }static const VMStateDescription vmstate_lm32_pic = {
hw/intc/slavio_intctl.c +0 -32
@@ -211,38 +211,6 @@ static const MemoryRegionOps slavio_intctlm_mem_ops = { }, }; -void slavio_pic_info (Monitor *mon,DeviceState *dev) -{ -SLAVIO_INTCTLState *s =SLAVIO_INTCTL (dev); -int i; - -for (i =0 ; i <MAX_CPUS ; i++) { -monitor_printf (mon,"per-cpu %d: pending 0x%08x\n" , i, - s->slaves[i].intreg_pending); - } -monitor_printf (mon,"master: pending 0x%08x, disabled 0x%08x\n" , - s->intregm_pending, s->intregm_disabled); -} - -void slavio_irq_info (Monitor *mon,DeviceState *dev) -{ -#ifndef DEBUG_IRQ_COUNT -monitor_printf (mon,"irq statistic code not compiled.\n" ); -#else -SLAVIO_INTCTLState *s =SLAVIO_INTCTL (dev); -int i; -int64_t count; - - s =SLAVIO_INTCTL (dev); -monitor_printf (mon,"IRQ statistics:\n" ); -for (i =0 ; i <32 ; i++) { - count = s->irq_count[i]; -if (count >0 ) -monitor_printf (mon,"%2d: %" PRId64"\n" , i, count); - } -#endif -} -static const uint32_t intbit_to_level[] = {2 ,3 ,5 ,7 ,9 ,11 ,13 ,2 ,3 ,5 ,7 ,9 ,11 ,13 ,12 ,12 ,6 ,13 ,4 ,10 ,8 ,9 ,11 ,0 ,0 ,0 ,0 ,15 ,15 ,15 ,15 ,0 ,
hw/sparc/sun4m.c +1 -14
@@ -159,20 +159,6 @@ static void nvram_init(Nvram *nvram, uint8_t *macaddr, } } -static DeviceState *slavio_intctl; - -void sun4m_hmp_info_pic (Monitor *mon,const QDict *qdict) -{ -if (slavio_intctl) -slavio_pic_info (mon, slavio_intctl); -} - -void sun4m_hmp_info_irq (Monitor *mon,const QDict *qdict) -{ -if (slavio_intctl) -slavio_irq_info (mon, slavio_intctl); -} -void cpu_check_irqs (CPUSPARCState *env) {CPUState *cs;
@@ -873,6 +859,7 @@ static void dummy_fdc_tc(void *opaque, int irq, int level)static void sun4m_hw_init (const struct sun4m_hwdef *hwdef,MachineState *machine) { +DeviceState *slavio_intctl;const char *cpu_model = machine->cpu_model;unsigned int i;void *iommu, *espdma, *ledma, *nvram;
include/hw/i386/pc.h +0 -2
@@ -181,8 +181,6 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq);qemu_irq *kvm_i8259_init (ISABus *bus);int pic_read_irq (DeviceState *d);int pic_get_output (DeviceState *d); -void hmp_info_pic (Monitor *mon,const QDict *qdict); -void hmp_info_irq (Monitor *mon,const QDict *qdict);/* ioapic.c */
include/hw/lm32/lm32_pic.h +0 -3
@@ -8,7 +8,4 @@ uint32_t lm32_pic_get_im(DeviceState *d);void lm32_pic_set_ip (DeviceState *d,uint32_t ip);void lm32_pic_set_im (DeviceState *d,uint32_t im); -void lm32_hmp_info_pic (Monitor *mon,const QDict *qdict); -void lm32_hmp_info_irq (Monitor *mon,const QDict *qdict); -#endif /* QEMU_HW_LM32_PIC_H */
include/hw/sparc/sun4m.h +0 -8
@@ -24,14 +24,6 @@ static inline void sparc_iommu_memory_write(void *opaque,sparc_iommu_memory_rw (opaque, addr, buf, len,1 ); } -/* slavio_intctl.c */ -void slavio_pic_info (Monitor *mon,DeviceState *dev); -void slavio_irq_info (Monitor *mon,DeviceState *dev); - -/* sun4m.c */ -void sun4m_hmp_info_pic (Monitor *mon,const QDict *qdict); -void sun4m_hmp_info_irq (Monitor *mon,const QDict *qdict); -/* sparc32_dma.c */ #include "hw/sparc/sparc32_dma.h"
monitor.c +0 -6
@@ -81,12 +81,6 @@#include "qemu/cutils.h" #include "qapi/qmp/dispatch.h" -/* for hmp_info_irq/pic */ -#if defined(TARGET_SPARC ) -#include "hw/sparc/sun4m.h" -#endif -#include "hw/lm32/lm32_pic.h" -#if defined(TARGET_S390X )#include "hw/s390x/storage-keys.h" #endif
Signature · 1 line
2.1.4
Quoted 12 lines · Hervé Poussineau
This patchset aims at genericizing the 'info irq' and 'info pic' HMP commands, so that it is available on all machines and can display details about more than one interrupt controller per machine.
Patch 1 adds a new interface IntCtrl, which is used to:
- gather statistics for the 'info irq' command
- print some text when 'info pic' is calledPatches 2 to 4 implement IntCtrl interface on interrupt controllers which have ad-hock code to handle 'info irq'/'info pic' commands.
Quoted 6 lines
Patch 5 removes ad-hock code, and replaces it by a generic version. You can get details about multiple interrupt controllers per machine starting here.
Patch 6 makes 'info irq'/'info pic' commands available on all architectures. For example, Alpha clipper machine is now able to display details about the i8259 interrupt controller.
Nice. The only remark is that I'd change IntCtrl to something more descriptive such as InterruptStatsProvider.
Paolo