From 5c7adcf422d4bd7235e0d2f2f85efcc393795fb2 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Thu, 17 Jan 2019 18:14:39 +0100 Subject: spapr: Rename xics to intc in interrupt controller agnostic code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All this code is used with both the XICS and XIVE interrupt controllers. Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index a5a7bf4837..51d81c4b7c 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -112,7 +112,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin) return spapr_qirq(spapr, phb->lsi_table[pin].irq); } -int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void *fdt, +int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t intc_phandle, void *fdt, uint32_t nr_msis); void spapr_pci_rtas_init(void); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a947a0a0dc..cbd276ed2b 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -683,7 +683,7 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *fdt, hwaddr addr); * "interrupt-controller" node has its "#interrupt-cells" property set to 2 (ie, * VIO devices, RTAS event sources and PHBs). */ -static inline void spapr_dt_xics_irq(uint32_t *intspec, int irq, bool is_lsi) +static inline void spapr_dt_irq(uint32_t *intspec, int irq, bool is_lsi) { intspec[0] = cpu_to_be32(irq); intspec[1] = is_lsi ? cpu_to_be32(1) : 0; -- cgit v1.2.3 From 0afed8c8195886111dd8ab0d078b189c55949521 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Tue, 12 Feb 2019 19:24:06 +0100 Subject: xive: Only set source type for LSIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MSI is the default and LSI specific code is guarded by the xive_source_irq_is_lsi() helper. The xive_source_irq_set() helper is a nop for MSIs. Simplify the code by turning xive_source_irq_set() into xive_source_irq_set_lsi() and only call it for LSIs. The call to xive_source_irq_set(false) in spapr_xive_irq_free() is also a nop. Just drop it. Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater Message-Id: <154999584656.690774.18352404495120358613.stgit@bahia.lan> Signed-off-by: David Gibson --- include/hw/ppc/xive.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h index ec3bb2aae4..13a487527b 100644 --- a/include/hw/ppc/xive.h +++ b/include/hw/ppc/xive.h @@ -283,13 +283,10 @@ static inline bool xive_source_irq_is_lsi(XiveSource *xsrc, uint32_t srcno) return test_bit(srcno, xsrc->lsi_map); } -static inline void xive_source_irq_set(XiveSource *xsrc, uint32_t srcno, - bool lsi) +static inline void xive_source_irq_set_lsi(XiveSource *xsrc, uint32_t srcno) { assert(srcno < xsrc->nr_irqs); - if (lsi) { - bitmap_set(xsrc->lsi_map, srcno, 1); - } + bitmap_set(xsrc->lsi_map, srcno, 1); } void xive_source_set_irq(void *opaque, int srcno, int val); -- cgit v1.2.3 From 94d1cc5f03a8f7e45925928d0c9a5ee9782e6c85 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Tue, 12 Feb 2019 19:24:59 +0100 Subject: qdev: pass an Object * to qbus_set_hotplug_handler() Certain devices types, like memory/CPU, are now being handled using a hotplug interface provided by a top-level MachineClass. Hotpluggable host bridges are another such device where it makes sense to use a machine-level hotplug handler. However, unlike those devices, host-bridges have a parent bus (the main system bus), and devices with a parent bus use a different mechanism for registering their hotplug handlers: qbus_set_hotplug_handler(). This interface currently expects a handler to be a subclass of DeviceClass, but this is not the case for MachineClass, which derives directly from ObjectClass. Internally, the interface only requires an ObjectClass, so expose that in qbus_set_hotplug_handler(). Cc: Michael S. Tsirkin Cc: Eduardo Habkost Signed-off-by: Michael Roth Signed-off-by: Greg Kurz Reviewed-by: David Gibson Reviewed-by: Cornelia Huck Acked-by: Halil Pasic Reviewed-by: Michael S. Tsirkin Message-Id: <154999589921.690774.3640149277362188566.stgit@bahia.lan> Signed-off-by: David Gibson --- include/hw/qdev-core.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 0a84c42756..e70a4bfa49 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -430,8 +430,7 @@ char *qdev_get_dev_path(DeviceState *dev); GSList *qdev_build_hotpluggable_device_list(Object *peripheral); -void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, - Error **errp); +void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp); void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp); -- cgit v1.2.3 From 2e66cdb715b2df674a9dd1b2899b958a46a98bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Wed, 13 Feb 2019 22:07:55 +0100 Subject: spapr/irq: add an 'nr_irq' parameter to initialize the backend. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the 'dual' interrupt mode, the source numbers of both sPAPR IRQ backends are aligned to share a common IRQ number space and to use a similar mapping of the machine qemu_irq array which is indexed by the source number. The XICS IRQ number range initially being [ 0x1000 - 0x2000 ], this requires to change the XICS ICSState offset to 0 and to provision for an extra 4K of source numbers and qemu_irqs which will never be used by the machine when running under the XICS interrupt mode. This is not an optimal solution. Change the init() method to allocate an IRQ number space of the expected size for the XICS sPAPR IRQ backend. It breaks the interrupt signaling when under the 'dual' mode because source numbers have unexpected values but next patch will fix that. Signed-off-by: Cédric Le Goater Message-Id: <20190213210756.27032-2-clg@kaod.org> Signed-off-by: David Gibson --- include/hw/ppc/spapr_irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 14b02c3aca..488511c3d8 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -35,7 +35,7 @@ typedef struct sPAPRIrq { uint32_t nr_msis; uint8_t ov5; - void (*init)(sPAPRMachineState *spapr, Error **errp); + void (*init)(sPAPRMachineState *spapr, int nr_irqs, Error **errp); int (*claim)(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp); void (*free)(sPAPRMachineState *spapr, int irq, int num); qemu_irq (*qirq)(sPAPRMachineState *spapr, int irq); -- cgit v1.2.3 From 0e5c7fad9cdc5d431796f899b6a0e860ec93b611 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:39:48 +0100 Subject: xics: Explicitely call KVM ICP methods from the common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pre_save(), post_load() and synchronize_state() methods of the ICPStateClass type are really KVM only things. Make that obvious by dropping the indirections and directly calling the KVM functions instead. Signed-off-by: Greg Kurz Message-Id: <155023078871.1011724.3083923389814185598.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index fad786e8b2..3236ccec92 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -66,10 +66,6 @@ struct ICPStateClass { DeviceRealize parent_realize; DeviceReset parent_reset; - - void (*pre_save)(ICPState *icp); - int (*post_load)(ICPState *icp, int version_id); - void (*synchronize_state)(ICPState *icp); }; struct ICPState { @@ -203,4 +199,9 @@ void icp_resend(ICPState *ss); Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp); +/* KVM */ +void icp_get_kvm_state(ICPState *icp); +int icp_set_kvm_state(ICPState *icp); +void icp_synchronize_state(ICPState *icp); + #endif /* XICS_H */ -- cgit v1.2.3 From d82f397183b41f25e5a2e41c4af887f102de60ef Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:39:54 +0100 Subject: xics: Handle KVM ICP reset from the common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KVM ICP reset handler simply writes the ICP state to KVM. This doesn't need the overkill parent_reset logic we have today. Call icp_set_kvm_state() from the base ICP reset function instead. Since there are no other users for ICPStateClass::parent_reset, and it isn't currently expected to change, drop it as well. Signed-off-by: Greg Kurz Message-Id: <155023079461.1011724.12644984391500635645.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 3236ccec92..e33282a576 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -65,7 +65,6 @@ struct ICPStateClass { DeviceClass parent_class; DeviceRealize parent_realize; - DeviceReset parent_reset; }; struct ICPState { -- cgit v1.2.3 From 8e6e6efef7af41c4d809b6991927949f354836f7 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:00 +0100 Subject: xics: Handle KVM ICP realize from the common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The realization of KVM ICP currently follows the parent_realize logic, which is a bit overkill here. Also we want to get rid of the KVM ICP class. Explicitely call icp_kvm_realize() from the base ICP realize function. Note that ICPStateClass::parent_realize is retained because powernv needs it. Signed-off-by: Greg Kurz Message-Id: <155023080049.1011724.15423463482790260696.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index e33282a576..ab61dc2401 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -202,5 +202,6 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, void icp_get_kvm_state(ICPState *icp); int icp_set_kvm_state(ICPState *icp); void icp_synchronize_state(ICPState *icp); +void icp_kvm_realize(DeviceState *dev, Error **errp); #endif /* XICS_H */ -- cgit v1.2.3 From 56af66566dc728d951cba9b9d6b9772259d43d8d Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:06 +0100 Subject: spapr/irq: Use the base ICP class for KVM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The base ICP class knows how to interact with KVM. Adapt sPAPR to use it instead of the ICP KVM class. Signed-off-by: Greg Kurz Message-Id: <155023080638.1011724.792095453419098948.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/spapr.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index cbd276ed2b..631fc5103b 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -178,7 +178,6 @@ struct sPAPRMachineState { /*< public >*/ char *kvm_type; - const char *icp_type; int32_t irq_map_nr; unsigned long *irq_map; sPAPRXive *xive; -- cgit v1.2.3 From 8c1ced677dd0d7ebe96abb634d7398cd64236b11 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:12 +0100 Subject: xics: Drop the KVM ICP class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KVM ICP class isn't used anymore. Drop it. Signed-off-by: Greg Kurz Message-Id: <155023081228.1011724.12474992370439652538.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index ab61dc2401..fae54e6f28 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -50,9 +50,6 @@ typedef struct XICSFabric XICSFabric; #define TYPE_ICP "icp" #define ICP(obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP) -#define TYPE_KVM_ICP "icp-kvm" -#define KVM_ICP(obj) OBJECT_CHECK(ICPState, (obj), TYPE_KVM_ICP) - #define TYPE_PNV_ICP "pnv-icp" #define PNV_ICP(obj) OBJECT_CHECK(PnvICPState, (obj), TYPE_PNV_ICP) -- cgit v1.2.3 From d80b2ccfa741dd689634ce6c2b2a703d7d449319 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:18 +0100 Subject: xics: Explicitely call KVM ICS methods from the common code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pre_save(), post_load() and synchronize_state() methods of the ICSStateClass type are really KVM only things. Make that obvious by dropping the indirections and directly calling the KVM functions instead. Signed-off-by: Greg Kurz Message-Id: <155023081817.1011724.14078777320394028836.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index fae54e6f28..06e87128f8 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -109,12 +109,9 @@ struct ICSStateClass { DeviceRealize parent_realize; DeviceReset parent_reset; - void (*pre_save)(ICSState *s); - int (*post_load)(ICSState *s, int version_id); void (*reject)(ICSState *s, uint32_t irq); void (*resend)(ICSState *s); void (*eoi)(ICSState *s, uint32_t irq); - void (*synchronize_state)(ICSState *s); }; struct ICSState { @@ -201,4 +198,8 @@ int icp_set_kvm_state(ICPState *icp); void icp_synchronize_state(ICPState *icp); void icp_kvm_realize(DeviceState *dev, Error **errp); +void ics_get_kvm_state(ICSState *ics); +int ics_set_kvm_state(ICSState *ics); +void ics_synchronize_state(ICSState *ics); + #endif /* XICS_H */ -- cgit v1.2.3 From 557b4567298a6952de347a4fb7676ff44775f495 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:30 +0100 Subject: xics: Handle KVM interrupt presentation from "simple" ICS code We want to use the "simple" ICS type in both KVM and non-KVM setups. Teach the "simple" ICS how to present interrupts to KVM and adapt sPAPR accordingly. Signed-off-by: Greg Kurz Message-Id: <155023082996.1011724.16237920586343905010.stgit@bahia.lan> Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 06e87128f8..61bd0fb978 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -180,7 +180,6 @@ void icp_eoi(ICPState *icp, uint32_t xirr); void ics_simple_write_xive(ICSState *ics, int nr, int server, uint8_t priority, uint8_t saved_priority); void ics_simple_set_irq(void *opaque, int srcno, int val); -void ics_kvm_set_irq(void *opaque, int srcno, int val); void ics_set_irq_type(ICSState *ics, int srcno, bool lsi); void icp_pic_print_info(ICPState *icp, Monitor *mon); @@ -201,5 +200,6 @@ void icp_kvm_realize(DeviceState *dev, Error **errp); void ics_get_kvm_state(ICSState *ics); int ics_set_kvm_state(ICSState *ics); void ics_synchronize_state(ICSState *ics); +void ics_kvm_set_irq(ICSState *ics, int srcno, int val); #endif /* XICS_H */ -- cgit v1.2.3 From 3272752a8b51cd91d8633048bf6f844117a4879c Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 15 Feb 2019 12:40:41 +0100 Subject: xics: Drop the KVM ICS class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KVM ICS class isn't used anymore. Drop it. Signed-off-by: Greg Kurz Message-Id: <155023084177.1011724.14693955932559990358.stgit@bahia.lan> Reviewed-by: Cédric Le Goater Signed-off-by: David Gibson --- include/hw/ppc/xics.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 61bd0fb978..d36bbe11ee 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -95,9 +95,6 @@ struct PnvICPState { #define TYPE_ICS_SIMPLE "ics" #define ICS_SIMPLE(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_SIMPLE) -#define TYPE_ICS_KVM "icskvm" -#define ICS_KVM(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_KVM) - #define ICS_BASE_CLASS(klass) \ OBJECT_CLASS_CHECK(ICSStateClass, (klass), TYPE_ICS_BASE) #define ICS_BASE_GET_CLASS(obj) \ -- cgit v1.2.3