From patchwork Mon Dec 5 18:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 29867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2409925wrr; Mon, 5 Dec 2022 10:29:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lPr3dUXU994g7UOkkGjxrqszQcyRaf+yC4BRFYPMDdjuQmP6+LWCSy2A6FGhyLDvW18Mg X-Received: by 2002:a63:4944:0:b0:44e:466f:4759 with SMTP id y4-20020a634944000000b0044e466f4759mr57843175pgk.194.1670264974817; Mon, 05 Dec 2022 10:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670264974; cv=none; d=google.com; s=arc-20160816; b=CiP0/B5QJhFj0kG+xjXcVXZ+H6TYLvAUVvkeRNPH3+XhYa8nqP8DyggegAxFVRj2aU gLZksMZoZ+1uDA0+KJFJOm32n6i+5g+qLFWWxhTcxK/BN5eOrt2NozRW2rcyxboMTIGp Xzg3UDRxq+Hjh/YjhH3q/+/ipbYYE+Wzv9y+pO9ju5bbP6Z9sLhZA1HTLX9ObaOsG2Xu kZU+Nx1TDKSlJtXq+1/Ks/S6ZQ+VhmbHfOxWXrHNvC+ETrG9jusINqolQ613MfhL2HmZ SPgDKphQuxDwcqXYOMqNCj//x37XmXtgduQc4TQj42XHv3F8GvpJXESTDjMVIoTAuNzb yVfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=+FuHGXJQ2eCwfFqjBR9ci6mT+JzX/TmthXfIpZNRGFo=; b=saQwL66fDE8IaF3VkaaGMpfwGbQkN84jG50kxnIzstaHJDMgJ7q8gJ02/KWGK/0MQR dEADs8yj2KQkUFMbTxFv7J2r/Bu5kCWAqtkLPaOnBCc8mCvgyTez2XNyG4VBiKYAlsrf 618BC6Ak5QMlwa+AIER8wUV9rUA78G3WG0L/MNqw/JJ5UXp/WZDfUoRG24B0TfeOP45y RsOR7H6wPZbqWeGFwV6lx9A/MoKDac2z3Z/ehywt9szH8naFMhfzUywGe92qAUJUKMta ZUzDNVWpKgGGsQix1VvqHr8c18fLilIDyWWnDcsvk8QrgJBP681Of9+05ToWViojgDMC +eqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=U6KwUJtf; 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 v202-20020a6361d3000000b00478c659e381si2221035pgb.782.2022.12.05.10.29.21; Mon, 05 Dec 2022 10:29:34 -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=U6KwUJtf; 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 S233508AbiLES2q (ORCPT + 99 others); Mon, 5 Dec 2022 13:28:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232597AbiLESZX (ORCPT ); Mon, 5 Dec 2022 13:25:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1435021256; Mon, 5 Dec 2022 10:25:22 -0800 (PST) Date: Mon, 05 Dec 2022 18:25:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670264720; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+FuHGXJQ2eCwfFqjBR9ci6mT+JzX/TmthXfIpZNRGFo=; b=U6KwUJtfluYtJFm3kZ+2+PYYOxxFAD2HFsxpoPCd4LLKL4stHQcpjvirbNjVhxADitGEwC PKnY/2A6rxEPS34WkbWV9rh2iheyYpnyvdyODGXWydQq/QbMWrPPPUr4ZBCstSe/MWT9I9 89b8kVf2pqwoT+WYjuLrn+fXv1lITvJG6BQKIrzfBWViBx/b9SsIqspGAxGg8dB7jxGxWM +2Su4A3V/knzZ6d2sgDkeaiM7fxzEV6kit4JFMnD4xluevMnSwjA2W9U7EonnLUOFmTpRB 1IcNpoNVRacliTPLFrQWAeJM9PFHQ3+QK7yXA+v7kl91AHMhd+AkjQ17BJGH2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670264720; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+FuHGXJQ2eCwfFqjBR9ci6mT+JzX/TmthXfIpZNRGFo=; b=Ui/xR3JD0AWUZeykhNOrVOalNw0voGfYOSpfe1A0O/mKlf65XPzu6Kf+BVNXNVkfZAg1uT KHLBpTW4I6SR1tBg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/msi: Add pointers for per device irq domains Cc: Thomas Gleixner , Kevin Tian , Marc Zyngier , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221124230313.923860399@linutronix.de> References: <20221124230313.923860399@linutronix.de> MIME-Version: 1.0 Message-ID: <167026472045.4906.13119084508984817791.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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?1750421843634986057?= X-GMAIL-MSGID: =?utf-8?q?1751399765743845212?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 64258eaa442b0b7d7eac8942cf27863ad9e6028e Gitweb: https://git.kernel.org/tip/64258eaa442b0b7d7eac8942cf27863ad9e6028e Author: Thomas Gleixner AuthorDate: Fri, 25 Nov 2022 00:24:22 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 05 Dec 2022 19:20:59 +01:00 genirq/msi: Add pointers for per device irq domains 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 add a domain pointer to the msi_dev_domain array in struct msi_device_data. This pointer is also used to 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 of the msi_dev_domain array. This allows to convert interfaces and implementation to domain ids while keeping everything existing working. Signed-off-by: Thomas Gleixner Reviewed-by: Kevin Tian Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20221124230313.923860399@linutronix.de --- include/linux/msi.h | 3 +++ kernel/irq/msi.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index f7b9c41..fdbc80d 100644 --- 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 @@ -177,9 +178,11 @@ enum msi_desc_filter { /** * struct msi_dev_domain - The internals of MSI domain info per device * @store: Xarray for storing MSI descriptor pointers + * @irqdomain: Pointer to a per device interrupt domain */ struct msi_dev_domain { struct xarray store; + struct irq_domain *domain; }; /** diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index c2bc94e..de65acc 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -220,6 +220,15 @@ int msi_setup_device_data(struct device *dev) for (i = 0; i < MSI_MAX_DEVICE_IRQDOMAINS; i++) xa_init(&md->__domains[i].store); + /* + * If @dev::msi::domain is set and is a global MSI domain, copy the + * pointer into the domain array so all code can operate on domain + * ids. The NULL pointer check is required to keep the legacy + * architecture specific PCI/MSI support working. + */ + if (dev->msi.domain && !irq_domain_is_msi_parent(dev->msi.domain)) + md->__domains[MSI_DEFAULT_DOMAIN].domain = dev->msi.domain; + mutex_init(&md->mutex); dev->msi.data = md; devres_add(dev, md);