Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6365041rwb; Mon, 5 Dec 2022 11:13:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VG7ou2/U0QMd0k++abXRGmdGj/J5W1dkcvl80wX+KlM3yE1h8C2fPD/d/yY45ypO74f8S X-Received: by 2002:a17:906:99cd:b0:7be:9340:b3e4 with SMTP id s13-20020a17090699cd00b007be9340b3e4mr11782376ejn.402.1670267626371; Mon, 05 Dec 2022 11:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670267626; cv=none; d=google.com; s=arc-20160816; b=D0MC+WTnFtn1IcOSpUqR66tS2sNi46VRbUXqrKzCTD6S6LcdOL72tJwRWr9mui74Lm u1xDQwo8+mHyhg7nWa6u51dhil1n4d+kIwyYGgYBM6r42Z7musltAala3JMAyEyvRcM3 Jkw8AK3ePDnXi94es1tyShJZvJLyFLcR6pHvcHf6nYQyDX5VNko5auyr28J1OeuEYIjq MqLUkajrJmHfWVRwLvyDaw4O4rfHtjLPFQ9D0Itu8n4rOt39P5nxP7/foRhlqiwv56Xe HKcP8xo6NeAZe+AxaNwoihT7HAyufrtiNdF890U9xYKlb6Ay5RjqmDruQiCKFrNF6Dgd C3uw== 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 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd27-20020a170907629b00b0078a19032c70si14059690ejc.334.2022.12.05.11.13.26; Mon, 05 Dec 2022 11:13:46 -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 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 S233508AbiLES2q (ORCPT + 82 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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);