All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Gavin Shan <shangw@linux.vnet.ibm.com>, alex.williamson@redhat.com
Cc: kvm@vger.kernel.org, benh@kernel.crashing.org
Subject: Re: [PATCH 3/3] drivers/vfio/pci: Fix MSIx message lost
Date: Wed, 02 Apr 2014 12:16:40 +1100	[thread overview]
Message-ID: <533B64F8.2060306@ozlabs.ru> (raw)
In-Reply-To: <1394430415-15574-4-git-send-email-shangw@linux.vnet.ibm.com>

On 03/10/2014 04:46 PM, Gavin Shan wrote:
> The problem is specific to the case of BIST reset issued to IPR
> adapter on the guest side. The IPR driver calls pci_save_state(),
> issues BIST reset and then pci_restore_state(). The issued BIST
> cleans out MSIx table and pci_restore_state() doesn't restore
> the MSIx table as expected. Eventually, MSIx messages with all
> zeros are sent and causes EEH error on Power platform.
> 
> The patch fixes it by writing MSIx message to MSIx table before
> reenabling the individual interrupts in the following path:
> 
> qemu/hw/pci/msix.c::msix_table_mmio_write
>                     msix_handle_mask_update
>                     msix_fire_vector_notifier
> qemu/hw/misc/vfio.c::vfio_msix_vector_use
>                     vfio_msix_vector_do_use
> 
> IOCTL Command VFIO_DEVICE_SET_IRQS to VFIO-PCI
> vfio/pci/vfio_pci.c::vfio_pci_ioctl
> vfio/pci/vfio_pci_intrs.c::vfio_pci_set_irqs_ioctl
>                     vfio_pci_set_msi_trigger
>                     vfio_msi_set_block
>                     vfio_msi_set_vector_signal
> 
> Reported-by: Wen Xiong <wenxiong@us.ibm.com>
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> ---
>  drivers/vfio/pci/vfio_pci_intrs.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
> index 2103576..83e0638 100644
> --- a/drivers/vfio/pci/vfio_pci_intrs.c
> +++ b/drivers/vfio/pci/vfio_pci_intrs.c
> @@ -17,6 +17,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/eventfd.h>
>  #include <linux/pci.h>
> +#include <linux/msi.h>
>  #include <linux/file.h>
>  #include <linux/poll.h>
>  #include <linux/vfio.h>
> @@ -517,6 +518,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
>  	struct pci_dev *pdev = vdev->pdev;
>  	int irq = msix ? vdev->msix[vector].vector : pdev->irq + vector;
>  	char *name = msix ? "vfio-msix" : "vfio-msi";
> +	struct msi_msg msg;
>  	struct eventfd_ctx *trigger;
>  	int ret;
>  
> @@ -544,6 +546,15 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
>  		return PTR_ERR(trigger);
>  	}
>  
> +	/* We possiblly lose the MSI/MSIx message in some cases, one
> +	 * of which is pci_save_state(), BIST reset and pci_restore_state()
> +	 * for IPR adapter. The BIST reset cleans out MSIx table and we
> +	 * don't have chance to restore it. Here, we have the trick to
> +	 * restore it before enabling individual interrupts. For MSI messages,
> +	 * it's harmless to write them back.
> +	 */
> +	get_cached_msi_msg(irq, &msg);
> +	write_msi_msg(irq, &msg);
>  	ret = request_irq(irq, vfio_msihandler, 0,
>  			  vdev->ctx[vector].name, trigger);
>  	if (ret) {
> 


This is missing to successfully compile VFIO as modules:


diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 2c10752..80ba2e9 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -283,6 +283,7 @@ void get_cached_msi_msg(unsigned int irq, struct
msi_msg *msg)

        __get_cached_msi_msg(entry, msg);
 }
+EXPORT_SYMBOL_GPL(get_cached_msi_msg);

 void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 {
@@ -327,6 +328,7 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg)

        __write_msi_msg(entry, msg);
 }
+EXPORT_SYMBOL_GPL(write_msi_msg);

 static void free_msi_irqs(struct pci_dev *dev)
 {




-- 
Alexey

  parent reply	other threads:[~2014-04-02  1:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10  5:46 [PATCH 0/3] VFIO Bug Fixes Gavin Shan
2014-03-10  5:46 ` [PATCH 1/3] drivers/vfio: Rework offsetofend() Gavin Shan
2014-03-10  5:46 ` [PATCH 2/3] drivers/vfio/pci: Fix wrong MSI interrupt count Gavin Shan
2014-03-10  5:46 ` [PATCH 3/3] drivers/vfio/pci: Fix MSIx message lost Gavin Shan
2014-03-17 22:16   ` Alex Williamson
     [not found]     ` <20140318013238.GA9843@shangw.(null)>
2014-03-18 22:44       ` Alex Williamson
2014-04-02  1:16   ` Alexey Kardashevskiy [this message]
2014-04-02  1:36     ` Alex Williamson
  -- strict thread matches above, loose matches on Subject: below --
2014-03-03  3:24 [PATCH 1/3] drivers/vfio: Rework offsetofend() Gavin Shan
2014-03-03  3:24 ` [PATCH 3/3] drivers/vfio/pci: Fix MSIx message lost Gavin Shan
2014-03-03  3:51   ` Benjamin Herrenschmidt
2014-03-03  4:43     ` Alexey Kardashevskiy
2014-03-03  5:00       ` Benjamin Herrenschmidt
2014-03-03  4:49     ` Alex Williamson
2014-03-03  5:05       ` Benjamin Herrenschmidt
     [not found]       ` <20140303061036.GA4447@shangw.(null)>
2014-03-03 19:36         ` Alex Williamson
     [not found]           ` <20140304023018.GA21672@shangw.(null)>
2014-03-04 20:45             ` Alex Williamson

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=533B64F8.2060306@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=kvm@vger.kernel.org \
    --cc=shangw@linux.vnet.ibm.com \
    /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.