public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Laxman Dewangan <ldewangan@nvidia.com>,
	Dmitry Osipenko <digetx@gmail.com>
Cc: Andi Shyti <andi.shyti@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Linus Walleij <linusw@kernel.org>,
	linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: [PATCH net-next] i2c: tegra: runtime PM is not IRQ-safe
Date: Tue, 17 Feb 2026 15:40:47 +0000	[thread overview]
Message-ID: <E1vsNBv-00000009nfA-27ZK@rmk-PC.armlinux.org.uk> (raw)

i2c-tegra marks its runtime PM as IRQ safe using pm_runtime_irq_safe().
However, tegra_i2c_runtime_suspend() calls
pinctrl_pm_select_idle_state(), which eventually calls
pinmux_disable_setting() which will take the desc->mux_lock mutex.
When this happens, the result is:

BUG: sleeping function called from invalid context at kernel/locking/mutex.c:591
in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 12, name: kworker/u24:0
preempt_count: 0, expected: 0
RCU nest depth: 0, expected: 0
3 locks held by kworker/u24:0/12:
 #0: ffff000080020d48 ((wq_completion)events_unbound#2){+.+.}-{0:0}, at: process_one_work+0x184/0x628
 #1: ffff80008225bde8 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work+0x1ac/0x628
 #2: ffff000080ad90f8 (&dev->mutex){....}-{4:4}, at: __device_attach+0x2c/0x188
irq event stamp: 97058
ktime_get+0x130/0x180
_raw_spin_lock_irqsave+0x84/0x88
handle_softirqs+0x448/0x494
__do_softirq+0x14/0x20
CPU: 1 UID: 0 PID: 12 Comm: kworker/u24:0 Not tainted 6.19.0-rc8-net-next+ #591 PREEMPT
Hardware name: NVIDIA NVIDIA Jetson Xavier NX Developer Kit/Jetson, BIOS 6.0-37391689 08/28/2024
Workqueue: events_unbound deferred_probe_work_func
Call trace:
 show_stack+0x18/0x30 (C)
 dump_stack_lvl+0x6c/0x94
 dump_stack+0x18/0x24
 __might_resched+0x154/0x220
 __might_sleep+0x48/0x80
 __mutex_lock+0x48/0x800
 mutex_lock_nested+0x24/0x30
 pinmux_disable_setting+0x9c/0x180
 pinctrl_commit_state+0x5c/0x260
 pinctrl_pm_select_idle_state+0x4c/0xa0
 tegra_i2c_runtime_suspend+0x2c/0x3c
 pm_generic_runtime_suspend+0x2c/0x44
 __rpm_callback+0x48/0x1ec
 rpm_callback+0x74/0x80
 rpm_suspend+0xec/0x630
 rpm_idle+0x274/0x42c
 __pm_runtime_idle+0x44/0x154
 tegra_i2c_probe+0x2c0/0x540
 platform_probe+0x5c/0xa4
 really_probe+0xbc/0x2c0
 __driver_probe_device+0x78/0x120
 driver_probe_device+0x3c/0x160
 __device_attach_driver+0xb8/0x140
 bus_for_each_drv+0x70/0xb8
 __device_attach+0xa4/0x188
 device_initial_probe+0x50/0x54
 bus_probe_device+0x38/0xa4
 deferred_probe_work_func+0x90/0xcc
 process_one_work+0x204/0x628
 worker_thread+0x1bc/0x360
 kthread+0x138/0x210
 ret_from_fork+0x10/0x20

This was observed on the nVidia Jetson Xavier NX platform.

Thus, no, the runtime PM is not IRQ-safe. Remove the call marking it as
such.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
The IRQ-safe marking was introduced by commit ede2299f7101 ("i2c:
tegra: Support atomic transfers").

However, since then there have been patches disabling the IRQ-safe
marking:

9e29420ddb13 i2c: tegra: Don't mark VI I2C as IRQ safe runtime PM
14d069d92951 i2c: tegra: Do not mark ACPI devices as irq safe

Clearly, the presence of pinctrl_pm_select_idle_state() which can sleep
means, definitively, that runtime PM on this device is not IRQ safe,
and if the original patch introducing atomic transfers relies on these
being IRQ safe, that patch was incorrect (maybe on such devices, it
should not change the pin state, and the driver should have a flag to
allow the driver to be used in atomic contexts?)

The alternative to this patch is to get rid of the pinctrl calls in the
runtime PM path.
---
 drivers/i2c/busses/i2c-tegra.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e533460bccc3..878a2d1c9749 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1829,18 +1829,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 	if (err)
 		goto release_clocks;
 
-	/*
-	 * VI I2C is in VE power domain which is not always ON and not
-	 * IRQ-safe.  Thus, IRQ-safe device shouldn't be attached to a
-	 * non IRQ-safe domain because this prevents powering off the power
-	 * domain.
-	 *
-	 * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't
-	 * be used for atomic transfers. ACPI device is not IRQ safe also.
-	 */
-	if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev))
-		pm_runtime_irq_safe(i2c_dev->dev);
-
 	pm_runtime_enable(i2c_dev->dev);
 
 	err = tegra_i2c_init_hardware(i2c_dev);
-- 
2.47.3


             reply	other threads:[~2026-02-17 15:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17 15:40 Russell King (Oracle) [this message]
2026-02-17 15:50 ` [PATCH net-next] i2c: tegra: runtime PM is not IRQ-safe Russell King (Oracle)
2026-02-17 15:55 ` Jon Hunter
2026-02-17 16:04   ` Russell King (Oracle)
2026-02-17 16:15     ` Jon Hunter
2026-02-17 16:40       ` Russell King (Oracle)
2026-02-17 16:46         ` Jon Hunter
2026-02-18  1:35           ` Mikko Perttunen
2026-02-18  8:30             ` Jon Hunter
2026-03-18 18:17               ` Russell King (Oracle)
2026-03-19  2:16                 ` Mikko Perttunen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1vsNBv-00000009nfA-27ZK@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andi.shyti@kernel.org \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox