From patchwork Thu Nov 17 15:08:28 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: 21738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp454009wrr; Thu, 17 Nov 2022 07:12:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6RqrOYgYpdTsMHrXKcoyQH/iKA2fqe+DLhiKOzr/y+wORfiNt6ZBaTWFVl+qBl+vzqnl3A X-Received: by 2002:a05:6402:2948:b0:463:bc31:2604 with SMTP id ed8-20020a056402294800b00463bc312604mr1515263edb.32.1668697968680; Thu, 17 Nov 2022 07:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697968; cv=none; d=google.com; s=arc-20160816; b=w8ZpMewugI3aJijhCbFB7VGHPzcvOfFcGLQk8ybo+8UQinrpDPd5XqnPMFJCraM38x VJUNG+JJxXHuWSkl6/ZEMjmB9+nrmaCUjNOg+IlOfuqRMTqH2TvkO841J1uR2RFpkD4V Usy6vaFmvf9rdtGxXzRQf2Pe9CWSpV86a3c5CO0nZ4ROPDkgiyV46i1gWLYV8BkT0dHR waF3RC9BSALEDT9KD1eXJGf9KKc1WBCXWHnmLR7ff+kNW486UHJd4OH1BPHpMPri8C1U gO3GRrW6HnfGZf27Lk51ceEQ+J89nHzzpNmGMBi2LU86Fa7MMivH0XIqs7Vw1utYQKFI +53Q== 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=h+m9S7ndn05IG4//0WovboMWPYNCLThWa+tMtJVVl3g=; b=v6TdgRDoEy6FYpYAaz9pHgEGwY4CxYYqHtK8Bqqs9XPXekC4fYTXIeVaAQmz+JcYPf gNtvFaX2CXnH7DfAscsZz+mbkNmDEcHMmnua2iXXhoxSrJoa3H7fJUmGa82V6QTHOoNH 0dNpzHdDnb2QSnHNl2k9BiDNxxEf2kBYfigTdUVud3qMWb5oQCRmYaGxoQCr4kWfsAwV aqrWjuZSw/xn8EL6Z+nqDuotwgSnaiI0Px140DBU0ukeVW7FyvnyLecPd44aRb+a3Mxk 41GkuJSsrW2y0f4JRGjPpB61P0GvvBLmN7zp3GoJApyZ7h9NGIPc+DaTqVDiiGguOYGm 29CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=i6OqWxIC; 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 dt16-20020a170907729000b007b271fa8e7asi1007521ejc.197.2022.11.17.07.12.24; Thu, 17 Nov 2022 07:12:48 -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=i6OqWxIC; 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 S240341AbiKQPL1 (ORCPT + 99 others); Thu, 17 Nov 2022 10:11:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240324AbiKQPJn (ORCPT ); Thu, 17 Nov 2022 10:09:43 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E0D391E3; Thu, 17 Nov 2022 07:08:31 -0800 (PST) Date: Thu, 17 Nov 2022 15:08:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668697709; 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=h+m9S7ndn05IG4//0WovboMWPYNCLThWa+tMtJVVl3g=; b=i6OqWxICJSDfYrR1F/6w1QZglM7rODbnVWb8aM3CimZpp4nTVMkbDkuRl7/vUh4lzsNyAW oXG9CJ3c6013dNfBi30pZjxnqFeC7xkkko13E9BDUzEVoMMLwrXhQxq0SR/uphQqJiHDEZ 3gQHJ2TJxhdMadMqR64m3lhvnpA+clzjaQCDoYY6LKFEekcfYH9lmCOmTHr78s++HRsSyN pGdkt1r37G0Mhx/avRqPieMgsCKjjVvbDXH8uzDkMZ78fYgQ9dFr4KtaPPfYFiaHxnxTB6 iTgnxk8U7AnSA/Knf50NKAQ5wYqwy2Teyv2hsrYh2PqXrOi/cCApglBaEbWUyw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668697709; 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=h+m9S7ndn05IG4//0WovboMWPYNCLThWa+tMtJVVl3g=; b=RbFdkCMuXxlKsJEuBocklvYHjtWWnDWnbqeoGrZ944/07Sq56byMTPexCes/x5yppfW7E7 B11SxfAhGOeNzDAA== 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: Remove filter from msi_free_descs_free_range() Cc: Thomas Gleixner , Ashok Raj , Jason Gunthorpe , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20221111122013.888850936@linutronix.de> References: <20221111122013.888850936@linutronix.de> MIME-Version: 1.0 Message-ID: <166869770851.4906.16694225027340647627.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?1749208248353951191?= X-GMAIL-MSGID: =?utf-8?q?1749756641572503088?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 2f2940d168236a92df524a1bd99fc7b0325918b5 Gitweb: https://git.kernel.org/tip/2f2940d168236a92df524a1bd99fc7b0325918b5 Author: Thomas Gleixner AuthorDate: Fri, 11 Nov 2022 14:54:22 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 17 Nov 2022 15:15:18 +01:00 genirq/msi: Remove filter from msi_free_descs_free_range() When a range of descriptors is freed then all of them are not associated to a linux interrupt. Remove the filter and add a warning to the free function. Signed-off-by: Thomas Gleixner Reviewed-by: Ashok Raj Reviewed-by: Jason Gunthorpe Link: https://lore.kernel.org/r/20221111122013.888850936@linutronix.de --- drivers/base/platform-msi.c | 2 +- include/linux/msi.h | 5 ++--- kernel/irq/msi.c | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c index 12b0441..dddafa1 100644 --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -325,7 +325,7 @@ void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int vir msi_lock_descs(data->dev); irq_domain_free_irqs_common(domain, virq, nr_irqs); - msi_free_msi_descs_range(data->dev, MSI_DESC_ALL, virq, virq + nr_irqs - 1); + msi_free_msi_descs_range(data->dev, virq, virq + nr_irqs - 1); msi_unlock_descs(data->dev); } diff --git a/include/linux/msi.h b/include/linux/msi.h index fc918a6..969ce46 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -247,8 +247,7 @@ static inline void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg) #endif /* CONFIG_PCI_MSI */ int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc); -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int first_index, unsigned int last_index); +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); /** * msi_free_msi_descs - Free MSI descriptors of a device @@ -256,7 +255,7 @@ void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, */ static inline void msi_free_msi_descs(struct device *dev) { - msi_free_msi_descs_range(dev, MSI_DESC_ALL, 0, MSI_MAX_INDEX); + msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX); } void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index bba6359..1ca4846 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -120,7 +120,7 @@ static int msi_add_simple_msi_descs(struct device *dev, unsigned int index, unsi fail_mem: ret = -ENOMEM; fail: - msi_free_msi_descs_range(dev, MSI_DESC_ALL, index, last); + msi_free_msi_descs_range(dev, index, last); return ret; } @@ -141,12 +141,11 @@ static bool msi_desc_match(struct msi_desc *desc, enum msi_desc_filter filter) /** * msi_free_msi_descs_range - Free MSI descriptors of a device * @dev: Device to free the descriptors - * @filter: Descriptor state filter * @first_index: Index to start freeing from * @last_index: Last index to be freed */ -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int first_index, unsigned int last_index) +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, + unsigned int last_index) { struct xarray *xa = &dev->msi.data->__store; struct msi_desc *desc; @@ -155,10 +154,12 @@ void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, lockdep_assert_held(&dev->msi.data->mutex); xa_for_each_range(xa, idx, desc, first_index, last_index) { - if (msi_desc_match(desc, filter)) { - xa_erase(xa, idx); - msi_free_desc(desc); - } + xa_erase(xa, idx); + + /* Leak the descriptor when it is still referenced */ + if (WARN_ON_ONCE(msi_desc_match(desc, MSI_DESC_ASSOCIATED))) + continue; + msi_free_desc(desc); } } @@ -739,7 +740,7 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, fail: for (--virq; virq >= virq_base; virq--) irq_domain_free_irqs_common(domain, virq, 1); - msi_free_msi_descs_range(dev, MSI_DESC_ALL, virq_base, virq_base + nvec - 1); + msi_free_msi_descs_range(dev, virq_base, virq_base + nvec - 1); unlock: msi_unlock_descs(dev); return ret;