From patchwork Mon Nov 21 14:39:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13051226 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 B46BEC4332F for ; Mon, 21 Nov 2022 14:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:MIME-Version:References:Subject:Cc :To:From:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=WyO7NCOLnqyWWkd8RW2kNoLcPJo1dJObXzYdVx6BjFo=; b=hfnvRE2sAyKmha bK2cyl6tN2lJyRN6cGj/yoXL6HZfOdxA4fYDL6ogA8f54BHuiKKlGqLfjtfMHZJ/sv4h1DgW2zx3f LBUPDJoAqjS+jlHltGCfXG64LJ25eLgXVWIZRysh652Yr0aa69qR/JsV0+pK/cl0qi+bdlunLp5iZ 7MmovFPJzwJhIwcr95p1cdNWuk8N+b3NRe9IyQWzR8tHFTlhS7spTjXR6xnOLETJAr4Lx2rSqysv7 EhoN4WZDyxWZkacL2/bsYavAb3VqA3ulfSwB3QWa/DrU79zAiKwqKr5dD5ExCaMS/iOACTG+K+oRx oMYLgiQvq11QywfZr4kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox8D3-00EuAo-I1; Mon, 21 Nov 2022 14:55:45 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox7xn-00EikA-95 for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 14:40:00 +0000 Message-ID: <20221121140049.743020502@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=npOaMCiYsoks0F7mHssoAU+zRn6o9Ysh3VW0SdHACSU=; b=3TXaiHo6uW/aaxhnn2KG2Uzs838Y0pUbjSbvGJnh1pBFM2qh0vmz1R1CYFhvBn/V+bBa+P qwqWNnGpZd1K7XNyAJNSF/r8d0eQhQKK2KrWIQcgxFdQV3gJ4j9EGNka2wfvb9+pEC2NWE pUT3CD6XMUO23n406SnSgCqYEEaLypzPm/EI8vzvarXHuJQSZM8qfFKN71TRhILFXcokWs 3m8TcmB+bIaUxk5/fU1lmgPgs9UYAq/aWa4Lrvw7upCGZKXiC6pcPn/vWdkMw+oPDE0qK3 mBY52Bdx0MYXhRgDTIQp8Pi2+l3VhW1IlOhtunxsXWhyA/QRkaBNRVESDO0VkQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=npOaMCiYsoks0F7mHssoAU+zRn6o9Ysh3VW0SdHACSU=; b=AwJHQdeqKACcGONTrz7Gd3yQY8ESpH15ZOH7wfsX2lcP4RybVMRkXhywwStrFS9S/RZXKw 5KwEx0d+A7/tCxDg== From: Thomas Gleixner To: LKML Cc: Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Ammar Faizi , Robin Murphy , Lorenzo Pieralisi , Nishanth Menon , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Vinod Koul , Sinan Kaya , Andy Gross , Bjorn Andersson , Mark Rutland , Shameerali Kolothum Thodi , Zenghui Yu , Shawn Guo , Sascha Hauer , Fabio Estevam Subject: [patch V2 23/40] genirq/irqdomain: Reroute device MSI create_mapping References: <20221121135653.208611233@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:39:57 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_063959_493913_B11D64BB X-CRM114-Status: GOOD ( 14.18 ) 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 Reroute interrupt allocation in irq_create_fwspec_mapping() if the domain is a MSI device domain. This is required to convert the support for wire to MSI bridges to per device MSI domains. Signed-off-by: Thomas Gleixner --- kernel/irq/irqdomain.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -26,6 +26,7 @@ static DEFINE_MUTEX(irq_domain_mutex); static struct irq_domain *irq_default_domain; static void irq_domain_check_hierarchy(struct irq_domain *domain); +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq); struct irqchip_fwid { struct fwnode_handle fwnode; @@ -822,7 +823,10 @@ unsigned int irq_create_fwspec_mapping(s } if (irq_domain_is_hierarchy(domain)) { - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); + if (irq_domain_is_msi_device(domain)) + virq = msi_device_domain_alloc_wired(domain, hwirq, type); + else + virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); if (virq <= 0) return 0; } else { @@ -835,7 +839,7 @@ unsigned int irq_create_fwspec_mapping(s irq_data = irq_get_irq_data(virq); if (!irq_data) { if (irq_domain_is_hierarchy(domain)) - irq_domain_free_irqs(virq, 1); + irq_domain_free_one_irq(domain, virq); else irq_dispose_mapping(virq); return 0; @@ -876,7 +880,7 @@ void irq_dispose_mapping(unsigned int vi return; if (irq_domain_is_hierarchy(domain)) { - irq_domain_free_irqs(virq, 1); + irq_domain_free_one_irq(domain, virq); } else { irq_domain_disassociate(domain, virq); irq_free_desc(virq); @@ -1706,6 +1710,14 @@ void irq_domain_free_irqs(unsigned int v irq_free_descs(virq, nr_irqs); } +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq) +{ + if (irq_domain_is_msi_device(domain)) + msi_device_domain_free_wired(domain, virq); + else + irq_domain_free_irqs(virq, 1); +} + /** * irq_domain_alloc_irqs_parent - Allocate interrupts from parent domain * @domain: Domain below which interrupts must be allocated @@ -1865,9 +1877,9 @@ void irq_domain_set_info(struct irq_doma irq_set_handler_data(virq, handler_data); } -static void irq_domain_check_hierarchy(struct irq_domain *domain) -{ -} +static void irq_domain_check_hierarchy(struct irq_domain *domain) { } +static void irq_domain_free_one_irq(struct irq_domain *domain, unsigned int virq) { } + #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ #ifdef CONFIG_GENERIC_IRQ_DEBUGFS