This is a note to let you know that I've just added the patch titled xen: do not re-use pirq number cached in pci device msi msg data to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xen-do-not-re-use-pirq-number-cached-in-pci-device-msi-msg-data.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Tue Mar 28 13:59:27 CEST 2017 From: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Date: Sat, 25 Mar 2017 21:48:01 +0530 Subject: xen: do not re-use pirq number cached in pci device msi msg data To: stable@xxxxxxxxxxxxxxx Cc: Dan Streetman <ddstreet@xxxxxxxx>, Dan Streetman <dan.streetman@xxxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Sasha Levin <alexander.levin@xxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Sumit Semwal <sumit.semwal@xxxxxxxxxx> Message-ID: <1490458699-24484-2-git-send-email-sumit.semwal@xxxxxxxxxx> From: Sumit Semwal <sumit.semwal@xxxxxxxxxx> From: Dan Streetman <ddstreet@xxxxxxxx> [ Upstream commit c74fd80f2f41d05f350bb478151021f88551afe8 ] Revert the main part of commit: af42b8d12f8a ("xen: fix MSI setup and teardown for PV on HVM guests") That commit introduced reading the pci device's msi message data to see if a pirq was previously configured for the device's msi/msix, and re-use that pirq. At the time, that was the correct behavior. However, a later change to Qemu caused it to call into the Xen hypervisor to unmap all pirqs for a pci device, when the pci device disables its MSI/MSIX vectors; specifically the Qemu commit: c976437c7dba9c7444fb41df45468968aaa326ad ("qemu-xen: free all the pirqs for msi/msix when driver unload") Once Qemu added this pirq unmapping, it was no longer correct for the kernel to re-use the pirq number cached in the pci device msi message data. All Qemu releases since 2.1.0 contain the patch that unmaps the pirqs when the pci device disables its MSI/MSIX vectors. This bug is causing failures to initialize multiple NVMe controllers under Xen, because the NVMe driver sets up a single MSIX vector for each controller (concurrently), and then after using that to talk to the controller for some configuration data, it disables the single MSIX vector and re-configures all the MSIX vectors it needs. So the MSIX setup code tries to re-use the cached pirq from the first vector for each controller, but the hypervisor has already given away that pirq to another controller, and its initialization fails. This is discussed in more detail at: https://lists.xen.org/archives/html/xen-devel/2017-01/msg00447.html Fixes: af42b8d12f8a ("xen: fix MSI setup and teardown for PV on HVM guests") Signed-off-by: Dan Streetman <dan.streetman@xxxxxxxxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/pci/xen.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -231,23 +231,14 @@ static int xen_hvm_setup_msi_irqs(struct return 1; for_each_pci_msi_entry(msidesc, dev) { - __pci_read_msi_msg(msidesc, &msg); - pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) | - ((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff); - if (msg.data != XEN_PIRQ_MSI_DATA || - xen_irq_from_pirq(pirq) < 0) { - pirq = xen_allocate_pirq_msi(dev, msidesc); - if (pirq < 0) { - irq = -ENODEV; - goto error; - } - xen_msi_compose_msg(dev, pirq, &msg); - __pci_write_msi_msg(msidesc, &msg); - dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq); - } else { - dev_dbg(&dev->dev, - "xen: msi already bound to pirq=%d\n", pirq); + pirq = xen_allocate_pirq_msi(dev, msidesc); + if (pirq < 0) { + irq = -ENODEV; + goto error; } + xen_msi_compose_msg(dev, pirq, &msg); + __pci_write_msi_msg(msidesc, &msg); + dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq); irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq, (type == PCI_CAP_ID_MSI) ? nvec : 1, (type == PCI_CAP_ID_MSIX) ? Patches currently in stable-queue which might be from sumit.semwal@xxxxxxxxxx are queue-4.4/pci-add-comments-about-rom-bar-updating.patch queue-4.4/acpi-blacklist-make-dell-latitude-3350-ethernet-work.patch queue-4.4/s390-zcrypt-introduce-cex6-toleration.patch queue-4.4/block-allow-write_same-commands-with-the-sg_io-ioctl.patch queue-4.4/pci-do-any-vf-bar-updates-before-enabling-the-bars.patch queue-4.4/x86-hyperv-handle-unknown-nmis-on-one-cpu-when-unknown_nmi_panic.patch queue-4.4/serial-8250_pci-detach-low-level-driver-during-pci-error-recovery.patch queue-4.4/xen-do-not-re-use-pirq-number-cached-in-pci-device-msi-msg-data.patch queue-4.4/pci-separate-vf-bar-updates-from-standard-bar-updates.patch queue-4.4/pci-ignore-bar-updates-on-virtual-functions.patch queue-4.4/pci-update-bars-using-property-bits-appropriate-for-type.patch queue-4.4/vfio-spapr-postpone-allocation-of-userspace-version-of-tce-table.patch queue-4.4/pci-don-t-update-vf-bars-while-vf-memory-space-is-enabled.patch queue-4.4/igb-workaround-for-igb-i210-firmware-issue.patch queue-4.4/pci-remove-pci_resource_bar-and-pci_iov_resource_bar.patch queue-4.4/pci-decouple-ioresource_rom_enable-and-pci_rom_address_enable.patch queue-4.4/acpi-blacklist-add-_rev-quirks-for-dell-precision-5520-and-3520.patch queue-4.4/igb-add-i211-to-i210-phy-workaround.patch queue-4.4/uvcvideo-uvc_scan_fallback-for-webcams-with-broken-chain.patch