Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94008C433F5 for ; Thu, 16 Dec 2021 21:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241931AbhLPVku (ORCPT ); Thu, 16 Dec 2021 16:40:50 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:56996 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241700AbhLPVk0 (ORCPT ); Thu, 16 Dec 2021 16:40:26 -0500 Date: Thu, 16 Dec 2021 21:40:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1639690825; 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=BIIHXt8Tfbk9UrqyUeDEzql0H21S4J8ZAgpYWPiUGys=; b=cjjtxaUN7rrNFYVw6iCCAfXAfqsePPehSGNA1+YuWlA7vLifXI8/q0W3Qd1e8mw3OLVvKS M6MS6eLi+u1sVTPPsvbopF2SN3nzPdq0Aqcdt9CoXRZ+CJulGLeP6Zn8k5yh9eb9VJ1Nul lHCGS9W5T5RQ1kueBywk/V1x7fLfIr7uU1R4PCRFXxV89JBSIv4VqFDGxYLOtza5TRZH1B sLHLZNSIaIxV1VRr8/C5eG0oeijlr86VKbOxil5/4gcukdPJLuHKreNv9Hwb23MdGPJ5mg e00ynLmbiaiUa0Jbe05jgjFJ5p725ZPRESh9jyjqnfOnOHHfPwZfHjUHyAs/2g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1639690825; 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=BIIHXt8Tfbk9UrqyUeDEzql0H21S4J8ZAgpYWPiUGys=; b=XCkLZLJG/JoYREMCqGMjGEY9ns7wDp/+G36I14lICk/jCmqrN8gt57fqmIaWLXZe+waqS7 sl0heUMADR8nQNAw== 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/msi] platform-msi: Let core code handle MSI descriptors Cc: Thomas Gleixner , Nishanth Menon , Jason Gunthorpe , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20211206210748.903173257@linutronix.de> References: <20211206210748.903173257@linutronix.de> MIME-Version: 1.0 Message-ID: <163969082474.23020.16753725289318118811.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/msi branch of tip: Commit-ID: 653b50c5f96918238e0b51e783b291f6e9e692f9 Gitweb: https://git.kernel.org/tip/653b50c5f96918238e0b51e783b291f6e9e692f9 Author: Thomas Gleixner AuthorDate: Mon, 06 Dec 2021 23:51:41 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 16 Dec 2021 22:22:19 +01:00 platform-msi: Let core code handle MSI descriptors Use the core functionality for platform MSI interrupt domains. The platform device MSI interrupt domains will be converted in a later step. Signed-off-by: Thomas Gleixner Tested-by: Nishanth Menon Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/20211206210748.903173257@linutronix.de --- drivers/base/platform-msi.c | 112 +++++++++++++++-------------------- 1 file changed, 48 insertions(+), 64 deletions(-) diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c index 88bdc4b..01c897c 100644 --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -107,57 +107,6 @@ static void platform_msi_update_chip_ops(struct msi_domain_info *info) info->flags &= ~MSI_FLAG_LEVEL_CAPABLE; } -static void platform_msi_free_descs(struct device *dev, int base, int nvec) -{ - struct msi_desc *desc, *tmp; - - list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) { - if (desc->msi_index >= base && - desc->msi_index < (base + nvec)) { - list_del(&desc->list); - free_msi_entry(desc); - } - } -} - -static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq, - int nvec) -{ - struct msi_desc *desc; - int i, base = 0; - - if (!list_empty(dev_to_msi_list(dev))) { - desc = list_last_entry(dev_to_msi_list(dev), - struct msi_desc, list); - base = desc->msi_index + 1; - } - - for (i = 0; i < nvec; i++) { - desc = alloc_msi_entry(dev, 1, NULL); - if (!desc) - break; - - desc->msi_index = base + i; - desc->irq = virq ? virq + i : 0; - - list_add_tail(&desc->list, dev_to_msi_list(dev)); - } - - if (i != nvec) { - /* Clean up the mess */ - platform_msi_free_descs(dev, base, nvec); - - return -ENOMEM; - } - - return 0; -} - -static int platform_msi_alloc_descs(struct device *dev, int nvec) -{ - return platform_msi_alloc_descs_with_irq(dev, 0, nvec); -} - /** * platform_msi_create_irq_domain - Create a platform MSI interrupt domain * @fwnode: Optional fwnode of the interrupt controller @@ -180,7 +129,8 @@ struct irq_domain *platform_msi_create_irq_domain(struct fwnode_handle *fwnode, platform_msi_update_dom_ops(info); if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) platform_msi_update_chip_ops(info); - info->flags |= MSI_FLAG_DEV_SYSFS; + info->flags |= MSI_FLAG_DEV_SYSFS | MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | + MSI_FLAG_FREE_MSI_DESCS; domain = msi_create_irq_domain(fwnode, info, parent); if (domain) @@ -262,20 +212,10 @@ int platform_msi_domain_alloc_irqs(struct device *dev, unsigned int nvec, if (err) return err; - err = platform_msi_alloc_descs(dev, nvec); - if (err) - goto out_free_priv_data; - err = msi_domain_alloc_irqs(dev->msi.domain, dev, nvec); if (err) - goto out_free_desc; - - return 0; + platform_msi_free_priv_data(dev); -out_free_desc: - platform_msi_free_descs(dev, 0, nvec); -out_free_priv_data: - platform_msi_free_priv_data(dev); return err; } EXPORT_SYMBOL_GPL(platform_msi_domain_alloc_irqs); @@ -287,7 +227,6 @@ EXPORT_SYMBOL_GPL(platform_msi_domain_alloc_irqs); void platform_msi_domain_free_irqs(struct device *dev) { msi_domain_free_irqs(dev->msi.domain, dev); - platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); platform_msi_free_priv_data(dev); } EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); @@ -361,6 +300,51 @@ free_priv: return NULL; } +static void platform_msi_free_descs(struct device *dev, int base, int nvec) +{ + struct msi_desc *desc, *tmp; + + list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) { + if (desc->msi_index >= base && + desc->msi_index < (base + nvec)) { + list_del(&desc->list); + free_msi_entry(desc); + } + } +} + +static int platform_msi_alloc_descs_with_irq(struct device *dev, int virq, + int nvec) +{ + struct msi_desc *desc; + int i, base = 0; + + if (!list_empty(dev_to_msi_list(dev))) { + desc = list_last_entry(dev_to_msi_list(dev), + struct msi_desc, list); + base = desc->msi_index + 1; + } + + for (i = 0; i < nvec; i++) { + desc = alloc_msi_entry(dev, 1, NULL); + if (!desc) + break; + + desc->msi_index = base + i; + desc->irq = virq + i; + + list_add_tail(&desc->list, dev_to_msi_list(dev)); + } + + if (i != nvec) { + /* Clean up the mess */ + platform_msi_free_descs(dev, base, nvec); + return -ENOMEM; + } + + return 0; +} + /** * platform_msi_device_domain_free - Free interrupts associated with a platform-msi * device domain