qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Isaku Yamahata <yamahata@valinux.co.jp>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 5/6] pci/aer: fix interrupt on config write
Date: Tue, 7 Dec 2010 16:23:06 +0900	[thread overview]
Message-ID: <20101207072306.GD18361@valinux.co.jp> (raw)
In-Reply-To: <6a342f04f29de984ba43f49722d9d8d2fdc3147b.1291330353.git.mst@redhat.com>

Looks good.

On Fri, Dec 03, 2010 at 12:54:43AM +0200, Michael S. Tsirkin wrote:
> config write handling for aer seems broken:
> For example, it won't clear a level interrupt
> when command register is set to 0.
> 
> Make it match the spec: level should equal
> the logical or of enabled bits, msi only
> be sent when the logical or changes.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/pcie_aer.c |   46 +++++++++++++++++-----------------------------
>  1 files changed, 17 insertions(+), 29 deletions(-)
> 
> diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
> index 0fc191f..1c513a7 100644
> --- a/hw/pcie_aer.c
> +++ b/hw/pcie_aer.c
> @@ -749,43 +749,31 @@ void pcie_aer_root_reset(PCIDevice *dev)
>       */
>  }
>  
> -static bool pcie_aer_root_does_trigger(uint32_t cmd, uint32_t status)
> -{
> -    return
> -        ((cmd & PCI_ERR_ROOT_CMD_COR_EN) && (status & PCI_ERR_ROOT_COR_RCV)) ||
> -        ((cmd & PCI_ERR_ROOT_CMD_NONFATAL_EN) &&
> -         (status & PCI_ERR_ROOT_NONFATAL_RCV)) ||
> -        ((cmd & PCI_ERR_ROOT_CMD_FATAL_EN) &&
> -         (status & PCI_ERR_ROOT_FATAL_RCV));
> -}
> -
>  void pcie_aer_root_write_config(PCIDevice *dev,
>                                  uint32_t addr, uint32_t val, int len,
>                                  uint32_t root_cmd_prev)
>  {
>      uint8_t *aer_cap = dev->config + dev->exp.aer_cap;
> -
> -    /* root command register */
> +    uint32_t root_status = pci_get_long(aer_cap + PCI_ERR_ROOT_STATUS);
> +    uint32_t enabled_cmd = pcie_aer_status_to_cmd(root_status);
>      uint32_t root_cmd = pci_get_long(aer_cap + PCI_ERR_ROOT_COMMAND);
> -    if (root_cmd & PCI_ERR_ROOT_CMD_EN_MASK) {
> -        /* 6.2.4.1.2 Interrupt Generation */
> +    /* 6.2.4.1.2 Interrupt Generation */
> +    if (!msix_enabled(dev) && !msi_enabled(dev)) {
> +        qemu_set_irq(dev->irq[dev->exp.aer_intx], !!(root_cmd & enabled_cmd));
> +        return;
> +    }
>  
> -        /* 0 -> 1 */
> -        uint32_t root_cmd_set = ~root_cmd_prev & root_cmd;
> -        uint32_t root_status = pci_get_long(aer_cap + PCI_ERR_ROOT_STATUS);
> -        bool assert = pcie_aer_root_does_trigger(root_cmd_set, root_status);
> +    if ((root_cmd_prev & enabled_cmd) || !(root_cmd & enabled_cmd)) {
> +        /* Send MSI on transition from false to true. */
> +        return;
> +    }
>  
> -        if (msix_enabled(dev)) {
> -            if (assert) {
> -                msix_notify(dev, pcie_aer_root_get_vector(dev));
> -            }
> -        } else if (msi_enabled(dev)) {
> -            if (assert) {
> -                msi_notify(dev, pcie_aer_root_get_vector(dev));
> -            }
> -        } else {
> -            qemu_set_irq(dev->irq[dev->exp.aer_intx], assert);
> -        }
> +    if (msix_enabled(dev)) {
> +        msix_notify(dev, pcie_aer_root_get_vector(dev));
> +    } else if (msi_enabled(dev)) {
> +        msi_notify(dev, pcie_aer_root_get_vector(dev));
> +    } else {
> +        assert(0);
>      }
>  }
>  
> -- 
> 1.7.3.2.91.g446ac
> 

-- 
yamahata

  reply	other threads:[~2010-12-07  7:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-02 22:54 [Qemu-devel] [PATCH 0/6] pcie aer fixes Michael S. Tsirkin
2010-12-02 22:54 ` [Qemu-devel] [PATCH 1/6] pci: untangle pci/msi dependency Michael S. Tsirkin
2010-12-04 13:35   ` [Qemu-devel] " Paolo Bonzini
2010-12-09  9:53     ` Michael S. Tsirkin
2010-12-07  7:21   ` Isaku Yamahata
2010-12-02 22:54 ` [Qemu-devel] [PATCH 3/6] pci/aer: remove dead code Michael S. Tsirkin
2010-12-07  7:29   ` [Qemu-devel] " Isaku Yamahata
2010-12-02 22:54 ` [Qemu-devel] [PATCH 4/6] pci/aer: fix error injection Michael S. Tsirkin
2010-12-02 22:54 ` [Qemu-devel] [PATCH 5/6] pci/aer: fix interrupt on config write Michael S. Tsirkin
2010-12-07  7:23   ` Isaku Yamahata [this message]
2010-12-02 22:54 ` [Qemu-devel] [PATCH 6/6] pci/aer: factor out common code Michael S. Tsirkin
2010-12-07  7:24   ` [Qemu-devel] " Isaku Yamahata
2010-12-02 22:54 ` [Qemu-devel] [PATCH 2/6] Makefile: make msix/msi depend on CONFIG_PCI Michael S. Tsirkin

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=20101207072306.GD18361@valinux.co.jp \
    --to=yamahata@valinux.co.jp \
    --cc=mst@redhat.com \
    --cc=qemu-devel@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).