Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp487218imn; Wed, 27 Jul 2022 11:33:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tZYKcNZ2Nw9RFz5d7VGAsPR98/R/urx5rdqpB/+sA6Uyv/5nn6rgmpygLbhNtWVg/YD6ZJ X-Received: by 2002:a17:906:5d0d:b0:72f:4782:2219 with SMTP id g13-20020a1709065d0d00b0072f47822219mr17931020ejt.498.1658946819164; Wed, 27 Jul 2022 11:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946819; cv=none; d=google.com; s=arc-20160816; b=sk2QZyC1nXc6qJ7YzCZemaLuUwJRJdXkRM8YgbYx8eLsm1X9ngF9aLOSYnGRgIZNps 2mgLNfFcHgNOmJ3Qj92yosK0Wcvu5VJjd+z0ado5a1eTj/4nJ8Gb3dWleeHtuUf4k/Ba nudwBmGbm7j5CmOPZSsYuY3Yx4RQm4dJjF4HnvwkIfWpv1BxCKTQcWdCGnI4hP01eIHk HFh6p958R1/cmMRFiAJzR/KtXItbGvqmuWNjbhJCa486vHZD+UNrpnEhneIes2NanM/C eWLniA8FHQkN7XoW9JDHTgH9rLE/UTKHBWekGL6uE8zeEDYSTnSaGxtLxURAN6ovxNie zGCg== 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=3aWTX0KF3CKdz8vZT5xdCoukjs6D0YJcdiOhEqlSHQU=; b=ogkPICBBMETvPGp0x0CXys0kPcXd6EfBqa1ilK7sxnvyuJDVESq5a6o4zQyyZe6s1w PBAVafBoEzKCNsW+4yD7MGdmzD5o31D2rFy31qVP6Ij/QpNyPCMLTd2LvetutlWyZA94 SmCWwkygHWU8Jr0Z/YiqylCp1iVYk67Sf/xf6sh9U1nHM+5f4orgT8mJcP9jNbgZJxqT 2ch0WHYfkYoIwiXCXcjuajUiD40Aaf2sQmZkjsRztMJFtjKO+umX38SR7A+aGBrmfPDn ZI8I8taibkhy7to13nTCWa3kPhRKjWsHoFlh4yqoZ10UsTQ3jiAClj+Uoig5TI70HUQO QZMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bBQn15pz; 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 hc39-20020a17090716a700b0072fa2e742f4si17704478ejc.906.2022.07.27.11.33.13; Wed, 27 Jul 2022 11:33:39 -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=bBQn15pz; 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 S236924AbiG0Qg4 (ORCPT + 99 others); Wed, 27 Jul 2022 12:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237994AbiG0QfJ (ORCPT ); Wed, 27 Jul 2022 12:35:09 -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 3504E56B98; Wed, 27 Jul 2022 09:27:44 -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 98B5FCE22FE; Wed, 27 Jul 2022 16:27:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5DFDC43470; Wed, 27 Jul 2022 16:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939230; bh=Z4lk6ktUBHjRvZGmo2nriJhEHvGNUYbhpQvob/fyIIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bBQn15pzPtRUD03fi96plEisfMp8W/qiRARSuedqxwt/KBX5u8R1wl9PY0Ekyc4CW LRCNmaASpctPOB0Za6TU3ez0XxHAtvjizoPgSlE325BfRHAh7SsrcsI9nw+jYQNiUA Akp/Uk1F9n/JpfRRop8uTyUY6xuijR2VgcGHpOC8= 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 4.19 59/62] PCI: hv: Fix multi-MSI to allow more than one MSI vector Date: Wed, 27 Jul 2022 18:11:08 +0200 Message-Id: <20220727161006.444801026@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@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(). 4.19 backport - 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 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 @@ -893,6 +893,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. @@ -1240,7 +1255,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, };