From patchwork Mon Dec 5 18:25:15 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: 29839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2409146wrr; Mon, 5 Dec 2022 10:27:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf4E29dDtUEn16Eis3SP1EEIsfRl0UeEiYptzookrowDb6i7Mc50le/EQho0lRKrm8D0du8b X-Received: by 2002:a17:906:ee1:b0:78a:efde:b84a with SMTP id x1-20020a1709060ee100b0078aefdeb84amr70505871eji.744.1670264860108; Mon, 05 Dec 2022 10:27:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670264860; cv=none; d=google.com; s=arc-20160816; b=bq34BqPfun5yHiaS6dBSYjth5mrZS7dwzFnwflfbpAZbR1jmasOnPTYNimh2zrU+Zv JhymNmvG985dn/hRyRtYpK7ZNu1Wo9e4eii0ydVsW16KLprXrF/m7irPC0iayJMGEmpD kEwYZiT3lPmdoNBZW9QRK2SOtEY3TaR0VNXsW1z7tS5Mo7ahxCY5ln+XXO+ETEc6q8P5 Vh/fT3fbwhIyhOV0/OTxxjjkrnw6mouA3p4hWFKdiLS6uhKmGNCv+xUlpTOzn/6w0Ot4 qzRjc2lCQdONgOVeXlxjoi7ex8K2l7yJlghzfcyjGxUFOFjoXN12QzcqkIs1cR78Er3u VpeQ== 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=QZedNHhsprNUnD/Sk//bQ8/DcxPxO0/K/n0mXz7RnHI=; b=xZGssH8BDoq50bp/UQyukm7DdjPcfGrY/ejtWiWtv6+TrjkHVTvo15cqplk6YctpoC qVS4pvHMlLubbrQnwdx2h0qx/LR/pEotyA9a1f9p5zNXGT2XqiUdcWJH61OSNIAxrOFG yGSjFyVU0Vjys881yeRJr2dXUiOobYiC6CKI7XmVJEiIkpoAhIzLJbB1iAk0H7OCZ9K8 cWl3hNIGWjhvdZ+8vEYpy3n+NshCtbTgkyBzavy/S8X5YUISRMjkEPTE4nMFm23NTSzX rPsHnxqcW46ulrGYiE6OuyVm8ki2PVhxceUx/4t3IXYBxKjDpYpQJ6K70nd12gJJr0af 1VNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gbGT6SYp; 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 dk15-20020a0564021d8f00b0046ac358ed89si154983edb.219.2022.12.05.10.27.16; Mon, 05 Dec 2022 10:27:40 -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=gbGT6SYp; 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 S233338AbiLES0o (ORCPT + 99 others); Mon, 5 Dec 2022 13:26:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbiLESZT (ORCPT ); Mon, 5 Dec 2022 13:25:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F0A20BE6; Mon, 5 Dec 2022 10:25:18 -0800 (PST) Date: Mon, 05 Dec 2022 18:25:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670264715; 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=QZedNHhsprNUnD/Sk//bQ8/DcxPxO0/K/n0mXz7RnHI=; b=gbGT6SYpiivaOGvBy7n9gXAuyKh3ISL1G3Bs3JuaoPYDp6RvFYhTdRnFHOyqjAsaP3IqF7 uxhgmHz/4O/FZEuXsHbYy4IyD3DzoF2R6YqatImSg+8JewL+wMni5ip9Q16p/K0shGjJWk ibOaa6ChWKsTiBO1ZRYyf+CIbns8cpKNhzf7Xe3SqGTjHfht12+SnsaGAoS6TrQUJ6V/dG QOVYQIbV4swHv9AoTMEPLJ84og+rKBKF9V2+rib2VGJ4s4O8Wc1HbiSzTPDV8QBhK30L5A 7XgTBcVljKospJl39yoa/IZLDIVex9tiYYYudTkpyGotKuzpFMEPd6l457t4+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670264715; 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=QZedNHhsprNUnD/Sk//bQ8/DcxPxO0/K/n0mXz7RnHI=; b=xP7s9XOJ0LFSeiXt+AJIUKGhsGF3KI6ZU6DirD3tEjvX96BVxZqPoHAxMV8xsZJsSqIjCU Ifhpu2kLnfQ9mnBw== 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: Provide msi_match_device_domain() Cc: Thomas Gleixner , Kevin Tian , Marc Zyngier , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221124232325.738047902@linutronix.de> References: <20221124232325.738047902@linutronix.de> MIME-Version: 1.0 Message-ID: <167026471551.4906.2567791541055402967.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?1750425281135312839?= X-GMAIL-MSGID: =?utf-8?q?1751399645652759671?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 26e91b75bf6108550035355c835bf0c93c885b61 Gitweb: https://git.kernel.org/tip/26e91b75bf6108550035355c835bf0c93c885b61 Author: Thomas Gleixner AuthorDate: Fri, 25 Nov 2022 00:25:57 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 05 Dec 2022 19:21:01 +01:00 genirq/msi: Provide msi_match_device_domain() 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 Reviewed-by: Kevin Tian Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20221124232325.738047902@linutronix.de --- include/linux/msi.h | 3 +++ kernel/irq/msi.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index ef46a3e..b4ab005 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -553,6 +553,9 @@ bool msi_create_device_irq_domain(struct device *dev, unsigned int domid, 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, diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 8b415bd..7449998 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -986,6 +986,31 @@ unlock: 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) {