From: "Cédric Le Goater" <clg@kaod.org>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
David Gibson <david@gibson.dropbear.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Greg Kurz <groug@kaod.org>
Cc: "Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH v2 07/19] spapr: push the XIVE EQ data in OS event queue
Date: Sat, 9 Dec 2017 09:43:26 +0100 [thread overview]
Message-ID: <20171209084338.29395-8-clg@kaod.org> (raw)
In-Reply-To: <20171209084338.29395-1-clg@kaod.org>
If a triggered event is let through by the XIVE virtualization routing
engine, the Event Queue data defined in the associated IVE is pushed
in the in-memory event queue. The latter is a circular buffer provided
by the OS using the H_INT_SET_QUEUE_CONFIG hcall, one per server and
priority couple. Each Event Queue entry is 4 bytes long, the first bit
being a 'generation' bit and the 31 following bits the EQ Data field.
The EQ Data field provides a way to set an invariant logical event
source number for an IRQ. It is set with the H_INT_SET_SOURCE_CONFIG
hcall when the EISN flag is used.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
Changes since v1:
- replaced dma_memory_write() by stl_be_dma()
- improved 'info pic' output
hw/intc/spapr_xive.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 95 insertions(+), 3 deletions(-)
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 8e990d58ecf4..629563d01998 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -196,9 +196,87 @@ static sPAPRXiveNVT *spapr_xive_nvt_get(sPAPRXive *xive, int server)
return cpu ? SPAPR_XIVE_NVT(cpu->intc) : NULL;
}
+static void spapr_xive_pic_print_info_eq(XiveEQ *eq, Monitor *mon)
+{
+ uint64_t qaddr_base = (((uint64_t)(eq->w2 & 0x0fffffff)) << 32) | eq->w3;
+ uint32_t qindex = GETFIELD(EQ_W1_PAGE_OFF, eq->w1);
+ uint32_t qgen = GETFIELD(EQ_W1_GENERATION, eq->w1);
+ uint32_t qsize = GETFIELD(EQ_W0_QSIZE, eq->w0);
+ uint32_t qentries = 1 << (qsize + 10);
+
+ monitor_printf(mon, "eq:@%08" PRIx64"% 6d/%5d ^%d", qaddr_base,
+ qindex, qentries, qgen);
+}
+
+static void spapr_xive_eq_push(XiveEQ *eq, uint32_t data)
+{
+ uint64_t qaddr_base = (((uint64_t)(eq->w2 & 0x0fffffff)) << 32) | eq->w3;
+ uint32_t qsize = GETFIELD(EQ_W0_QSIZE, eq->w0);
+ uint32_t qindex = GETFIELD(EQ_W1_PAGE_OFF, eq->w1);
+ uint32_t qgen = GETFIELD(EQ_W1_GENERATION, eq->w1);
+
+ uint64_t qaddr = qaddr_base + (qindex << 2);
+ uint32_t qdata = (qgen << 31) | (data & 0x7fffffff);
+ uint32_t qentries = 1 << (qsize + 10);
+
+ if (stl_be_dma(&address_space_memory, qaddr, qdata)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to write EQ data @0x%"
+ HWADDR_PRIx "\n", qaddr);
+ return;
+ }
+
+ qindex = (qindex + 1) % qentries;
+ if (qindex == 0) {
+ qgen ^= 1;
+ eq->w1 = SETFIELD(EQ_W1_GENERATION, eq->w1, qgen);
+ }
+ eq->w1 = SETFIELD(EQ_W1_PAGE_OFF, eq->w1, qindex);
+}
+
static void spapr_xive_irq(sPAPRXive *xive, int lisn)
{
+ XiveIVE *ive;
+ XiveEQ *eq;
+ uint32_t eq_idx;
+ uint8_t priority;
+
+ ive = spapr_xive_get_ive(xive, lisn);
+ if (!ive || !(ive->w & IVE_VALID)) {
+ qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid LISN %d\n", lisn);
+ return;
+ }
+ if (ive->w & IVE_MASKED) {
+ return;
+ }
+
+ /* Find our XiveEQ */
+ eq_idx = GETFIELD(IVE_EQ_INDEX, ive->w);
+ eq = spapr_xive_get_eq(xive, XIVE_EQ_INDEX_SERVER(eq_idx),
+ XIVE_EQ_INDEX_PRIO(eq_idx));
+ if (!eq) {
+ qemu_log_mask(LOG_GUEST_ERROR, "XIVE: No EQ for LISN %d\n", lisn);
+ return;
+ }
+
+ if (eq->w0 & EQ_W0_ENQUEUE) {
+ spapr_xive_eq_push(eq, GETFIELD(IVE_EQ_DATA, ive->w));
+ }
+
+ if (!(eq->w0 & EQ_W0_UCOND_NOTIFY)) {
+ qemu_log_mask(LOG_UNIMP, "XIVE: !UCOND_NOTIFY not implemented\n");
+ }
+
+ if (GETFIELD(EQ_W6_FORMAT_BIT, eq->w6) == 0) {
+ priority = GETFIELD(EQ_W7_F0_PRIORITY, eq->w7);
+
+ /* The EQ is masked. Can this happen ? */
+ if (priority == 0xff) {
+ g_assert_not_reached();
+ }
+ } else {
+ qemu_log_mask(LOG_UNIMP, "XIVE: w7 format1 not implemented\n");
+ }
}
/*
@@ -480,14 +558,28 @@ void spapr_xive_pic_print_info(sPAPRXive *xive, Monitor *mon)
pq = spapr_xive_pq_get(xive, i);
eq_idx = GETFIELD(IVE_EQ_INDEX, ive->w);
- monitor_printf(mon, " %4x %s %s %c%c server:%d prio:%d %08x\n", i,
+ monitor_printf(mon, " %4x %s %s %c%c server:%d prio:%d ", i,
spapr_xive_irq_is_lsi(xive, i) ? "LSI" : "MSI",
ive->w & IVE_MASKED ? "M" : " ",
pq & XIVE_ESB_VAL_P ? 'P' : '-',
pq & XIVE_ESB_VAL_Q ? 'Q' : '-',
XIVE_EQ_INDEX_SERVER(eq_idx),
- XIVE_EQ_INDEX_PRIO(eq_idx),
- (int) GETFIELD(IVE_EQ_DATA, ive->w));
+ XIVE_EQ_INDEX_PRIO(eq_idx));
+
+ if (!(ive->w & IVE_MASKED)) {
+ XiveEQ *eq;
+
+ eq = spapr_xive_get_eq(xive, XIVE_EQ_INDEX_SERVER(eq_idx),
+ XIVE_EQ_INDEX_PRIO(eq_idx));
+ if (eq) {
+ spapr_xive_pic_print_info_eq(eq, mon);
+ monitor_printf(mon, " data:%08x",
+ (int) GETFIELD(IVE_EQ_DATA, ive->w));
+ } else {
+ monitor_printf(mon, "no eq ?!");
+ }
+ }
+ monitor_printf(mon, "\n");
}
}
--
2.13.6
next prev parent reply other threads:[~2017-12-09 8:44 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-09 8:43 [Qemu-devel] [PATCH v2 00/19] spapr: Guest exploitation of the XIVE interrupt controller (POWER9) Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 01/19] dma-helpers: add a return value to store helpers Cédric Le Goater
2017-12-19 4:46 ` David Gibson
2017-12-19 6:43 ` Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 02/19] spapr: introduce a skeleton for the XIVE interrupt controller Cédric Le Goater
2017-12-09 14:06 ` Cédric Le Goater
2017-12-20 5:09 ` David Gibson
2017-12-20 7:38 ` Cédric Le Goater
2018-04-12 5:07 ` David Gibson
2018-04-12 8:18 ` Cédric Le Goater
2018-04-16 4:26 ` David Gibson
2018-04-19 17:40 ` Cédric Le Goater
2018-04-26 5:36 ` David Gibson
2018-04-26 8:17 ` Cédric Le Goater
2018-05-03 2:29 ` David Gibson
2018-05-03 8:43 ` Cédric Le Goater
2018-05-04 6:35 ` David Gibson
2018-05-04 15:35 ` Cédric Le Goater
2017-12-21 0:12 ` Benjamin Herrenschmidt
2017-12-21 9:16 ` Cédric Le Goater
2017-12-21 10:09 ` Cédric Le Goater
2017-12-21 22:53 ` Benjamin Herrenschmidt
2018-01-17 9:18 ` Cédric Le Goater
2018-01-17 11:10 ` Benjamin Herrenschmidt
2018-01-17 14:39 ` Cédric Le Goater
2018-01-17 17:57 ` Cédric Le Goater
2018-01-17 21:27 ` Benjamin Herrenschmidt
2018-01-18 13:27 ` Cédric Le Goater
2018-01-18 21:08 ` Benjamin Herrenschmidt
2018-02-11 8:08 ` David Gibson
2018-02-11 22:55 ` Benjamin Herrenschmidt
2018-02-12 2:02 ` Alexey Kardashevskiy
2018-02-12 12:20 ` [Qemu-devel] [Qemu-ppc] " Andrea Bolognani
2018-02-12 14:40 ` Benjamin Herrenschmidt
2018-02-13 1:11 ` Alexey Kardashevskiy
2018-02-13 7:40 ` Cédric Le Goater
2018-02-12 7:10 ` [Qemu-devel] " Cédric Le Goater
2018-04-12 5:16 ` David Gibson
2018-04-12 8:36 ` Cédric Le Goater
2018-04-16 4:29 ` David Gibson
2018-04-19 13:01 ` Cédric Le Goater
2018-04-12 5:15 ` David Gibson
2018-04-12 8:51 ` Cédric Le Goater
2018-04-12 5:10 ` David Gibson
2018-04-12 8:41 ` Cédric Le Goater
2018-04-12 5:08 ` David Gibson
2018-04-12 8:28 ` Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 03/19] spapr: introduce the XIVE interrupt sources Cédric Le Goater
2017-12-14 15:24 ` Cédric Le Goater
2017-12-18 0:59 ` Benjamin Herrenschmidt
2017-12-19 6:37 ` Cédric Le Goater
2017-12-20 5:13 ` David Gibson
2017-12-20 5:22 ` David Gibson
2017-12-20 7:54 ` Cédric Le Goater
2017-12-20 18:08 ` Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 04/19] spapr: add support for the LSI " Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 05/19] spapr: introduce a XIVE interrupt presenter model Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 06/19] spapr: introduce the XIVE Event Queues Cédric Le Goater
2017-12-09 8:43 ` Cédric Le Goater [this message]
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 08/19] spapr: notify the CPU when the XIVE interrupt priority is more privileged Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 09/19] spapr: add support for the SET_OS_PENDING command (XIVE) Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 10/19] spapr: introduce a 'xive_exploitation' boolean to enable XIVE Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 11/19] spapr: add a sPAPRXive object to the machine Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 12/19] spapr: add hcalls support for the XIVE exploitation interrupt mode Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 13/19] spapr: add device tree support for the XIVE " Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 14/19] spapr: introduce a helper to map the XIVE memory regions Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 15/19] spapr: add XIVE support to spapr_qirq() Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 16/19] spapr: introduce a spapr_icp_create() helper Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 17/19] spapr: toggle the ICP depending on the selected interrupt mode Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 18/19] spapr: add support to dump XIVE information Cédric Le Goater
2017-12-09 8:43 ` [Qemu-devel] [PATCH v2 19/19] spapr: advertise XIVE exploitation mode in CAS Cédric Le Goater
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=20171209084338.29395-8-clg@kaod.org \
--to=clg@kaod.org \
--cc=benh@kernel.crashing.org \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).