Skip to content

i2c: imx: Avoid deadlock between clk_prepare_lock and i2c bus lock#40

Open
boesec wants to merge 1 commit intonxp-imx:lf-6.6.yfrom
boesec:lf-6.6.y
Open

i2c: imx: Avoid deadlock between clk_prepare_lock and i2c bus lock#40
boesec wants to merge 1 commit intonxp-imx:lf-6.6.yfrom
boesec:lf-6.6.y

Conversation

@boesec
Copy link

@boesec boesec commented Feb 17, 2026

During deferred probing, clock registration can call into i2c (e.g. via pcf85063_clkout_recalc_rate() using regmap_i2c_read()) while the I2C bus lock is held. In parallel, the i.MX I2C transfer path calls clk_get_rate() from i2c_imx_start() while holding the same bus lock.

This seems to be a rare corner case, but it is definitely reproducible. For us, a workaround for this is e.g. setting a fixed clock rate to RTC which avoids a call on clk_get_rate. We first encounter this issue after a kernel update to 6.6.
This patch fixed it for us entirely.

Since this issue was was introduced by 0e94d44 which is only in here, not in mainline, I assume this is the place to fix it?
Hung-task-probing-6.6.log

@wangxiaoningnxp

During deferred probing, clock registration can call into i2c (e.g. via
pcf85063_clkout_recalc_rate() using regmap_i2c_read()) while the I2C bus
lock is held. In parallel, the i.MX I2C transfer path calls clk_get_rate()
from i2c_imx_start() while holding the same bus lock.

clk_get_rate() takes clk_prepare_lock, which can already be held by the
clock framework while invoking notifiers. This results in an ABBA deadlock
between clk_prepare_lock and the I2C bus lock, stalling deferred probe.

This patch fixes the issue by caching the clock rate in the notifier
callback and removing the `clk_get_rate()` call from the transfer path.

Signed-off-by: Christoph Boese <boesesc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant