From patchwork Mon Dec 5 18:25:19 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: 29865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2409875wrr; Mon, 5 Dec 2022 10:29:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cWrz33znY6DgfjZFxbFud1TNZvA1heFSklEUsZzK26C+ve9PYF8nxq5LyDaZZpu2Akxax X-Received: by 2002:a17:90a:8c83:b0:219:99cd:2951 with SMTP id b3-20020a17090a8c8300b0021999cd2951mr15416945pjo.16.1670264969299; Mon, 05 Dec 2022 10:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670264969; cv=none; d=google.com; s=arc-20160816; b=vi7Ii9JWqiRNl4JYgplRG+ZRleR6+yOtcMNibA5wxHh4vZmCrmOOLPjs1PAwuM8CYP fQH20sKhsaE3/vrSbWBaUoP+EXFzux7ZtQLq5dVHhNwdQM9Y6luQaCmkBUu1lj/VFHUr QRyY2hgAU0tC5hZ0PBJMU4rxvP0k/VMfTYx3m+J5W1XSlLPgMLnhBcEnUYLF8lpikQiT NSJigz+30A8jjtjaVRbXyzcZ/zeWdf924q754FJwgFDgYCVbJrJmBVv0kqq1SRFS00hi bPUVEJO50YGiE6vtKfQaqbbcOToAtuGA/dnefFszNQQ2hnRb76oGzwI7yC9al3i7LsyA 3oPg== 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=8BhJMBOGAfhpi5lKYkdWInx8QY9zmvpuj0sqwlUK/84=; b=m04LrfLHAOef7WWEX0W71/9RD50sa8TlQmegd6CEgrcDYRYWHUrSqli4pdeZKRWua2 c4UwBrFQY7eXBuZNGYr+3Idh/6MyXmboQUlOdHu1XFRp7DO0FNrNLFq3W67IP/STnp7b GLaFQNY1JF5NlVfJJXRqXh9mFr8JS0FgqQNTIjkVamK6MIFjmRcXjGOKXaV8ATulrEv+ u2lDOZZ+W4jhoTfSYqZaPwZQj0ac8Mp0ewg1PyKLi7h/Ny9G0/QSvtjPtqiOCcqnUuMQ E/OuTvJULG3BxZ1gNGQEq2spCScJKUxjIpoJbaPxHq9J5RE4Ml0aPdPNsD9b2xk8DLa1 C6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1+mTLT8h; 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 w17-20020a63c111000000b00476b15a02cesi15478245pgf.70.2022.12.05.10.29.15; Mon, 05 Dec 2022 10:29: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=1+mTLT8h; 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 S233478AbiLES2h (ORCPT + 99 others); Mon, 5 Dec 2022 13:28:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbiLESZW (ORCPT ); Mon, 5 Dec 2022 13:25:22 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC34E2124D; Mon, 5 Dec 2022 10:25:21 -0800 (PST) Date: Mon, 05 Dec 2022 18:25:19 -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=8BhJMBOGAfhpi5lKYkdWInx8QY9zmvpuj0sqwlUK/84=; b=1+mTLT8ho0bOb9/lIOBxlLqO9WO2ElaqGrmWthK49NoP3Szew225SxT9N1YvGGMUnctuNM xSoijBIVuR3LZ6dhtslOUelVK+t7xayTRDrXb6JsypnJyffQLzmWGDbEzSUrZl6lwyIVO3 XK6J2eanJxs/UmBRVFYhwPwMH4zNRZ9ATOei+RFuJ4P0btv2SLFNhs6qK6CZbDrQtnCZDy kelNmGiYSKiQ+QqzQhdSk/TXxkU+sH270GgQTGZRCcRTSoLK4ob86GEhJ2yBRgP7M8POFy cshcAYxSb6bqi1aW52GjQyViBQRxHeYKcsZW/OkUip013Qity4UNHk8OZ73JUg== 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=8BhJMBOGAfhpi5lKYkdWInx8QY9zmvpuj0sqwlUK/84=; b=Kz3Jrqqy7c9j5a0xEXiM+1akmMDjd0Km8MM2QZlO5d8CUFrrFZR+gmrTLG2DDe9r9K4+UE K/83YUCD+zBQy/BA== From: "tip-bot2 for Ahmed S. Darwish" 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: Make msi_get_virq() device domain aware Cc: "Ahmed S. Darwish" , Thomas Gleixner , Kevin Tian , Marc Zyngier , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221124230314.044613697@linutronix.de> References: <20221124230314.044613697@linutronix.de> MIME-Version: 1.0 Message-ID: <167026471995.4906.14550334218511486751.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?1750421853033308178?= X-GMAIL-MSGID: =?utf-8?q?1751399760894389651?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 98043704f375f63a47efeff123ab92fcf34b95e6 Gitweb: https://git.kernel.org/tip/98043704f375f63a47efeff123ab92fcf34b95e6 Author: Ahmed S. Darwish AuthorDate: Fri, 25 Nov 2022 00:24:25 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 05 Dec 2022 19:20:59 +01:00 genirq/msi: Make msi_get_virq() device domain aware 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 Reviewed-by: Kevin Tian Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20221124230314.044613697@linutronix.de --- include/linux/msi_api.h | 14 +++++++++++++- kernel/irq/msi.c | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/linux/msi_api.h b/include/linux/msi_api.h index 4dbbce6..8640171 100644 --- 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 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index ec08d1f..e1593c1 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -337,26 +337,32 @@ struct msi_desc *msi_next_desc(struct device *dev, unsigned int domid, 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 = false; struct xarray *xa; - bool pcimsi; 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 || domid >= MSI_MAX_DEVICE_IRQDOMAINS)) + 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); - xa = &dev->msi.data->__domains[MSI_DEFAULT_DOMAIN].store; + xa = &dev->msi.data->__domains[domid].store; desc = xa_load(xa, pcimsi ? 0 : index); if (desc && desc->irq) { /* @@ -371,10 +377,11 @@ unsigned int msi_get_virq(struct device *dev, unsigned int index) ret = desc->irq; } } + 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[] = {