From nobody Wed Dec 17 08:54:36 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A9AE723CE; Thu, 11 Jul 2024 15:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720710969; cv=none; b=As2O+Nfk7qTfNdVHeY5UlwzpL2J61uYxLPVmQotoSYWfta3neirTMSCAy8K9U5Kfu1DWmhYcxoqIKtQGX90rt0aFe3Dn2MX9VB4HqqWBJXzpUXy/GjsPxnwiEfHYaJq3kvWH9wk09QpQPhQ5vuLxySpAxV8zbCpUn6VzZJPAU6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720710969; c=relaxed/simple; bh=BfBSUOPqmi3LuNAPGcdlMxJ0qVCvioaU4Xh7gZ+xN8g=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=LlWj1mr+xXeU/RN571PqAFMen13kOXxc/q5fUVs73WKzjtxKgGt6YHxtoj6yIBcPSK4Ks2c4FLVe1S4EOzBH9ifO9NXfcpdeIclqGiQf5skQtEHQwXrsUNtGr2g85t78bHJryEZvgDGR1iQz+Lh1RHEeLUTuiSzVOpl2L2GjPjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yHhHCPYC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8i3hr4Jg; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yHhHCPYC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8i3hr4Jg" Date: Thu, 11 Jul 2024 15:16:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1720710966; 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=ZaNplFVYapEUI3M23Goml2uSiimpfDyZ8+AUduFpyrg=; b=yHhHCPYC4gwQjyuVSCQRtrjDg5Hd02lksfjDmuzfTL1lpxhgikuu5I7Il/hM5dRSC8FyXD eTBTIc2uzAtReJefdy3ub7KRFQbjvPD5jSsfZMvUbelDgKwvKuXMdK+ivZXraKthEsJei4 6m5T+EYvmJlxLRq4P+ZIkceF4E00euRqFHpCiLoFz62bRvXtq/XAo2AOyPW2C/UkVVvV4v OZPEGDP57HkdHwm2feXLn9msb+32+lLkxdDanVq3VwsqnL6amcgh16ud4Rk86ogVro33Bb XpGLbOx+RggrkQIgAqCtZfZCo9lJkeLremaD8fi3T+pujvDZd3dMQnMiuIlQLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1720710966; 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=ZaNplFVYapEUI3M23Goml2uSiimpfDyZ8+AUduFpyrg=; b=8i3hr4Jg1DdZ7YXyDIctxZ1R1rQwOZTqQw1MgPK86/7GnF293Eol5iPb1t/e/Y8ciUmYzi wS1HVy4uKFX+mfCg== From: "tip-bot2 for Shenwei Wang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/imx-irqsteer: Handle runtime power management correctly Cc: Shenwei Wang , Thomas Gleixner , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20240703163250.47887-1-shenwei.wang@nxp.com> References: <20240703163250.47887-1-shenwei.wang@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172071096497.2215.13516438615600678880.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/core branch of tip: Commit-ID: cd0406fab8d4a16ec4f617c0a4b405bf70543b5b Gitweb: https://git.kernel.org/tip/cd0406fab8d4a16ec4f617c0a4b405bf7= 0543b5b Author: Shenwei Wang AuthorDate: Wed, 03 Jul 2024 11:32:50 -05:00 Committer: Thomas Gleixner CommitterDate: Thu, 11 Jul 2024 17:06:02 +02:00 irqchip/imx-irqsteer: Handle runtime power management correctly The power domain is automatically activated from clk_prepare(). However, on certain platforms like i.MX8QM and i.MX8QXP, the power-on handling invokes sleeping functions, which triggers the 'scheduling while atomic' bug in the context switch path during device probing: BUG: scheduling while atomic: kworker/u13:1/48/0x00000002 Call trace: __schedule_bug+0x54/0x6c __schedule+0x7f0/0xa94 schedule+0x5c/0xc4 schedule_preempt_disabled+0x24/0x40 __mutex_lock.constprop.0+0x2c0/0x540 __mutex_lock_slowpath+0x14/0x20 mutex_lock+0x48/0x54 clk_prepare_lock+0x44/0xa0 clk_prepare+0x20/0x44 imx_irqsteer_resume+0x28/0xe0 pm_generic_runtime_resume+0x2c/0x44 __genpd_runtime_resume+0x30/0x80 genpd_runtime_resume+0xc8/0x2c0 __rpm_callback+0x48/0x1d8 rpm_callback+0x6c/0x78 rpm_resume+0x490/0x6b4 __pm_runtime_resume+0x50/0x94 irq_chip_pm_get+0x2c/0xa0 __irq_do_set_handler+0x178/0x24c irq_set_chained_handler_and_data+0x60/0xa4 mxc_gpio_probe+0x160/0x4b0 Cure this by implementing the irq_bus_lock/sync_unlock() interrupt chip callbacks and handle power management in them as they are invoked from non-atomic context. [ tglx: Rewrote change log, added Fixes tag ] Fixes: 0136afa08967 ("irqchip: Add driver for imx-irqsteer controller") Signed-off-by: Shenwei Wang Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240703163250.47887-1-shenwei.wang@nxp.com --- drivers/irqchip/irq-imx-irqsteer.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-imx-irqsteer.c b/drivers/irqchip/irq-imx-i= rqsteer.c index 20cf7a9..75a0e98 100644 --- a/drivers/irqchip/irq-imx-irqsteer.c +++ b/drivers/irqchip/irq-imx-irqsteer.c @@ -36,6 +36,7 @@ struct irqsteer_data { int channel; struct irq_domain *domain; u32 *saved_reg; + struct device *dev; }; =20 static int imx_irqsteer_get_reg_index(struct irqsteer_data *data, @@ -72,10 +73,26 @@ static void imx_irqsteer_irq_mask(struct irq_data *d) raw_spin_unlock_irqrestore(&data->lock, flags); } =20 +static void imx_irqsteer_irq_bus_lock(struct irq_data *d) +{ + struct irqsteer_data *data =3D d->chip_data; + + pm_runtime_get_sync(data->dev); +} + +static void imx_irqsteer_irq_bus_sync_unlock(struct irq_data *d) +{ + struct irqsteer_data *data =3D d->chip_data; + + pm_runtime_put_autosuspend(data->dev); +} + static const struct irq_chip imx_irqsteer_irq_chip =3D { - .name =3D "irqsteer", - .irq_mask =3D imx_irqsteer_irq_mask, - .irq_unmask =3D imx_irqsteer_irq_unmask, + .name =3D "irqsteer", + .irq_mask =3D imx_irqsteer_irq_mask, + .irq_unmask =3D imx_irqsteer_irq_unmask, + .irq_bus_lock =3D imx_irqsteer_irq_bus_lock, + .irq_bus_sync_unlock =3D imx_irqsteer_irq_bus_sync_unlock, }; =20 static int imx_irqsteer_irq_map(struct irq_domain *h, unsigned int irq, @@ -150,6 +167,7 @@ static int imx_irqsteer_probe(struct platform_device *p= dev) if (!data) return -ENOMEM; =20 + data->dev =3D &pdev->dev; data->regs =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(data->regs)) { dev_err(&pdev->dev, "failed to initialize reg\n");