public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Mikko Perttunen <mperttunen@nvidia.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <sashal@kernel.org>,
	andi.shyti@kernel.org, ldewangan@nvidia.com,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.1] i2c: tegra: Don't mark devices with pins as IRQ safe
Date: Tue, 24 Mar 2026 07:19:16 -0400	[thread overview]
Message-ID: <20260324111931.3257972-7-sashal@kernel.org> (raw)
In-Reply-To: <20260324111931.3257972-1-sashal@kernel.org>

From: Mikko Perttunen <mperttunen@nvidia.com>

[ Upstream commit ec69c9e88315c4be70c283f18c2ff130da6320b5 ]

I2C devices with associated pinctrl states (DPAUX I2C controllers)
will change pinctrl state during runtime PM. This requires taking
a mutex, so these devices cannot be marked as IRQ safe.

Add PINCTRL as dependency to avoid build errors.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Reported-by: Russell King <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/all/E1vsNBv-00000009nfA-27ZK@rmk-PC.armlinux.org.uk/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Record for Phase 6:
- The buggy code exists in ALL active stable trees (v5.15, v6.1, v6.6,
  v6.12)
- The condition varies across trees — backporting needs minor adaptation
  for trees without the ACPI check
- Pinctrl code has been in the driver since v4.9
- The Kconfig change (adding PINCTRL dependency) is needed in all trees
- For v5.15/v6.1: the condition is `if (!i2c_dev->is_vi)` — patch must
  add `&& !i2c_dev->dev->pins`
- For v6.6: `if (!IS_VI(i2c_dev))` — same adaptation needed
- For v6.12+: `if (!IS_VI(i2c_dev) &&
  !has_acpi_companion(i2c_dev->dev))` — closest to mainline, minor
  conflict

## PHASE 7: SUBSYSTEM AND MAINTAINER CONTEXT

### Step 7.1: SUBSYSTEM CRITICALITY
- **Subsystem:** drivers/i2c/busses — I2C bus driver (NVIDIA Tegra
  specific)
- **Criticality:** PERIPHERAL — affects Tegra SoC users (NVIDIA Jetson
  platforms, embedded/automotive)
- However, Tegra is a significant embedded platform used in NVIDIA
  Jetson (AI/robotics), automotive (NVIDIA Drive), and Nintendo Switch

### Step 7.2: SUBSYSTEM ACTIVITY
The driver has moderate activity — updated regularly for new Tegra
generations.

## PHASE 8: IMPACT AND RISK ASSESSMENT

### Step 8.1: WHO IS AFFECTED
- Users with Tegra SoCs that have DPAUX I2C controllers (Tegra124,
  Tegra132, Tegra210+)
- Specifically Jetson Xavier NX was reported as affected (Russell King's
  report)
- Platform-specific: only NVIDIA Tegra platforms

### Step 8.2: TRIGGER CONDITIONS
- **Trigger:** Device probe when the I2C controller has associated
  pinctrl states
- **How common:** Happens on every boot for affected hardware — not a
  race condition, not timing-dependent
- **Unprivileged trigger:** No (hardware-dependent, happens at boot)

### Step 8.3: FAILURE MODE SEVERITY
- **Failure:** BUG: sleeping function called from invalid context
  (mutex_lock in atomic context)
- **Severity:** CRITICAL — kernel BUG/panic on every boot for affected
  hardware
- The device cannot be used at all — it crashes during probe

### Step 8.4: RISK-BENEFIT RATIO
- **Benefit:** HIGH — fixes kernel BUG on every boot for DPAUX I2C
  controllers on Tegra
- **Risk:** VERY LOW — adds one additional condition (`!dev->pins`) to
  an existing if-statement, plus a Kconfig dependency
- The fix is obviously correct: if pinctrl operations need a mutex, the
  device cannot be IRQ-safe
- **Ratio:** Strongly favors backporting

## PHASE 9: FINAL SYNTHESIS

### Step 9.1: COMPILE THE EVIDENCE

**Evidence FOR backporting:**
1. Fixes a real BUG (sleeping in atomic context) with stack trace from
   Russell King
2. Affects every boot on affected hardware (not a theoretical race)
3. Fix is extremely small and surgical (one condition added + Kconfig
   dep)
4. Obviously correct — if runtime PM calls mutex, device cannot be IRQ-
   safe
5. Same class of bug was already fixed twice (VI: 9e29420ddb133, ACPI:
   14d069d92951a) — ACPI fix was Cc'd to stable
6. Reported by Russell King, a highly respected ARM kernel developer
7. Merged directly by Linus Torvalds
8. Buggy code exists in all active stable trees (since v4.9)
9. Went through 3 patch iterations — well-reviewed

**Evidence AGAINST backporting:**
1. Tegra-specific — affects only NVIDIA Tegra platform users
2. Requires minor adaptation for older stable trees (different condition
   syntax)
3. The Kconfig PINCTRL dependency might affect COMPILE_TEST
   configurations

**UNRESOLVED:**
- Exact list of hardware models/boards affected (known: Jetson Xavier
  NX)

### Step 9.2: STABLE RULES CHECKLIST
1. **Obviously correct and tested?** YES — reported and tested by
   Russell King, 3 patch iterations, merged by Linus
2. **Fixes a real bug?** YES — BUG: sleeping function called from
   invalid context, with stack trace
3. **Important issue?** YES — kernel BUG/crash on every boot for
   affected hardware
4. **Small and contained?** YES — ~6 lines changed, single condition
   addition + Kconfig dep
5. **No new features or APIs?** CORRECT — no new features
6. **Can apply to stable trees?** With minor adaptation — the condition
   syntax differs across stable trees

### Step 9.3: EXCEPTION CATEGORIES
Not an exception category — this is a standard bug fix that meets all
stable rules.

### Step 9.4: DECISION
This is a clear bug fix that causes a kernel BUG (crash) on every boot
for affected Tegra hardware. The fix is small, surgical, obviously
correct, and follows the same pattern as two previous fixes for the same
class of bug (one of which was already Cc'd to stable). The previous
ACPI variant (commit 14d069d92951a) was explicitly marked `Cc: stable` —
this is the same bug with a different trigger.

## Verification

- [Phase 1] Parsed tags: Reported-by Russell King, Link to lore, merged
  by Linus Torvalds directly
- [Phase 1] Commit explains: pinctrl state transitions need mutex, IRQ-
  safe marking causes BUG
- [Phase 2] Diff analysis: +1 condition `!i2c_dev->dev->pins` in
  probe(), +2 lines Kconfig PINCTRL dep, +3 lines comment
- [Phase 3] git blame: `pm_runtime_irq_safe()` call existed since VI
  exception was added; pinctrl support added in v4.9 (718917b9875fc)
- [Phase 3] Related fix 14d069d92951a (ACPI variant) had `Cc: stable
  v5.17+` — same class of bug
- [Phase 3] Author Mikko Perttunen is NVIDIA Tegra subsystem contributor
- [Phase 4] Lore link confirms: BUG sleeping function called from
  invalid context, stack trace: tegra_i2c_runtime_suspend →
  pinctrl_pm_select_idle_state → mutex_lock
- [Phase 4] Patch went through v1/v2/v3, kernel test robot found build
  issue leading to PINCTRL Kconfig dep
- [Phase 5] `dev->pins` is `#ifdef CONFIG_PINCTRL` in
  include/linux/device.h:592 — Kconfig dep ensures it compiles
- [Phase 5] `tegra_i2c_probe` is platform driver probe, called during
  device enumeration
- [Phase 6] Verified buggy code exists in v5.15 (`if
  (!i2c_dev->is_vi)`), v6.1 (same), v6.6 (`if (!IS_VI(i2c_dev))`), v6.12
  (has ACPI check) — all need this fix
- [Phase 6] Backport needs minor adaptation for trees without ACPI check
  (v5.15, v6.1, v6.6)
- [Phase 7] Subsystem: Tegra I2C driver, PERIPHERAL but significant
  embedded platform
- [Phase 8] Failure mode: kernel BUG on every boot for affected
  hardware, severity CRITICAL
- [Phase 8] Risk: VERY LOW (one additional condition in existing if-
  statement)

**YES**

 drivers/i2c/busses/Kconfig     | 2 ++
 drivers/i2c/busses/i2c-tegra.c | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 09ba55bae1fac..7d0afdc7d8862 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -1220,6 +1220,8 @@ config I2C_TEGRA
 	tristate "NVIDIA Tegra internal I2C controller"
 	depends on ARCH_TEGRA || (COMPILE_TEST && (ARC || ARM || ARM64 || M68K || RISCV || SUPERH || SPARC))
 	# COMPILE_TEST needs architectures with readsX()/writesX() primitives
+	depends on PINCTRL
+	# ARCH_TEGRA implies PINCTRL, but the COMPILE_TEST side doesn't.
 	help
 	  If you say yes to this option, support will be included for the
 	  I2C controller embedded in NVIDIA Tegra SOCs
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e533460bccc39..a9aed411e3190 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1837,8 +1837,11 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 	 *
 	 * 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.
+	 *
+	 * Devices with pinctrl states cannot be marked IRQ-safe as the pinctrl
+	 * state transitions during runtime PM require mutexes.
 	 */
-	if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev))
+	if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev) && !i2c_dev->dev->pins)
 		pm_runtime_irq_safe(i2c_dev->dev);
 
 	pm_runtime_enable(i2c_dev->dev);
-- 
2.51.0


  parent reply	other threads:[~2026-03-24 11:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 11:19 [PATCH AUTOSEL 6.19] drm/amd/display: Fix gamma 2.2 colorop TFs Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19] mshv: Fix error handling in mshv_region_pin Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.1] tg3: replace placeholder MAC address with device property Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.12] btrfs: reserve enough transaction items for qgroup ioctls Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.10] objtool: Fix Clang jump table detection Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.12] HID: logitech-hidpp: Prevent use-after-free on force feedback initialisation failure Sasha Levin
2026-03-24 11:19 ` Sasha Levin [this message]
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.18] smb: client: fix generic/694 due to wrong ->i_blocks Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.10] atm: lec: fix use-after-free in sock_def_readable() Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.10] HID: wacom: fix out-of-bounds read in wacom_intuos_bt_irq Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.6] spi: geni-qcom: Check DMA interrupts early in ISR Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.12] wifi: mac80211: check tdls flag in ieee80211_tdls_oper Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19] objtool/klp: fix mkstemp() failure with long paths Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.6] arm64/scs: Fix handling of advance_loc4 Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.12] HID: logitech-hidpp: Enable MX Master 4 over bluetooth Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.15] btrfs: reject root items with drop_progress and zero drop_level Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.15] btrfs: don't take device_list_mutex when querying zone info Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-6.18] HID: core: Mitigate potential OOB by removing bogus memset() Sasha Levin
2026-03-24 11:19 ` [PATCH AUTOSEL 6.19-5.10] HID: multitouch: Check to ensure report responses match the request Sasha Levin

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=20260324111931.3257972-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=andi.shyti@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=patches@lists.linux.dev \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=stable@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=torvalds@linux-foundation.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