From patchwork Wed Jul 17 19:59:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13735729 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C334C3DA60 for ; Wed, 17 Jul 2024 20:00:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=LSUeoxESZ1lQ0498drVFzUtdNeLIeVXCVkSKhIY99Do=; b=vmCEbrnLlHpTDnlojBhd8xE8av Olc5geCpBdWvYCjWWZABs7Dci6BOII78ZU4OZnCbsZGmmlX5pXL1qy4J4uLDAiG+iie9zZlHiKyEb 7R6ZY4D3nLO9VAzPzyrdfWAcT3/Lpw7b4GvrmDi4bupMgjWP7jLd0Pr9ubi+sb2Ux3hGMhDbEk337 tQNK5YsSQljkw9PFHMil++Bk3V6Q04eQZfOLBPUmiaQasxMku+worf1boR47wi0HalmsFZ1QX0BDI GzIITXoWV5VgFtEOxKk/TX8A/eRwWgJGDDTt6V6eTB3AgdqUUgp8J7B+l6XEk/rVvnSTkyW8CL9uL xuJrLkjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUAoz-0000000ElDf-3Q6U; Wed, 17 Jul 2024 20:00:17 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUAoe-0000000El9l-0q5J for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2024 19:59:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 18086CE1822; Wed, 17 Jul 2024 19:59:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 570A1C2BD10; Wed, 17 Jul 2024 19:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721246393; bh=Xa8iIRp/QrL+NXF/NWxhMBa9cqpleNTcaQVEvxD2GyA=; h=From:To:Cc:Subject:Date:From; b=YvrBbTiP1ouucMeyf0JXSOhKE31RMt7HFWj9EVD79VwSP3FQcsah6A3telphThdUV HlF5tYHzmWGRCGcjn87HYNRu4Lzkx1Zi33h0QjhSAKs1+NZuFd5pHBOSSZ6Nh6uBwf bgS7OprjUWNY+ikBvI65OeEqlMSIUfRV9MhLt4SHf+hUFVpV/dQ6Pkeu4KreoJ7fs2 LCc5BFMbgxr43TZLmvp3LIoJoTicCKD/ESAu2NQDkZSRhnYrRab4OEyzhu2u3K6aoT sz5YCDRN32BOnjk8tOL9MvcHgSuWNqsdRy2sTo8QtInolBinpC5g7aJ/PidYOE5w1k FdFTsT/fW3wiQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sUAoY-00DFCv-Gv; Wed, 17 Jul 2024 20:59:50 +0100 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Johan Hovold , Thomas Gleixner Subject: [PATCH] irqchip/gic-v3-its: Correctly honor the RID remapping Date: Wed, 17 Jul 2024 20:59:37 +0100 Message-Id: <20240717195937.2240400-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, johan@kernel.org, tglx@linutronix.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_125956_620607_ACEB781D X-CRM114-Status: GOOD ( 17.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since 6adb35ff43a16 ("irqchip/gic-v3-its: Provide MSI parent for PCI/MSI[-X]"), the primary domain a PCI device allocates its interrupts from is the one that is directly attached to the device itself. By virtue of being a PCI device, it has no OF node. This domain is (through more layer than it is worth describing) passed to its_pci_msi_prepare(), which tries to compute the full RID that is presented to the ITS by the device. This is ultimately done by calling pci_msi_domain_get_msi_rid(), passing both the domain and the PCI device as arguments. The baked-in assumption is that either the domain that is passed to pci_msi_domain_get_msi_rid() describes an interrupt controller with either an OF node or an entry in an ACPI IORT table. In our case, it is *neither*. This domain is does not represent anything firmware-based, but just an allocation unit for the device. As a result, we fail to provide the full RID (which requires inspecting the msi-map/msi-mask properties in the DT), and stick to the BDF, which isn't very useful. Tragedy follows with a litany of devices that randomly die as they fail to see any MSI (because the RID is wrong) or fail to get an allocation (because they try to steal LPIs from their neighbour's pool). This will happen on any system where a single ITS is shared by multiple root ports and end-points with overlapping BDF numbers, and has the topology described in the device-tree. Simpler DT topologies will luckily work, and so will ACPI-based systems. Solve it by pointing pci_msi_domain_get_msi_rid() at the *parent* domain, which is the ITS, resulting in a correct mapping and a restored happiness in my personal zoo. Fixes: 6adb35ff43a16 ("irqchip/gic-v3-its: Provide MSI parent for PCI/MSI[-X]") Reported-by: Johan Hovold Signed-off-by: Marc Zyngier Cc: Thomas Gleixner Tested-by: Johan Hovold --- drivers/irqchip/irq-gic-v3-its-msi-parent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its-msi-parent.c b/drivers/irqchip/irq-gic-v3-its-msi-parent.c index 780e1bc9df549..2f3fc597331ba 100644 --- a/drivers/irqchip/irq-gic-v3-its-msi-parent.c +++ b/drivers/irqchip/irq-gic-v3-its-msi-parent.c @@ -65,7 +65,7 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev, } /* ITS specific DeviceID, as the core ITS ignores dev. */ - info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain, pdev); + info->scratchpad[0].ul = pci_msi_domain_get_msi_rid(domain->parent, pdev); /* * @domain->msi_domain_info->hwsize contains the size of the