From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CDD3266581 for ; Wed, 1 Apr 2026 21:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775080341; cv=none; b=fVN90btKzYC3mY/YMi/d/v88QpXZaJhLWRifZevK0rnjGr3JVRGjrClaNMM/2YFeI83/4yX6WOBFjWGRAAqpYlpxDc6pSzw0C4sabrcpKhqUB5ZNJ86nZHwx6gOz5spyisNwfG2kD0C9bX6TbXNfWNbJaQccymIvfCTGAYyZbVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775080341; c=relaxed/simple; bh=6+7HNw8/xBnvIjwnxMCAUCmDYEgaIuljqZlpai4G470=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JKcBdNPZYSsK9gKnoekAGhWz3SYesVumiyhn1k00aFTz6S9ZDlB0pIN0hqpcKV2iJjhoaZoIac+fITaNf/9uxxyl7Iyu2VhZpQOlw6+rroK6iDaWIgbBx5VFUMFg+bY5nrD7hXz8bbhfOTxrugIIGuTmVipcGWAq8OS24UM0zac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KDeXXilc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KDeXXilc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E53CC4CEF7; Wed, 1 Apr 2026 21:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775080340; bh=6+7HNw8/xBnvIjwnxMCAUCmDYEgaIuljqZlpai4G470=; h=Date:From:To:Cc:Subject:References:From; b=KDeXXilcX9R+nBgs72sQRUzfcKp25/wN3tVR9RzGM0WrqLSe0zbBalDNgnjEArZBR PuPOrxW16vooM3pBe0+8QiFC5kvvarqlDN8m/ltsnaR+YPm9RKayNdkvuu3Qi8l/e9 PfeQ3U4xm+C7Mjf5cCAtC1mLyxsJL3sOMgPXFUjKzlQRvCphF4HriNep/rVhK9qRPW yYMCS5VbY3vygyC6/35VFo4p8Wu7VEexMlfsOHG25AF499ga8zNWoUFDETMklEqX3X xu1lUCG7I2FUVU+vk0h59NzqBR2rqUHO4Py9yGuf71Bx5N/LILWQM9s50I/A2BJN9X UiuBgHC0vAT/g== Date: Wed, 01 Apr 2026 23:52:17 +0200 Message-ID: <20260401201348.628060046@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Michael Kelley , Dmitry Ilvokhin , Radu Rendec , Jan Kiszka , Kieran Bingham , Florian Fainelli , Marc Zyngier Subject: [patch V5 09/15] genirq/manage: Make NMI cleanup RT safe References: <20260401195625.213446764@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Eventually blocking functions cannot be invoked with interrupts disabled and a raw spin lock held. Restructure the code so this happens outside of the descriptor lock held region. Signed-off-by: Thomas Gleixner --- V4: New patch. Found when adding the validation update to it --- kernel/irq/manage.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2026,24 +2026,30 @@ const void *free_irq(unsigned int irq, v } EXPORT_SYMBOL(free_irq); -/* This function must be called with desc->lock held */ static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) { + struct irqaction *action = NULL; const char *devname = NULL; - desc->istate &= ~IRQS_NMI; + scoped_guard(raw_spinlock_irqsave, &desc->lock) { + irq_nmi_teardown(desc); - if (!WARN_ON(desc->action == NULL)) { - irq_pm_remove_action(desc, desc->action); - devname = desc->action->name; - unregister_handler_proc(irq, desc->action); + desc->istate &= ~IRQS_NMI; - kfree(desc->action); + if (!WARN_ON(desc->action == NULL)) { + action = desc->action; + irq_pm_remove_action(desc, action); + devname = action->name; + } desc->action = NULL; + + irq_settings_clr_disable_unlazy(desc); + irq_shutdown_and_deactivate(desc); } - irq_settings_clr_disable_unlazy(desc); - irq_shutdown_and_deactivate(desc); + if (action) + unregister_handler_proc(irq, action); + kfree(action); irq_release_resources(desc); @@ -2067,8 +2073,6 @@ const void *free_nmi(unsigned int irq, v if (WARN_ON(desc->depth == 0)) disable_nmi_nosync(irq); - guard(raw_spinlock_irqsave)(&desc->lock); - irq_nmi_teardown(desc); return __cleanup_nmi(irq, desc); } @@ -2318,13 +2322,14 @@ int request_nmi(unsigned int irq, irq_ha /* Setup NMI state */ desc->istate |= IRQS_NMI; retval = irq_nmi_setup(desc); - if (retval) { - __cleanup_nmi(irq, desc); - return -EINVAL; - } - return 0; } + if (retval) { + __cleanup_nmi(irq, desc); + return -EINVAL; + } + return 0; + err_irq_setup: irq_chip_pm_put(&desc->irq_data); err_out: