qemu-devel.nongnu.org archive mirror
 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,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Andrea Bolognani <abologna@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] ppc/pnv: Add model for Power8 PHB3 PCIe Host bridge
Date: Thu, 26 Jul 2018 11:03:18 +0200	[thread overview]
Message-ID: <adea078d-3e69-9ba3-aea7-1e4f8affb1c4@kaod.org> (raw)
In-Reply-To: <20180628083633.12413-2-clg@kaod.org>

Ben,

I have found out recently that the QEMU PowerNV could hang while accessing
the disk. 

The issue seems to be the phb3_msi_try_send() routine when called from 
the resend() handler. The 'P' is ignored in that case but not the 'Q' 
bit which means that no interrupt will be resent if P|Q are set. 

See the log extract below  :

  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005000000fd eff pq=0 prio=5 server=8 ignore_p=0
  PHB3(phb3_msi_set_p): MSI 0: setting P
  PHB3(phb3_msi_set_p):  IVE readback: 0x2005010000fd
  PHB3(phb3_msi_reject): MSI 0 rejected
  PHB3(phb3_msi_resend): MSI resend...
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010000fd eff pq=0 prio=5 server=8 ignore_p=1
  PHB3(phb3_msi_set_p): MSI 0: setting P
  PHB3(phb3_msi_set_p):  IVE readback: 0x2005010000fd
  PHB3(phb3_msi_reject): MSI 0 rejected
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010000fd eff pq=2 prio=5 server=8 ignore_p=0
  PHB3(phb3_msi_set_q): MSI 0: setting Q
  PHB3(phb3_msi_set_q):  IVE readback: 0x2005010100fd
  PHB3(phb3_msi_resend): MSI resend...
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010100fd eff pq=1 prio=5 server=8 ignore_p=1
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010100fd eff pq=3 prio=5 server=8 ignore_p=0
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010100fd eff pq=3 prio=5 server=8 ignore_p=0
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010100fd eff pq=3 prio=5 server=8 ignore_p=0
  PHB3(phb3_msi_try_send): MSI 0: try_send, ive=0x2005010100fd eff pq=3 prio=5 server=8 ignore_p=0
  ... goes on and on ...
  hangs

I have added the relevant code at the bottom of the email. 


If the 'Q' bit is ignored also, the results are good with a SATA drive 
or a SCSI drive using the megasas model. Do you think this is correct ?
I would say so but I am still discovering that part.

I have no idea why it didn't show up before. May be because we mostly 
used virtio-blk.

Thanks,

C. 

> +static void phb3_msi_try_send(Phb3MsiState *msi, int srcno, bool ignore_p)
> +{
> +    ICSState *ics = ICS_BASE(msi);
> +    uint64_t ive;
> +    uint64_t server, prio, pq, gen;
> +
> +    if (!phb3_msi_read_ive(msi->phb, srcno, &ive)) {
> +        return;
> +    }
> +
> +    server = GETFIELD(IODA2_IVT_SERVER, ive);
> +    prio = GETFIELD(IODA2_IVT_PRIORITY, ive);
> +    pq = GETFIELD(IODA2_IVT_Q, ive);
> +    if (!ignore_p) {
> +        pq |= GETFIELD(IODA2_IVT_P, ive) << 1;
> +    }
> +    gen = GETFIELD(IODA2_IVT_GEN, ive);
> +
> +    /*
> +     * The low order 2 bits are the link pointer (Type II interrupts).
> +     * Shift back to get a valid IRQ server.
> +     */
> +    server >>= 2;
> +
> +    switch (pq) {
> +    case 0: /* 00 */
> +        if (prio == 0xff) {
> +            /* Masked, set Q */
> +            phb3_msi_set_q(msi, srcno);
> +        } else {
> +            /* Enabled, set P and send */
> +            phb3_msi_set_p(msi, srcno, gen);
> +            icp_irq(ics, server, srcno + ics->offset, prio);
> +        }
> +        break;
> +    case 2: /* 10 */
> +        /* Already pending, set Q */
> +        phb3_msi_set_q(msi, srcno);
> +        break;
> +    case 1: /* 01 */
> +    case 3: /* 11 */
> +    default:
> +        /* Just drop stuff if Q already set */
> +        break;
> +    }
> +}
> +
> +static void phb3_msi_set_irq(void *opaque, int srcno, int val)
> +{
> +    Phb3MsiState *msi = PHB3_MSI(opaque);
> +
> +    if (val) {
> +        phb3_msi_try_send(msi, srcno, false);
> +    }
> +}

[ ... ]
 
> +static void phb3_msi_resend(ICSState *ics)
> +{
> +    Phb3MsiState *msi = PHB3_MSI(ics);
> +    unsigned int i, j;
> +
> +    if (msi->rba_sum == 0) {
> +        return;
> +    }
> +
> +    for (i = 0; i < 32; i++) {
> +        if ((msi->rba_sum & (1u << i)) == 0) {
> +            continue;
> +        }
> +        msi->rba_sum &= ~(1u << i);
> +        for (j = 0; j < 64; j++) {
> +            if ((msi->rba[i] & (1ull << j)) == 0) {
> +                continue;
> +            }
> +            msi->rba[i] &= ~(1u << j);
> +            phb3_msi_try_send(msi, i * 64 + j, true);
> +        }
> +    }
> +}

  parent reply	other threads:[~2018-07-26  9:03 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-28  8:36 [Qemu-devel] [PATCH v2 0/2] ppc/pnv: Add model for Power8 PHB3 PCIe Host bridge Cédric Le Goater
2018-06-28  8:36 ` [Qemu-devel] [PATCH v2 1/2] " Cédric Le Goater
2018-07-09  7:22   ` Cédric Le Goater
2018-07-18  6:13     ` David Gibson
2018-07-18  6:12   ` David Gibson
2018-07-18  8:03     ` Benjamin Herrenschmidt
2018-07-23  4:16       ` David Gibson
2018-07-23 23:55         ` Benjamin Herrenschmidt
2018-07-24  2:14           ` David Gibson
2018-07-24  3:49             ` Benjamin Herrenschmidt
2018-07-24  4:10               ` David Gibson
2018-07-23 21:35     ` Cédric Le Goater
2018-07-23 21:37     ` Cédric Le Goater
2018-07-24  1:29       ` David Gibson
2018-07-23 21:38     ` Cédric Le Goater
2018-07-24 12:18     ` Cédric Le Goater
2018-07-27  5:32       ` David Gibson
2018-07-27  7:33         ` Cédric Le Goater
2018-07-27  8:08         ` Benjamin Herrenschmidt
2018-07-27  8:25           ` Cédric Le Goater
2018-07-27  8:43             ` Benjamin Herrenschmidt
2018-07-27  9:19               ` Cédric Le Goater
2018-07-30  8:56                 ` Cédric Le Goater
2018-07-26  9:03   ` Cédric Le Goater [this message]
2018-07-26 22:36     ` Benjamin Herrenschmidt
2018-07-27  7:16       ` Cédric Le Goater
2018-07-27  8:18         ` Benjamin Herrenschmidt
2018-06-28  8:36 ` [Qemu-devel] [PATCH v2 2/2] ppc/pnv: make the PHB3 devices user creatable Cédric Le Goater
2018-07-01 18:33 ` [Qemu-devel] [PATCH v2 0/2] ppc/pnv: Add model for Power8 PHB3 PCIe Host bridge no-reply

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=adea078d-3e69-9ba3-aea7-1e4f8affb1c4@kaod.org \
    --to=clg@kaod.org \
    --cc=abologna@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --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).