From patchwork Mon Nov 21 14:36:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626328wrr; Mon, 21 Nov 2022 06:37:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Gf9L1Zb+luvXCojKhDwOeUtimJDqROeK7RtodwUORnD/m7n5RK9mesQ3Bhwv499mpK3tt X-Received: by 2002:a05:6a00:27ab:b0:56c:71a4:efe with SMTP id bd43-20020a056a0027ab00b0056c71a40efemr3515297pfb.84.1669041449524; Mon, 21 Nov 2022 06:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041449; cv=none; d=google.com; s=arc-20160816; b=1LgKVl/KSxmMTzkSQtIMqydnm3up+ZNfva+XS1lD/ylWEZDGnABI6noTAdJNfGwoim BuAjZuDhsXefl6BfjVxNcEJou3STQRLDwGbh3yJHvQFMjfnLDQ5pNKcDTAdiJvxJeE8m GfCyN06d58nqidYw6/fRXWb8vXf8h2tW09t1XvpSWdALUyPt92sfFo4OWZi5D3dIiyq7 SHY7KVSBGxym8li4meZKZY7MTAvt5gFfNyErE7pUXj4HKTCuqUl1H6njN+Thvk3FS/p/ Jlh2Zgb+tMo/Kbr5iMHQjkiEM6zc0cCk044YDr+Cy61X18p+BtQ/P5dlipCpO1lwGFhh 2dQw== 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=XzEU6xpUtYERldMqsji8DXGQ2kRnY83P6uKMpYacBXc=; b=GgfdRvaMR56y3cJAslVT1/FIE2VHJznfO/6DU4ejUe9mpiVVJl6f41zVZcPdNe13q5 AEWZVOGDwc/ePla0v58xhWpp1CxRUIwwRdQiCfR8rqtIgwA4qUhtAb9Mk1jhrn3tN66L 0jPo4jhPQwMaS7m8Ron1a8gIJhTs/peE5oRlVgkoWbJp+ICeNUGJtKXvZQAvbT0z7AIZ 5U2nBhCmW7UvehkyHk8KYOtdf042RODVxNNeoCWCld2MEWi+iwy6YjAJbvmOGcrj38It 8ACXFj+D4Y+fGxPGb1oAIe2wSuCMRwFF+IsNRrzQZ9MUko7k4scSZIIvWmUQc3b6aLWK NZNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dU8Pv1A3; dkim=neutral (no key) header.i=@linutronix.de header.b=9Rk1Rpr8; 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 z6-20020a1709027e8600b0018867e3182esi11057218pla.335.2022.11.21.06.37.13; Mon, 21 Nov 2022 06:37:29 -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=dU8Pv1A3; dkim=neutral (no key) header.i=@linutronix.de header.b=9Rk1Rpr8; 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 S229985AbiKUOgu (ORCPT + 99 others); Mon, 21 Nov 2022 09:36:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbiKUOgh (ORCPT ); Mon, 21 Nov 2022 09:36:37 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16BEBC80EF; Mon, 21 Nov 2022 06:36:21 -0800 (PST) Message-ID: <20221121083325.573428885@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041379; 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=XzEU6xpUtYERldMqsji8DXGQ2kRnY83P6uKMpYacBXc=; b=dU8Pv1A3KUHAjBDxJCqRcuMbTTS80Mc9lLCZK9YTQfwuRkQG4KnB7JSpzEEgcazLqmhi+l GFCfaHXM2ER96zq2r0Xi+UM6H83wimW9tR1zE0vhzqSSi4NafFsz5bXbM6dGdsJjKUdiPx rxgIb4NqlHDYu0592wWnTFdv4mbSy03cWeWNDvBL+pvlybHGuLYmN0vhriVCH3Xs2/BNkJ h8wQunObOJceMdqn2Welwg5gVQdLuBmt6tqUdE4sHj1l8SVXSLRtVlvtBJyViyV7+vsfdP dXdBwDLc/hp01ZyPTMzJPIOV6fandAXVQhzMthGzYTDX3Cs8eh6S5AS4/cVfDw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041379; 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=XzEU6xpUtYERldMqsji8DXGQ2kRnY83P6uKMpYacBXc=; b=9Rk1Rpr8yUYA05RyCHr0jXkegrQlwrh5f3aqgh5NaQ1HphRHReVuGD6lvPq8XCdKSk5c6w mIaWKFsPb4X/QqDA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Jason Gunthorpe Subject: [patch V2 01/21] genirq/msi: Move IRQ_DOMAIN_MSI_NOMASK_QUIRK to MSI flags References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:19 +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?1750116807091737668?= X-GMAIL-MSGID: =?utf-8?q?1750116807091737668?= It's truly a MSI only flag and for the upcoming per device MSI domains this must be in the MSI flags so it can be set during domain setup without exposing this quirk outside of x86. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe Acked-by: Marc Zyngier --- arch/x86/kernel/apic/msi.c | 5 ++--- include/linux/irqdomain.h | 9 +-------- include/linux/msi.h | 6 ++++++ kernel/irq/msi.c | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -176,7 +176,8 @@ static struct msi_domain_ops pci_msi_dom static struct msi_domain_info pci_msi_domain_info = { .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_PCI_MSIX, + MSI_FLAG_PCI_MSIX | MSI_FLAG_NOMASK_QUIRK, + .ops = &pci_msi_domain_ops, .chip = &pci_msi_controller, .handler = handle_edge_irq, @@ -200,8 +201,6 @@ struct irq_domain * __init native_create if (!d) { irq_domain_free_fwnode(fn); pr_warn("Failed to initialize PCI-MSI irqdomain.\n"); - } else { - d->flags |= IRQ_DOMAIN_MSI_NOMASK_QUIRK; } return d; } --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -186,15 +186,8 @@ enum { /* Irq domain implements MSI remapping */ IRQ_DOMAIN_FLAG_MSI_REMAP = (1 << 5), - /* - * Quirk to handle MSI implementations which do not provide - * masking. Currently known to affect x86, but partially - * handled in core code. - */ - IRQ_DOMAIN_MSI_NOMASK_QUIRK = (1 << 6), - /* Irq domain doesn't translate anything */ - IRQ_DOMAIN_FLAG_NO_MAP = (1 << 7), + IRQ_DOMAIN_FLAG_NO_MAP = (1 << 6), /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -399,6 +399,12 @@ enum { MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 9), /* Free MSI descriptors */ MSI_FLAG_FREE_MSI_DESCS = (1 << 10), + /* + * Quirk to handle MSI implementations which do not provide + * masking. Currently known to affect x86, but has to be partially + * handled in the core MSI code. + */ + MSI_FLAG_NOMASK_QUIRK = (1 << 11), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -875,7 +875,7 @@ static int __msi_domain_alloc_irqs(struc * MSI affinity setting requires a special quirk (X86) when * reservation mode is active. */ - if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK) + if (info->flags & MSI_FLAG_NOMASK_QUIRK) vflags |= VIRQ_NOMASK_QUIRK; } From patchwork Mon Nov 21 14:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626361wrr; Mon, 21 Nov 2022 06:37:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7UPrlgSoUIk/UH+YFcVZ6Rtn9jE+qisfs++lzt5dt+SkZMt4PKD/pTiy9981fbl1tFRJN6 X-Received: by 2002:a63:1f1d:0:b0:474:66fb:41fa with SMTP id f29-20020a631f1d000000b0047466fb41famr1674826pgf.21.1669041451939; Mon, 21 Nov 2022 06:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041451; cv=none; d=google.com; s=arc-20160816; b=aLwI2AIZyDR8IwRps1m7FVcbBFgj2NK3KB2wjC92bNxZEugCzUzlmOOHtxImj5p3x7 ChSTMhK8fAkpxHCIrEwlRbi9LZZ+z0g3dBZ/g1rYw6jtLGIdLrwP3upyB8cToA02NAfW lje0cjci27yLSUzvCbcCiGeHPBtHng51RsI5Hs3Dwrxv9nT7nUoeW9Aqc3XmqdkkWEx8 eU614QxuxOj5o4fvxeJWyRzHBtLGDBpszrhQX1HHCXe/is1KWqjQshIMKLOZgNn78zVZ YzWp7pFIjMtRRhC2QGCtDzjDOFPmKCb6Jz5XsVgRUqpN25xFW06RGCxMhNDsBrsZeShp JPaA== 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=E6KtSq0yDLolu/6n+fAhU+2bN1LDYJtV3H1STAwY1WQ=; b=SGnZSq2s08ZEOwlBnIHTVrO6ozw/Zaut9DdExwjyl75VZqI/Jz0fZBG5IL8JmUrASv wCkIpfJN3WCQbyW2le6aAARdL9i9oify57BW4XmoyZAOGJSSG41puzsDLtBsZe5YMLmh 0ZKeRYkbxZE4O51uZ3luBlbQiDOAfMhWU0cfG2FbyEwrUfPh8Msn7yfNoDeESrdWCV1T aTtVPGynLnh6IwBXXIXZ6TAzHHpPth6PqtyhPDdEJggiWQMkxoM/KmpOkUhklurAPKx9 ji2jRteeNbFxoUcySyXTnxRmhDTkPuXWPvnFS72Xat5FwwlznGlUjDfjYhKkQkdSJBz7 Eybg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nt0tprtl; dkim=neutral (no key) header.i=@linutronix.de; 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 w16-20020a056a0014d000b0056ba70bef19si11763365pfu.350.2022.11.21.06.37.17; Mon, 21 Nov 2022 06:37:31 -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=Nt0tprtl; dkim=neutral (no key) header.i=@linutronix.de; 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 S231295AbiKUOgy (ORCPT + 99 others); Mon, 21 Nov 2022 09:36:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231214AbiKUOgi (ORCPT ); Mon, 21 Nov 2022 09:36:38 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B39C80F2; Mon, 21 Nov 2022 06:36:22 -0800 (PST) Message-ID: <20221121083325.630349797@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041381; 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=E6KtSq0yDLolu/6n+fAhU+2bN1LDYJtV3H1STAwY1WQ=; b=Nt0tprtlmlqk2lf7EOvYegqH2iEYraQbuzbummDc3Ly5HJJlma5z7AHRanIBlbOHqYYKM2 xbVNXqsX5zjzJKnMBGrgV9LwnoA0jNJv5liQy0PbjXO69LClOTedsIA99AeHbXzcP4AocU GtuZCnEi6zeFFU/eFrmNZLzSTn+HIs9Kt/T8RbNLz1Tz9j+MyhNu0sgZJQ6NCVmV4c/wsx WVCEsqfgGh31lwBB0dwS5jyWuakisVDNUnPDGAJsDFhKBtj8sAMF2QVAebOYl7E9kAJM8/ qUuf3Qs28jJU7LcnuhtocUQ2l5YsQB7nBfa+/qHM2L1xXPGfsOmI0HeUllYyzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041381; 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=E6KtSq0yDLolu/6n+fAhU+2bN1LDYJtV3H1STAwY1WQ=; b=oVMdpkcOMrzUphf3qTmecZ9EKyRBFky6Tvp/k05MIcbTxFWCqJJazJ8RH+9yMine/iNcAv 9UEeYShYlfJ5jCAA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 02/21] genirq/irqdomain: Make struct irqdomain readable References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:20 +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?1750116809567964748?= X-GMAIL-MSGID: =?utf-8?q?1750116809567964748?= Tabular alignment of both kernel-doc and the actual struct declaration make visual parsing way more conveniant. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Marc Zyngier --- V2: Split out from the irqdomain::dev rename patch (Jason) --- include/linux/irqdomain.h | 74 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -117,53 +117,53 @@ struct irq_domain_chip_generic; /** * struct irq_domain - Hardware interrupt number translation object - * @link: Element in global irq_domain list. - * @name: Name of interrupt domain - * @ops: pointer to irq_domain methods - * @host_data: private data pointer for use by owner. Not touched by irq_domain - * core code. - * @flags: host per irq_domain flags - * @mapcount: The number of mapped interrupts + * @link: Element in global irq_domain list. + * @name: Name of interrupt domain + * @ops: Pointer to irq_domain methods + * @host_data: Private data pointer for use by owner. Not touched by irq_domain + * core code. + * @flags: Per irq_domain flags + * @mapcount: The number of mapped interrupts * - * Optional elements - * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy - * to swap it for the of_node via the irq_domain_get_of_node accessor - * @gc: Pointer to a list of generic chips. There is a helper function for - * setting up one or more generic chips for interrupt controllers - * drivers using the generic chip library which uses this pointer. - * @dev: Pointer to a device that the domain represent, and that will be - * used for power management purposes. - * @parent: Pointer to parent irq_domain to support hierarchy irq_domains + * Optional elements: + * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy + * to swap it for the of_node via the irq_domain_get_of_node accessor + * @gc: Pointer to a list of generic chips. There is a helper function for + * setting up one or more generic chips for interrupt controllers + * drivers using the generic chip library which uses this pointer. + * @dev: Pointer to a device that can be utilized for power management + * purposes related to the irq domain. + * @parent: Pointer to parent irq_domain to support hierarchy irq_domains * - * Revmap data, used internally by irq_domain - * @revmap_size: Size of the linear map table @revmap[] - * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map - * @revmap_mutex: Lock for the revmap - * @revmap: Linear table of irq_data pointers + * Revmap data, used internally by the irq domain code: + * @revmap_size: Size of the linear map table @revmap[] + * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map + * @revmap_mutex: Lock for the revmap + * @revmap: Linear table of irq_data pointers */ struct irq_domain { - struct list_head link; - const char *name; - const struct irq_domain_ops *ops; - void *host_data; - unsigned int flags; - unsigned int mapcount; + struct list_head link; + const char *name; + const struct irq_domain_ops *ops; + void *host_data; + unsigned int flags; + unsigned int mapcount; /* Optional data */ - struct fwnode_handle *fwnode; - enum irq_domain_bus_token bus_token; - struct irq_domain_chip_generic *gc; - struct device *dev; + struct fwnode_handle *fwnode; + enum irq_domain_bus_token bus_token; + struct irq_domain_chip_generic *gc; + struct device *dev; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY - struct irq_domain *parent; + struct irq_domain *parent; #endif /* reverse map data. The linear map gets appended to the irq_domain */ - irq_hw_number_t hwirq_max; - unsigned int revmap_size; - struct radix_tree_root revmap_tree; - struct mutex revmap_mutex; - struct irq_data __rcu *revmap[]; + irq_hw_number_t hwirq_max; + unsigned int revmap_size; + struct radix_tree_root revmap_tree; + struct mutex revmap_mutex; + struct irq_data __rcu *revmap[]; }; /* Irq domain flags */ From patchwork Mon Nov 21 14:36:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626367wrr; Mon, 21 Nov 2022 06:37:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6/BKAzOEMkxBmG5fBeo0s6pX/5iQVvHeKTiQoKr0TaKZMJp7MpWBL/xI+tpF26dkvGerJL X-Received: by 2002:a05:6a02:108:b0:46b:3acb:77ab with SMTP id bg8-20020a056a02010800b0046b3acb77abmr17952484pgb.359.1669041452036; Mon, 21 Nov 2022 06:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041452; cv=none; d=google.com; s=arc-20160816; b=M5uO7MWlfFjSOWPjubZtO/FZGxShdTFm0GMSjd19wyYQIXKy7Q0PnHpDWjHRyCB4Aw T73Lf0Wz1vAaiopicgj2lxlgPT+855tVSBvAq4rOWA1oc0pok+Y3cSXYc6ObjHojwZQd +2Jb8tWVERld9t6OnKT2WFET+1kWnesSzuXmRkU4/6TRzbD4gZgTAYPcde5A+8BXF54R b7IOur+cTAgrxGq8Z0dkK+QIivw5x+qmcrIeqG8K0bgOmJvDvgD72zDL+M+6qRPT3xzu 1zngmURO6zGcjxhEqZ4/917Ng3uV3WmGqJSeefkbW5PzxpwCrtMhxz6o/ttLfkLVUmax zA6w== 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=r4t3gJp+Epgg61Tiq3or6HjYA/efOz+SN1LtRddhdOs=; b=cwtEjc/XJp0mXsjBt3pHIDnbYC2M33s0SzJ1kN5Vh4rvPDYcZKlDe9qv2MCxw9zBre veZ7OBG84uPCKlC/jQIpXez7a2UNU4PjMr8aZ3K+OfqwKsIV99A4InJUFSvQGV2MqEWz tD3DtRM76hOaB68BMhH8cD4GiBAuPPeQySKwj0kc8JnUyG0boV3sb3GZDemSG13uBcVd Hcn+0jhGoOt/zIi47k5im/uXzHY9H8RGLVVJ9PjUVlJUjczIYHcM9gnNQVlyUT0ca02v kGA1HaCHolAqGfWI4i58zrTRnmxeHpK9atI0WVojLC1iSSsrB2pybOaUF7xsEhUSBFrQ H7YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ByJ4TGTD; dkim=neutral (no key) header.i=@linutronix.de; 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 j9-20020a632309000000b00476f4361438si11097819pgj.382.2022.11.21.06.37.18; Mon, 21 Nov 2022 06:37:32 -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=ByJ4TGTD; dkim=neutral (no key) header.i=@linutronix.de; 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 S231318AbiKUOg7 (ORCPT + 99 others); Mon, 21 Nov 2022 09:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbiKUOgi (ORCPT ); Mon, 21 Nov 2022 09:36:38 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD99C80F7; Mon, 21 Nov 2022 06:36:23 -0800 (PST) Message-ID: <20221121083325.684903415@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041382; 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=r4t3gJp+Epgg61Tiq3or6HjYA/efOz+SN1LtRddhdOs=; b=ByJ4TGTDiZ/BCKI9AZssqVDMX6vzAcNgwwDKR9d9tUEqtIqB7eYIjBJ8UATg87Yta+GF/1 4vU8hFIIP3pgRnRpoDk/NXC9rcKc6dhdaBKS7VjKzPEoQRCGKMzk+YNCGOuiMiK9+SKUIt 4ai1idtByA/HKdfh43swzNhSDkRuC2GkkMRG5br9Nj3I1Xd5Oep6nru74DT9U80IbXR+7w X+MnA1Y/WNJOUv+VJBqbnNRxaCiS7C/xZ5usb0hdm4wAraeS3y9jUDC8qSAyyGH1NhV8HU 3LFpI79QKgF/lqPvCyFMAVIaZztJ95Du29vdMT5XYWGcKC4ziYa/oDuRKqmqLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041382; 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=r4t3gJp+Epgg61Tiq3or6HjYA/efOz+SN1LtRddhdOs=; b=C377Nk6LN+Na+cdZLBgNMKV2GHWZARy1u0FfATTUT5yEm2Fmv1vj7kR6hCVIxojpsep9fx MZbSP3mGqvJ0BADA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Jason Gunthorpe Subject: [patch V2 03/21] genirq/irqdomain: Rename irq_domain::dev to irq_domain::pm_dev References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:22 +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?1750116809385607764?= X-GMAIL-MSGID: =?utf-8?q?1750116809385607764?= irq_domain::dev is a misnomer as it's usually the rule that a device pointer points to something which is directly related to the instance. irq_domain::dev can point to some other device for power management to ensure that this underlying device is not powered down when an interrupt is allocated. The upcoming per device MSI domains really require a pointer to the device which instantiated the irq domain and not to some random other device which is required for power management down the chain. Rename irq_domain::dev to irq_domain::pm_dev and fixup the few sites which use that pointer. Conversion was done with the help of coccinelle. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe Reviewed-by: Marc Zyngier --- drivers/irqchip/irq-gic.c | 4 ++-- include/linux/irqdomain.h | 6 +++--- kernel/irq/chip.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -401,8 +401,8 @@ static void gic_irq_print_chip(struct ir { struct gic_chip_data *gic = irq_data_get_irq_chip_data(d); - if (gic->domain->dev) - seq_printf(p, gic->domain->dev->of_node->name); + if (gic->domain->pm_dev) + seq_printf(p, gic->domain->pm_dev->of_node->name); else seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0])); } --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -131,7 +131,7 @@ struct irq_domain_chip_generic; * @gc: Pointer to a list of generic chips. There is a helper function for * setting up one or more generic chips for interrupt controllers * drivers using the generic chip library which uses this pointer. - * @dev: Pointer to a device that can be utilized for power management + * @pm_dev: Pointer to a device that can be utilized for power management * purposes related to the irq domain. * @parent: Pointer to parent irq_domain to support hierarchy irq_domains * @@ -153,7 +153,7 @@ struct irq_domain { struct fwnode_handle *fwnode; enum irq_domain_bus_token bus_token; struct irq_domain_chip_generic *gc; - struct device *dev; + struct device *pm_dev; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY struct irq_domain *parent; #endif @@ -206,7 +206,7 @@ static inline void irq_domain_set_pm_dev struct device *dev) { if (d) - d->dev = dev; + d->pm_dev = dev; } #ifdef CONFIG_IRQ_DOMAIN --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1561,10 +1561,10 @@ int irq_chip_compose_msi_msg(struct irq_ return 0; } -static struct device *irq_get_parent_device(struct irq_data *data) +static struct device *irq_get_pm_device(struct irq_data *data) { if (data->domain) - return data->domain->dev; + return data->domain->pm_dev; return NULL; } @@ -1578,7 +1578,7 @@ static struct device *irq_get_parent_dev */ int irq_chip_pm_get(struct irq_data *data) { - struct device *dev = irq_get_parent_device(data); + struct device *dev = irq_get_pm_device(data); int retval = 0; if (IS_ENABLED(CONFIG_PM) && dev) @@ -1597,7 +1597,7 @@ int irq_chip_pm_get(struct irq_data *dat */ int irq_chip_pm_put(struct irq_data *data) { - struct device *dev = irq_get_parent_device(data); + struct device *dev = irq_get_pm_device(data); int retval = 0; if (IS_ENABLED(CONFIG_PM) && dev) From patchwork Mon Nov 21 14:36:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626415wrr; Mon, 21 Nov 2022 06:37:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lSPFyDDmo1FdmAPte5oTb6NO1IbTF6IolHVWEGm7AqOwTRD7JXqd/8CAmaqFoXDKojgyS X-Received: by 2002:a17:902:7686:b0:177:faf5:58c5 with SMTP id m6-20020a170902768600b00177faf558c5mr108757pll.166.1669041458030; Mon, 21 Nov 2022 06:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041458; cv=none; d=google.com; s=arc-20160816; b=XIUiU9W+v37ftv2d9cSorscbRAzVlv1wn/Bv47c42c9+GFV/LbBEu3Whf5cg5ZBV9K 32bAc2u6JD0Ao8JvAK6v2/QII+YeKlT0MoOMe44uAmoO8l9fYXaSUnRZY/TM6ROKi1la Qk6xWpi+FHx3wOKkVGXRzCger6wP48axh+JpJgjdaHViwH3XWNpfUXTQ/1Rh7lLf9E6R 03+axm8309cCM+2C6z3WEXJeS7WPjSNjlqcu3/h3hI3fSZUo4xvjj8IXkXZ+W6F56g7p Qh4O1KFPFYk+HARHs10Tzei8LQMTlpdgfs4AFY2ssr/pQGBx+f7CW2LSVUkwYLis6wgi 2+Eg== 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=fX3YyaTkrRIM3kSpqK/PVSD3oj0zimiyOCtXLtrgK+M=; b=pTc67H1Eg0ul1R/Gy0UntM/cx/Dyhf5hEs901CA9NSEXaR12F5dJCkGtV1PondvvuE nQkbGAkjXIZvVhPN6GbIgxIpJBGSsm1om5nX1coG4qD8K1WcDdoq3tE1gSS+mlKKAPnz bxBo6Q+rg7hSwtVf6tvY28mrJIphaGz81eel80fKiw+4yWgVCVnv08rGMuEGZZJFFlP6 poRxbe7VQXJEkAoP3Z1lKxp5D5AiwY53aJSAUcQRAEQ4LxiUqCD/fD6lE+KvIVr0ZSrL vLVzM6r33fE0aXDUE0baGKIcl7CGepTKVqIjGErZy/p3juIzyIBzc9B4ew5C3JGuK1nS iyUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=07AUa4ie; dkim=neutral (no key) header.i=@linutronix.de; 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 n1-20020a634d41000000b0046b2bef339csi11350415pgl.257.2022.11.21.06.37.22; Mon, 21 Nov 2022 06:37:38 -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=07AUa4ie; dkim=neutral (no key) header.i=@linutronix.de; 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 S231363AbiKUOhD (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbiKUOgj (ORCPT ); Mon, 21 Nov 2022 09:36:39 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7643C8440; Mon, 21 Nov 2022 06:36:24 -0800 (PST) Message-ID: <20221121083325.741538017@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041383; 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=fX3YyaTkrRIM3kSpqK/PVSD3oj0zimiyOCtXLtrgK+M=; b=07AUa4iet7fSYqd60LLyVgrQcBpD/0U3skBP8nPL3Wpkw+0D/vqRQp/xYMTAAr4PQVv05e ThkWMW0Kaf2JuMzIapqBFhqPq+xztn2dgSZbP48V+3Qvz3KuL7TyBSijTq3L7/6r78Pn4t t7qadKTQtawlyO1HQbp3yT7eN3fn1fAk+Va24K3MfYggSo3RX7cL00ZBeix30pecrYH4Nh h+Zq7Kt9Qc0OTcv+i2QouEuRmYrHUfypKzoXaAk6DHv/JCFw6Z97faXC0jZZ/yzkBkl1PE K9bSvBgazsA9ORZiK/O7WxFbOJDwyVD4sMIt9PR4ItmH5qVS9Wb+ND2vxHmkVA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041383; 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=fX3YyaTkrRIM3kSpqK/PVSD3oj0zimiyOCtXLtrgK+M=; b=jUUGa1+CU4hAamt7oCsjQtnY1L/HCzsi+lv3jUC0kT1+6UQuyIuTKFYPm0R5J8ud/LxxSs veZXWz6oc8f+/bDA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Jason Gunthorpe Subject: [patch V2 04/21] genirq/msi: Create msi_api.h References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:23 +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?1750116815551305157?= X-GMAIL-MSGID: =?utf-8?q?1750116815551305157?= Create a API header for MSI specific functions which are relevant to device drivers. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe Acked-by: Marc Zyngier --- include/linux/msi.h | 6 ++++-- include/linux/msi_api.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -13,11 +13,14 @@ * * Regular device drivers have no business with any of these functions and * especially storing MSI descriptor pointers in random code is considered - * abuse. The only function which is relevant for drivers is msi_get_virq(). + * abuse. + * + * Device driver relevant functions are available in */ #include #include +#include #include #include #include @@ -188,7 +191,6 @@ struct msi_device_data { int msi_setup_device_data(struct device *dev); -unsigned int msi_get_virq(struct device *dev, unsigned int index); void msi_lock_descs(struct device *dev); void msi_unlock_descs(struct device *dev); --- /dev/null +++ b/include/linux/msi_api.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef LINUX_MSI_API_H +#define LINUX_MSI_API_H + +/* + * APIs which are relevant for device driver code for allocating and + * freeing MSI interrupts and querying the associations between + * hardware/software MSI indices and the Linux interrupt number. + */ + +struct device; + +unsigned int msi_get_virq(struct device *dev, unsigned int index); + +#endif From patchwork Mon Nov 21 14:36:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626468wrr; Mon, 21 Nov 2022 06:37:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6f5EO9o2BoM8SK4s3knJJFDSshXKnNSyhj7nKADdb2tcbaYvJHY4PpjAe0t63qHcXMgDMI X-Received: by 2002:a17:902:aa06:b0:182:f36b:3221 with SMTP id be6-20020a170902aa0600b00182f36b3221mr319393plb.36.1669041463491; Mon, 21 Nov 2022 06:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041463; cv=none; d=google.com; s=arc-20160816; b=hZA9sSiuV/ZBKT6HlqKT5esDqJ2PbHWKnnIuy5oFtqJpF0410ME2xal9G+oIMg6peW a5WnLxsOJh0jCwvLLMHcYQP2iA7pCGYQ4DMRYNw0Td8x+ZiUP+VdeAmYhKccO9stw5Qm RxBhgqbbptaik74cfxc8D6lfE0JX87oi1pKba7SgA1YqR8LB956DXJenQ6SakLecvGWH 3GkIRTcl6RroSi5u7a6LH9HUDGfkvKxR4HR8ifz4HMnMai760GwgL8bFff5aCHYN30L2 PSEPr7IpyBCi2ApENNV6RSXWu5ntXVP7xptaHTDcNsxl7PwXJUzNWI/CnoRP7UHjqciY DBKg== 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=5KOdOFErPOp6C7y41wmv9AEPY8LdxWiLCXWagjX0LQo=; b=pSzdZdB1gsQy88zBTKrCYQ4jwUgE/d3BPTH5/mrtz45rBnxpbhvc3O+WGbhceKAhMx EV2iCXQPWq2qeU6JHYAHhSzUEKhf7vaggxkoL6D01j2isIHUEFIdPOxnNKNgfJ3e9e0J V/b3fPE7gQuczCbBNgHhHOol5WaXeXCbU/LYII+cwNClny2MyWUjqlUA5Fz5nCeIVNE4 eZD0wDNxsUlh2o5dfQyylSEZ6RQrDkxq4qOLUU2dRD+XWLAv18IWZS58d0UJqRPB6G8A yNYlX3igoAN3W+uptlnAyAl+YvpHBDYc1Gw10rRzy5YOPTrcUrxbqVBlOns6LBu6h+/G mGaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=haQMldzF; dkim=neutral (no key) header.i=@linutronix.de header.b=XELV3RIw; 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 nu11-20020a17090b1b0b00b0020b2101908asi12195340pjb.16.2022.11.21.06.37.27; Mon, 21 Nov 2022 06:37:43 -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=haQMldzF; dkim=neutral (no key) header.i=@linutronix.de header.b=XELV3RIw; 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 S230283AbiKUOhN (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbiKUOgk (ORCPT ); Mon, 21 Nov 2022 09:36:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45D1163CC; Mon, 21 Nov 2022 06:36:26 -0800 (PST) Message-ID: <20221121083325.794346723@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041384; 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=5KOdOFErPOp6C7y41wmv9AEPY8LdxWiLCXWagjX0LQo=; b=haQMldzFjmkYzIKzl0buWuioeUdG3ipmHGvSoCdp4PTxoH+E0zllOk407xEqX/FPxFvXZw SHdagyp2CIPIBWHHXK+YQFfIhNwYxKOGTPQYRB53frUY38164440fDcieiL2nXJpUn9/Ha ynGPjdO1YmU5iLbAnXlJA6Z1n9oT1BoS1mbrM4htaLjRwlUfSiunL/AvOfRH85kQGomsRq eGXQfNUl9lK1inNjTuCbPLV8Jzyawst4PyUcByboVNmvpHUE/StFXY4fu7dd9K8VMrm0M0 kR7vPr6+NgVqqg1l1QgU+eS66aEuv85qu0sBQuIGEs88NNgMzfcrVx+GJJcI9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041384; 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=5KOdOFErPOp6C7y41wmv9AEPY8LdxWiLCXWagjX0LQo=; b=XELV3RIw2uCnyajDA/yPX3948niuq2PrCPyxuWtwlDvfTH6apAXM5pU/JirIUkUC26s2sF COE0xQU6YqNEPyAA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Jason Gunthorpe Subject: [patch V2 05/21] genirq/irqdomain: Provide IRQ_DOMAIN_FLAG_MSI_PARENT References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:24 +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?1750116821440316588?= X-GMAIL-MSGID: =?utf-8?q?1750116821440316588?= The new PCI/IMS (Interrupt Message Store) functionality is allowing hardware vendors to provide implementation specific storage for the MSI messages. This can be device memory and also host/guest memory, e.g. in queue memory which is shared with the hardware. This requires device specific MSI interrupt domains, which cannot be achieved by expanding the existing PCI/MSI interrupt domain concept which is a global interrupt domain shared by all PCI devices on a particular (IOMMU) segment: |--- device 1 [Vector]---[Remapping]---[PCI/MSI]--|... |--- device N This works because the PCI/MSI[-X] space is uniform, but falls apart with PCI/IMS which is implementation defined and must be available along with PCI/MSI[-X] on the same device. To support PCI/MSI[-X] plus PCI/IMS on the same device it is required to rework the PCI/MSI interrupt domain hierarchy concept in the following way: |--- [PCI/MSI] device 1 [Vector]---[Remapping]---|... |--- [PCI/MSI] device N That allows in the next step to create multiple interrupt domains per device: |--- [PCI/MSI] device 1 |--- [PCI/IMS] device 1 [Vector]---[Remapping]---|... |--- [PCI/MSI] device N |--- [PCI/IMS] device N So the domain which previously created the global PCI/MSI domain must now act as parent domain for the per device domains. The hierarchy depth is the same as before, but the PCI/MSI domains are then device specific and not longer global. Provide IRQ_DOMAIN_FLAG_MSI_PARENT, which allows to identify these parent domains, along with helpers to query it. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/irqdomain.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -189,6 +189,9 @@ enum { /* Irq domain doesn't translate anything */ IRQ_DOMAIN_FLAG_NO_MAP = (1 << 6), + /* Irq domain is a MSI parent domain */ + IRQ_DOMAIN_FLAG_MSI_PARENT = (1 << 8), + /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the @@ -551,6 +554,11 @@ static inline bool irq_domain_is_msi_rem extern bool irq_domain_hierarchical_is_msi_remap(struct irq_domain *domain); +static inline bool irq_domain_is_msi_parent(struct irq_domain *domain) +{ + return domain->flags & IRQ_DOMAIN_FLAG_MSI_PARENT; +} + #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */ static inline int irq_domain_alloc_irqs(struct irq_domain *domain, unsigned int nr_irqs, int node, void *arg) @@ -596,6 +604,12 @@ irq_domain_hierarchical_is_msi_remap(str { return false; } + +static inline bool irq_domain_is_msi_parent(struct irq_domain *domain) +{ + return false; +} + #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ #else /* CONFIG_IRQ_DOMAIN */ From patchwork Mon Nov 21 14:36:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626589wrr; Mon, 21 Nov 2022 06:37:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4W5xDglcAoMy17j0F4Oka7cNj/L1KADI+3KRttXHiLu4Fcq/NSaDp8ozELbU09L2DhLyme X-Received: by 2002:a63:5544:0:b0:477:6fe2:c1d1 with SMTP id f4-20020a635544000000b004776fe2c1d1mr4775207pgm.444.1669041477563; Mon, 21 Nov 2022 06:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041477; cv=none; d=google.com; s=arc-20160816; b=y/52aFJwlt/DFfRcQXYrnlnK8vcoHG/Tfm4z/bSeLDW20UC89HlziAH9Ved2p3Y41q S7nHbutUakUElMRURgoz2UzWjP0ohCtqjiWUxrs7f12qmfJNkcXFtkLUgPqF3qc5OIH5 b2xanEflve9ZgdnC4A+jPtznAxqNGW4/AtHhWsbla95ypn8czuIQeYFfaEezS951pwVN 7e9UHUWKdXAIR4RwB3qorUVTBQUYHDnsOG0hYtyrjXND5nDs0zKPxMWP1osletRLllqH /QtkHJ7IdyjI06GyGxSIn1sXXvMZ/HYQw9DU8hPaT2TIaNOC2Yb1YYuHMJ7595LTkMaC vI9g== 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=+CkTPHTMXOvRSl4YB673TzHqsVFLjHUDowE8deLkwuw=; b=mTBmntqHAZlBEfFTXNCL9YZdA4Z7JjKfnrumOeq+MGsRYZgIpdGU4qmLxZRRxKHTzB muZAHF6fEQFTMm2AWd4ZZEmMZvxgIqRdLOBPWYuHemSDU8TwFOtszYQwnVwrJkTauU+x co1+pPdFX/yzbr5kdBUQTe9QaXN8Ww25f4w1XLn0SYnwwq4NsEfdMD3hxv7PtJEGQjG5 WBUTIJ/kXpDZPgNvmRgG6tBRJiZRk6VMsi/JaqUHNPHF5pJTwYc8OnmQFBemZHaIyrb4 bxI9nzXqBrrwsGb3cau+JP5SAplMS5d1m/EWmk0Jg1TpYo+7GpfHgIQINu8mPlN9dbiU 0f9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zV8w1tsS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 w4-20020a656944000000b0045ceafe40cesi10230977pgq.395.2022.11.21.06.37.43; Mon, 21 Nov 2022 06:37:57 -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=zV8w1tsS; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231292AbiKUOhU (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231262AbiKUOgl (ORCPT ); Mon, 21 Nov 2022 09:36:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9362C6D11; Mon, 21 Nov 2022 06:36:27 -0800 (PST) Message-ID: <20221121083325.846660254@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041386; 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=+CkTPHTMXOvRSl4YB673TzHqsVFLjHUDowE8deLkwuw=; b=zV8w1tsStuX6XpptBJYxfR/+top3jj9uLazwOM4LRF4mOE0WH71cTpcWF13zcM9azFKYGG n/NlPSy3li4+/81QJ7uLjbotwoeDCCkqcKocTWCJCZj8wCvqAfvFrFR3Ebo46e4tmuN5M9 coCDxseOpxTiaFZaPqh1yomqRBzLa9bk4GZiP6E3hRq3BlGNMkCYMhbUc5Q8S92nf8Ioka 1U2niNxlRISp2fhx/2JbGRCxyq+JdehVWrc2aBpNTspddQZvlGLgEgFuthyIAjH9kHqp/e //M9aKh3z2LcrtbCvHWpw/U/a18yIoikzOq6omMcr41tPkURgtyEEFeCoYMFKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041386; 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=+CkTPHTMXOvRSl4YB673TzHqsVFLjHUDowE8deLkwuw=; b=Dy8ze2Ov2RrLoLEbR8EjWXrxDOY3VkF3/JAWrN7RTBPFmdy+I9uhjCYlI5C59VeO8E1J1u t71IP+PC25I8S5Dg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 06/21] genirq/irqdomain: Provide IRQ_DOMAIN_FLAG_MSI_DEVICE References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:25 +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?1750116836198276992?= X-GMAIL-MSGID: =?utf-8?q?1750116836198276992?= Similar to marking parent MSI domains it's required to identify per device domains. Add flag and helpers. Signed-off-by: Thomas Gleixner --- include/linux/irqdomain.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -192,6 +192,9 @@ enum { /* Irq domain is a MSI parent domain */ IRQ_DOMAIN_FLAG_MSI_PARENT = (1 << 8), + /* Irq domain is a MSI device domain */ + IRQ_DOMAIN_FLAG_MSI_DEVICE = (1 << 9), + /* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the @@ -559,6 +562,11 @@ static inline bool irq_domain_is_msi_par return domain->flags & IRQ_DOMAIN_FLAG_MSI_PARENT; } +static inline bool irq_domain_is_msi_device(struct irq_domain *domain) +{ + return domain->flags & IRQ_DOMAIN_FLAG_MSI_DEVICE; +} + #else /* CONFIG_IRQ_DOMAIN_HIERARCHY */ static inline int irq_domain_alloc_irqs(struct irq_domain *domain, unsigned int nr_irqs, int node, void *arg) @@ -609,6 +617,11 @@ static inline bool irq_domain_is_msi_par { return false; } + +static inline bool irq_domain_is_msi_device(struct irq_domain *domain) +{ + return false; +} #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ From patchwork Mon Nov 21 14:36:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626524wrr; Mon, 21 Nov 2022 06:37:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf6W1HpVB9/cnmeex36M+2IwxEfYE/M2axM7s8IRxw3o7Pd8+RaxG6MpR4DVdp0FBBhJnF5Z X-Received: by 2002:a62:8686:0:b0:56c:636a:ac94 with SMTP id x128-20020a628686000000b0056c636aac94mr312322pfd.38.1669041471129; Mon, 21 Nov 2022 06:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041471; cv=none; d=google.com; s=arc-20160816; b=AoqApVRx+tro/nsxK6b2ZzQ51ubowp7z9qFCDn2xaYYR51PxSL7MlDlW1MUkhWfdJB czehgyfp+km6D23c2r1rJvlKfd4RH6Iah36G2ksruQy51i5+a0RqQ1eU+BanysUkDlj/ a1jfPs62hzrykG87+pAdQ32WeTzUU/oIX8C+cBv2MvAn1wqYuRZVxOb4jgHBIneWPVVs pf1aEvMgGXH1L0kDCcaw08brUUSQE1GMNBwQtb8gwYhqrilJZc7jwS3mbd2YhKg3dVAT VFkSQjCnuQb3/cusPOIGzIB23S+J+lvTy8njFiGxz80AtVTa59ydsIFxJTeVD7xlkzbc HC2Q== 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=9rEv0ZCHRcbwfGXHvRaB+26Gs3i0vHsf2KEnMS96bjY=; b=ZVbN912+T0kTre7O2OwzkqmJfwUUjufd8V5iu5JXyn0TvhRs88/4s6JboLY3GTveyu 2nRPIkPcfMznPqUumyBLeMUYnR6x2arHjAWU7ZAeKIp5ea/bPzJntkcmftp3OGXUH4mM Qy/8NLcxBX0/jA/nLurA4R4Hm+BLWT9Xsh+lxlGZKFl6rEy0PN2vYMV+kU/etGp0z5Nn lh3uCYEHVIXwfo4lBC0HwS+ZFwsdqrcQCnhPJTQ6x1dT61xIJX7UqdBGZLdh2NP9ZVDR Aj2jIMFNksyXPJUgX/sXUcpCX0fRcrS8FRnSXp1CWdjCeT6M2kuTcNpCDX4eey+kGUit avZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GXvys4RN; dkim=neutral (no key) header.i=@linutronix.de; 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 f21-20020a056a0022d500b0056bc627dbeesi11878335pfj.124.2022.11.21.06.37.36; Mon, 21 Nov 2022 06:37:51 -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=GXvys4RN; dkim=neutral (no key) header.i=@linutronix.de; 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 S231178AbiKUOhR (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbiKUOgl (ORCPT ); Mon, 21 Nov 2022 09:36:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A504DC6D13; Mon, 21 Nov 2022 06:36:28 -0800 (PST) Message-ID: <20221121083325.898535631@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041387; 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=9rEv0ZCHRcbwfGXHvRaB+26Gs3i0vHsf2KEnMS96bjY=; b=GXvys4RNHQ7h0QJBqveM//QK3VblBKRZ4eYHP/cRMku42RLzjX3JH3BHs7zUb5U/ORz0Qn N/TjGTvzSeYuMzUs3dVZUk7xyyDqIZD7+dy/qhNkL/ggGFqlVZb4G+lODo4RrmjkA0pLsE DXFG8m0zubDhD9Qz+DOsxZR6jxULosiRgtLhI3HKwk3k601W1wPVdNf9bvxFOndczykdZW PLQMuQ9BMlXYsARIKsuQCR0r5ZuInW1CMdeYh/vRpwlFsPwFiIVT/UZe7GSZ53s870/4pS ZJp3wL0ucDww9DednLFrLw2+oEbJVvjebsyGeh7/YoO/rYDFIXSVqTGyIvWsyQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041387; 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=9rEv0ZCHRcbwfGXHvRaB+26Gs3i0vHsf2KEnMS96bjY=; b=/ryo2wZZtD3zkaTdpxsEJC9pzfQODO2gG/rLr9x6xv7NCtw5ssyjyawTKgkSyCSIBjSgiM iNZJtqjUellQKGCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 07/21] genirq/msi: Check for invalid MSI parent domain usage References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:27 +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?1750116829889827500?= X-GMAIL-MSGID: =?utf-8?q?1750116829889827500?= In the upcoming per device MSI domain concept the MSI parent domains are not allowed to be used as regular MSI domains where the MSI allocation/free operations are applicable. Add appropriate checks. Signed-off-by: Thomas Gleixner --- V2: Made the error return understandable. (Kevin) --- kernel/irq/msi.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -937,13 +937,21 @@ int msi_domain_alloc_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); + if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) { + ret = -EINVAL; + goto free; + } + + /* Frees allocated descriptors in case of failure. */ ret = msi_domain_add_simple_msi_descs(info, dev, nvec); if (ret) - return ret; + goto free; ret = ops->domain_alloc_irqs(domain, dev, nvec); - if (ret) - msi_domain_free_irqs_descs_locked(domain, dev); + if (!ret) + return 0; +free: + msi_domain_free_irqs_descs_locked(domain, dev); return ret; } @@ -1013,6 +1021,9 @@ void msi_domain_free_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); + if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) + return; + ops->domain_free_irqs(domain, dev); if (ops->msi_post_free) ops->msi_post_free(domain, dev); From patchwork Mon Nov 21 14:36:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626967wrr; Mon, 21 Nov 2022 06:38:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6bOzgcCr4ZVz/TzBFtnfq/GP6XmB40uCfUWtW4lLcPsH37pkgl+vfzKVTJsW/OxTn1ZLFi X-Received: by 2002:aa7:942f:0:b0:56b:a149:1d89 with SMTP id y15-20020aa7942f000000b0056ba1491d89mr810282pfo.83.1669041516030; Mon, 21 Nov 2022 06:38:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041516; cv=none; d=google.com; s=arc-20160816; b=BkXFdX7J18vWLccIa2IkBzxFqQOBLhjyZgQZnuoJ2Q/zMEZiWOOTKfA+rPVIc7JKGn SoZPotiNjI7GCa3QVz+EA98iCqdg+WFaLR4OodTihLzXHMz4b3vGPjw5fAjNLMqCPRCY HiKjLcntDaaBJYJhHFwRXxU/fdS8DSgegkgBj6sqVRC31L9Kr+Lkk5Y/5urrA+0zDZ4P 08t4DktHyGk2qoTm8D2WMQoLdK6sU4qSIHmjDxlrW+x8Nsz4g5Wf95Z31Tyte+7NOgD6 9q3MqdmmDSHZ3X/yHSvSZQuWpewjhIagYzdNIGCmmVr3e6YEmhkXkdSmBTd/qJhp15qD xpdw== 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=W7qVbQgLsW9+eyoM2fn4CU+n/dlKHe6NknzgWNBQJFM=; b=C6xeHvsI7dn0l1JdI6PCP+Ct9UP/UzZAcoxvXphpvbwScxQBTbi3yAtV3zql/kYBun 8sq2milLjj+liGlUICfTn1+4NWVZuWiLJTyHuIltfsWf2ZfVLDdcJvB8BZLGcIgJyOmk Rr4XR9JrC23LBzWWtDM2Eh9RV7ToatKaS3u5/bqPm6EUVBxpRsQITTmPeASBaF+0/h4S Me4rDLvcWOMIHa/NBe5BaDJkmM5mnFuoYGaLpB7fzddp5aY6U/bSDu7UX99E2GFgVqg5 RDSyJDodEw52OXKfN/N0dP1qbBakxDsaa8gr2uYEnoS9zmQbc+DrSliSWrCtPYG/hlg1 bgDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nQVGQACb; dkim=neutral (no key) header.i=@linutronix.de; 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 a38-20020a056a001d2600b0056c231e4447si12294579pfx.198.2022.11.21.06.38.21; Mon, 21 Nov 2022 06:38:36 -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=nQVGQACb; dkim=neutral (no key) header.i=@linutronix.de; 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 S231586AbiKUOhf (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbiKUOgl (ORCPT ); Mon, 21 Nov 2022 09:36:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0370DC6D16; Mon, 21 Nov 2022 06:36:30 -0800 (PST) Message-ID: <20221121083325.950255253@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041388; 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=W7qVbQgLsW9+eyoM2fn4CU+n/dlKHe6NknzgWNBQJFM=; b=nQVGQACbwDgZgFx6Yzjx95AJmLSoQLwxKE1n+al/J1KQEZFIX5TbDcZEuaFUjQuLDeJ0iO GbY/q/6UgN99PnEeTDHVJMVoz5hbW2y4TWu8fv3219e4f1sBqPbJQRUt3TNboXcIQOHB3C BQ4SP8gLZ5wrn/taAL/7kxxIqz2CkmCAEdYIl1UAs8oMvGY6+X2j+Gks1jIXOzoFksie6R lUGpRKjCdlDJ9AsF04mx3GzyZrgsXv6tHTGy5OswCQ/tvR6t3kfFjmJxBjtszWXxvuxZ4z fn9fdLbTr84EWKgXasbHdlhHz4dN2pXJkVp0n+g5f0Z9KxvGffVK36G1nIHqPQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041388; 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=W7qVbQgLsW9+eyoM2fn4CU+n/dlKHe6NknzgWNBQJFM=; b=U4VJ4dAgXGtzIyaO0c7BJIiFHBNo3jeZHyXGDxSY68cLTykCaDumafui4CSyQh6fJZRQaB 8m/CSoIAq4Bug9DQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 08/21] genirq/msi: Add pointers for per device irq domains References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:28 +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?1750116876415461865?= X-GMAIL-MSGID: =?utf-8?q?1750116876415461865?= With the upcoming per device MSI interrupt domain support it is necessary to store the domain pointers per device. Instead of delegating that storage to device drivers or subsystems create a storage array in struct msi_device_data which will also take care of tearing down the irq domains when msi_device_data is cleaned up via devres. The interfaces into the MSI core will be changed from irqdomain pointer based interfaces to domain id based interfaces to support multiple MSI domains on a single device (e.g. PCI/MSI[-X] and PCI/IMS. Once the per device domain support is complete the irq domain pointer in struct device::msi.domain will not longer contain a pointer to the "global" MSI domain. It will contain a pointer to the MSI parent domain instead. It would be a horrible maze of conditionals to evaluate all over the place which domain pointer should be used, i.e. the "global" one in device::msi::domain or one from the internal pointer array. To avoid this evaluate in msi_setup_device_data() whether the irq domain which is associated to a device is a "global" or a parent MSI domain. If it is global then copy the pointer into the first entry in the irqdomain pointer array. This allows to convert interfaces and implementation to domain ids while keeping everything existing working. Signed-off-by: Thomas Gleixner Reviewed-by: Marc Zyngier --- include/linux/msi.h | 3 +++ include/linux/msi_api.h | 8 ++++++++ kernel/irq/msi.c | 14 ++++++++++++++ 3 files changed, 25 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -77,6 +77,7 @@ struct msi_desc; struct pci_dev; struct platform_msi_priv_data; struct device_attribute; +struct irq_domain; void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg); #ifdef CONFIG_GENERIC_MSI_IRQ @@ -180,6 +181,7 @@ enum msi_desc_filter { * @mutex: Mutex protecting the MSI descriptor store * @__store: Xarray for storing MSI descriptor pointers * @__iter_idx: Index to search the next entry for iterators + * @__irqdomains: Per device interrupt domains */ struct msi_device_data { unsigned long properties; @@ -187,6 +189,7 @@ struct msi_device_data { struct mutex mutex; struct xarray __store; unsigned long __iter_idx; + struct irq_domain *__irqdomains[MSI_MAX_DEVICE_IRQDOMAINS]; }; int msi_setup_device_data(struct device *dev); --- a/include/linux/msi_api.h +++ b/include/linux/msi_api.h @@ -10,6 +10,14 @@ struct device; +/* + * Per device interrupt domain related constants. + */ +enum msi_domain_ids { + MSI_DEFAULT_DOMAIN, + MSI_MAX_DEVICE_IRQDOMAINS, +}; + unsigned int msi_get_virq(struct device *dev, unsigned int index); #endif --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -21,6 +21,18 @@ static inline int msi_sysfs_create_group(struct device *dev); +static inline void msi_setup_default_irqdomain(struct device *dev, struct msi_device_data *md) +{ + if (!dev->msi.domain) + return; + /* + * If @dev::msi::domain is a global MSI domain, copy the pointer + * into the domain array to avoid conditionals all over the place. + */ + if (!irq_domain_is_msi_parent(dev->msi.domain)) + md->__irqdomains[MSI_DEFAULT_DOMAIN] = dev->msi.domain; +} + /** * msi_alloc_desc - Allocate an initialized msi_desc * @dev: Pointer to the device for which this is allocated @@ -213,6 +225,8 @@ int msi_setup_device_data(struct device return ret; } + msi_setup_default_irqdomain(dev, md); + xa_init(&md->__store); mutex_init(&md->mutex); dev->msi.data = md; From patchwork Mon Nov 21 14:36:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626897wrr; Mon, 21 Nov 2022 06:38:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6DM2PDiva/CCss9NEdmkYx1gx29HGUAAztEgCo3Wlajz9jDi/xSNNYVqL49ZprFrJV/lP5 X-Received: by 2002:a17:90a:760f:b0:218:bf69:a7b2 with SMTP id s15-20020a17090a760f00b00218bf69a7b2mr2595494pjk.106.1669041509025; Mon, 21 Nov 2022 06:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041509; cv=none; d=google.com; s=arc-20160816; b=guFqw3TicIC/8NAjb+RpTurnHkt+T9W3wsGHqPlz+p6ZxTT/sJIpQfMTdcyWLShDjM JaW0yUB6AI7aAlG6se9lDBxgVYeTqwAU8L1j/RTdWwJO+mWjKe+oqAh9jsn1QR1VfD/u uBb4DTyJ7p12oRcT+QIk+ficO5xn98kT72d4iHRpwjoSvM025cxNTiWGE+so0HjY/qZU /Nih9RZaw7osAyB8ibgchWnq4Qwq/UZ4gtn35Dc4C70iY8JqLjGnE1+UC6ylUdPkAx0a HMCeBNtDEMwbnJzW8F2+aSqxvKDLkwinXHgVclMoRay+LM1NbZ7ONkfuWT/IgXiZJlRL 24jg== 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=FZrl2FVP1hN+AFQ07RZcCo5g9uO23ic8F3HA5Y+tWWI=; b=gSprzHhwtRj9fb+GzXogedU1EUnXwDDBFFzC2xZJ6IUgkCgcqtWFAOhSk3gYBJ8RoB c4B+wBq/j+wdG0lXeyJ/f0Nq/V3mmOIx4d62d+6JZHNLXiXtI4rWku6642syk7O+cR4b P/I9cs2EGWSMtikku2tEEoBhll/f1cLl6GiDH+fGqyZUheW5ZJF6bDMEGsOiM3DLUYMm OwjXZhb+45mRUPjqb+Ax2WAssc1iAc9XJi/FhxrFkuf74wqifkbEDusqfZCEpEM6Q5gj 7PoOBnyLfOM1SNrW5D4fAHE0SwLuX7+klDCkwlvZoUCuda1GgT6nDp1zo7PT/xGSsZV3 sIBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hPqYNF2D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 h11-20020a056a00230b00b00562617987a1si11079827pfh.264.2022.11.21.06.38.12; Mon, 21 Nov 2022 06:38:29 -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=hPqYNF2D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231597AbiKUOhj (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbiKUOgl (ORCPT ); Mon, 21 Nov 2022 09:36:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 356DFC6D21; Mon, 21 Nov 2022 06:36:31 -0800 (PST) Message-ID: <20221121083326.002153609@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041389; 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=FZrl2FVP1hN+AFQ07RZcCo5g9uO23ic8F3HA5Y+tWWI=; b=hPqYNF2DsT62d8jFpqufSgUXB2xq4BHYK46LQXLs8LvhhMRZmJxDY1OoVVTvaVjoqWpZ0Y ThYxzYkV8YhufbGeDBZffz4iA2L12l5gXZPwYrmsxoxohz4UUm8geUVp9ioqOxZih0RIbT mvmwSmS7Ny4e22DTMKGbYJd2ZrHDYKb00OZgUogfOGyZPJSsoyVnjLtFvS48AjwAGCn4RY I8bV2OLSVL0UBv1sbVQKa+F4e9uthLGMV1eWASwZ8p6OV/vb0vGMSHly5fy2J7TF/LRf2o 6LUKpPaCIRZ/K9eiUV+IE+R+1CrU6lsEFjJQIimVhgJcmq+0m46oyb5i2wAl6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041389; 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=FZrl2FVP1hN+AFQ07RZcCo5g9uO23ic8F3HA5Y+tWWI=; b=o0e/ebYAoMgZUK81TTG6lP8jMxcUsK/2dHJpOIeH/cIYMCTmlye3uklyty7gZi7+LyjxqI Be4IPoUPOZGCGKDA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 09/21] genirq/msi: Make MSI descriptor iterators device domain aware References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:29 +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?1750116869214756286?= X-GMAIL-MSGID: =?utf-8?q?1750116869214756286?= To support multiple MSI interrupt domains per device it is necessary to segment the xarray MSI descriptor storage. Each domain gets up to MSI_MAX_INDEX entries. Change the iterators so they operate with domain ids and take the domain offsets into account. The publicly available iterators which are mostly used in legacy implementations and the PCI/MSI core default to MSI_DEFAULT_DOMAIN (0) which is the id for the existing "global" domains. No functional change. Signed-off-by: Thomas Gleixner --- V2: Fix the off by one so the index space is including MSI_MAX_INDEX (Kevin) --- include/linux/msi.h | 45 +++++++++++++++++++++++++++++++++++++++++---- kernel/irq/msi.c | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 76 insertions(+), 12 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -181,6 +181,7 @@ enum msi_desc_filter { * @mutex: Mutex protecting the MSI descriptor store * @__store: Xarray for storing MSI descriptor pointers * @__iter_idx: Index to search the next entry for iterators + * @__iter_max: Index to limit the search * @__irqdomains: Per device interrupt domains */ struct msi_device_data { @@ -189,6 +190,7 @@ struct msi_device_data { struct mutex mutex; struct xarray __store; unsigned long __iter_idx; + unsigned long __iter_max; struct irq_domain *__irqdomains[MSI_MAX_DEVICE_IRQDOMAINS]; }; @@ -197,14 +199,34 @@ int msi_setup_device_data(struct device void msi_lock_descs(struct device *dev); void msi_unlock_descs(struct device *dev); -struct msi_desc *msi_first_desc(struct device *dev, enum msi_desc_filter filter); +struct msi_desc *msi_domain_first_desc(struct device *dev, unsigned int domid, + enum msi_desc_filter filter); + +/** + * msi_first_desc - Get the first MSI descriptor of the default irqdomain + * @dev: Device to operate on + * @filter: Descriptor state filter + * + * Must be called with the MSI descriptor mutex held, i.e. msi_lock_descs() + * must be invoked before the call. + * + * Return: Pointer to the first MSI descriptor matching the search + * criteria, NULL if none found. + */ +static inline struct msi_desc *msi_first_desc(struct device *dev, + enum msi_desc_filter filter) +{ + return msi_domain_first_desc(dev, MSI_DEFAULT_DOMAIN, filter); +} + struct msi_desc *msi_next_desc(struct device *dev, enum msi_desc_filter filter); /** - * msi_for_each_desc - Iterate the MSI descriptors + * msi_domain_for_each_desc - Iterate the MSI descriptors in a specific domain * * @desc: struct msi_desc pointer used as iterator * @dev: struct device pointer - device to iterate + * @domid: The id of the interrupt domain which should be walked. * @filter: Filter for descriptor selection * * Notes: @@ -212,10 +234,25 @@ struct msi_desc *msi_next_desc(struct de * pair. * - It is safe to remove a retrieved MSI descriptor in the loop. */ -#define msi_for_each_desc(desc, dev, filter) \ - for ((desc) = msi_first_desc((dev), (filter)); (desc); \ +#define msi_domain_for_each_desc(desc, dev, domid, filter) \ + for ((desc) = msi_domain_first_desc((dev), (domid), (filter)); (desc); \ (desc) = msi_next_desc((dev), (filter))) +/** + * msi_for_each_desc - Iterate the MSI descriptors in the default irqdomain + * + * @desc: struct msi_desc pointer used as iterator + * @dev: struct device pointer - device to iterate + * @filter: Filter for descriptor selection + * + * Notes: + * - The loop must be protected with a msi_lock_descs()/msi_unlock_descs() + * pair. + * - It is safe to remove a retrieved MSI descriptor in the loop. + */ +#define msi_for_each_desc(desc, dev, filter) \ + msi_domain_for_each_desc((desc), (dev), MSI_DEFAULT_DOMAIN, (filter)) + #define msi_desc_to_dev(desc) ((desc)->dev) #ifdef CONFIG_IRQ_MSI_IOMMU --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -21,6 +21,10 @@ static inline int msi_sysfs_create_group(struct device *dev); +/* Invalid XA index which is outside of any searchable range */ +#define MSI_XA_MAX_INDEX (ULONG_MAX - 1) +#define MSI_XA_DOMAIN_SIZE (MSI_MAX_INDEX + 1) + static inline void msi_setup_default_irqdomain(struct device *dev, struct msi_device_data *md) { if (!dev->msi.domain) @@ -33,6 +37,20 @@ static inline void msi_setup_default_irq md->__irqdomains[MSI_DEFAULT_DOMAIN] = dev->msi.domain; } +static int msi_get_domain_base_index(struct device *dev, unsigned int domid) +{ + lockdep_assert_held(&dev->msi.data->mutex); + + if (WARN_ON_ONCE(domid >= MSI_MAX_DEVICE_IRQDOMAINS)) + return -ENODEV; + + if (WARN_ON_ONCE(!dev->msi.data->__irqdomains[domid])) + return -ENODEV; + + return domid * MSI_XA_DOMAIN_SIZE; +} + + /** * msi_alloc_desc - Allocate an initialized msi_desc * @dev: Pointer to the device for which this is allocated @@ -229,6 +247,7 @@ int msi_setup_device_data(struct device xa_init(&md->__store); mutex_init(&md->mutex); + md->__iter_idx = MSI_XA_MAX_INDEX; dev->msi.data = md; devres_add(dev, md); return 0; @@ -251,7 +270,7 @@ EXPORT_SYMBOL_GPL(msi_lock_descs); void msi_unlock_descs(struct device *dev) { /* Invalidate the index wich was cached by the iterator */ - dev->msi.data->__iter_idx = MSI_MAX_INDEX; + dev->msi.data->__iter_idx = MSI_XA_MAX_INDEX; mutex_unlock(&dev->msi.data->mutex); } EXPORT_SYMBOL_GPL(msi_unlock_descs); @@ -260,17 +279,18 @@ static struct msi_desc *msi_find_desc(st { struct msi_desc *desc; - xa_for_each_start(&md->__store, md->__iter_idx, desc, md->__iter_idx) { + xa_for_each_range(&md->__store, md->__iter_idx, desc, md->__iter_idx, md->__iter_max) { if (msi_desc_match(desc, filter)) return desc; } - md->__iter_idx = MSI_MAX_INDEX; + md->__iter_idx = MSI_XA_MAX_INDEX; return NULL; } /** - * msi_first_desc - Get the first MSI descriptor of a device + * msi_domain_first_desc - Get the first MSI descriptor of an irqdomain associated to a device * @dev: Device to operate on + * @domid: The id of the interrupt domain which should be walked. * @filter: Descriptor state filter * * Must be called with the MSI descriptor mutex held, i.e. msi_lock_descs() @@ -279,19 +299,26 @@ static struct msi_desc *msi_find_desc(st * Return: Pointer to the first MSI descriptor matching the search * criteria, NULL if none found. */ -struct msi_desc *msi_first_desc(struct device *dev, enum msi_desc_filter filter) +struct msi_desc *msi_domain_first_desc(struct device *dev, unsigned int domid, + enum msi_desc_filter filter) { struct msi_device_data *md = dev->msi.data; + int baseidx; if (WARN_ON_ONCE(!md)) return NULL; lockdep_assert_held(&md->mutex); - md->__iter_idx = 0; + baseidx = msi_get_domain_base_index(dev, domid); + if (baseidx < 0) + return NULL; + + md->__iter_idx = baseidx; + md->__iter_max = baseidx + MSI_MAX_INDEX; return msi_find_desc(md, filter); } -EXPORT_SYMBOL_GPL(msi_first_desc); +EXPORT_SYMBOL_GPL(msi_domain_first_desc); /** * msi_next_desc - Get the next MSI descriptor of a device @@ -315,7 +342,7 @@ struct msi_desc *msi_next_desc(struct de lockdep_assert_held(&md->mutex); - if (md->__iter_idx >= (unsigned long)MSI_MAX_INDEX) + if (md->__iter_idx >= md->__iter_max) return NULL; md->__iter_idx++; From patchwork Mon Nov 21 14:36:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626745wrr; Mon, 21 Nov 2022 06:38:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BIbFKyNCW/QQm+Qt+1rbZLqWU9Gd9XlnOApMKEpuwPSf6aZA1KeDTwI/sEyS429XJn6Jj X-Received: by 2002:a65:694e:0:b0:474:6749:407d with SMTP id w14-20020a65694e000000b004746749407dmr477585pgq.425.1669041492128; Mon, 21 Nov 2022 06:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041492; cv=none; d=google.com; s=arc-20160816; b=q+uiel8Fqs7Tc4O6WsgAyPcv5EuMT8XjlWCX4OEdfCXTDBzxB0Rep2vypuGY/7YANw ScTxIKZBZDaw9mmVxhSF2A0o3dlSLU+fZW2X3dkIebBZ1DjlWT2w+m0ymCgI9motyX9R DdS3A/IRGvSDR49kTh1KCn5rv7NyIpHU8AStDNYxZHzKYa3oPtsdIQtdSYksp4ud3c+E i44FK4WhTXLhXg+Uz/gfYHoacTbQuuQoOd4RHikF84uuDVpErBCAMLnsQLqWp5cyAz0f B64Wh/EeRCRWSFSXeSk7AhgTpKR+5yS+Ij0ufxN7cxMGg/t7WSA2fp48JlDlqCVr5Vq0 8Ozg== 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=XKtpijacgcV8/nCTByztO8f4qnhUrmimBQl8oQuyrjc=; b=WaocIQa34yGtLqsI7UAHeoC5oeVQzzutrVKzKXFdreiWSNJFsuZ8cT/oVibwSmhMbN rQ05kKss3NdqEWCycBqQ+yWXFIlFAd7kg+EVzbryoFgb5OKud8OikB6VGbirAuOqRwVn j0zk7U1E1CF3LOxsY7Z8Plhw1LzLH0nrDUhdJN8oiLxk9nrf6r/yu+LqdRhMvSCco3eH OB6hpGtelkLf96izyVPote//ss1YLkLcD+PyEsS/8A9Fmsd+mbLIpbJNTpHUeBNXG20q Fxc/5rQc+omF0BZo3k04sF+oTHjfsZxtzg49ocDldhL9mQHgg785qJvxjFdqI/OgWt8q auFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fmTlkmLm; dkim=neutral (no key) header.i=@linutronix.de header.b=SUifxZ3Y; 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 w5-20020a63af05000000b0047679c34e33si11235215pge.428.2022.11.21.06.37.58; Mon, 21 Nov 2022 06:38:12 -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=fmTlkmLm; dkim=neutral (no key) header.i=@linutronix.de header.b=SUifxZ3Y; 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 S231322AbiKUOh2 (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231279AbiKUOgm (ORCPT ); Mon, 21 Nov 2022 09:36:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2E1C7210; Mon, 21 Nov 2022 06:36:32 -0800 (PST) Message-ID: <20221121083326.056299459@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041391; 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=XKtpijacgcV8/nCTByztO8f4qnhUrmimBQl8oQuyrjc=; b=fmTlkmLmeCpYnQ2H384C1kftB37lQDAfjPUvbAxzkY6TKz4z1CMnXEhYFYOBbKR90REmp9 /Fbn+ghuUprcA0TS1MngifG+Hcf8OksUXJ3Q8E59tSyKCUe10iXuJQKzWZ02s4lJ/Dknmv 83HZoU36SrSzuabJ3Kifdcmq8iw1OckNtYx3tAV1COuknF81ZPFdqCaQF7AsNJKTCqG+YW pNI/LfXMbN7LQJxZUx6vB5tsJritM8Ymon9DE4g8uuXnR0lWgKN1ex/MZe0Z29i1d3gWo/ l5aJeQHmbAXvwAsp2jY2wHw9Wc43dpuzYW+pjbr8xMNUQldRA1WZ4i+jBdF5Iw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041391; 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=XKtpijacgcV8/nCTByztO8f4qnhUrmimBQl8oQuyrjc=; b=SUifxZ3Y0/AmPPpqvb6faM2hoCT6jLvDLeTgZ+9bYVKXEnuEhV/NLYlTe15YSGbT4T66N+ RIi40TUBSFPM9uDQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" Subject: [patch V2 10/21] genirq/msi: Make msi_get_virq() device domain aware References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:30 +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?1750116852007961227?= X-GMAIL-MSGID: =?utf-8?q?1750116852007961227?= From: Ahmed S. Darwish In preparation of the upcoming per device multi MSI domain support, change the interface to support lookups based on domain id and zero based index within the domain. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner --- V2: Fix the locking leak and the operator precedence issue (kernel robot) --- include/linux/msi_api.h | 14 +++++++++++++- kernel/irq/msi.c | 27 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) --- a/include/linux/msi_api.h +++ b/include/linux/msi_api.h @@ -18,6 +18,18 @@ enum msi_domain_ids { MSI_MAX_DEVICE_IRQDOMAINS, }; -unsigned int msi_get_virq(struct device *dev, unsigned int index); +unsigned int msi_domain_get_virq(struct device *dev, unsigned int domid, unsigned int index); + +/** + * msi_get_virq - Lookup the Linux interrupt number for a MSI index on the default interrupt domain + * @dev: Device for which the lookup happens + * @index: The MSI index to lookup + * + * Return: The Linux interrupt number on success (> 0), 0 if not found + */ +static inline unsigned int msi_get_virq(struct device *dev, unsigned int index) +{ + return msi_domain_get_virq(dev, MSI_DEFAULT_DOMAIN, index); +} #endif --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -351,25 +351,38 @@ struct msi_desc *msi_next_desc(struct de EXPORT_SYMBOL_GPL(msi_next_desc); /** - * msi_get_virq - Return Linux interrupt number of a MSI interrupt + * msi_domain_get_virq - Lookup the Linux interrupt number for a MSI index on a interrupt domain * @dev: Device to operate on + * @domid: Domain ID of the interrupt domain associated to the device * @index: MSI interrupt index to look for (0-based) * * Return: The Linux interrupt number on success (> 0), 0 if not found */ -unsigned int msi_get_virq(struct device *dev, unsigned int index) +unsigned int msi_domain_get_virq(struct device *dev, unsigned int domid, unsigned int index) { struct msi_desc *desc; unsigned int ret = 0; - bool pcimsi; + bool pcimsi = false; + int base; if (!dev->msi.data) return 0; - pcimsi = dev_is_pci(dev) ? to_pci_dev(dev)->msi_enabled : false; + if (WARN_ON_ONCE(index > MSI_MAX_INDEX)) + return 0; + + /* This check is only valid for the PCI default MSI domain */ + if (dev_is_pci(dev) && domid == MSI_DEFAULT_DOMAIN) + pcimsi = to_pci_dev(dev)->msi_enabled; msi_lock_descs(dev); - desc = xa_load(&dev->msi.data->__store, pcimsi ? 0 : index); + + base = msi_get_domain_base_index(dev, domid); + if (base < 0) + goto unlock; + + base += pcimsi ? 0 : index; + desc = xa_load(&dev->msi.data->__store, base); if (desc && desc->irq) { /* * PCI-MSI has only one descriptor for multiple interrupts. @@ -383,10 +396,12 @@ unsigned int msi_get_virq(struct device ret = desc->irq; } } + +unlock: msi_unlock_descs(dev); return ret; } -EXPORT_SYMBOL_GPL(msi_get_virq); +EXPORT_SYMBOL_GPL(msi_domain_get_virq); #ifdef CONFIG_SYSFS static struct attribute *msi_dev_attrs[] = { From patchwork Mon Nov 21 14:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626679wrr; Mon, 21 Nov 2022 06:38:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4G3H74Q4oJKEfr2fdXyrXRqo9MzQaCjkwKZzG+86hDCiDWMxw2co8ixWosYO+vRQTnZJIb X-Received: by 2002:a63:e617:0:b0:41a:4bd4:f466 with SMTP id g23-20020a63e617000000b0041a4bd4f466mr7597530pgh.499.1669041486060; Mon, 21 Nov 2022 06:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041486; cv=none; d=google.com; s=arc-20160816; b=vlD0S+E564oREQ0y7S0/0GhmiAwqQJkJ5TI7glg4xoKKhMGUZHEgnoq83atQ1lv0ju EAvlzGAnCl9WftRo04qfncuBbDs5XmNC3wK11BpWfKgo+Cjmf2dtlsIy35tBWiqfL0ER x6aRO3FpEMQCbt8YciRSD3fLgjMj7794nIYhr3vuqxvkUOOOz3TnAb9ew358GkSmXEqG cU1GNtdSLNrL9+4Sym9ZCZo662P8uUbn/QfwhRiWgg3R5mMhqQm4AqtGKXbLlIMSQ3oW Ru8wsBCEZhTUwTWAAz50Zcxy8bGOZIa8DUrMXL37wOAqfz9ox33riwyakVNZ0fiN7SFu z0wQ== 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=ZnCGeE1zb0VOfmSO6TChoSBAluSJ9ZEH47yEg4s6I+c=; b=zuLUFrZnfAXk4rSteTIiaer8uMDz8MXICHfSSnvX+44Ve73J1YaJlY/FDpISUQKN7h R/aAfuLDUTD6LhdW2iL3qTR2NL/rKhXTCDytXmeF+X1FJRMiaHVk68o3fGkMomuXYj4+ L1JTTf91uxSwNsly5IVGH4MhdBf5g0sHeBY8hmEd9WqQ1YOT44E57cNb32SvWN6Qbc1Q aT+w+2jaJvMv/xjtcWRLjpz79F9itXPqAvxjPEXkUnRc/WI7T5mg3LDRqoIOuS2zNl/z 2JAhVqjIC3oGrQhfIo829dOjfaDH5Dmjgh7YIsUiKh0JunPqpiihl4NaHJAy6JuGuAEh l/Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oYspf330; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qxpgalKr; 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 na18-20020a17090b4c1200b00218641b1acdsi14688558pjb.68.2022.11.21.06.37.51; Mon, 21 Nov 2022 06:38:06 -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=oYspf330; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qxpgalKr; 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 S231535AbiKUOhY (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiKUOgm (ORCPT ); Mon, 21 Nov 2022 09:36:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61EBC721C; Mon, 21 Nov 2022 06:36:33 -0800 (PST) Message-ID: <20221121083326.115115268@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041392; 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=ZnCGeE1zb0VOfmSO6TChoSBAluSJ9ZEH47yEg4s6I+c=; b=oYspf330JJzfcvl+HoWtCvZqLfSJ0tQbLWEl6imwjD+Kj9As6U7lsGbGnYi5wxHu8n6Dyh /atf44J3Us6nQMPCijNLdTwB9/2+cZUkunHX+Bju911ldLYdO/S39/9UiurA+JCKiXjtkA B3rwwijzwg02IpfkuoD4FEV+W20KMtvs8UWOFOml2kxEP/W5s4HZtSGi+xb4q1x+vcnZca 1Ax2D5oqP3HcyE/uWGibZ7SzCq6As0m/YQoJ7InOUV8T/FwtWStbt4NbPO17Gg9qInIlJh Z+20YRF5sNSWgoxztWyNxKfwwsQWa0LhOW4sagMpRuAzNduAofzZwJDQgQTk3w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041392; 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=ZnCGeE1zb0VOfmSO6TChoSBAluSJ9ZEH47yEg4s6I+c=; b=qxpgalKrCpsi2LFTsSGZlfuUyMGezkHsnxxgRb8k9Jt+igSkegorfK5mijnvrnar1p5Dsx sspv3lkYuWrWIDDg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Jason Gunthorpe Subject: [patch V2 11/21] genirq/msi: Rename msi_add_msi_desc() to msi_insert_msi_desc() References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:32 +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?1750116845421711476?= X-GMAIL-MSGID: =?utf-8?q?1750116845421711476?= This reflects the functionality better. No functional change. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/msi.c | 4 ++-- drivers/soc/ti/ti_sci_inta_msi.c | 4 ++-- include/linux/msi.h | 2 +- kernel/irq/msi.c | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -308,7 +308,7 @@ static int msi_setup_msi_desc(struct pci if (desc.pci.msi_attrib.can_mask) pci_read_config_dword(dev, desc.pci.mask_pos, &desc.pci.msi_mask); - return msi_add_msi_desc(&dev->dev, &desc); + return msi_insert_msi_desc(&dev->dev, &desc); } static int msi_verify_entries(struct pci_dev *dev) @@ -591,7 +591,7 @@ static int msix_setup_msi_descs(struct p desc.pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL); } - ret = msi_add_msi_desc(&dev->dev, &desc); + ret = msi_insert_msi_desc(&dev->dev, &desc); if (ret) break; } --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -73,13 +73,13 @@ static int ti_sci_inta_msi_alloc_descs(s for (set = 0; set < res->sets; set++) { for (i = 0; i < res->desc[set].num; i++, count++) { msi_desc.msi_index = res->desc[set].start + i; - if (msi_add_msi_desc(dev, &msi_desc)) + if (msi_insert_msi_desc(dev, &msi_desc)) goto fail; } for (i = 0; i < res->desc[set].num_sec; i++, count++) { msi_desc.msi_index = res->desc[set].start_sec + i; - if (msi_add_msi_desc(dev, &msi_desc)) + if (msi_insert_msi_desc(dev, &msi_desc)) goto fail; } } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -278,7 +278,7 @@ static inline void msi_desc_set_iommu_co } #endif -int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc); +int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc); void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); /** --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -100,13 +100,15 @@ static int msi_insert_desc(struct msi_de } /** - * msi_add_msi_desc - Allocate and initialize a MSI descriptor + * msi_insert_msi_desc - Allocate and initialize a MSI descriptor and + * insert it at @init_desc->msi_index + * * @dev: Pointer to the device for which the descriptor is allocated * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor * * Return: 0 on success or an appropriate failure code. */ -int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc) +int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) { struct msi_desc *desc; From patchwork Mon Nov 21 14:36:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626961wrr; Mon, 21 Nov 2022 06:38:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5M6Rs/AI7TXHGyQ3lXtAHQlC8J9CliD5SXMtgkT+1sXmsOdcTf5rJvxqs/1fQDp/c3IWiL X-Received: by 2002:a17:90a:4049:b0:210:5de0:f3e3 with SMTP id k9-20020a17090a404900b002105de0f3e3mr20459130pjg.61.1669041515247; Mon, 21 Nov 2022 06:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041515; cv=none; d=google.com; s=arc-20160816; b=aAsqP2WJV2Q0wM36WZNlh3u17rBWmrPa/ZLV/FpRg1wcS0CeOtu55QzozzFBK6R0aH n3tLLO0k2wF1NONFAwNT7X7VqmvbtO2GxJC8Gj11hvEF6zRL5uSo+/7eTGkK+mznA/fF 9UtM8wj0yrZW4GiH6JH7LvXjq3jSnf9Dea92PfOPoncjC7EtanjDiJm5kFKq6OQ1oQiL hu0blbqw/jc4YwTMcdADKVyQqatDZVvMn8pVZ0miptTERt6O/Uju4d/Lwj97CPhGqGgN Z3dBW6Aod7vDbr9mz9swb9z5aKYdQVQ9PH54LubKjmpPM50VEii4fAfiUefiOFFyYnTr EcYg== 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=A5WJRb2/4teczUo5tLJ1BYRZTZjOFdwhWlgYTs4xkWo=; b=LjVtuNjO7kxSFB7jHxt9dH1oyoQsSp9DU+C3lV2NFOLF0H9F0vgdQP71ulNRtg2kJK vfSyLZEx8sWcGov6I18TGqc4TU+/oEWkECG2KS9XaaPJ+c0IcruvDOei3gKBAwnyRh6e TCgJyVnaJAw8su7ew72L5xNqHrLpW+N2P2WbiM0SDJelCdkVTNHt1jCKxC7YtVTG42/C N7tEg4/sVW+8zaS3cYydiKn8noms6JCqQHWzjYDoCoL/lq+1ClNSgGc3a9BQK4OUFF4p LH6I/a/8Bz4unXqAZD8/3xMwHOqtqJF//GKR3o57fjZo8U2h7aQgiaDfCR8Ub0uxQHsG Kw9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GqcsxI4U; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bP6WwDkZ; 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 w189-20020a6382c6000000b00477632e6011si2485055pgd.308.2022.11.21.06.38.18; Mon, 21 Nov 2022 06:38:35 -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=GqcsxI4U; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bP6WwDkZ; 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 S230505AbiKUOhr (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiKUOgn (ORCPT ); Mon, 21 Nov 2022 09:36:43 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26229C72E2; Mon, 21 Nov 2022 06:36:35 -0800 (PST) Message-ID: <20221121083326.172418628@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041393; 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=A5WJRb2/4teczUo5tLJ1BYRZTZjOFdwhWlgYTs4xkWo=; b=GqcsxI4UBE4uCcl41WHYFRRjiTlVU3Rty+qxgKvdKG2bvTdRbVKRURNgNxXS3TGRw6OyIV wUYQq5i4ItodyAogUXTBzcHuHa1MjHoY4Vvy3j7k/nQ1nXWD+UPs17Z5NYQ4vc8R3V+brM XCETZUE4KCPo8z7gsWMz7KQUMW9tyGTP8vDT69Ns+Qb/ViLa5SYzKf6HO1vcn7RXbuuW/V 1J0ybhVeHoSA5VwIAynQUeCYYPb8kPWET5qWThLRgWFbToHJBL/bv9dEEIGv+lZWANfQgi l1MIEgMHavoXdPPJ9C2QJuQu6ljOv2YdFDHz44AWHMgG9yIRjwyUIqpHmxfJMg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041393; 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=A5WJRb2/4teczUo5tLJ1BYRZTZjOFdwhWlgYTs4xkWo=; b=bP6WwDkZXkBORZ2Vav6whh5bDM9I958EHSnWwhNTHSuWRimb4swaIHfet++FUEnDbiovOk ldRkeQ3UG39FD4DA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 12/21] genirq/msi: Make descriptor allocation device domain aware References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:33 +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?1750116876168477488?= X-GMAIL-MSGID: =?utf-8?q?1750116876168477488?= Change the descriptor allocation and insertion functions to take a domain id to prepare for the upcoming multi MSI domain per device support. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 16 +++++++++++++++- kernel/irq/msi.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 10 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -278,7 +278,21 @@ static inline void msi_desc_set_iommu_co } #endif -int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc); +int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid, + struct msi_desc *init_desc); +/** + * msi_insert_msi_desc - Allocate and initialize a MSI descriptor in the + * default irqdomain and insert it at @init_desc->msi_index + * @dev: Pointer to the device for which the descriptor is allocated + * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor + * + * Return: 0 on success or an appropriate failure code. + */ +static inline int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) +{ + return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc); +} + void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); /** --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -63,7 +63,7 @@ static int msi_get_domain_base_index(str * Return: pointer to allocated &msi_desc on success or %NULL on failure */ static struct msi_desc *msi_alloc_desc(struct device *dev, int nvec, - const struct irq_affinity_desc *affinity) + const struct irq_affinity_desc *affinity) { struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL); @@ -88,27 +88,42 @@ static void msi_free_desc(struct msi_des kfree(desc); } -static int msi_insert_desc(struct msi_device_data *md, struct msi_desc *desc, unsigned int index) +static int msi_insert_desc(struct device *dev, struct msi_desc *desc, + unsigned int domid, unsigned int index) { - int ret; + struct msi_device_data *md = dev->msi.data; + int baseidx, ret; + + baseidx = msi_get_domain_base_index(dev, domid); + if (baseidx < 0) { + ret = baseidx; + goto fail; + } desc->msi_index = index; + index += baseidx; ret = xa_insert(&md->__store, index, desc, GFP_KERNEL); if (ret) - msi_free_desc(desc); + goto fail; + return 0; + +fail: + msi_free_desc(desc); return ret; } /** - * msi_insert_msi_desc - Allocate and initialize a MSI descriptor and - * insert it at @init_desc->msi_index + * msi_domain_insert_msi_desc - Allocate and initialize a MSI descriptor and + * insert it at @init_desc->msi_index * * @dev: Pointer to the device for which the descriptor is allocated + * @domid: The id of the interrupt domain to which the desriptor is added * @init_desc: Pointer to an MSI descriptor to initialize the new descriptor * * Return: 0 on success or an appropriate failure code. */ -int msi_insert_msi_desc(struct device *dev, struct msi_desc *init_desc) +int msi_domain_insert_msi_desc(struct device *dev, unsigned int domid, + struct msi_desc *init_desc) { struct msi_desc *desc; @@ -120,7 +135,8 @@ int msi_insert_msi_desc(struct device *d /* Copy type specific data to the new descriptor. */ desc->pci = init_desc->pci; - return msi_insert_desc(dev->msi.data, desc, init_desc->msi_index); + + return msi_insert_desc(dev, desc, domid, init_desc->msi_index); } /** @@ -143,7 +159,7 @@ static int msi_add_simple_msi_descs(stru desc = msi_alloc_desc(dev, 1, NULL); if (!desc) goto fail_mem; - ret = msi_insert_desc(dev->msi.data, desc, idx); + ret = msi_insert_desc(dev, desc, MSI_DEFAULT_DOMAIN, idx); if (ret) goto fail; } From patchwork Mon Nov 21 14:36:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1626934wrr; Mon, 21 Nov 2022 06:38:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf55501ci+6AHAsE+o5G4YvkRoLYV9xoCFYKQ/rGwy86S5M02RczZE8M9bZET9b/Va3gfgpF X-Received: by 2002:a17:902:6a86:b0:188:cfc6:31fb with SMTP id n6-20020a1709026a8600b00188cfc631fbmr11959048plk.150.1669041512627; Mon, 21 Nov 2022 06:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041512; cv=none; d=google.com; s=arc-20160816; b=yuYddbMLKLfpklHX28PmQGwc7J5Og+gjqluLBHSbinDCCQosryRIKt/mqb4hHCe+fA DemFiF8WCJZoHrXAC9/lN0ToSjCuP8jJT4ZDnWiUDYI6Lr8n/+Zs0u4sjiWYUTqnPQT9 mpxXBDiyhaWeY314w2REe8svnN2LhkfI6yxUb+ZgxkqyaTdTdN6Cwz5Sbthm+Ewb4/wN /JnHyM0G/COhtLvPJTQtUG/25bBOpa/kCf9+e9B4u5dFqxpZEZAePmK03pBneZRfGgT0 UKBp/Lvxrx/BLIb/D10sGpC3WO7HReSaTKayaF4p0c59Yz8S/BcEt0uVwod14Pdnx5Eh PJrw== 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=dOtgU6S/AgeNLAQ6bDFFp47i8FpSOtxAOpG1mn2gg6Q=; b=S8WgNlr0JkUtYBNHkfUB3CrdDcpon2o8xk6U4CvsE/91QRi9WVm1CN/v/9Ge4xQGAa t+QPAWIM1m10iFJwnE+J+Nl5uAut8Z+02P0eAqMpOFkM8yU4eaupVxvbHC1MK27Ftfhf 5lfG2UDLYI8PjiKS4B4OetYBvBdS7scw0E0JwaAIwjzepP5uOdREdf7hetB7y61/NS/Z LdpUG+07A2qF7fQ0nLGtZxfRojAKA4sXoGB52NG/Ne6V5126VBNV35jOGDeVnHktdGvr VCcxwioDucP+GXuL6/u0Tp3G2H80Vg2xafKSkIc5BejLMQEo3tQ/rGZby3asHDMAG1ai G2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eANtBftp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="IKIFpPt/"; 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 i190-20020a6387c7000000b0045b00922ba5si11519328pge.871.2022.11.21.06.38.16; Mon, 21 Nov 2022 06:38:32 -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=eANtBftp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="IKIFpPt/"; 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 S230016AbiKUOhm (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbiKUOgo (ORCPT ); Mon, 21 Nov 2022 09:36:44 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43929C6BD2; Mon, 21 Nov 2022 06:36:36 -0800 (PST) Message-ID: <20221121083326.228016703@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041394; 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=dOtgU6S/AgeNLAQ6bDFFp47i8FpSOtxAOpG1mn2gg6Q=; b=eANtBftpzxrc/QJI1MS1MPLfVlliOfzLA5VFooCP2oe5d999Sf94Yn1GwHLltwr/ONwfmP GTQHvhVgKzDcpSUUuEPiodjPaRi6PfJsDdXbECf3csavvZFIx8rkGJrqbZS2DXc8MTEyZO 6FZNqW4qcyZpoyMu9DiGm9KyBVC7VSeMMnvQWeklNfTgRCdG/K4a9PXugtgAxknZwIk367 0yKmOGdcAecjjzz5/m8VGQW6dCQx2pg0spOJbIfsPBrxWJti+GzhSPBxG1UKjksSBguMWB KtqKl1KqnISiroMZ2X93fEu5mUn+gmzb0H9Z7Aqm5UkktMO/VfH5qZlAvFIDtw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041394; 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=dOtgU6S/AgeNLAQ6bDFFp47i8FpSOtxAOpG1mn2gg6Q=; b=IKIFpPt/bx0HdBkZi/rRcmDUUaF0E6lO43z9DYZ6frAcRg8uu1Q6A+Yex7RTONoeUdpJkL CIJSrveTDVevtwBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 13/21] genirq/msi: Make descriptor freeing domain aware References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:34 +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?1750116873136669664?= X-GMAIL-MSGID: =?utf-8?q?1750116873136669664?= Change the descriptor free functions to take a domain id to prepare for the upcoming multi MSI domain per device support. To avoid changing and extending the interfaces over and over use an core internal control struct and hand the pointer through the various functions. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 19 ++++++++++++++-- kernel/irq/msi.c | 59 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 11 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -293,10 +293,25 @@ static inline int msi_insert_msi_desc(st return msi_domain_insert_msi_desc(dev, MSI_DEFAULT_DOMAIN, init_desc); } -void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); +void msi_domain_free_msi_descs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last); /** - * msi_free_msi_descs - Free MSI descriptors of a device + * msi_free_msi_descs_range - Free a range of MSI descriptors of a device + * in the default irqdomain + * + * @dev: Device for which to free the descriptors + * @first: Index to start freeing from (inclusive) + * @last: Last index to be freed (inclusive) + */ +static inline void msi_free_msi_descs_range(struct device *dev, unsigned int first, + unsigned int last) +{ + msi_domain_free_msi_descs_range(dev, MSI_DEFAULT_DOMAIN, first, last); +} + +/** + * msi_free_msi_descs - Free all MSI descriptors of a device in the default irqdomain * @dev: Device to free the descriptors */ static inline void msi_free_msi_descs(struct device *dev) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -19,6 +19,18 @@ #include "internals.h" +/** + * struct msi_ctrl - MSI internal management control structure + * @domid: ID of the domain on which management operations should be done + * @first: First (hardware) slot index to operate on + * @last: Last (hardware) slot index to operate on + */ +struct msi_ctrl { + unsigned int domid; + unsigned int first; + unsigned int last; +}; + static inline int msi_sysfs_create_group(struct device *dev); /* Invalid XA index which is outside of any searchable range */ @@ -186,22 +198,32 @@ static bool msi_desc_match(struct msi_de return false; } -/** - * msi_free_msi_descs_range - Free MSI descriptors of a device - * @dev: Device to free the descriptors - * @first_index: Index to start freeing from - * @last_index: Last index to be freed - */ -void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, - unsigned int last_index) +static bool msi_ctrl_range_valid(struct device *dev, struct msi_ctrl *ctrl) +{ + if (WARN_ON_ONCE(ctrl->first > ctrl->last || + ctrl->first > MSI_MAX_INDEX || + ctrl->last > MSI_MAX_INDEX)) + return false; + return true; +} + +static void msi_domain_free_descs(struct device *dev, struct msi_ctrl *ctrl) { struct xarray *xa = &dev->msi.data->__store; struct msi_desc *desc; unsigned long idx; + int base; lockdep_assert_held(&dev->msi.data->mutex); - xa_for_each_range(xa, idx, desc, first_index, last_index) { + if (!msi_ctrl_range_valid(dev, ctrl)) + return; + + base = msi_get_domain_base_index(dev, ctrl->domid); + if (base < 0) + return; + + xa_for_each_range(xa, idx, desc, ctrl->first + base, ctrl->last + base) { xa_erase(xa, idx); /* Leak the descriptor when it is still referenced */ @@ -211,6 +233,25 @@ void msi_free_msi_descs_range(struct dev } } +/** + * msi_domain_free_msi_descs_range - Free a range of MSI descriptors of a device in an irqdomain + * @dev: Device for which to free the descriptors + * @domid: Id of the domain to operate on + * @first: Index to start freeing from (inclusive) + * @last: Last index to be freed (inclusive) + */ +void msi_domain_free_msi_descs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last) +{ + struct msi_ctrl ctrl = { + .domid = domid, + .first = first, + .last = last, + }; + + msi_domain_free_descs(dev, &ctrl); +} + void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg) { *msg = entry->msg; From patchwork Mon Nov 21 14:36:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627148wrr; Mon, 21 Nov 2022 06:38:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JwvsyZAymPX9wTQQOPvTyIprO7TPMRRTPIpdLEaGXM6IFBz/geiLdvGSHgbzdPzUuzWK2 X-Received: by 2002:a17:90a:c095:b0:213:2411:50e7 with SMTP id o21-20020a17090ac09500b00213241150e7mr21076820pjs.212.1669041536897; Mon, 21 Nov 2022 06:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041536; cv=none; d=google.com; s=arc-20160816; b=jvfZ3F3Q4gO36ndibzgtnCaeFdycrNZbz+9sfVMQl3yBNEBE2KLTV1hLBXAFP5rimF SgDnqDhBZsw/E6/dKIRE9pA2u5THxxz8NnFak7LAFD5UEMW4QGWM7EOP5E0O5l4t7x0z hICn0HbRHLPCOImXGdPmIwSLtttNhx/aDvHIWbCiGBQ86TUuV85npwj8XNg2Mb0L73pE ZObZmaSRYUi+MXYU8sO7jgnAU+ycF0I17+ch0p15VlaLxL/TmNp16D9we5fzOCYqSlTC ASmZe50CKCw+2cOSHOw5vsrU3tcgw1f7/OhUQcjbja/+kNRTWPNa9MQqkTQkERHIjses 4vjw== 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=eC4gIOc4oAqcyJBm6YiAoyMVqS0TXVnMO5WX7cXyl7A=; b=w1M7Q5V6Iv8mpjJrabmi/XJ9qjguVznS0LAYI0KezNIdZRddPPVObmU/WM/SaqRTu/ WEVYUsIKPevbo1DYjb+q18xtBn3/goXq2l3nvJBtVOEdi36SAhwdaMVSWBbXmlReOfiR vFdQxpT7OpilAruy7iFKd/9yOC0dTyUfInSm1ELMvprxRSRPn5mskr3Mf89uStesSuMi 6OHOlRp/4zy68qeLkxt2/+YNLAbBIDLdvOla/VOIK6oK6ybzg2yqorh+xzsCxYLISkgB YKnyXGn3CMswYMIGzOTN70pA8ZRU6v2naoYdonDpY8altmlkwxw3ItMAgIbux/6szfRQ r3cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Mmw/iZCo"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pYW1zhTW; 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 h2-20020a636c02000000b0043c0b452d3esi10943361pgc.292.2022.11.21.06.38.43; Mon, 21 Nov 2022 06:38:56 -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="Mmw/iZCo"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pYW1zhTW; 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 S231617AbiKUOhy (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbiKUOgo (ORCPT ); Mon, 21 Nov 2022 09:36:44 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D807C76A5; Mon, 21 Nov 2022 06:36:37 -0800 (PST) Message-ID: <20221121083326.283961511@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041396; 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=eC4gIOc4oAqcyJBm6YiAoyMVqS0TXVnMO5WX7cXyl7A=; b=Mmw/iZCoXopDZkikPGc686sDpHyI56c592bIaqzK3aEwLkERPVG2zXSW+1P4EjrLT+Dr9W AF2QnmzKkQOS5i3RtvCLQBE2eRVxOMdmjbdpXV6UHok5MgbVJXDozEthTDuY+zu2TzJosC vJd2kWxLONFzHoCLKwYcACw9IVQdJjShbSohY94euytWWpRY3yMvInE2fdcBXs3LWPePTv gDXxfPgEWuPg7xY1PRoUI1e0E0j+vwNVfVBNksMxa6jeeV/yYqqkqECPnOz+rL0yV/8Pcw UVVg2RMdw2sdCsmQYjQaf29IKl8uXWZe7Ze6ER/fnfVTDTWeWdJz8HuL/I9RKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041396; 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=eC4gIOc4oAqcyJBm6YiAoyMVqS0TXVnMO5WX7cXyl7A=; b=pYW1zhTWlu4AGtZjwmr/gXyTA0paLO7hcyGr56JG9zl8OWvaEiILhzE81i1pB1Lz1mdiW8 z1y45YbUgt3EdADw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 14/21] genirq/msi: Make msi_add_simple_msi_descs() device domain aware References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:35 +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?1750116898354437830?= X-GMAIL-MSGID: =?utf-8?q?1750116898354437830?= Allocating simple interrupt descriptors in the core code has to be multi device irqdomain aware for the upcoming PCI/IMS support. Change the interfaces to take a domain id into account. Use the internal control struct for transport of arguments. Signed-off-by: Thomas Gleixner --- kernel/irq/msi.c | 99 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 40 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -151,39 +151,6 @@ int msi_domain_insert_msi_desc(struct de return msi_insert_desc(dev, desc, domid, init_desc->msi_index); } -/** - * msi_add_simple_msi_descs - Allocate and initialize MSI descriptors - * @dev: Pointer to the device for which the descriptors are allocated - * @index: Index for the first MSI descriptor - * @ndesc: Number of descriptors to allocate - * - * Return: 0 on success or an appropriate failure code. - */ -static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsigned int ndesc) -{ - unsigned int idx, last = index + ndesc - 1; - struct msi_desc *desc; - int ret; - - lockdep_assert_held(&dev->msi.data->mutex); - - for (idx = index; idx <= last; idx++) { - desc = msi_alloc_desc(dev, 1, NULL); - if (!desc) - goto fail_mem; - ret = msi_insert_desc(dev, desc, MSI_DEFAULT_DOMAIN, idx); - if (ret) - goto fail; - } - return 0; - -fail_mem: - ret = -ENOMEM; -fail: - msi_free_msi_descs_range(dev, index, last); - return ret; -} - static bool msi_desc_match(struct msi_desc *desc, enum msi_desc_filter filter) { switch (filter) { @@ -252,6 +219,45 @@ void msi_domain_free_msi_descs_range(str msi_domain_free_descs(dev, &ctrl); } +/** + * msi_domain_add_simple_msi_descs - Allocate and initialize MSI descriptors + * @dev: Pointer to the device for which the descriptors are allocated + * @ctrl: Allocation control struct + * + * Return: 0 on success or an appropriate failure code. + */ +static int msi_domain_add_simple_msi_descs(struct device *dev, struct msi_ctrl *ctrl) +{ + struct msi_desc *desc; + unsigned int idx; + int ret, baseidx; + + lockdep_assert_held(&dev->msi.data->mutex); + + if (!msi_ctrl_range_valid(dev, ctrl)) + return -EINVAL; + + baseidx = msi_get_domain_base_index(dev, ctrl->domid); + if (baseidx < 0) + return baseidx; + + for (idx = ctrl->first; idx <= ctrl->last; idx++) { + desc = msi_alloc_desc(dev, 1, NULL); + if (!desc) + goto fail_mem; + ret = msi_insert_desc(dev, desc, ctrl->domid, idx); + if (ret) + goto fail; + } + return 0; + +fail_mem: + ret = -ENOMEM; +fail: + msi_domain_free_descs(dev, ctrl); + return ret; +} + void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg) { *msg = entry->msg; @@ -821,11 +827,19 @@ int msi_domain_populate_irqs(struct irq_ { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; + struct msi_ctrl ctrl = { + .domid = MSI_DEFAULT_DOMAIN, + .first = virq_base, + .last = virq_base + nvec - 1, + }; struct msi_desc *desc; int ret, virq; + if (!msi_ctrl_range_valid(dev, &ctrl)) + return -EINVAL; + msi_lock_descs(dev); - ret = msi_add_simple_msi_descs(dev, virq_base, nvec); + ret = msi_domain_add_simple_msi_descs(dev, &ctrl); if (ret) goto unlock; @@ -846,7 +860,7 @@ int msi_domain_populate_irqs(struct irq_ fail: for (--virq; virq >= virq_base; virq--) irq_domain_free_irqs_common(domain, virq, 1); - msi_free_msi_descs_range(dev, virq_base, virq_base + nvec - 1); + msi_domain_free_descs(dev, &ctrl); unlock: msi_unlock_descs(dev); return ret; @@ -1020,14 +1034,19 @@ static int __msi_domain_alloc_irqs(struc return 0; } -static int msi_domain_add_simple_msi_descs(struct msi_domain_info *info, - struct device *dev, - unsigned int num_descs) +static int msi_domain_alloc_simple_msi_descs(struct device *dev, + struct msi_domain_info *info, + unsigned int num_descs) { + struct msi_ctrl ctrl = { + .domid = MSI_DEFAULT_DOMAIN, + .last = num_descs - 1, + }; + if (!(info->flags & MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS)) return 0; - return msi_add_simple_msi_descs(dev, 0, num_descs); + return msi_domain_add_simple_msi_descs(dev, &ctrl); } /** @@ -1058,7 +1077,7 @@ int msi_domain_alloc_irqs_descs_locked(s } /* Frees allocated descriptors in case of failure. */ - ret = msi_domain_add_simple_msi_descs(info, dev, nvec); + ret = msi_domain_alloc_simple_msi_descs(dev, info, nvec); if (ret) goto free; From patchwork Mon Nov 21 14:36:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627005wrr; Mon, 21 Nov 2022 06:38:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7D5iVKeTZNjH1IXOYJYgDCe+fjoveJd7NM3VUOi/jM8KEklIPOvuyJthc3j9D3FHn4e78r X-Received: by 2002:a17:902:efd3:b0:186:a3ad:4c63 with SMTP id ja19-20020a170902efd300b00186a3ad4c63mr12294753plb.1.1669041521736; Mon, 21 Nov 2022 06:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041521; cv=none; d=google.com; s=arc-20160816; b=JK+Ss3HgkSzDPI+/xv2vNTol9CjqTBqr6Wz22lW9OlIFzdQqnu+IDIE9UrdCGcCufa JNfcmxrdUIleY/iK54EUFKGsGaX/+Tx1jQhHNUbnu9Y8/KQ7BK9+llNatYfQhTB12Z1m jExhaPYoL8onMhBhR8DsDQiLPSbRihNF6VKD5ytqUHaZjJPFtuN0REAi/C9IemzuvKfW 1a+Nixc+iQxdiRhGxUcyGH43wi8h2u46QWas2JdAxbMZZiwStpZJsCZZVDSBzKqhTYxz HoIqw6/Chnn3GjkGP8qVu9gN2vdDC2+yKljZasRWRxIFTwJz6dt7fjLcQYGaZXbPpnum qIdg== 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=zI5hL6Om6U/wesfweo1nHUdrqPQtkL8zWiWvAT55sAo=; b=bEZy1oA1QlpOM/I02VD4hil/R/tDJH64hucfVJNgWMXkSVZvLRqJKOcF2A5xwFtlPV wulUCi5AGuhai7Q9niUB7Ar6gGV4jKf4RL4YyN4yZKTIeO6TKJ9o/r/dDOtcYUpieNBE K9u7hFrA8BZqBQdC7etNJctwBi7hOkYvjUgaswvTae0MSjlA9PshYBQkF9yC9iRtidn1 emP9yKinyfuizLHdLav5x+Uit/lwFkZb3FqVNMMIOSghOucjmaYDURKWWoQurkf3/Su5 OFknCXXkUI3lmVVfCmJyTo5PlAQVC3DZMeHeeh7bLhI9PB9Au+nWUVVuAyEOkD6oSKSt ZAdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EOflo+mB; dkim=neutral (no key) header.i=@linutronix.de; 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 c16-20020a63ea10000000b00476ba5e977bsi11009449pgi.327.2022.11.21.06.38.25; Mon, 21 Nov 2022 06:38:41 -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=EOflo+mB; dkim=neutral (no key) header.i=@linutronix.de; 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 S231368AbiKUOhu (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbiKUOgo (ORCPT ); Mon, 21 Nov 2022 09:36:44 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2817C76A0; Mon, 21 Nov 2022 06:36:38 -0800 (PST) Message-ID: <20221121083326.339579071@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041397; 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=zI5hL6Om6U/wesfweo1nHUdrqPQtkL8zWiWvAT55sAo=; b=EOflo+mBRewFofpk62tLzHd6LDTyplTOPtouEa3OmsTyo8z2DDPT5ftLYWuFWuoMcZ97BO M+UTIKf6EyIavihWjJ8GNlCkfhbX3r+aZa6EnugirF9+PM8F+2Ja7vXWRgNmU4X1Bip01i xkDKSKVLhdrKnZmubyAPeB+PkstzRwJq0rComVVzGE4sul3AkEvNHkLQDKQ2eQAdkUliBr XXVCKnjHPjsmTh8bgC1GxgtUqXDG0LXVb9E9vAJ4cEKd4IZBd2mfmF4/9folZR8fkKgfPn mJ6+r7XqvdfAhh7l/NJCLHd+UkCJDf5AFlLXoW8umVDHE+WHa7h6ocHn1dqY1Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041397; 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=zI5hL6Om6U/wesfweo1nHUdrqPQtkL8zWiWvAT55sAo=; b=EOZrJZgxmXNe82DswH8+g/7O8aYRPlbEtGkZTMe1g5cfF8lSKnsNaBDW8yNJTo5IR+dACQ 5xeqNLu+ic9/+gDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 15/21] genirq/msi: Provide new domain id based interfaces for freeing interrupts References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:37 +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?1750116883117215539?= X-GMAIL-MSGID: =?utf-8?q?1750116883117215539?= Provide two sorts of interfaces to handle the different use cases: - msi_domain_free_irqs_range(): Handles a caller defined precise range - msi_domain_free_irqs_all(): Frees all interrupts associated to a domain The latter is useful for device teardown and to handle the legacy MSI support which does not have any range information available. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 9 +++ kernel/irq/msi.c | 146 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 132 insertions(+), 23 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -490,6 +490,15 @@ int msi_domain_alloc_irqs(struct irq_dom int nvec); void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); + +void msi_domain_free_irqs_range_locked(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last); +void msi_domain_free_irqs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last); + +void msi_domain_free_irqs_all_locked(struct device *dev, unsigned int domid); +void msi_domain_free_irqs_all(struct device *dev, unsigned int domid); + struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -583,7 +583,25 @@ static inline void msi_sysfs_remove_desc #endif /* !CONFIG_SYSFS */ static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); -static void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); + +static struct irq_domain *msi_get_device_domain(struct device *dev, unsigned int domid) +{ + struct irq_domain *domain; + + lockdep_assert_held(&dev->msi.data->mutex); + + if (WARN_ON_ONCE(domid >= MSI_MAX_DEVICE_IRQDOMAINS)) + return NULL; + + domain = dev->msi.data->__irqdomains[domid]; + if (!domain) + return NULL; + + if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) + return NULL; + + return domain; +} static inline void irq_chip_write_msi_msg(struct irq_data *data, struct msi_msg *msg) @@ -744,7 +762,6 @@ static struct msi_domain_ops msi_domain_ .msi_prepare = msi_domain_ops_prepare, .set_desc = msi_domain_ops_set_desc, .domain_alloc_irqs = __msi_domain_alloc_irqs, - .domain_free_irqs = __msi_domain_free_irqs, }; static void msi_domain_update_dom_ops(struct msi_domain_info *info) @@ -758,8 +775,6 @@ static void msi_domain_update_dom_ops(st if (ops->domain_alloc_irqs == NULL) ops->domain_alloc_irqs = msi_domain_ops_default.domain_alloc_irqs; - if (ops->domain_free_irqs == NULL) - ops->domain_free_irqs = msi_domain_ops_default.domain_free_irqs; if (!(info->flags & MSI_FLAG_USE_DEF_DOM_OPS)) return; @@ -1108,15 +1123,23 @@ int msi_domain_alloc_irqs(struct irq_dom return ret; } -static void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) +static void __msi_domain_free_irqs(struct device *dev, struct irq_domain *domain, + struct msi_ctrl *ctrl) { struct msi_domain_info *info = domain->host_data; + struct xarray *xa = &dev->msi.data->__store; struct irq_data *irqd; struct msi_desc *desc; - int i; + unsigned long idx; + int i, base; + + base = ctrl->domid * MSI_XA_DOMAIN_SIZE; + + xa_for_each_range(xa, idx, desc, ctrl->first + base, ctrl->last + base) { + /* Only handle MSI entries which have an interrupt associated */ + if (!msi_desc_match(desc, MSI_DESC_ASSOCIATED)) + continue; - /* Only handle MSI entries which have an interrupt associated */ - msi_for_each_desc(desc, dev, MSI_DESC_ASSOCIATED) { /* Make sure all interrupts are deactivated */ for (i = 0; i < desc->nvec_used; i++) { irqd = irq_domain_get_irq_data(domain, desc->irq + i); @@ -1131,11 +1154,99 @@ static void __msi_domain_free_irqs(struc } } -static void msi_domain_free_msi_descs(struct msi_domain_info *info, - struct device *dev) +static void msi_domain_free_locked(struct device *dev, struct msi_ctrl *ctrl) { + struct msi_domain_info *info; + struct msi_domain_ops *ops; + struct irq_domain *domain; + + if (!msi_ctrl_range_valid(dev, ctrl)) + return; + + domain = msi_get_device_domain(dev, ctrl->domid); + if (!domain) + return; + + info = domain->host_data; + ops = info->ops; + + if (ops->domain_free_irqs) + ops->domain_free_irqs(domain, dev); + else + __msi_domain_free_irqs(dev, domain, ctrl); + + if (ops->msi_post_free) + ops->msi_post_free(domain, dev); + if (info->flags & MSI_FLAG_FREE_MSI_DESCS) - msi_free_msi_descs(dev); + msi_domain_free_descs(dev, ctrl); +} + +/** + * msi_domain_free_irqs_range_locked - Free a range of interrupts from a MSI interrupt domain + * associated to @dev with msi_lock held + * @dev: Pointer to device struct of the device for which the interrupts + * are freed + * @domid: Id of the interrupt domain to operate on + * @first: First index to free (inclusive) + * @last: Last index to free (inclusive) + */ +void msi_domain_free_irqs_range_locked(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last) +{ + struct msi_ctrl ctrl = { + .domid = domid, + .first = first, + .last = last, + }; + msi_domain_free_locked(dev, &ctrl); +} + +/** + * msi_domain_free_irqs_range - Free a range of interrupts from a MSI interrupt domain + * associated to @dev + * @dev: Pointer to device struct of the device for which the interrupts + * are freed + * @domid: Id of the interrupt domain to operate on + * @first: First index to free (inclusive) + * @last: Last index to free (inclusive) + */ +void msi_domain_free_irqs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last) +{ + msi_lock_descs(dev); + msi_domain_free_irqs_range_locked(dev, domid, first, last); + msi_unlock_descs(dev); +} + +/** + * msi_domain_free_irqs_all_locked - Free all interrupts from a MSI interrupt domain + * associated to a device + * @dev: Pointer to device struct of the device for which the interrupts + * are freed + * @domid: The id of the domain to operate on + * + * Must be invoked from within a msi_lock_descs() / msi_unlock_descs() + * pair. Use this for MSI irqdomains which implement their own vector + * allocation. + */ +void msi_domain_free_irqs_all_locked(struct device *dev, unsigned int domid) +{ + msi_domain_free_irqs_range_locked(dev, domid, 0, MSI_MAX_INDEX); +} + +/** + * msi_domain_free_irqs_all - Free all interrupts from a MSI interrupt domain + * associated to a device + * @dev: Pointer to device struct of the device for which the interrupts + * are freed + * @domid: The id of the domain to operate on + */ +void msi_domain_free_irqs_all(struct device *dev, unsigned int domid) +{ + msi_lock_descs(dev); + msi_domain_free_irqs_all_locked(dev, domid); + msi_unlock_descs(dev); } /** @@ -1150,18 +1261,7 @@ static void msi_domain_free_msi_descs(st */ void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev) { - struct msi_domain_info *info = domain->host_data; - struct msi_domain_ops *ops = info->ops; - - lockdep_assert_held(&dev->msi.data->mutex); - - if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) - return; - - ops->domain_free_irqs(domain, dev); - if (ops->msi_post_free) - ops->msi_post_free(domain, dev); - msi_domain_free_msi_descs(info, dev); + msi_domain_free_irqs_range_locked(dev, MSI_DEFAULT_DOMAIN, 0, MSI_MAX_INDEX); } /** From patchwork Mon Nov 21 14:36:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627182wrr; Mon, 21 Nov 2022 06:39:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Uj01yrQwSi70Nflxc2bkFLuSjL9LhxrpbqTMPw9pPfJ5WMXvc4gcjtk8Zm86rrnb2A2u5 X-Received: by 2002:a17:902:ca14:b0:188:dcfb:f2dc with SMTP id w20-20020a170902ca1400b00188dcfbf2dcmr7351300pld.5.1669041540794; Mon, 21 Nov 2022 06:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041540; cv=none; d=google.com; s=arc-20160816; b=RkYvfm3NwZ9K3q+OVeJtX82mZzKsBQH8jMFg+37tpd5Z7KEwAJ8BLFShjeWXGAKQHc G9PCctHSDs3Hw+ZtPt1w40QEMebXdpQ3ehJhDZsgudbv3MmIhj50GllbN64cU2/oi2pr 7R5VJqmCZWDH3qKGat2hDz3+ff8xZMUAHVbxdeJsSd9CCcxkZ66j56aDRm51OCQ3X35W 1fRGuGjHNsl2nG0UaZJsHEc32AJj+SCIqSRGfWqSbZPl13D2w8a34SV/ouifvxSbB8rP TwZAxeAIRoaavjZq3rD6wOCR3LRoWjMJekBfuYD6D167fHfURD5/SND60B4zVqHjNxQd G/3Q== 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=KIVieCT5YrO5ZtFgVkPWDpR/xD55B+v0G1YHqVi8nCg=; b=MO3GIjjyuPugyB2zdx2bweFNv1DVjFQ0xg5yT2A9niNFc0ux3lGr6MVp6y/tFl5UW2 uf7gz2EsBWmprAJAM+KABSMbzJhNqrFFpd5OJy+0/9kg4X8AlOLJ0Z/brOHsPEdEpaSz 2Mt0uNjbjnKXuikIuOoJXyiB3HefGrxfXj8rpExyj9SI89UfaobvHsAIuW7Rje9xqq7y tf2ZRoF9+P95XRD7W8VndFY2PYMcoJJcPC2rwDhFtRXuYhM9JMfe3qw0pgKlQqgouJf4 1bFHAXTmDyUP9LPHAT7EK45OjKiZTDgrDYjpCGg37GTpPN3kkJ1ONa88wisohOLOxzeO tPOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xfJG1y2I; dkim=neutral (no key) header.i=@linutronix.de; 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 oj6-20020a17090b4d8600b001fb23f3f238si11601992pjb.71.2022.11.21.06.38.45; Mon, 21 Nov 2022 06:39:00 -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=xfJG1y2I; dkim=neutral (no key) header.i=@linutronix.de; 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 S231631AbiKUOh5 (ORCPT + 99 others); Mon, 21 Nov 2022 09:37:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbiKUOgp (ORCPT ); Mon, 21 Nov 2022 09:36:45 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167AD73BA7; Mon, 21 Nov 2022 06:36:40 -0800 (PST) Message-ID: <20221121083326.395696242@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041398; 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=KIVieCT5YrO5ZtFgVkPWDpR/xD55B+v0G1YHqVi8nCg=; b=xfJG1y2I8oEJ4WqfO+qW9vGRmn0Xq9fdfaJMfTzfRQ9bIIDFwaFnFQMJ5TVnq+puLo4hlK XxwgUiyofGNLy9c3tUPlpb+efh6Mqz0BoM0p7NFs/FO/YP0YVCRn8v5OWO/tj2WlrDBkH4 RTAWKf7qz6DKhANvc8FJFnKlbcNv3vkXWaz0sjDGOcJSrurY2hhMlBymXmGz7w8LfMaxVS 0WMqT06BOgUwgzPd6eLfJN5are53wTiinvRJhsYDzwnyUkDNJfHn/aKSJaurwdqNHNcB5u UxR1Oi7cNj290CeBnW3Akv9Z1rqm0mug/Zgjyv/OTG/ysrio0rBUB7yPFQ0nHg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041398; 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=KIVieCT5YrO5ZtFgVkPWDpR/xD55B+v0G1YHqVi8nCg=; b=HqeOGsiPjcvholJQ3lRCiEvZpOrwG9jZqWJ0tZD9IHYZ0Wk8xe6WIl32619xdRagN46144 NbTXzblp9aFY6PBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 16/21] genirq/msi: Provide new domain id allocation functions References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:38 +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?1750116902920814215?= X-GMAIL-MSGID: =?utf-8?q?1750116902920814215?= Provide two sorts of interfaces to handle the different use cases: - msi_domain_alloc_irqs_range(): Handles a caller defined precise range - msi_domain_alloc_irqs_all(): Allocates all interrupts associated to a domain by scanning the allocated MSI descriptors The latter is useful for the existing PCI/MSI support which does not have range information available. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 18 ++--- kernel/irq/msi.c | 179 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 149 insertions(+), 48 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -375,8 +375,8 @@ struct msi_domain_info; * @get_hwirq, @msi_init and @msi_free are callbacks used by the underlying * irqdomain. * - * @msi_check, @msi_prepare and @set_desc are callbacks used by - * msi_domain_alloc/free_irqs(). + * @msi_check, @msi_prepare and @set_desc are callbacks used by the + * msi_domain_alloc/free_irqs*() variants. * * @domain_alloc_irqs, @domain_free_irqs can be used to override the * default allocation/free functions (__msi_domain_alloc/free_irqs). This @@ -384,11 +384,6 @@ struct msi_domain_info; * be wrapped into the regular irq domains concepts by mere mortals. This * allows to universally use msi_domain_alloc/free_irqs without having to * special case XEN all over the place. - * - * Contrary to other operations @domain_alloc_irqs and @domain_free_irqs - * are set to the default implementation if NULL and even when - * MSI_FLAG_USE_DEF_DOM_OPS is not set to avoid breaking existing users and - * because these callbacks are obviously mandatory. */ struct msi_domain_ops { irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info, @@ -488,14 +483,21 @@ int msi_domain_alloc_irqs_descs_locked(s int nvec); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); + void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); +int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last); +int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last); +int msi_domain_alloc_irqs_all_locked(struct device *dev, unsigned int domid, int nirqs); + + void msi_domain_free_irqs_range_locked(struct device *dev, unsigned int domid, unsigned int first, unsigned int last); void msi_domain_free_irqs_range(struct device *dev, unsigned int domid, unsigned int first, unsigned int last); - void msi_domain_free_irqs_all_locked(struct device *dev, unsigned int domid); void msi_domain_free_irqs_all(struct device *dev, unsigned int domid); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -24,13 +24,17 @@ * @domid: ID of the domain on which management operations should be done * @first: First (hardware) slot index to operate on * @last: Last (hardware) slot index to operate on + * @nirqs: The number of Linux interrupts to allocate. Can be larger + * than the range due to PCI/multi-MSI. */ struct msi_ctrl { unsigned int domid; unsigned int first; unsigned int last; + unsigned int nirqs; }; +static void msi_domain_free_locked(struct device *dev, struct msi_ctrl *ctrl); static inline int msi_sysfs_create_group(struct device *dev); /* Invalid XA index which is outside of any searchable range */ @@ -582,8 +586,6 @@ static inline int msi_sysfs_populate_des static inline void msi_sysfs_remove_desc(struct device *dev, struct msi_desc *desc) { } #endif /* !CONFIG_SYSFS */ -static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); - static struct irq_domain *msi_get_device_domain(struct device *dev, unsigned int domid) { struct irq_domain *domain; @@ -761,7 +763,6 @@ static struct msi_domain_ops msi_domain_ .msi_init = msi_domain_ops_init, .msi_prepare = msi_domain_ops_prepare, .set_desc = msi_domain_ops_set_desc, - .domain_alloc_irqs = __msi_domain_alloc_irqs, }; static void msi_domain_update_dom_ops(struct msi_domain_info *info) @@ -773,9 +774,6 @@ static void msi_domain_update_dom_ops(st return; } - if (ops->domain_alloc_irqs == NULL) - ops->domain_alloc_irqs = msi_domain_ops_default.domain_alloc_irqs; - if (!(info->flags & MSI_FLAG_USE_DEF_DOM_OPS)) return; @@ -986,18 +984,19 @@ static int msi_init_virq(struct irq_doma return 0; } -static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec) +static int __msi_domain_alloc_irqs(struct device *dev, struct irq_domain *domain, + struct msi_ctrl *ctrl) { struct msi_domain_info *info = domain->host_data; + struct xarray *xa = &dev->msi.data->__store; struct msi_domain_ops *ops = info->ops; + unsigned int vflags = 0, allocated = 0; msi_alloc_info_t arg = { }; - unsigned int vflags = 0; + int i, ret, virq, base; struct msi_desc *desc; - int allocated = 0; - int i, ret, virq; + unsigned long idx; - ret = msi_domain_prepare_irqs(domain, dev, nvec, &arg); + ret = msi_domain_prepare_irqs(domain, dev, ctrl->nirqs, &arg); if (ret) return ret; @@ -1023,7 +1022,16 @@ static int __msi_domain_alloc_irqs(struc vflags |= VIRQ_NOMASK_QUIRK; } - msi_for_each_desc(desc, dev, MSI_DESC_NOTASSOCIATED) { + base = ctrl->domid * MSI_XA_DOMAIN_SIZE; + + xa_for_each_range(xa, idx, desc, ctrl->first + base, ctrl->last + base) { + if (!msi_desc_match(desc, MSI_DESC_NOTASSOCIATED)) + continue; + + /* This should return -ECONFUSED... */ + if (WARN_ON_ONCE(allocated >= ctrl->nirqs)) + return -EINVAL; + ops->set_desc(&arg, desc); virq = __irq_domain_alloc_irqs(domain, -1, desc->nvec_used, @@ -1051,17 +1059,122 @@ static int __msi_domain_alloc_irqs(struc static int msi_domain_alloc_simple_msi_descs(struct device *dev, struct msi_domain_info *info, - unsigned int num_descs) + struct msi_ctrl *ctrl) +{ + if (!(info->flags & MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS)) + return 0; + + return msi_domain_add_simple_msi_descs(dev, ctrl); +} + +static int __msi_domain_alloc_locked(struct device *dev, struct msi_ctrl *ctrl) +{ + struct msi_domain_info *info; + struct msi_domain_ops *ops; + struct irq_domain *domain; + int ret; + + if (!msi_ctrl_range_valid(dev, ctrl)) + return -EINVAL; + + domain = msi_get_device_domain(dev, ctrl->domid); + if (!domain) + return -ENODEV; + + info = domain->host_data; + + ret = msi_domain_alloc_simple_msi_descs(dev, info, ctrl); + if (ret) + return ret; + + ops = info->ops; + if (ops->domain_alloc_irqs) + return ops->domain_alloc_irqs(domain, dev, ctrl->nirqs); + + return __msi_domain_alloc_irqs(dev, domain, ctrl); +} + +static int msi_domain_alloc_locked(struct device *dev, struct msi_ctrl *ctrl) +{ + int ret = __msi_domain_alloc_locked(dev, ctrl); + + if (ret) + msi_domain_free_locked(dev, ctrl); + return ret; +} + +/** + * msi_domain_alloc_irqs_range_locked - Allocate interrupts from a MSI interrupt domain + * @dev: Pointer to device struct of the device for which the interrupts + * are allocated + * @domid: Id of the interrupt domain to operate on + * @first: First index to allocate (inclusive) + * @last: Last index to allocate (inclusive) + * + * Must be invoked from within a msi_lock_descs() / msi_unlock_descs() + * pair. Use this for MSI irqdomains which implement their own descriptor + * allocation/free. + * + * Return: %0 on success or an error code. + */ +int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last) { struct msi_ctrl ctrl = { - .domid = MSI_DEFAULT_DOMAIN, - .last = num_descs - 1, + .domid = domid, + .first = first, + .last = last, + .nirqs = last + 1 - first, }; - if (!(info->flags & MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS)) - return 0; + return msi_domain_alloc_locked(dev, &ctrl); +} + +/** + * msi_domain_alloc_irqs_range - Allocate interrupts from a MSI interrupt domain + * @dev: Pointer to device struct of the device for which the interrupts + * are allocated + * @domid: Id of the interrupt domain to operate on + * @first: First index to allocate (inclusive) + * @last: Last index to allocate (inclusive) + * + * Return: %0 on success or an error code. + */ +int msi_domain_alloc_irqs_range(struct device *dev, unsigned int domid, + unsigned int first, unsigned int last) +{ + int ret; - return msi_domain_add_simple_msi_descs(dev, &ctrl); + msi_lock_descs(dev); + ret = msi_domain_alloc_irqs_range_locked(dev, domid, first, last); + msi_unlock_descs(dev); + return ret; +} + +/** + * msi_domain_alloc_irqs_all_locked - Allocate all interrupts from a MSI interrupt domain + * + * @dev: Pointer to device struct of the device for which the interrupts + * are allocated + * @domid: Id of the interrupt domain to operate on + * @nirqs: The number of interrupts to allocate + * + * This function scans all MSI descriptors of the MSI domain and allocates interrupts + * for all unassigned ones. That function is to be used for MSI domain usage where + * the descriptor allocation is handled at the call site, e.g. PCI/MSI[X]. + * + * Return: %0 on success or an error code. + */ +int msi_domain_alloc_irqs_all_locked(struct device *dev, unsigned int domid, int nirqs) +{ + struct msi_ctrl ctrl = { + .domid = domid, + .first = 0, + .last = MSI_MAX_INDEX, + .nirqs = nirqs, + }; + + return msi_domain_alloc_locked(dev, &ctrl); } /** @@ -1080,28 +1193,14 @@ static int msi_domain_alloc_simple_msi_d int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, int nvec) { - struct msi_domain_info *info = domain->host_data; - struct msi_domain_ops *ops = info->ops; - int ret; - - lockdep_assert_held(&dev->msi.data->mutex); - - if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) { - ret = -EINVAL; - goto free; - } - - /* Frees allocated descriptors in case of failure. */ - ret = msi_domain_alloc_simple_msi_descs(dev, info, nvec); - if (ret) - goto free; + struct msi_ctrl ctrl = { + .domid = MSI_DEFAULT_DOMAIN, + .first = 0, + .last = MSI_MAX_INDEX, + .nirqs = nvec, + }; - ret = ops->domain_alloc_irqs(domain, dev, nvec); - if (!ret) - return 0; -free: - msi_domain_free_irqs_descs_locked(domain, dev); - return ret; + return msi_domain_alloc_locked(dev, &ctrl); } /** From patchwork Mon Nov 21 14:36:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627207wrr; Mon, 21 Nov 2022 06:39:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7tjBlNijxOP0GVCxauFZ/dsWR4LiyxMo1K48oolpy9SacAttVKjMObbWIGWceS1jhm1uxq X-Received: by 2002:a17:902:7d94:b0:188:f0e1:ef42 with SMTP id a20-20020a1709027d9400b00188f0e1ef42mr2023751plm.166.1669041543788; Mon, 21 Nov 2022 06:39:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041543; cv=none; d=google.com; s=arc-20160816; b=I3Ay4uirVxe9qCfMfx3lQm7y5eCG7tekcrwuvUCDv8JvIUe0YyFqgfFWHSVfVkVZD6 rKlUxsJqrUjzEFz8iyvVr5zjSPMRUTd8AW19OPkUm5t+RXekKwMOJcU4MIlwy6kR4iLl nQF1LV7PwlJBi9/hapTk0s1LxW34vBoY3Qzj2wD3XkpRbtijVFNjHseEdKIly9uVLEon kb242s1pA7nIJN+VElQLjshzpkFbrXKFwsofyq8f8iT5PG6BcZSqfqiextQMlyWcBx8+ DYO5z7XKTR/hiGokCXKL0DWLhYen4N/5EOFgl3MyjkyC4ZJrO+DdpVllIK9ewFt/SpSD YO2Q== 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=g4QPlbf/kZK7IE6hnczsu6AmVOXaYfuEpjg2N6VHa1U=; b=nBs9AuyhxPHE2TZREFd3VKG2Hqcuw73NTDZwOd9I7V/j8cW2R46Yh4DXHfZ+k17jyM m9sNrPTiMECG2yZ32WUN04QNLkpbozjtmjDFg0AqTixJ6Cfh4UGmg6rV8BDr77ezbosv sSnWGQ5Vdvonevae8+/hLBAOspkuCCvdnOwFyTEmJvPoQeH1CqNy6f0AP2D9BLhilDIG Hy4C1O14H2BoV4u6Bwxnv3EgRKGM/57Oz0DbPpOaIHVm66I+CjR58NEz5Zu6mtsrUQRp MB6sp35temAMrsZ3bWOBe7z64sZlx25nQFw/4E9utO+oERF9Ca2ahX59llmucuOMivHc AUxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="JhNtr/my"; dkim=neutral (no key) header.i=@linutronix.de; 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 n10-20020a170902d2ca00b00188f0ca6838si12939338plc.569.2022.11.21.06.38.49; Mon, 21 Nov 2022 06:39:03 -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="JhNtr/my"; dkim=neutral (no key) header.i=@linutronix.de; 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 S231553AbiKUOiD (ORCPT + 99 others); Mon, 21 Nov 2022 09:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbiKUOgp (ORCPT ); Mon, 21 Nov 2022 09:36:45 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A86C6BFE; Mon, 21 Nov 2022 06:36:41 -0800 (PST) Message-ID: <20221121083326.451412447@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041399; 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=g4QPlbf/kZK7IE6hnczsu6AmVOXaYfuEpjg2N6VHa1U=; b=JhNtr/myl7sTYsZkFaNXoZvsyFXwR7OsO5tGwrf0hUhsIoeB2vfgzbvdci+jZxbbxYU4Yn GrjMKBmOUYe4nZ8i1eFehzLYDcKYq8LzTeTZIwcnnquXm1pOgxbvJUhtbuQ2Fptk1+I4qF UGBT2sakYMRQVqr6f9jaunHUaCESHQ8o/LvCu3m5Yh9Nd7Jtv38FrUfIon3dVuZL3JWjKc wEX5aW6srGp9g4I0Q/svAouCR3HqFXrg3YS4Cld57SSDV0JCZ2BhbCdsfkAhVLE8TkIr2A qY0x+Kv8PHFpj2XcTfRXWTxJGE8/hXNlqVSS2U9vr6vi/1KSjJCoCHliy+oJWw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041399; 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=g4QPlbf/kZK7IE6hnczsu6AmVOXaYfuEpjg2N6VHa1U=; b=R4JlIJg7yrPBj1VvEB0zM08yCyUsfvtNcRcEXwT0rxRbiBaMx9pM6gugtWAraRu71rFZH/ zi5XsKplaUbLuGAg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 17/21] PCI/MSI: Use msi_domain_alloc/free_irqs_all_locked() References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:39 +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?1750116906153637385?= X-GMAIL-MSGID: =?utf-8?q?1750116906153637385?= Switch to the new domain id aware interfaces to phase out the previous ones. This uses the _all() variants of the MSI allocation/free interfaces because due to potentially sparse indices of the preallocated MSI descriptors describing the range precisely is not possible. No functional change. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/irqdomain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -14,7 +14,7 @@ int pci_msi_setup_msi_irqs(struct pci_de domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) - return msi_domain_alloc_irqs_descs_locked(domain, &dev->dev, nvec); + return msi_domain_alloc_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN, nvec); return pci_msi_legacy_setup_msi_irqs(dev, nvec, type); } @@ -25,7 +25,7 @@ void pci_msi_teardown_msi_irqs(struct pc domain = dev_get_msi_domain(&dev->dev); if (domain && irq_domain_is_hierarchy(domain)) { - msi_domain_free_irqs_descs_locked(domain, &dev->dev); + msi_domain_free_irqs_all_locked(&dev->dev, MSI_DEFAULT_DOMAIN); } else { pci_msi_legacy_teardown_msi_irqs(dev); msi_free_msi_descs(&dev->dev); From patchwork Mon Nov 21 14:36:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627214wrr; Mon, 21 Nov 2022 06:39:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf558rzdCEB+9y8gRKEnyznQpmiTvTr/MtpQ6Js0oNHxk4flL5asTmZBjE3T7FH0F/Ul+370 X-Received: by 2002:a63:4046:0:b0:460:fa0c:ab73 with SMTP id n67-20020a634046000000b00460fa0cab73mr6406776pga.315.1669041544786; Mon, 21 Nov 2022 06:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041544; cv=none; d=google.com; s=arc-20160816; b=gr8B354gNDs4VpQVVLRgyxHXT4RcFBlO6RQm1+GyxYKSZzaznnvKXOemuQmEKLYVm6 CyNyPiNli6dRWiCEDGFSiaj1cOE6Cf/e6mTHU0v9BOSwBAPPldb5N4Vi3XIkAKCWnPOL eVNz+yUOpMFfSkoTtDxKFVEcYHk5tulK5rQ7WtDd9g5CzqZ1yJxpHgwRVuzM2FR5F5pU xs/BxxFG3j8p+iD0gsuC6HPib4FdO0tJ9lwVrX3H8aT//pUcBer96aAJWQvksPwg0ag8 /x1CKdqkV3Ezmrv9xL1AGZ0VlxsucHRjGciOaINtPrLIyJ0fuvpqOEN0MWSx59+Y2dfg nAug== 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=KdxaqYbUAroipCiY9Q/sHRBQvYFsOFnVJz7w23FqFeo=; b=rOsEgTAY/HuwZPKSWz5hljrhEvAtTfak3ipEODboV3gviMW1Wgu2LE4YE+lY5lrikd jaJdUfsc3s+XcWrolHiWHyViodC5eKSYXkUyoAIls1u0JF4Mqc6Hk6kGJzIG6AkDWWNr aWA0pX1B7lT/6afYXuFAFTTrEICbxAGboPjJRvmzob6AOHQH5yNMJ/th791NpBU4wXvs bbjvxDuRyrY8MUEO6VurEVUEwpErHvfuwCQZMbP5zqRmGyOhKc3lcBEJRZXioXKRNY81 9mUvRJG9LuSbHxy1/RqGdDhm6/+79EU6Ijp0V5zQh9as2uWL3bqpd8nIB2D7rLRtsjTb 0kIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NOios5We; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 p12-20020a056a000b4c00b0056d7aaaf1eesi11193437pfo.122.2022.11.21.06.38.50; Mon, 21 Nov 2022 06:39:04 -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=NOios5We; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231682AbiKUOiM (ORCPT + 99 others); Mon, 21 Nov 2022 09:38:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230345AbiKUOgp (ORCPT ); Mon, 21 Nov 2022 09:36:45 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F558C76A4; Mon, 21 Nov 2022 06:36:42 -0800 (PST) Message-ID: <20221121083326.506769769@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041401; 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=KdxaqYbUAroipCiY9Q/sHRBQvYFsOFnVJz7w23FqFeo=; b=NOios5WejLcPP5Q9VeeaXfoWZvS8Ir8ZWLx+007Su5rzKenKqqbIWCQfMSww6qa8dc+CZU qsB32jkH/7fgJIBXbEttedCh7XaE7g/KcSXK6mSLU5Y+rUeiGBEnlxPMLXJklVE24+Jz0R Eyc+3HdDp6dTiTiuTqbhjHjwRfLEE8/wRTm94vqdcvlf7ZZTAbnxAyk+J1URQxK0JKQqUi KRn6XzDl0lrtyT4HfONIkCbCl5qlDT2lmLSb8OJcSnZzVHW33Psl4psy8UZly+lIpKTdW1 +bX6ZThtNt5aXkGqfDv0O6fiYutrS7+suFpBAzZfhowpH47HifNupXDXUbueDg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041401; 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=KdxaqYbUAroipCiY9Q/sHRBQvYFsOFnVJz7w23FqFeo=; b=4JEeV+scQUqhhKLeb+3YP0NzubdIlifZaQ3kDRjWdvsouIu5isL//dqrvCZxuMwUFzhBgi AoOK+iW9RpO97zCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" Subject: [patch V2 18/21] platform-msi: Switch to the domain id aware MSI interfaces References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:40 +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?1750116907199110090?= X-GMAIL-MSGID: =?utf-8?q?1750116907199110090?= From: Ahmed S. Darwish Switch to the new domain id aware interfaces to phase out the previous ones. Use the range interface for allocation as the MSI descriptors are allocate by the MSI core and therefore a precise range has to be given. On free just tear down all MSI interrupts for simplicity. No functional change. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner --- drivers/base/platform-msi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -213,7 +213,7 @@ int platform_msi_domain_alloc_irqs(struc if (err) return err; - err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec); + err = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0, nvec - 1); if (err) platform_msi_free_priv_data(dev); @@ -227,7 +227,7 @@ EXPORT_SYMBOL_GPL(platform_msi_domain_al */ void platform_msi_domain_free_irqs(struct device *dev) { - msi_domain_free_irqs(dev->msi.domain, dev); + msi_domain_free_irqs_all(dev, MSI_DEFAULT_DOMAIN); platform_msi_free_priv_data(dev); } EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); From patchwork Mon Nov 21 14:36:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627250wrr; Mon, 21 Nov 2022 06:39:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NtABKFf+/tEwCMvJT/c448Q8/IUSv0490PFwG/vrq5KCX8yk4P4bzn3ZEJ8TVS+rEHglR X-Received: by 2002:a17:902:ca04:b0:188:f993:724a with SMTP id w4-20020a170902ca0400b00188f993724amr769209pld.77.1669041549121; Mon, 21 Nov 2022 06:39:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041549; cv=none; d=google.com; s=arc-20160816; b=AGJAP/MRzCg+VwEP1GKNYQSraS1drqW3JeUPhlkSxsfHc8b9D210LO9JJ745aT2BPX T5NVKqiLSvJeq6rqKPSGeFb2SUvEiUITirKdjgqG6jaAPfiA27GH6IpRXcllO2D2awtl +YkPho28G/BybU//ZFPo2VwWq0kgXkrHdaw2RXuhJ/s11HpWov4wIv1/crw1HaAoZIZr 8z8BWJ1Dr5ewzofzMQhmmRzXQ+Td1Vw79KuS9R9FyXGDKcF2hZlMrfuWOIbNOS1up0EK o0haOApzAi7cW65IVI8PdWZsqPnG0guI2qQ+WP+PnbZb5Txt3pADQ4LYU1UuVfpcGVZy bqRw== 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=Dc0ZFlk2JAPmF0v24u3+k7yycgC6/ipKg9qXDEwD/vU=; b=UeRnMBbYlTxEZv098PpHudQHfbzjCJ7/VLDpR3+fSvZkgEIGy5wu0v2McFjXWvdPnd LyJ/K/cZ+l7Vz3N3ug4sFRUFLCqEsUtcbBFDzoVAhc3UtCHzjl4wnDnUcI7Iahmovj18 12gNQRKhhSszdXE04fUZUZQh4BOf5goekA4mhFoCoFANKgK5H9S0or10ZOdPT81P1Hiz mvrwX+KoFemylDMyTrZYUC74tb3FIkygqkw2rtlmyM3u0CDRXCBKgK5YBDq4A/o+ZIML fX83s1jz4DUIDaB56/RHpWs5GAPT3mNanLInlHVHpjnjNR8pFEYU5A5nOnM1r5QO/mrE HYXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VaFlFjBD; dkim=neutral (no key) header.i=@linutronix.de header.b=Su3d0lcf; 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 q1-20020a170902dac100b0018914bd1b66si6190316plx.105.2022.11.21.06.38.54; Mon, 21 Nov 2022 06:39:09 -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=VaFlFjBD; dkim=neutral (no key) header.i=@linutronix.de header.b=Su3d0lcf; 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 S231700AbiKUOiQ (ORCPT + 99 others); Mon, 21 Nov 2022 09:38:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbiKUOgq (ORCPT ); Mon, 21 Nov 2022 09:36:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0683C76A6; Mon, 21 Nov 2022 06:36:43 -0800 (PST) Message-ID: <20221121083326.562323643@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041402; 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=Dc0ZFlk2JAPmF0v24u3+k7yycgC6/ipKg9qXDEwD/vU=; b=VaFlFjBDVa6HJIaY2cjyzQLRAvezi2uSZ+cBOuDTxCVMmoHTN6adMFOUrGJEzxSBjOHzTD IQsDEqMDdQUp0SRI6nlodNzN4jeE/jgE5dtLQjCtdYJTu8F7QCsgySYaIWicqhP3/m6Uk8 77ZO4ZPdMaLayxnyk5eSvKarJsPpctkv7/3X4hVm2zu2Bc04CRpLD9P0LWKIAnlxj+HAO7 vA2OrMMx5OFxcMzgBieRWfqeAM2eoKUjEm5UMkY7rYpQDyzdpD9Xv+wDzxkhfL7iF0Pdkn zmwEMwBAwPyE8nWUDMxL3Mj6LWG3F4G9fsTvpDYOMKx6IwsFBPjk8wtS/fIHOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041402; 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=Dc0ZFlk2JAPmF0v24u3+k7yycgC6/ipKg9qXDEwD/vU=; b=Su3d0lcfmOFRa+bdpPmWSdcHlphAcY6+INF+dRNd/JtIJhIX4d+Lv6AK1iO2DYU/fVzQkR 99rdhYMi5TtbEcBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 19/21] bus: fsl-mc-msi: Switch to domain id aware interfaces References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:42 +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?1750116911478496815?= X-GMAIL-MSGID: =?utf-8?q?1750116911478496815?= Switch to the new domain id aware interfaces to phase out the previous ones. Get rid of the MSI descriptor and domain checks as the core code detects these issues anyway. No functional change. Signed-off-by: Thomas Gleixner --- drivers/bus/fsl-mc/fsl-mc-msi.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) --- a/drivers/bus/fsl-mc/fsl-mc-msi.c +++ b/drivers/bus/fsl-mc/fsl-mc-msi.c @@ -213,21 +213,8 @@ struct irq_domain *fsl_mc_find_msi_domai int fsl_mc_msi_domain_alloc_irqs(struct device *dev, unsigned int irq_count) { - struct irq_domain *msi_domain; - int error; + int error = msi_setup_device_data(dev); - msi_domain = dev_get_msi_domain(dev); - if (!msi_domain) - return -EINVAL; - - error = msi_setup_device_data(dev); - if (error) - return error; - - msi_lock_descs(dev); - if (msi_first_desc(dev, MSI_DESC_ALL)) - error = -EINVAL; - msi_unlock_descs(dev); if (error) return error; @@ -235,7 +222,7 @@ int fsl_mc_msi_domain_alloc_irqs(struct * NOTE: Calling this function will trigger the invocation of the * its_fsl_mc_msi_prepare() callback */ - error = msi_domain_alloc_irqs(msi_domain, dev, irq_count); + error = msi_domain_alloc_irqs_range(dev, MSI_DEFAULT_DOMAIN, 0, irq_count - 1); if (error) dev_err(dev, "Failed to allocate IRQs\n"); @@ -244,11 +231,5 @@ int fsl_mc_msi_domain_alloc_irqs(struct void fsl_mc_msi_domain_free_irqs(struct device *dev) { - struct irq_domain *msi_domain; - - msi_domain = dev_get_msi_domain(dev); - if (!msi_domain) - return; - - msi_domain_free_irqs(msi_domain, dev); + msi_domain_free_irqs_all(dev, MSI_DEFAULT_DOMAIN); } From patchwork Mon Nov 21 14:36:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627268wrr; Mon, 21 Nov 2022 06:39:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf7I9f0BHG9kKsXgz0QMDxihChnVT3RSb/S+na0/VAZgo+Ed0lIx1Awigz0iJLKG/7TRU11e X-Received: by 2002:a17:902:680e:b0:188:d552:fb02 with SMTP id h14-20020a170902680e00b00188d552fb02mr500787plk.76.1669041551950; Mon, 21 Nov 2022 06:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041551; cv=none; d=google.com; s=arc-20160816; b=ODdHHG2TQ3DiarMCDzy5dLRXnXzi3MIxQbjFiPMXnA5wQiyje/rfMRTXdEouqgRq2/ ozPPxbTVcHfNHPweV8D6oe4aSIpluKX7PJZQc4ax5edE++U4P7LeDrjnyN2ir6DZ7Jom ey6kVbuPm2Ws0kPOaHiOO9ScwNU8W/JZQHkmn2sMEAKzbl5GNtXNJTNSJbugC2NncELg H0zILjTEz94AlxNEqUztCF+v2DxZT/yzrIjCOV+l14Cl/XSPXCbHGfw50nex2jAVy1HB AG4ghgZozJ8tigVCRS9WxvB5VJBw8h5O2gjZYGMIenTMj5By5RGLRmi7D7NmSq6siglz m8Aw== 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=/bVC6uqxnLqu0Y//SpNf+743RFr9freD3IllzYYvzRs=; b=U27Al1Whcaag50kZJKCsF8yvlQXv2hRAe04RR4umLhTb3k4gv/LUYHPosI/kedxxIj ccHgBdrEPZI2t8q5IeoPuGAbx27e20T3+PJT1m7b4Wu6xSCwmyFGNgtmOb4svt9D7mSJ MgKzElzsVe4/eW0aNkRQEsuf3h+0dlwaQM6AyOmbtKy0DLKZhwOa9BXRHL7nn8n0/P/d +iOV+lip5P8lkAQBPCkVR8Qt+HrjPksKDME/9nRrSjUzEghNwVCVwRN8IEVnApbiePIn 21O2R2vS61gZOCuhfdqzCEYkFIMndS6vvLCKFz2NxFVJv4/f/rUH0dNYxLmV0JQ+Ffhl yxuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=W4ofMafV; dkim=neutral (no key) header.i=@linutronix.de; 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 l6-20020a170903120600b0017f7fa141f2si12895211plh.583.2022.11.21.06.38.56; Mon, 21 Nov 2022 06:39:11 -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=W4ofMafV; dkim=neutral (no key) header.i=@linutronix.de; 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 S231566AbiKUOiS (ORCPT + 99 others); Mon, 21 Nov 2022 09:38:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiKUOgq (ORCPT ); Mon, 21 Nov 2022 09:36:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B759C76A7; Mon, 21 Nov 2022 06:36:45 -0800 (PST) Message-ID: <20221121083326.617156908@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041403; 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=/bVC6uqxnLqu0Y//SpNf+743RFr9freD3IllzYYvzRs=; b=W4ofMafVh7rm8emZNfhg4DWL9YKcdUtjs6guGjP+2xWvPEkM/Z3g8zvywlJ26EKcimUPrG p+0rRkGpxZfQIsBIfNoLlxbsP8n0+fTwgcTFVghxl/CvmU4D4r4XCylHgj9HYAdcp4f2vy gcXpl9/m4tFuqoq1GI2UKZVzxjKi7LD3xsvuo7grqLp4btDr97+UovVC9Rtu89uH1UqTQ9 RArVsqghKaGxoK2DCPrp0AePChj16INqKWprmxNEB3ydCybr6uPJxRgf3EFp3Kske6WiGc rKecQRavmplxvjIuu/blQKmUMnhRFhPmDx86o+uFKcQEHU7AXLfmQN8EYMGn1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041403; 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=/bVC6uqxnLqu0Y//SpNf+743RFr9freD3IllzYYvzRs=; b=wL0px/wfju+i+mk2KAVG6Hi7dBxm2Ya43G2ZKWk//5waKcYH38ir3ie5RLpaUd9kfqjs/Q KmVlvoEmJ4gsRWBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , "Ahmed S. Darwish" Subject: [patch V2 20/21] oc: ti: ti_sci_inta_msi: Switch to domain id aware MSI functions References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:43 +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?1750116914574652854?= X-GMAIL-MSGID: =?utf-8?q?1750116914574652854?= From: Ahmed S. Darwish Switch to the new domain id aware interfaces to phase out the previous ones. Remove the domain check as it happens in the core code now. No functional change. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner --- drivers/soc/ti/ti_sci_inta_msi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/drivers/soc/ti/ti_sci_inta_msi.c +++ b/drivers/soc/ti/ti_sci_inta_msi.c @@ -93,13 +93,8 @@ int ti_sci_inta_msi_domain_alloc_irqs(st struct ti_sci_resource *res) { struct platform_device *pdev = to_platform_device(dev); - struct irq_domain *msi_domain; int ret, nvec; - msi_domain = dev_get_msi_domain(dev); - if (!msi_domain) - return -EINVAL; - if (pdev->id < 0) return -ENODEV; @@ -114,7 +109,8 @@ int ti_sci_inta_msi_domain_alloc_irqs(st goto unlock; } - ret = msi_domain_alloc_irqs_descs_locked(msi_domain, dev, nvec); + /* Use alloc ALL as it's unclear whether there are gaps in the indices */ + ret = msi_domain_alloc_irqs_all_locked(dev, MSI_DEFAULT_DOMAIN, nvec); if (ret) dev_err(dev, "Failed to allocate IRQs %d\n", ret); unlock: From patchwork Mon Nov 21 14:36:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 23810 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1627311wrr; Mon, 21 Nov 2022 06:39:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5SAb99yNShKnt3ZIu5gFVgLiikKRsY9GP2aXSYLCgVgiwKU9XgHADoovMD3oHUeOHFdOtE X-Received: by 2002:aa7:81d8:0:b0:561:c694:80b with SMTP id c24-20020aa781d8000000b00561c694080bmr20710872pfn.47.1669041555648; Mon, 21 Nov 2022 06:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669041555; cv=none; d=google.com; s=arc-20160816; b=Nj9/17QkK+sPSzsfZ7i76kuD7FBFK+Ciidn3rc8cWOMyIRxbODwjHlcjvuve+eOzmX +wI2zNRcL0n3woCHjm82RI+Ur29rTTLMJ6onDOJ02jc4koDybnWvZuUz5oAr8/wCsqCe cf1GX9qY8zvhFKY21/r/Ta9YZI595jVMgQPXyU5U+Dgelqb4NbuiDcjGbg5ugj24tOO7 bANF13d4TcztFqLXYS2IuIa4yuoOvRUtQ4i9KGr+pq3DGEJb03uR7H5HBNCT5CUMyvTt eQWJb/yE3mkyPqJfqBuTmtZMXPLZG/ekKnMLf5nMyUmpEhomnD6kdDcl2CKIxSo6aQ7h roHw== 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=kKZ6YRjY9aGG9HRn9rYYYIg6fBxMMWfqpTeU5FCww7w=; b=ZkybZMiZ8WAs2osSSAfctIYee/ta3RP81hVNNQpRIqxnuoij4KipEgwYiO8Q47zRGn VScKP840jeKVvLJha51yPY6WU45IcEnf2Ludwvado03TTpgiF5nwxaTbZgO22gQOnpfd 41xhUBcw0hI/TixiKXoAgA8ET5XXLAMzh+0rTZSBrI57DYp4ONXdRLFAkFnvg/UU2xO0 EIxGTGJ6ZK1nQseZTCmklCcct+TFmLTI+cN0HvaGppf+3BbSU9lJnJtDKYrctUSuwi7F bJD1popOPD4dhgKqW9CMVpz7avjKo0p1s5Yr4FHGKDBzzOMDCLK+LEyFGkyMDxzLarJG 8qcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=O7mY7LLD; dkim=neutral (no key) header.i=@linutronix.de; 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 b18-20020a170903229200b00177fd8409b7si13429319plh.73.2022.11.21.06.38.57; Mon, 21 Nov 2022 06:39:15 -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=O7mY7LLD; dkim=neutral (no key) header.i=@linutronix.de; 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 S231710AbiKUOi0 (ORCPT + 99 others); Mon, 21 Nov 2022 09:38:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbiKUOgs (ORCPT ); Mon, 21 Nov 2022 09:36:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDF8C76B6; Mon, 21 Nov 2022 06:36:46 -0800 (PST) Message-ID: <20221121083326.673666308@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041404; 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=kKZ6YRjY9aGG9HRn9rYYYIg6fBxMMWfqpTeU5FCww7w=; b=O7mY7LLDCEdlO9BZwAQSu6EAgv6+QZBT5QlMxlEyy0NAfJcKPFQBNsfmPTnh0YDd3mrZDG +qA8nd+P/c/8eqVC4VJqwbDWKyjWMqFvKdxdwcVrbQwDKx6hhH/JSynOWDj1ogiIwOOU5g YT7MuejVMpmKE+LUDXOx3HkWqkxECKyswHgpOJjKuYolSWTtPl+AjGHNerDeKEbeu7Mw+k 0aFrg6waFCGhGCqtdbJKvbcSKUzveP6iDPXSJs5D1zDw3cwZYLUHmcnDC/DYG0l7iH1gSM y+8MbNF6iV0gv3MbcrmQt17sFVRbzIsYSkZPVcx+XgvhOfRCDUY314RgwQ02GQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041404; 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=kKZ6YRjY9aGG9HRn9rYYYIg6fBxMMWfqpTeU5FCww7w=; b=6Q93etPjq8tbOMJBZNVd8aH+AvSLsfPS2H8ym1Rys7qwauH0Uo+6iax97pEb8weS7QoF/E Va8QMkAZZvl1q5Bw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe Subject: [patch V2 21/21] genirq/msi: Remove unused alloc/free interfaces References: <20221121083210.309161925@linutronix.de> MIME-Version: 1.0 Date: Mon, 21 Nov 2022 15:36:44 +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?1750116918450584325?= X-GMAIL-MSGID: =?utf-8?q?1750116918450584325?= Now that all users are converted remove the old interfaces. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 7 ---- kernel/irq/msi.c | 73 ---------------------------------------------------- 2 files changed, 80 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -479,13 +479,6 @@ int msi_domain_set_affinity(struct irq_d struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); -int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, - int nvec); -int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec); - -void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); -void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); int msi_domain_alloc_irqs_range_locked(struct device *dev, unsigned int domid, unsigned int first, unsigned int last); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1177,51 +1177,6 @@ int msi_domain_alloc_irqs_all_locked(str return msi_domain_alloc_locked(dev, &ctrl); } -/** - * msi_domain_alloc_irqs_descs_locked - Allocate interrupts from a MSI interrupt domain - * @domain: The domain to allocate from - * @dev: Pointer to device struct of the device for which the interrupts - * are allocated - * @nvec: The number of interrupts to allocate - * - * Must be invoked from within a msi_lock_descs() / msi_unlock_descs() - * pair. Use this for MSI irqdomains which implement their own vector - * allocation/free. - * - * Return: %0 on success or an error code. - */ -int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, - int nvec) -{ - struct msi_ctrl ctrl = { - .domid = MSI_DEFAULT_DOMAIN, - .first = 0, - .last = MSI_MAX_INDEX, - .nirqs = nvec, - }; - - return msi_domain_alloc_locked(dev, &ctrl); -} - -/** - * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain - * @domain: The domain to allocate from - * @dev: Pointer to device struct of the device for which the interrupts - * are allocated - * @nvec: The number of interrupts to allocate - * - * Return: %0 on success or an error code. - */ -int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec) -{ - int ret; - - msi_lock_descs(dev); - ret = msi_domain_alloc_irqs_descs_locked(domain, dev, nvec); - msi_unlock_descs(dev); - return ret; -} - static void __msi_domain_free_irqs(struct device *dev, struct irq_domain *domain, struct msi_ctrl *ctrl) { @@ -1348,34 +1303,6 @@ void msi_domain_free_irqs_all(struct dev msi_unlock_descs(dev); } -/** - * msi_domain_free_irqs_descs_locked - Free interrupts from a MSI interrupt @domain associated to @dev - * @domain: The domain to managing the interrupts - * @dev: Pointer to device struct of the device for which the interrupts - * are free - * - * Must be invoked from within a msi_lock_descs() / msi_unlock_descs() - * pair. Use this for MSI irqdomains which implement their own vector - * allocation. - */ -void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev) -{ - msi_domain_free_irqs_range_locked(dev, MSI_DEFAULT_DOMAIN, 0, MSI_MAX_INDEX); -} - -/** - * msi_domain_free_irqs - Free interrupts from a MSI interrupt @domain associated to @dev - * @domain: The domain to managing the interrupts - * @dev: Pointer to device struct of the device for which the interrupts - * are free - */ -void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) -{ - msi_lock_descs(dev); - msi_domain_free_irqs_descs_locked(domain, dev); - msi_unlock_descs(dev); -} - /** * msi_get_domain_info - Get the MSI interrupt domain info for @domain * @domain: The interrupt domain to retrieve data from