Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp476495imn; Wed, 27 Jul 2022 11:16:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tYsoFh7vlZHHn3Rm/dSTAYrKbXwQqKVG33Vr+Z6Tx1m44ywWnguIDyizYX1l2weztjJuee X-Received: by 2002:a17:907:3f07:b0:72b:54b2:f57f with SMTP id hq7-20020a1709073f0700b0072b54b2f57fmr18258122ejc.502.1658945772845; Wed, 27 Jul 2022 11:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945772; cv=none; d=google.com; s=arc-20160816; b=DhnOoEB5qSb4p4enZqRagT/9peGxT2l19ogFOUSjhXRQBpRwwcDvyP3H5f8iJKCc5Q aTmTEGALAo4LXTktSCEXe3diBeIuWRRaoMpIjtlPhNvPB1PNpTATwln91IfJBUr0CJl8 Aj95Ns/WQZEFSRsVRVaY5OMvq6itjSkmHY/HSqWF1VriGZRGcbv8r8V6m8Efm3Y2eZS4 aqRPw3GsEBfOg4QxkCGFcjCfUeoirBjhysuweFGMgBHxBWSbXzyLViaV1FwPAm9rkrTZ 5YDkfQcyWI1cu0NRmagmFT2+tI9aXhcIolT+Qklc6wFbgSDVm86/R1BLkxsvvpJPRnY8 ue9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DPWbq0bDyvJI3eCkllThAsq2Nq/BeDUT2UFNFjl1RZY=; b=cqO14Lwn4i6Z2RKr63KhqwMETn6i36mn3OxoPoJlKH9Prd9hav2n7MqpXG9rS/P440 UxFWjgoLEP+m7RM127ZBJemQmDf96EJegT8VEdpIR/utxbKxrUjIyPGQlcPo6+36O1fB n8PAD6dTBCQhsF0y20m9cxsIkN/dLZL18iMrsj2v32vBIaj35JLeyOgZW7DeB9LsFTpO QgIGqX+562lk/rbko6sOsdwnEfAVjEOfM5krAW9/94Ld8v77kZufmb4czHoU+XIgh502 F7qV5yA8OUYQlf3KJQa3uj2WX0FAsJwqKwKBFi16ficLjy3FxNXX2yiOpj2QPx8hoeAw Q13A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wAqT5Rgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk39-20020a1709077fa700b0072f67932939si20321691ejc.865.2022.07.27.11.15.47; Wed, 27 Jul 2022 11:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wAqT5Rgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240610AbiG0QtD (ORCPT + 99 others); Wed, 27 Jul 2022 12:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240381AbiG0QsS (ORCPT ); Wed, 27 Jul 2022 12:48:18 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 355A5606BC; Wed, 27 Jul 2022 09:32:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9DF85CE2314; Wed, 27 Jul 2022 16:32:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C2E7C433D6; Wed, 27 Jul 2022 16:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939539; bh=Adbbu1OtqKpBLR7cImkQjexzh2KtnEpmmMYEVwK8/Ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wAqT5Rgsy9Agzam+AtWM4F6deGindjYrlnN34ldtVTAP2pNK1RdX+Mm4aPve8m7Ty PYaSTzxLnK4njAtJxgi9Lm6YfF6pw8jmXZN8TjxUXciwwBp5XF/TuWM6IiWo/wowkl BSkk+mnalaU2oNb2a6mx2T/3sYeWfyqySKeQmYRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Jeffrey Hugo , Dexuan Cui , Wei Liu , Carl Vanderlip Subject: [PATCH 5.10 017/105] PCI: hv: Fix multi-MSI to allow more than one MSI vector Date: Wed, 27 Jul 2022 18:10:03 +0200 Message-Id: <20220727161012.776500218@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161012.056867467@linuxfoundation.org> References: <20220727161012.056867467@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeffrey Hugo 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(). 5.10 backport - adds the hv_msi_prepare wrapper function Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs") Signed-off-by: Jeffrey Hugo Reviewed-by: Dexuan Cui Link: https://lore.kernel.org/r/1649856981-14649-1-git-send-email-quic_jhugo@quicinc.com Signed-off-by: Wei Liu Signed-off-by: Carl Vanderlip Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-hyperv.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1180,6 +1180,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_PCI_MSI) + info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; + + return ret; +} + /** * hv_irq_unmask() - "Unmask" the IRQ by setting its current * affinity. @@ -1545,7 +1560,7 @@ static struct irq_chip hv_msi_irq_chip = }; static struct msi_domain_ops hv_msi_ops = { - .msi_prepare = pci_msi_prepare, + .msi_prepare = hv_msi_prepare, .msi_free = hv_msi_free, };