From patchwork Wed Jul 13 12:56:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1655990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=HdN9aYiO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ljd1v2QqHz9sFr for ; Wed, 13 Jul 2022 22:57:23 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oBbvN-0006CE-Am; Wed, 13 Jul 2022 12:57:05 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oBbvL-00069a-M7 for kernel-team@lists.ubuntu.com; Wed, 13 Jul 2022 12:57:03 +0000 Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B8D3D3FA41 for ; Wed, 13 Jul 2022 12:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657717022; bh=dLCMaZ+hP63Ieb4N2IC++BXQ1ZfRb+HEryqfiBkeZDI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HdN9aYiODl/V+P9fZya1Eq955kN6Cl5uSYwyIRtZPDpwc2NrFY2tuXGc+/miC9Wc8 RqAChEb2jgziEkPWfuL9e2pgpDwSfgP/fJfiHznbPkkqHB6KU1r0p1U4zGz1IZ7ueo QHSU4kKT8kq21/BacEOJSDR5OM29dKGY7vlhwHff9dQPglsZN4l8B23iS9/sy9ie4p uPzzu6QjFog0u/ZZVZhqME5po0nlCrKueobPoZekEKAbssT2/Cps6pPRx40sAw6lm/ xokBh8dcuoBhUbjGB1AiDkUyuLqUsxKKfVNkakzLIo4wcYrIeYjVb4bM2lc6R2ObrE gGbjcuZHGEVpw== Received: by mail-pj1-f72.google.com with SMTP id n14-20020a17090a2bce00b001ef85fef37fso1474162pje.7 for ; Wed, 13 Jul 2022 05:57:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dLCMaZ+hP63Ieb4N2IC++BXQ1ZfRb+HEryqfiBkeZDI=; b=URKcRt7FyRUtDxfKRRskDYye8DsY0CLUQkll+m8gK3OfJLmLnOLARzYwCLElmsiKKj sK/HCnSAkFTr+OHBXbKo2pLaUScNKjGPduoE/tHAHhg3bruV81XANPSPkyIYgNE8imIT cFVNFiWbvsRrKOoSAFfnwW0SzrYavvif4uxStH6CIIRe6ubC0gylhYieWD8MfmBmz0JT mJIP03P3o67rhwVlstrhEk0ek7jncQ90sfeVSFl1uk9INYhbIcGAigEI7Hwc4TiwZP6N 6MvqzsQ036KmuegEbc9lMmyq+jb0heH09d6kQGgIzqMjaRDq/CbkzxUedTrtcfMfeYjE gZlQ== X-Gm-Message-State: AJIora+NqEFWAP9YHergK2j+UyCohn0RXRDSS+sZFfzwyYO3PkO/GtZ0 U/UD64RtKpSk7iav0rKEvmbfIx+cFYLFrIWka8tSidX+GhIMgd5K+gvtoyt2sT6WOhmhHBax0IS NK96FR31kb6fpXrVlIZDS5SdHM2BlugPRO43xgk3G3g== X-Received: by 2002:a17:90a:2c0d:b0:1ef:c839:c34b with SMTP id m13-20020a17090a2c0d00b001efc839c34bmr10276837pjd.39.1657717020219; Wed, 13 Jul 2022 05:57:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vUXePm7oqILSsymLHW+56GfYB2kKlH1wHUEhgAp3WyxMiLZVjRxUyvVvUecViaU0wNKyIY2A== X-Received: by 2002:a17:90a:2c0d:b0:1ef:c839:c34b with SMTP id m13-20020a17090a2c0d00b001efc839c34bmr10276816pjd.39.1657717019968; Wed, 13 Jul 2022 05:56:59 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id k91-20020a17090a14e400b001ec798b0dc4sm1551135pja.38.2022.07.13.05.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 05:56:58 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4][Focal/linux-azure] PCI: hv: Fix multi-MSI to allow more than one MSI vector Date: Wed, 13 Jul 2022 06:56:35 -0600 Message-Id: <20220713125649.24063-2-tim.gardner@canonical.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220713125649.24063-1-tim.gardner@canonical.com> References: <20220713125649.24063-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeffrey Hugo BugLink: https://bugs.launchpad.net/bugs/1981577 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 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 (backported from commit 08e61e861a0e47e5e1a3fb78406afd6b0cea6b6d) [rtg - Missing commit 801b5e4c4eec7b6c7f968d4bbce43da7cacffae4 ("x86_irq_Rename_X86_IRQ_ALLOC_TYPE_MSI_to_reflect_PCI_dependency"). Use X86_IRQ_ALLOC_TYPE_MSI instead. ] Signed-off-by: Tim Gardner --- 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 5714c313f548..7d38cda1cacf 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -619,7 +619,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 is not needed for multi-MSI + */ + if (info->type == X86_IRQ_ALLOC_TYPE_MSI) + info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; + + return ret; } #elif defined(CONFIG_ARM64) /*