This is a note to let you know that I've just added the patch titled PCI: hv: Fix multi-MSI to allow more than one MSI vector to the 4.14-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: pci-hv-fix-multi-msi-to-allow-more-than-one-msi-vector.patch and it can be found in the queue-4.14 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 Wed Jul 27 12:33:16 PM CEST 2022 From: Carl Vanderlip <quic_carlv@xxxxxxxxxxx> Date: Mon, 25 Jul 2022 16:33:40 +0000 Subject: PCI: hv: Fix multi-MSI to allow more than one MSI vector To: <stable@xxxxxxxxxxxxxxx> Cc: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx>, <kys@xxxxxxxxxxxxx>, <haiyangz@xxxxxxxxxxxxx>, <sthemmin@xxxxxxxxxxxxx>, <wei.liu@xxxxxxxxxxxxx>, <decui@xxxxxxxxxxxxx>, <lorenzo.pieralisi@xxxxxxx>, <robh@xxxxxxxxxx>, <kw@xxxxxxxxx>, <bhelgaas@xxxxxxxxxx>, Wei Liu <wei.liu@xxxxxxxxxx>, "Carl Vanderlip" <quic_carlv@xxxxxxxxxxx> Message-ID: <20220725163343.13071-2-quic_carlv@xxxxxxxxxxx> From: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx> commit 08e61e861a0e47e5e1a3fb78406afd6b0cea6b6d upstream. If the allocation of multiple MSI vectors for multi-MSI fails in the core PCI framework, the framework will retry the allocation as a single MSI vector, assuming that meets the min_vecs specified by the requesting driver. Hyper-V advertises that multi-MSI is supported, but reuses the VECTOR domain to implement that for x86. The VECTOR domain does not support multi-MSI, so the alloc will always fail and fallback to a single MSI allocation. In short, Hyper-V advertises a capability it does not implement. Hyper-V can support multi-MSI because it coordinates with the hypervisor to map the MSIs in the IOMMU's interrupt remapper, which is something the VECTOR domain does not have. Therefore the fix is simple - copy what the x86 IOMMU drivers (AMD/Intel-IR) do by removing X86_IRQ_ALLOC_CONTIGUOUS_VECTORS after calling the VECTOR domain's pci_msi_prepare(). 4.14 backport - file location change to host/pci-hyperv.c. adds the hv_msi_prepare wrapper function. X86_IRQ_ALLOC_TYPE_PCI_MSI changed to X86_IRQ_ALLOC_TYPE_MSI (same value). Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs") Signed-off-by: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx> Reviewed-by: Dexuan Cui <decui@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/1649856981-14649-1-git-send-email-quic_jhugo@xxxxxxxxxxx Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx> Signed-off-by: Carl Vanderlip <quic_carlv@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/pci/host/pci-hyperv.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -908,6 +908,21 @@ static void hv_irq_mask(struct irq_data pci_msi_mask_irq(data); } +static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, + int nvec, msi_alloc_info_t *info) +{ + int ret = pci_msi_prepare(domain, dev, nvec, info); + + /* + * By using the interrupt remapper in the hypervisor IOMMU, contiguous + * CPU vectors is not needed for multi-MSI + */ + if (info->type == X86_IRQ_ALLOC_TYPE_MSI) + info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; + + return ret; +} + /** * hv_irq_unmask() - "Unmask" the IRQ by setting its current * affinity. @@ -1259,7 +1274,7 @@ static irq_hw_number_t hv_msi_domain_ops static struct msi_domain_ops hv_msi_ops = { .get_hwirq = hv_msi_domain_ops_get_hwirq, - .msi_prepare = pci_msi_prepare, + .msi_prepare = hv_msi_prepare, .set_desc = pci_msi_set_desc, .msi_free = hv_msi_free, }; Patches currently in stable-queue which might be from quic_carlv@xxxxxxxxxxx are queue-4.14/pci-hv-fix-interrupt-mapping-for-multi-msi.patch queue-4.14/pci-hv-fix-multi-msi-to-allow-more-than-one-msi-vector.patch queue-4.14/pci-hv-reuse-existing-irte-allocation-in-compose_msi_msg.patch queue-4.14/pci-hv-fix-hv_arch_irq_unmask-for-multi-msi.patch