[PATCH v5 0/2] i2c: imx-lpi2c: fix probe error handling and reset controller

From: carlos . song

Date: Tue Jun 30 2026 - 07:02:45 EST


From: Carlos Song <carlos.song@xxxxxxx>

During probe, two issues exist in the LPI2C driver:

1. The error paths do not properly unwind all acquired resources on
failure. Clocks enabled before runtime PM initialization are never
disabled on certain error paths, when probe fails after runtime PM
is initialized, the previous error path called pm_runtime_put_sync(),
however, due to different clock management strategies on different
SoCs[1] (to avoid deadlocks between the global prepare_lock and runtime
PM), the callback may only disable clocks without unpreparing them,
causing an incomplete unwind.

2. The LPI2C controller may retain unexpected state from previous
boot stages, causing the system to hang during probe.

This series addresses both issues. Patch 1 restructures the probe
error paths to ensure correct resource cleanup on failure. Patch 2
resets the Master and Target controller logic before IRQ registration
to clear any leftover state.

[1] https://lore.kernel.org/all/20251125084718.2156168-1-carlos.song@xxxxxxx/

Changes for v5:
- Remove devm_free_irq() and free_irq err label.
- Change commit log to explain why not using runtime PM to manage clocks
during the probe phase.

Changes for v4:
- Split v3 into two patches per reviewer feedback:
* Patch 1 contains only the error path restructuring.
* Patch 2 contains only the controller reset and the IRQ
relocation that is required by the reset ordering.

Changes for v3:
- Reset the Target logic via LPI2C_SCR in addition to MCR.
- Replace pm_runtime_put_sync() with pm_runtime_disable() +
pm_runtime_set_suspended() + pm_runtime_put_noidle() to avoid
triggering the suspend callback during error recovery.
- Add clk_disable and free_irq labels for complete error unwinding.
- Update commit log to cover the SCR reset rationale.

Changes for v2:
- Jump to rpm_disable instead of returning directly if the IRQ
request fails.

Carlos Song (2):
i2c: imx-lpi2c: properly unwind resources on probe failure
i2c: imx-lpi2c: reset controller in probe stage

drivers/i2c/busses/i2c-imx-lpi2c.c | 43 +++++++++++++++++++++---------
1 file changed, 31 insertions(+), 12 deletions(-)

--
2.43.0