All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH v2 14/22] ppc/xics: use the QOM interface to grab an ICP
Date: Thu, 16 Feb 2017 14:47:37 +0100	[thread overview]
Message-ID: <1487252865-12064-15-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1487252865-12064-1-git-send-email-clg@kaod.org>

Also introduce a xics_icp_get() helper to simplify the changes.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/intc/xics.c          | 31 ++++++++++++++++++-------------
 hw/intc/xics_spapr.c    | 17 +++++++++--------
 hw/ppc/spapr_cpu_core.c |  4 ++--
 include/hw/ppc/xics.h   |  8 ++++----
 4 files changed, 33 insertions(+), 27 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index c14797fb1964..dd41340d41a5 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -49,26 +49,26 @@ int xics_get_cpu_index_by_dt_id(int cpu_dt_id)
     return -1;
 }
 
-void xics_cpu_destroy(XICSState *xics, PowerPCCPU *cpu)
+void xics_cpu_destroy(XICSInterface *xi, PowerPCCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *ss = &xics->ss[cs->cpu_index];
+    ICPState *ss = xics_icp_get(xi, cs->cpu_index);
 
-    assert(cs->cpu_index < xics->nr_servers);
+    assert(ss);
     assert(cs == ss->cs);
 
     ss->output = NULL;
     ss->cs = NULL;
 }
 
-void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
+void xics_cpu_setup(XICSInterface *xi, PowerPCCPU *cpu)
 {
     CPUState *cs = CPU(cpu);
     CPUPPCState *env = &cpu->env;
-    ICPState *ss = &xics->ss[cs->cpu_index];
+    ICPState *ss = xics_icp_get(xi, cs->cpu_index);
     XICSStateClass *info;
 
-    assert(cs->cpu_index < xics->nr_servers);
+    assert(ss);
 
     ss->cs = cs;
 
@@ -307,8 +307,9 @@ void icp_eoi(ICPState *ss, uint32_t xirr)
 
 static void icp_irq(ICSState *ics, int server, int nr, uint8_t priority)
 {
-    XICSState *xics = ics->xics;
-    ICPState *ss = xics->ss + server;
+    XICSInterface *xi = XICS_INTERFACE(qdev_get_machine());
+    XICSInterfaceClass *xic = XICS_INTERFACE_GET_CLASS(xi);
+    ICPState *ss = xic->icp_get(xi, server);
 
     trace_xics_icp_irq(server, nr, priority);
 
@@ -582,12 +583,9 @@ static void ics_simple_reset(DeviceState *dev)
 static int ics_simple_post_load(ICSState *ics, int version_id)
 {
     XICSInterface *xi = XICS_INTERFACE(qdev_get_machine());
-    int i;
-
-    for (i = 0; i < ics->xics->nr_servers; i++) {
-        icp_resend(xi, &ics->xics->ss[i]);
-    }
+    XICSInterfaceClass *xic = XICS_INTERFACE_GET_CLASS(xi);
 
+    xic->icp_resend(xi);
     return 0;
 }
 
@@ -737,6 +735,13 @@ qemu_irq xics_get_qirq(XICSInterface *xi, int irq)
     return NULL;
 }
 
+ICPState *xics_icp_get(XICSInterface *xi, int server)
+{
+    XICSInterfaceClass *xic = XICS_INTERFACE_GET_CLASS(xi);
+
+    return xic->icp_get(xi, server);
+}
+
 void ics_set_irq_type(ICSState *ics, int srcno, bool lsi)
 {
     assert(!(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK));
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 1501e796e5e0..a837ca655f87 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -44,7 +44,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                            target_ulong opcode, target_ulong *args)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), cs->cpu_index);
     target_ulong cppr = args[0];
 
     icp_set_cppr(icp, cppr);
@@ -56,12 +56,13 @@ static target_ulong h_ipi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
 {
     target_ulong server = xics_get_cpu_index_by_dt_id(args[0]);
     target_ulong mfrr = args[1];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), server);
 
-    if (server >= spapr->xics->nr_servers) {
+    if (!icp) {
         return H_PARAMETER;
     }
 
-    icp_set_mfrr(spapr->xics->ss + server, mfrr);
+    icp_set_mfrr(icp, mfrr);
     return H_SUCCESS;
 }
 
@@ -69,7 +70,7 @@ static target_ulong h_xirr(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                            target_ulong opcode, target_ulong *args)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), cs->cpu_index);
     uint32_t xirr = icp_accept(icp);
 
     args[0] = xirr;
@@ -80,7 +81,7 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                              target_ulong opcode, target_ulong *args)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), cs->cpu_index);
     uint32_t xirr = icp_accept(icp);
 
     args[0] = xirr;
@@ -92,7 +93,7 @@ static target_ulong h_eoi(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                           target_ulong opcode, target_ulong *args)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), cs->cpu_index);
     target_ulong xirr = args[0];
 
     icp_eoi(icp, xirr);
@@ -103,7 +104,7 @@ static target_ulong h_ipoll(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                             target_ulong opcode, target_ulong *args)
 {
     CPUState *cs = CPU(cpu);
-    ICPState *icp = &spapr->xics->ss[cs->cpu_index];
+    ICPState *icp = xics_icp_get(XICS_INTERFACE(spapr), cs->cpu_index);
     uint32_t mfrr;
     uint32_t xirr = icp_ipoll(icp, &mfrr);
 
@@ -134,7 +135,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, sPAPRMachineState *spapr,
     server = xics_get_cpu_index_by_dt_id(rtas_ld(args, 1));
     priority = rtas_ld(args, 2);
 
-    if (!ics_valid_irq(ics, nr) || (server >= ics->xics->nr_servers)
+    if (!ics_valid_irq(ics, nr) || !xics_icp_get(XICS_INTERFACE(spapr), server)
         || (priority > 0xff)) {
         rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
         return;
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 55cd0456ebe8..2c289a6c72e2 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -42,7 +42,7 @@ static void spapr_cpu_destroy(PowerPCCPU *cpu)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
 
-    xics_cpu_destroy(spapr->xics, cpu);
+    xics_cpu_destroy(XICS_INTERFACE(spapr), cpu);
     qemu_unregister_reset(spapr_cpu_reset, cpu);
 }
 
@@ -76,7 +76,7 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,
             cs->numa_node = i;
     }
 
-    xics_cpu_setup(spapr->xics, cpu);
+    xics_cpu_setup(XICS_INTERFACE(spapr), cpu);
 
     qemu_register_reset(spapr_cpu_reset, cpu);
     spapr_cpu_reset(cpu);
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
index 0375d7d481ef..498f187c0dd2 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -197,16 +197,16 @@ typedef struct XICSInterfaceClass {
 
 #define XICS_IRQS_SPAPR               1024
 
-qemu_irq xics_get_qirq(XICSInterface *xi, int irq);
-
 int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp);
 int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align,
                            Error **errp);
 void spapr_ics_free(ICSState *ics, int irq, int num);
 void spapr_dt_xics(XICSState *xics, void *fdt, uint32_t phandle);
 
-void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu);
-void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu);
+qemu_irq xics_get_qirq(XICSInterface *xi, int irq);
+ICPState *xics_icp_get(XICSInterface *xi, int server);
+void xics_cpu_setup(XICSInterface *xi, PowerPCCPU *cpu);
+void xics_cpu_destroy(XICSInterface *xi, PowerPCCPU *cpu);
 
 /* Internal XICS interfaces */
 int xics_get_cpu_index_by_dt_id(int cpu_dt_id);
-- 
2.7.4

  parent reply	other threads:[~2017-02-16 13:49 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16 13:47 [Qemu-devel] [PATCH v2 00/22] ppc/xics: simplify ICS and ICP creation Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 01/22] ppc/xics: remove set_nr_irqs() handler from XICSStateClass Cédric Le Goater
2017-02-22  3:21   ` David Gibson
2017-02-24 10:46     ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 02/22] ppc/xics: remove set_nr_servers() " Cédric Le Goater
2017-02-22  6:23   ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 03/22] ppc/xics: store the ICS object under the sPAPR machine Cédric Le Goater
2017-02-22  6:59   ` David Gibson
2017-02-24 10:47     ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 04/22] ppc/xics: add an InterruptStatsProvider interface to ICS and ICP objects Cédric Le Goater
2017-02-23  2:15   ` David Gibson
2017-02-24 10:52     ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-26 23:43       ` David Gibson
2017-02-27  8:48         ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 05/22] ppc/xics: introduce a QOM interface to handle ICSs Cédric Le Goater
2017-02-23  2:18   ` David Gibson
2017-02-24 10:55     ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 06/22] ppc/xics: use the QOM interface under the sPAPR machine Cédric Le Goater
2017-02-23  2:21   ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 07/22] ppc/xics: use the QOM interface to get irqs Cédric Le Goater
2017-02-23  2:25   ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 08/22] ppc/xics: use the QOM interface to resend irqs Cédric Le Goater
2017-02-23  2:29   ` David Gibson
2017-02-24 11:12     ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-24 17:34       ` Cédric Le Goater
2017-02-27  0:37         ` David Gibson
2017-02-27  0:30       ` David Gibson
2017-02-27  8:45         ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 09/22] ppc/xics: remove xics_find_source() Cédric Le Goater
2017-02-23  2:31   ` David Gibson
2017-02-24 11:13     ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 10/22] ppc/xics: register the reset handler of ICS objects Cédric Le Goater
2017-02-23  2:33   ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 11/22] ppc/xics: remove the XICS list of ICS Cédric Le Goater
2017-02-23  2:33   ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 12/22] ppc/xics: extend the QOM interface to handle ICPs Cédric Le Goater
2017-02-23  2:39   ` David Gibson
2017-02-24 11:15     ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-27  0:57       ` David Gibson
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 13/22] ppc/xics: simplify the cpu_setup() handler Cédric Le Goater
2017-02-16 13:47 ` Cédric Le Goater [this message]
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 15/22] ppc/xics: simplify spapr_dt_xics() interface Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 16/22] ppc/xics: register the reset handler of ICP objects Cédric Le Goater
2017-02-23  2:42   ` David Gibson
2017-02-24 11:27     ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-27  1:00       ` David Gibson
2017-02-27  9:21         ` Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 17/22] ppc/xics: move the ICP array under the sPAPR machine Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 18/22] ppc/xics: move kernel_xics_fd out of KVMXICSState Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 19/22] ppc/xics: move the cpu_setup() handler under the ICPState class Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 20/22] ppc/xics: remove the 'xics' backlinks Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 21/22] ppc/xics: export the XICS init routines Cédric Le Goater
2017-02-16 13:47 ` [Qemu-devel] [PATCH v2 22/22] ppc/xics: remove the XICSState classes Cédric Le Goater
2017-02-22  3:34 ` [Qemu-devel] [PATCH v2 00/22] ppc/xics: simplify ICS and ICP creation David Gibson
2017-02-22 10:55   ` Cédric Le Goater
2017-02-23  3:07     ` David Gibson
2017-02-23  6:49       ` Cédric Le Goater
2017-02-23  7:19       ` [Qemu-devel] [Qemu-ppc] " Cédric Le Goater
2017-02-23 22:55         ` David Gibson

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=1487252865-12064-15-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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 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.