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,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [Qemu-devel] [PATCH for-2.10 6/8] ppc/pnv: Add cut down PSI bridge model and hookup external interrupt
Date: Tue, 21 Mar 2017 14:36:19 +0100 [thread overview]
Message-ID: <bf3a15e3-9ba5-0dcb-dc83-b24a9f36e085@kaod.org> (raw)
In-Reply-To: <b6948010-fe70-0fa9-89fc-ce8061b7c119@kaod.org>
[ ... ]
>>> +void pnv_psi_irq_set(PnvPsi *psi, PnvPsiIrq irq, bool state)
>>> +{
>>> + ICSState *ics = &psi->ics;
>>> + uint32_t xivr_reg;
>>> + uint32_t stat_reg;
>>> + uint64_t stat_bit;
>>> + uint32_t src;
>>> + bool masked;
>>> +
>>> + if (!pnv_psi_irq_bits(psi, irq, &xivr_reg, &stat_reg, &stat_bit)) {
>>> + qemu_log_mask(LOG_GUEST_ERROR, "PSI: Unsupported irq %d\n", irq);
>>> + return;
>>> + }
>>> +
>>> + src = (psi->regs[xivr_reg] & PSIHB_XIVR_SRC_MSK) >> PSIHB_XIVR_SRC_SH;
>>> + masked = (psi->regs[xivr_reg] & PSIHB_XIVR_PRIO_MSK) == PSIHB_XIVR_PRIO_MSK;
>>> + if (state) {
>>> + psi->regs[stat_reg] |= stat_bit;
>>> + /* XXX optimization: check mask here. That means re-evaluating
>>> + * when unmasking, thus TODO
>>> + */
>>> + qemu_irq_raise(ics->qirqs[src]);
>>> + } else {
>>> + psi->regs[stat_reg] &= ~stat_bit;
>>> +
>>> + /* FSP and PSI are muxed so don't lower if either still set */
>>> + if (stat_reg != PSIHB_XSCOM_CR ||
>>> + !(psi->regs[stat_reg] & (PSIHB_CR_PSI_IRQ | PSIHB_CR_FSP_IRQ))) {
>>> + qemu_irq_lower(ics->qirqs[src]);
>>> + } else {
>>> + state = true;
ugly.
>>> + }
>>> + }
>>
>> It might be cleaner to just revaluate the irq level from scratch here,
>> and set the level, rather than doing this complicated dance to work
>> out if it has changed.
>
> OK. I need to take a closer look at that.
So I took a closer a look and some parts are not clear, even if
correct. The FSP and PSI interrupts are muxed and the above code
tries to re-conciliate the IRQ triggering in a single routine.
But we ended up (I think) using some hacks. See below PnvPsiIrq.
[ ... ]
>>> +static void pnv_psi_realize(DeviceState *dev, Error **errp)
>>> +{
>>> + PnvPsi *psi = PNV_PSI(dev);
>>> + ICSState *ics = &psi->ics;
>>> + Object *obj;
>>> + Error *err = NULL, *local_err = NULL;
>>> + unsigned int i;
>>> +
>>> + /* Initialize MMIO region */
>>> + memory_region_init_io(&psi->regs_mr, OBJECT(dev), &psi_mmio_ops, psi,
>>> + "psihb", PNV_PSIHB_BAR_SIZE);
>>> +
>>> + /* Default BAR. Use object properties ? */
>>> + pnv_psi_set_bar(psi, PNV_PSIHB_BAR | PSIHB_BAR_EN);
>>> +
>>> + /* Default sources in XIVR */
>>> + psi->regs[PSIHB_XSCOM_XIVR_PSI] = PSIHB_XIVR_PRIO_MSK |
>>> + (0ull << PSIHB_XIVR_SRC_SH);
>>> + psi->regs[PSIHB_XSCOM_XIVR_OCC] = PSIHB_XIVR_PRIO_MSK |
>>> + (1ull << PSIHB_XIVR_SRC_SH);
>>> + psi->regs[PSIHB_XSCOM_XIVR_FSI] = PSIHB_XIVR_PRIO_MSK |
>>> + (2ull << PSIHB_XIVR_SRC_SH);
>>> + psi->regs[PSIHB_XSCOM_XIVR_LPCI2C] = PSIHB_XIVR_PRIO_MSK |
>>> + (3ull << PSIHB_XIVR_SRC_SH);
>>> + psi->regs[PSIHB_XSCOM_XIVR_LOCERR] = PSIHB_XIVR_PRIO_MSK |
>>> + (4ull << PSIHB_XIVR_SRC_SH);
>>> + psi->regs[PSIHB_XSCOM_XIVR_EXT] = PSIHB_XIVR_PRIO_MSK |
>>> + (5ull << PSIHB_XIVR_SRC_SH);
>>> +
The above is not using a loop on PnvPsiIrq because the numbers
do not match the PSI IRQ definitions.
[ ... ]
>>> +
>>> +typedef enum PnvPsiIrq {
>>> + PSIHB_IRQ_PSI, /* internal use only */
>>> + PSIHB_IRQ_FSP, /* internal use only */
>>> + PSIHB_IRQ_OCC,
>>> + PSIHB_IRQ_FSI,
>>> + PSIHB_IRQ_LPC_I2C,
>>> + PSIHB_IRQ_LOCAL_ERR,
>>> + PSIHB_IRQ_EXTERNAL,
>>> +} PnvPsiIrq;
>>> +
>>> +#define PSI_NUM_INTERRUPTS 6
a maximum of 6 interrupts for an enum containing 7 entries. It is a
little ugly.
I am going to rewrite this part in a more straight forward way.
C.
next prev parent reply other threads:[~2017-03-21 13:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 10:52 [Qemu-devel] [PATCH for-2.10 0/8] ppc/pnv: interrupt controller (POWER8) Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 1/8] ppc/xics: add a xics_get_cpu_index_by_pir() helper Cédric Le Goater
2017-03-14 5:38 ` David Gibson
2017-03-14 8:11 ` Cédric Le Goater
2017-03-14 17:00 ` Cédric Le Goater
2017-03-15 4:53 ` David Gibson
2017-03-15 10:04 ` Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 2/8] ppc/xics: add an ics_eoi() handler to XICSFabric Cédric Le Goater
2017-03-14 5:40 ` David Gibson
2017-03-14 8:12 ` Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 3/8] ppc/pnv: create the ICP and ICS objects under the machine Cédric Le Goater
2017-03-14 5:45 ` David Gibson
2017-03-14 9:47 ` Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 4/8] ppc/pnv: add memory regions for the ICP registers Cédric Le Goater
2017-03-08 11:24 ` Philippe Mathieu-Daudé
2017-03-08 13:33 ` Cédric Le Goater
2017-03-14 5:49 ` David Gibson
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 5/8] ppc/pnv: map the ICP memory regions Cédric Le Goater
2017-03-14 5:52 ` David Gibson
2017-03-14 10:02 ` Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 6/8] ppc/pnv: Add cut down PSI bridge model and hookup external interrupt Cédric Le Goater
2017-03-15 6:16 ` David Gibson
2017-03-15 9:38 ` Benjamin Herrenschmidt
2017-03-16 13:52 ` Cédric Le Goater
2017-03-17 2:00 ` David Gibson
2017-03-17 8:27 ` Cédric Le Goater
2017-03-21 13:36 ` Cédric Le Goater [this message]
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 7/8] ppc/pnv: Add OCC model stub with interrupt support Cédric Le Goater
2017-03-08 10:52 ` [Qemu-devel] [PATCH for-2.10 8/8] ppc/pnv: Add support for POWER8+ LPC Controller 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=bf3a15e3-9ba5-0dcb-dc83-b24a9f36e085@kaod.org \
--to=clg@kaod.org \
--cc=benh@kernel.crashing.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.