linux/drivers/i2c
Abdurrahman Hussain d33373c565
i2c: xiic: restore non-managed runtime PM to fix clk WARN flood
The devres conversion replaced manual pm_runtime_enable()/disable() with
devm_pm_runtime_set_active_enabled() and dropped the remove-time runtime
PM teardown. The managed release tears runtime PM down in the wrong
order: it calls pm_runtime_dont_use_autosuspend() before
pm_runtime_disable(), i.e. while runtime PM is still enabled, and devres
is LIFO so the devm_clk_get_enabled() release runs afterwards.

At remove(), pm_runtime_put_sync() leaves the device active with the
autosuspend timer armed. Clearing use_autosuspend then makes rpm_idle()
suspend immediately, and xiic_i2c_runtime_suspend() clk_disable()s the
clock. The later devm_clk_get_enabled() release clk_disable_unprepare()s
the already-disabled clock, so clk_core_disable() WARNs ("clkN already
disabled") on every teardown.

Drop the managed helper and restore the non-managed runtime PM setup and
teardown, so runtime PM is enabled once in probe and disabled once in
remove and the clock enable count stays balanced.

Order the remove teardown so runtime PM is disabled before the usage
count is dropped: pm_runtime_disable() followed by pm_runtime_put_noidle()
instead of pm_runtime_put_sync(). Dropping the count first with autosuspend
still enabled arms the autosuspend timer, and a preemption before
pm_runtime_disable() lets it expire, suspend the device and clk_disable()
the clock, which the devm release then disables again - the same WARN.

Restore the non-managed IRQ request as well. The probe error paths now
unwind runtime PM by hand via goto, and a devm-registered handler is only
freed later during devres unwind, so it would stay live across the manual
teardown (and across any future failing step added after it). Request the
IRQ with request_threaded_irq() and free it explicitly in the probe error
path and in remove. The probe error path also clears use_autosuspend, to
match the teardown in remove().

Fixes: 50c63491ff ("i2c: xiic: switch to devres managed APIs")
Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Cc: <stable@vger.kernel.org> # v7.1+
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://patch.msgid.link/20261014-i2c-xiic-restore-runtime-pm-teardown-v8-1-40668c270069@nexthop.ai
2026-10-15 22:34:34 +02:00
..
algos i2c: algo: bit: Allow to skip bit test 2026-07-29 20:51:16 +02:00
busses i2c: xiic: restore non-managed runtime PM to fix clk WARN flood 2026-10-15 22:34:34 +02:00
muxes i2c: mux: demux-pinctrl: fix OF node leak on kstrdup failure 2026-08-19 21:55:53 +02:00
i2c-atr.c i2c: atr: fix dangling adapter pointer on add failure 2026-09-16 07:30:36 +02:00
i2c-boardinfo.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-core-acpi.c i2c for v7.3 2026-08-19 09:23:13 -07:00
i2c-core-base.c i2c: core: fix debugfs UAF on adapter removal 2026-08-28 03:12:01 +02:00
i2c-core-of-prober.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
i2c-core-of.c Revert "treewide: Fix probing of devices in DT overlays" 2026-05-22 13:33:58 +02:00
i2c-core-slave.c i2c: Use trace_call__##name() at guarded tracepoint call sites 2026-03-26 10:24:39 -04:00
i2c-core-smbus.c i2c: smbus: fix a potential uninitialization bug 2026-05-19 12:43:08 +02:00
i2c-core.h i2c: Let i2c-core.h include <linux/i2c.h> 2026-07-03 07:38:15 +02:00
i2c-dev.c i2c: dev: prevent integer overflow in I2C_TIMEOUT ioctl 2026-05-04 11:31:35 +02:00
i2c-mux.c i2c: mux: Fix channel node leak on adapter add failure 2026-08-26 15:39:36 +02:00
i2c-slave-eeprom.c i2c: Use named initializers for arrays of i2c_device_data 2026-06-05 01:09:25 +02:00
i2c-slave-testunit.c i2c for v7.2 2026-06-16 07:43:29 +05:30
i2c-smbus.c i2c: Use named initializers for arrays of i2c_device_data 2026-06-05 01:09:25 +02:00
i2c-stub.c i2c: stub: Reject I2C block transfers with invalid length 2026-05-04 13:23:53 +02:00
Kconfig i2c: Remove I2C_COMPAT config symbol and related code 2024-09-07 18:31:28 +02:00
Makefile i2c: Introduce OF component probe function 2024-11-27 12:04:10 +01:00