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: 23863 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1644523wrr; Mon, 21 Nov 2022 07:09:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf465qnak3/t4UenSLkXQWKl+/c7QG6pxCk9wxlGUD0pVKjmUDOst5PdoG2FGxDCfTSHAcmA X-Received: by 2002:a17:907:c70a:b0:7ad:d6c6:eb7c with SMTP id ty10-20020a170907c70a00b007add6c6eb7cmr8582577ejc.249.1669043347341; Mon, 21 Nov 2022 07:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669043347; cv=none; d=google.com; s=arc-20160816; b=VtFrpS1VKgf7MJygOTCHoM1InXLhkEctk2Ahp6YoOloZ9gi84QgDp6nn0+LYivytRW ftKWlxcZKytVNSXGd3OnCYWX3D3lBWJYrjEv8XftMkPH8etK1tiJG24cP6HZzgiYTRIb GAbJpZbSZKzx6ksK2Qw4GaReJHI6+aTMNl8+NmMAhML/roPeUTorsvAzem9jJEVJ6xXm g2sWCBuh77jUqjmj2alBO8lSUpMwZc0AxAiFCJQdfe9ItzhtZGBn5m79KqiolSRO8gFA tRZmNUuBz3snSAbtLQjGZL6Z9ZhAh/Y1X0pCjI8mrkg7+lctnUyxgzGs8A7D4t+IBElp KUeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=npOaMCiYsoks0F7mHssoAU+zRn6o9Ysh3VW0SdHACSU=; b=JG0vxkcS9iadYuJTTW8HGGSy2/cQaew/Aw2UnzJw/18TbH2rzNOAmRfVqDUKAKZjDg sRZs1uwA9LIavJ2zFnV1O/gAvrCG84LL29mP8Q7ahlCrwDwbKrs1qL7zy9Ar+2i0bpHi sYokIz+V0gohCYaocgp5EStlXJjdzjBpRm9J710h95B20APW2N1rKwgT8O3pWUCFVSlU 70uW9F4zOOjjZFKqjaWlCcKcugvJoCjnZmgkHXY1Sp8h5emDSb2bguojEioJBfWuu5E7 Yi9h4PZuiBbhc5SNnJnuCO13rr6asLPALgYop9wxAYyqOoNvgb9aS+x8eX0vy69TWP6k /cKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3TXaiHo6; dkim=neutral (no key) header.i=@linutronix.de header.b=AwJHQdeq; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb11-20020a170907160b00b007ae6fe0f286si10226897ejc.12.2022.11.21.07.08.07; Mon, 21 Nov 2022 07:09:07 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=3TXaiHo6; dkim=neutral (no key) header.i=@linutronix.de header.b=AwJHQdeq; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbiKUOug (ORCPT + 99 others); Mon, 21 Nov 2022 09:50:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231903AbiKUOtr (ORCPT ); Mon, 21 Nov 2022 09:49:47 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13A0C847F; Mon, 21 Nov 2022 06:42:24 -0800 (PST) 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750118796717848788?= X-GMAIL-MSGID: =?utf-8?q?1750118796717848788?= 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