|
|
ddf19c |
From 5aea41b56f07f586e0f56a5c8b3e8443e485cd77 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Thomas Huth <thuth@redhat.com>
|
|
|
ddf19c |
Date: Fri, 5 Jun 2020 07:41:09 -0400
|
|
|
ddf19c |
Subject: [PATCH 39/42] spapr: Pass the maximum number of vCPUs to the KVM
|
|
|
ddf19c |
interrupt controller
|
|
|
ddf19c |
MIME-Version: 1.0
|
|
|
ddf19c |
Content-Type: text/plain; charset=UTF-8
|
|
|
ddf19c |
Content-Transfer-Encoding: 8bit
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
ddf19c |
Message-id: <20200605074111.2185-2-thuth@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 97368
|
|
|
ddf19c |
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 1/3] spapr: Pass the maximum number of vCPUs to the KVM interrupt controller
|
|
|
ddf19c |
Bugzilla: 1756946
|
|
|
ddf19c |
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: Greg Kurz <groug@kaod.org>
|
|
|
ddf19c |
|
|
|
ddf19c |
The XIVE and XICS-on-XIVE KVM devices on POWER9 hosts can greatly reduce
|
|
|
ddf19c |
their consumption of some scarce HW resources, namely Virtual Presenter
|
|
|
ddf19c |
identifiers, if they know the maximum number of vCPUs that may run in the
|
|
|
ddf19c |
VM.
|
|
|
ddf19c |
|
|
|
ddf19c |
Prepare ground for this by passing the value down to xics_kvm_connect()
|
|
|
ddf19c |
and kvmppc_xive_connect(). This is purely mechanical, no functional
|
|
|
ddf19c |
change.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
ddf19c |
Message-Id: <157478678301.67101.2717368060417156338.stgit@bahia.tlslab.ibm.com>
|
|
|
ddf19c |
Reviewed-by: Cédric Le Goater <clg@kaod.org>
|
|
|
ddf19c |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
ddf19c |
(cherry picked from commit 4ffb7496881ec361deaf1f51c41a933bde3cbf7b)
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
hw/intc/spapr_xive.c | 6 ++++--
|
|
|
ddf19c |
hw/intc/spapr_xive_kvm.c | 3 ++-
|
|
|
ddf19c |
hw/intc/xics_kvm.c | 3 ++-
|
|
|
ddf19c |
hw/intc/xics_spapr.c | 5 +++--
|
|
|
ddf19c |
hw/ppc/spapr_irq.c | 8 +++++---
|
|
|
ddf19c |
include/hw/ppc/spapr_irq.h | 10 ++++++++--
|
|
|
ddf19c |
include/hw/ppc/spapr_xive.h | 3 ++-
|
|
|
ddf19c |
include/hw/ppc/xics_spapr.h | 3 ++-
|
|
|
ddf19c |
8 files changed, 28 insertions(+), 13 deletions(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
|
|
|
ddf19c |
index 9cb8d38a3b..a570e6e90a 100644
|
|
|
ddf19c |
--- a/hw/intc/spapr_xive.c
|
|
|
ddf19c |
+++ b/hw/intc/spapr_xive.c
|
|
|
ddf19c |
@@ -651,12 +651,14 @@ static void spapr_xive_dt(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
plat_res_int_priorities, sizeof(plat_res_int_priorities)));
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
-static int spapr_xive_activate(SpaprInterruptController *intc, Error **errp)
|
|
|
ddf19c |
+static int spapr_xive_activate(SpaprInterruptController *intc,
|
|
|
ddf19c |
+ uint32_t nr_servers, Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
SpaprXive *xive = SPAPR_XIVE(intc);
|
|
|
ddf19c |
|
|
|
ddf19c |
if (kvm_enabled()) {
|
|
|
ddf19c |
- int rc = spapr_irq_init_kvm(kvmppc_xive_connect, intc, errp);
|
|
|
ddf19c |
+ int rc = spapr_irq_init_kvm(kvmppc_xive_connect, intc, nr_servers,
|
|
|
ddf19c |
+ errp);
|
|
|
ddf19c |
if (rc < 0) {
|
|
|
ddf19c |
return rc;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
|
|
|
ddf19c |
index 08012ac7cd..c1c837a764 100644
|
|
|
ddf19c |
--- a/hw/intc/spapr_xive_kvm.c
|
|
|
ddf19c |
+++ b/hw/intc/spapr_xive_kvm.c
|
|
|
ddf19c |
@@ -740,7 +740,8 @@ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgoff, size_t len,
|
|
|
ddf19c |
* All the XIVE memory regions are now backed by mappings from the KVM
|
|
|
ddf19c |
* XIVE device.
|
|
|
ddf19c |
*/
|
|
|
ddf19c |
-int kvmppc_xive_connect(SpaprInterruptController *intc, Error **errp)
|
|
|
ddf19c |
+int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
+ Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
SpaprXive *xive = SPAPR_XIVE(intc);
|
|
|
ddf19c |
XiveSource *xsrc = &xive->source;
|
|
|
ddf19c |
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
|
|
|
ddf19c |
index 954c424b36..a1f1b7b0d3 100644
|
|
|
ddf19c |
--- a/hw/intc/xics_kvm.c
|
|
|
ddf19c |
+++ b/hw/intc/xics_kvm.c
|
|
|
ddf19c |
@@ -342,7 +342,8 @@ void ics_kvm_set_irq(ICSState *ics, int srcno, int val)
|
|
|
ddf19c |
}
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
-int xics_kvm_connect(SpaprInterruptController *intc, Error **errp)
|
|
|
ddf19c |
+int xics_kvm_connect(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
+ Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
ICSState *ics = ICS_SPAPR(intc);
|
|
|
ddf19c |
int rc;
|
|
|
ddf19c |
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
|
|
|
ddf19c |
index b3705dab0e..8ae4f41459 100644
|
|
|
ddf19c |
--- a/hw/intc/xics_spapr.c
|
|
|
ddf19c |
+++ b/hw/intc/xics_spapr.c
|
|
|
ddf19c |
@@ -422,10 +422,11 @@ static int xics_spapr_post_load(SpaprInterruptController *intc, int version_id)
|
|
|
ddf19c |
return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
-static int xics_spapr_activate(SpaprInterruptController *intc, Error **errp)
|
|
|
ddf19c |
+static int xics_spapr_activate(SpaprInterruptController *intc,
|
|
|
ddf19c |
+ uint32_t nr_servers, Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
if (kvm_enabled()) {
|
|
|
ddf19c |
- return spapr_irq_init_kvm(xics_kvm_connect, intc, errp);
|
|
|
ddf19c |
+ return spapr_irq_init_kvm(xics_kvm_connect, intc, nr_servers, errp);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
|
|
|
ddf19c |
index d6bb7fd2d6..9da423658a 100644
|
|
|
ddf19c |
--- a/hw/ppc/spapr_irq.c
|
|
|
ddf19c |
+++ b/hw/ppc/spapr_irq.c
|
|
|
ddf19c |
@@ -70,15 +70,16 @@ void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num)
|
|
|
ddf19c |
bitmap_clear(spapr->irq_map, irq - SPAPR_IRQ_MSI, num);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
-int spapr_irq_init_kvm(int (*fn)(SpaprInterruptController *, Error **),
|
|
|
ddf19c |
+int spapr_irq_init_kvm(SpaprInterruptControllerInitKvm fn,
|
|
|
ddf19c |
SpaprInterruptController *intc,
|
|
|
ddf19c |
+ uint32_t nr_servers,
|
|
|
ddf19c |
Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
MachineState *machine = MACHINE(qdev_get_machine());
|
|
|
ddf19c |
Error *local_err = NULL;
|
|
|
ddf19c |
|
|
|
ddf19c |
if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
|
|
|
ddf19c |
- if (fn(intc, &local_err) < 0) {
|
|
|
ddf19c |
+ if (fn(intc, nr_servers, &local_err) < 0) {
|
|
|
ddf19c |
if (machine_kernel_irqchip_required(machine)) {
|
|
|
ddf19c |
error_prepend(&local_err,
|
|
|
ddf19c |
"kernel_irqchip requested but unavailable: ");
|
|
|
ddf19c |
@@ -495,6 +496,7 @@ static void set_active_intc(SpaprMachineState *spapr,
|
|
|
ddf19c |
SpaprInterruptController *new_intc)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
SpaprInterruptControllerClass *sicc;
|
|
|
ddf19c |
+ uint32_t nr_servers = spapr_max_server_number(spapr);
|
|
|
ddf19c |
|
|
|
ddf19c |
assert(new_intc);
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -512,7 +514,7 @@ static void set_active_intc(SpaprMachineState *spapr,
|
|
|
ddf19c |
|
|
|
ddf19c |
sicc = SPAPR_INTC_GET_CLASS(new_intc);
|
|
|
ddf19c |
if (sicc->activate) {
|
|
|
ddf19c |
- sicc->activate(new_intc, &error_fatal);
|
|
|
ddf19c |
+ sicc->activate(new_intc, nr_servers, &error_fatal);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
spapr->active_intc = new_intc;
|
|
|
ddf19c |
diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
|
|
|
ddf19c |
index ff814d13de..ca8cb44213 100644
|
|
|
ddf19c |
--- a/include/hw/ppc/spapr_irq.h
|
|
|
ddf19c |
+++ b/include/hw/ppc/spapr_irq.h
|
|
|
ddf19c |
@@ -43,7 +43,8 @@ typedef struct SpaprInterruptController SpaprInterruptController;
|
|
|
ddf19c |
typedef struct SpaprInterruptControllerClass {
|
|
|
ddf19c |
InterfaceClass parent;
|
|
|
ddf19c |
|
|
|
ddf19c |
- int (*activate)(SpaprInterruptController *intc, Error **errp);
|
|
|
ddf19c |
+ int (*activate)(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
+ Error **errp);
|
|
|
ddf19c |
void (*deactivate)(SpaprInterruptController *intc);
|
|
|
ddf19c |
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
@@ -98,8 +99,13 @@ qemu_irq spapr_qirq(SpaprMachineState *spapr, int irq);
|
|
|
ddf19c |
int spapr_irq_post_load(SpaprMachineState *spapr, int version_id);
|
|
|
ddf19c |
void spapr_irq_reset(SpaprMachineState *spapr, Error **errp);
|
|
|
ddf19c |
int spapr_irq_get_phandle(SpaprMachineState *spapr, void *fdt, Error **errp);
|
|
|
ddf19c |
-int spapr_irq_init_kvm(int (*fn)(SpaprInterruptController *, Error **),
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+typedef int (*SpaprInterruptControllerInitKvm)(SpaprInterruptController *,
|
|
|
ddf19c |
+ uint32_t, Error **);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+int spapr_irq_init_kvm(SpaprInterruptControllerInitKvm fn,
|
|
|
ddf19c |
SpaprInterruptController *intc,
|
|
|
ddf19c |
+ uint32_t nr_servers,
|
|
|
ddf19c |
Error **errp);
|
|
|
ddf19c |
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
|
|
|
ddf19c |
index 742b7e834f..3a103c224d 100644
|
|
|
ddf19c |
--- a/include/hw/ppc/spapr_xive.h
|
|
|
ddf19c |
+++ b/include/hw/ppc/spapr_xive.h
|
|
|
ddf19c |
@@ -66,7 +66,8 @@ int spapr_xive_end_to_target(uint8_t end_blk, uint32_t end_idx,
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
* KVM XIVE device helpers
|
|
|
ddf19c |
*/
|
|
|
ddf19c |
-int kvmppc_xive_connect(SpaprInterruptController *intc, Error **errp);
|
|
|
ddf19c |
+int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
+ Error **errp);
|
|
|
ddf19c |
void kvmppc_xive_disconnect(SpaprInterruptController *intc);
|
|
|
ddf19c |
void kvmppc_xive_reset(SpaprXive *xive, Error **errp);
|
|
|
ddf19c |
void kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
|
|
|
ddf19c |
diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h
|
|
|
ddf19c |
index 28b87038c8..1c65c96e3c 100644
|
|
|
ddf19c |
--- a/include/hw/ppc/xics_spapr.h
|
|
|
ddf19c |
+++ b/include/hw/ppc/xics_spapr.h
|
|
|
ddf19c |
@@ -32,7 +32,8 @@
|
|
|
ddf19c |
#define TYPE_ICS_SPAPR "ics-spapr"
|
|
|
ddf19c |
#define ICS_SPAPR(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_SPAPR)
|
|
|
ddf19c |
|
|
|
ddf19c |
-int xics_kvm_connect(SpaprInterruptController *intc, Error **errp);
|
|
|
ddf19c |
+int xics_kvm_connect(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
ddf19c |
+ Error **errp);
|
|
|
ddf19c |
void xics_kvm_disconnect(SpaprInterruptController *intc);
|
|
|
ddf19c |
bool xics_kvm_has_broken_disconnect(SpaprMachineState *spapr);
|
|
|
ddf19c |
|
|
|
ddf19c |
--
|
|
|
ddf19c |
2.27.0
|
|
|
ddf19c |
|