From patchwork Thu Apr 6 16:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stanislav Kinsburskii X-Patchwork-Id: 13205418 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF39EC77B6E for ; Fri, 7 Apr 2023 20:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbjDGU6W (ORCPT ); Fri, 7 Apr 2023 16:58:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbjDGU6T (ORCPT ); Fri, 7 Apr 2023 16:58:19 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45E1AC17E; Fri, 7 Apr 2023 13:58:17 -0700 (PDT) Received: from skinsburskii.localdomain (unknown [131.107.1.229]) by linux.microsoft.com (Postfix) with ESMTPSA id AE674213B634; Fri, 7 Apr 2023 13:58:16 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AE674213B634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680901096; bh=32mhPLCSnFqlWC0muL7q44icEI++yknNcaEQIU1ZLvE=; h=Subject:From:Cc:Date:In-Reply-To:References:From; b=rLRQUe03PQBMKbXvSZ/VJWDxgdc9PySimsj3H5+d3DxKwZjzOd7WeHSUUetID2zxh nayWNjg4p5Co3J52iHGyG4JgzQm14NIt/oJhXv8wMvDRwEzY6CKH3KWd94mThdmOxA wVJYjO39KNVcye7uCLbs6BOrthe+MQi/hGzv8c+c= Subject: [PATCH 2/2] PCI: hv: Deal with nested MSHV setup From: Stanislav Kinsburskii Cc: Stanislav Kinsburskii , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 06 Apr 2023 09:33:24 -0700 Message-ID: <168079879905.14175.16212926378045082102.stgit@skinsburskii.localdomain> In-Reply-To: <168079806973.14175.17999267023207421381.stgit@skinsburskii.localdomain> References: <168079806973.14175.17999267023207421381.stgit@skinsburskii.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Stanislav Kinsburskii Running Microsoft hypervisor as nested (i.e., on top of another Microsoft hypervisor) imposes a different requirement for the PCI-hyperv controller. In this setup, the interrupt will first come to the nested (L1) hypervisor from the hypervisor, running on bare metal (L0), and then the L1 hypervisor will deliver the interrupt to the appropriate CPU of the nested root partition. Thus, instead of issuing the RETARGET hypercall to the L0 hypervisor, MAP_DEVICE_INTERRUPT hypercall should be issued to the L1 hypervisor to complete the interrupt setup. Signed-off-by: Stanislav Kinsburskii CC: "K. Y. Srinivasan" CC: Haiyang Zhang CC: Wei Liu CC: Dexuan Cui CC: Lorenzo Pieralisi CC: "Krzysztof WilczyƄski" CC: Rob Herring CC: Bjorn Helgaas CC: linux-hyperv@vger.kernel.org CC: linux-pci@vger.kernel.org CC: linux-kernel@vger.kernel.org --- 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 f33370b75628..61bee8babad4 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1570,7 +1570,16 @@ static void hv_irq_mask(struct irq_data *data) static void hv_irq_unmask(struct irq_data *data) { - hv_arch_irq_unmask(data); + if (hv_nested && hv_root_partition) + /* + * In case of the nested root partition, the nested hypervisor + * is taking care of interrupt remapping and thus the + * MAP_DEVICE_INTERRUPT hypercall is required instead of the + * RETARGET_INTERRUPT one. + */ + (void)hv_map_msi_interrupt(data, NULL); + else + hv_arch_irq_unmask(data); if (data->parent_data->chip->irq_unmask) irq_chip_unmask_parent(data);