Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp11589lfv; Tue, 12 Apr 2022 15:12:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz83TmvniPYSGEtEI42Quv3pFzKnw62luBzaD96xsZTIjQqVx0+EZC5xsVtv9213kqldiaM X-Received: by 2002:a05:6a00:238f:b0:4f7:78b1:2f6b with SMTP id f15-20020a056a00238f00b004f778b12f6bmr40224783pfc.17.1649801570987; Tue, 12 Apr 2022 15:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649801570; cv=none; d=google.com; s=arc-20160816; b=lnU+qP8tNIIUBg8HrpueM4+QQ7j3QbX2TPCvtgWPX3MyNpoJBllhW3LGtNFooS6sJI R2Mj2OoSv2/lGTMCAlZQfxmSgGsObRbYESicvexNGokdu0sZkyMUjOcy92LUsGwN8FO/ z42ZXu16+Hm2JXaKCV3glMz2N+dbOPC1kenLH/Cr7oDSDQZpSAwFzb0g2SayLVlmZH1N R+1AApvXN9mTfRtRjxQHHNgLoR7r+TNCv3ZeFXiy5I/1lSDU3lllPbv9flIJnDoGD7e8 /qRxNp844XxoXs/u+4TUN9BNlnwICa1ydrgFt9BlKqQEJONE1YID8XcJZxfJyKwO8yOP OmyQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=GLjqyzQYMnGSzgVdFrP5fPLH9ciyOjiLJCqlZIStZkY=; b=o+n61xldlqq4Kcmmq9AbRVcgv5hiYAeW8z0qXaiBF6dpnsAkcNnvgE1SCRX/b1uPr8 Nr+BiNkpYYR2melsw1uHbTmFUUIjAzuhhkeiISnhVjFSmCRT4prA9tR85x4OEB58YOcK mmRm3QHFPZGXe5qjy6XkQu6MMXX/5TkZXxHSnCm0BNv+4+XOW2EfvLClfnC3pAMZa2g2 z9iyRC1/jxEyE/VfUn4tXANVDDcqqlbowBAxOydCXpgramIAMmDTq3UOnx+ALnAt7TlK eY3EcZmSm7XmXS52km3+DJokkDFb7b0S1InAyakLOZ0Vz8znGui15LBEWsW6cGg827R/ ZpTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xsSYaEVn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id kn11-20020a17090b480b00b001cccf5c187dsi2542129pjb.65.2022.04.12.15.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xsSYaEVn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 231E0185968; Tue, 12 Apr 2022 14:06:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356482AbiDLOTQ (ORCPT + 99 others); Tue, 12 Apr 2022 10:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235000AbiDLOTO (ORCPT ); Tue, 12 Apr 2022 10:19:14 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CB4201B8; Tue, 12 Apr 2022 07:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649773016; x=1681309016; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GLjqyzQYMnGSzgVdFrP5fPLH9ciyOjiLJCqlZIStZkY=; b=xsSYaEVncQdddrNeTwR1zXy0rof6wuhxXROKGHhgI3gvgZGQgVnUvO/2 bwdQR8qb6xh33K5efg3/TiM95BwwHwEZZigrBiUhdASzVM/DZLfrB6z3C p6pmhIRbhXyJX7l4f6yEhIbC9WAEDqPapnVjn46Nb6cGN7NzGNl0Jn6pn A=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 12 Apr 2022 07:16:56 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2022 07:16:55 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Apr 2022 07:16:55 -0700 Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 12 Apr 2022 07:16:54 -0700 From: Jeffrey Hugo To: , , , , , , , , , CC: , , , , Jeffrey Hugo Subject: [PATCH] PCI: hv: Fix multi-MSI to allow more than one MSI vector Date: Tue, 12 Apr 2022 08:16:31 -0600 Message-ID: <1649772991-10285-1-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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(). Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs") Signed-off-by: Jeffrey Hugo --- drivers/pci/controller/pci-hyperv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index d270a204..41be63e 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -614,7 +614,16 @@ static void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry, static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { - return pci_msi_prepare(domain, dev, nvec, info); + int ret = pci_msi_prepare(domain, dev, nvec, info); + + /* + * By using the interrupt remapper in the hypervisor IOMMU, contiguous + * CPU vectors in not needed for multi-MSI + */ + if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) + info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; + + return ret; } /** -- 2.7.4