[PATCH v6 0/2] i2c: imx-lpi2c: fix probe error handling and reset controller
| Newsgroups | org.kernel.vger.linux-i2c,dev.linux.lists.imx,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Carlos Song <[email protected]> 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/[email protected]/ Changes for v6: - According to Markus Elfring suggestion, use a consistent format dev_err_probe to return ret, it help avoid duplicate source code. 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 | 42 +++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) -- 2.43.0