From patchwork Fri Nov 11 13:58: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: 18836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp760616wru; Fri, 11 Nov 2022 06:09:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KO9TAaFE0z1ZRslAwZ1b3Lfx4GfXugGDaA43yfU5a0v8cCfKXOUxwr/7V1skKX5DtpUV1 X-Received: by 2002:a17:906:7e4e:b0:7a8:3ecb:bd62 with SMTP id z14-20020a1709067e4e00b007a83ecbbd62mr1938239ejr.721.1668175751384; Fri, 11 Nov 2022 06:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175751; cv=none; d=google.com; s=arc-20160816; b=NhejligVGflxIXE4J/xx54ykXUJ/EV/PXX1CMLffHbrN1ozI4dAOZMewfllj+RT0oX xG0t8pq9G0GPn4ltTLDYGlPOqZT0dDt9dw5Qx8MMY3R4ln+ByriSCjV18Sq48DoT0pCg S1rMuGWmaSiAs3Vn/FTnfLvlbzt4SKL4DfQwp1bDuENnTo4uHuw6MjnoLiyy8bL7UtoS /P+uqUmnRr8nDzEr4BdU/O+9Jt1B00uIkzOjgF/AUcfeKua6Pcy3LeaCyUUZTknNHRxh QNKiAw0gX/W4RuR9AYYX4r4IPX9KdDvJaYTzvbQHX+GRo3/FGLrx3AYciOA6MAWkzsp+ upGw== 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=6sl/l9myt20lNdigYL4yWzzuJo6j8gI/Xo6NnbnNhEc=; b=X9ReDV5pcMyG3A+p44L96tsRrhlZUtTYqajkweoyGUrsGiaQU5OS/5E3RBP+S9Yhbh Hx0BjapHlvFahLViq21ORQpd+jF+qnSCjSscw3Rl9o5OwtOmH1GAbNzOc1eusHWiphGC vba9mgxbhiQNNS42cxJsjrL7NQdJyjzNuZ4nI5EPNOaswIQp9GTXmBgXwh5oQ8rXvIRe cB/ZEGC+jMy/94JfE+d4KcjzuZP7EEr7429kM7YP5ZyuD668ljiHO3Rdts0/3z0g/QvX LZs5faCk9tIE1OefU8bVfuHL9EE2KIOQ5MWJIsf0IXsOdmwBBTY910F5ntWBpY24SnnC jlgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CUXpw24Z; 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 d15-20020a1709063ecf00b007ad8bc64c89si1448549ejj.701.2022.11.11.06.07.57; Fri, 11 Nov 2022 06:09: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=CUXpw24Z; 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 S234201AbiKKOGo (ORCPT + 99 others); Fri, 11 Nov 2022 09:06:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233758AbiKKOGS (ORCPT ); Fri, 11 Nov 2022 09:06:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C854B99311; Fri, 11 Nov 2022 05:59:37 -0800 (PST) Message-ID: <20221111135205.715249181@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668175104; 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=6sl/l9myt20lNdigYL4yWzzuJo6j8gI/Xo6NnbnNhEc=; b=CUXpw24Z4dNnYpWulhOHoxu2VLnVVH6Qi+7TSuHfvfE4PR9u0SVc7ys8dJtXtXCDqb0Csq z5cB3IaAcD2M7fDNFs9NJSMt0Jp4ABPDsynuJbb/JTMR1wWLqHO63TYc4FOfm51YMWqnJd 9kQkxBQwInZk7vcT2A1rnPb/XtzkarrzibeQDU/ZQvXAET5BmtQHO1QBQtk+K2EMCJZIUl IDKpfAp+WcDnTjOJDLYmR5JCdtKVhyqnWYH2WN3CMdLtAg+UA5kzEa9BAvgIpAt2WTUfkO nBakLx3IZzP0i6+HrsLvCOoFUwVznrmw0vuo09Hrkoe5uQsydxTreB/NdFb9jw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668175104; 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=6sl/l9myt20lNdigYL4yWzzuJo6j8gI/Xo6NnbnNhEc=; b=cCgJ7SqTxK+BiY/mINACXMkjSUhgO8Wvz00QcM3lSNNA9xIx9FBZdYNxqRcSnuiJsA1eik QvVPdH0kHZUt/dAQ== 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" , Reinette Chatre Subject: [patch 08/33] genirq/msi: Provide msi_match_device_domain() References: <20221111133158.196269823@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:58: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?1749209056744371866?= X-GMAIL-MSGID: =?utf-8?q?1749209056744371866?= Provide an interface to match a per device domain bus token. This allows to query which type of domain is installed for a particular domain id. Will be used for PCI to avoid frequent create/remove cycles for the MSI resp. MSI-X domains. Signed-off-by: Thomas Gleixner --- include/linux/msi.h | 3 +++ kernel/irq/msi.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -537,6 +537,9 @@ bool msi_create_device_irq_domain(struct void *chip_data); void msi_remove_device_irq_domain(struct device *dev, unsigned int domid); +bool msi_match_device_irq_domain(struct device *dev, unsigned int domid, + enum irq_domain_bus_token bus_token); + 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, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1011,6 +1011,31 @@ void msi_remove_device_irq_domain(struct msi_unlock_descs(dev); } +/** + * msi_match_device_irq_domain - Match a device irq domain against a bus token + * @dev: Pointer to the device + * @domid: Domain id + * @bus_token: Bus token to match against the domain bus token + * + * Return: True if device domain exists and bus tokens match. + */ +bool msi_match_device_irq_domain(struct device *dev, unsigned int domid, + enum irq_domain_bus_token bus_token) +{ + struct msi_domain_info *info; + struct irq_domain *domain; + bool ret = false; + + msi_lock_descs(dev); + domain = msi_get_device_domain(dev, domid); + if (domain && irq_domain_is_msi_device(domain)) { + info = domain->host_data; + ret = info->bus_token == bus_token; + } + msi_unlock_descs(dev); + return ret; +} + int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg) {