Re: [PATCH 1/2] i2c: designware: Avoid taking clk_prepare mutex in PM callbacks

From: Jisheng Zhang
Date: Wed Aug 20 2025 - 12:50:46 EST


On Wed, Aug 20, 2025 at 07:05:42PM +0300, Andy Shevchenko wrote:
> On Wed, Aug 20, 2025 at 11:31:24PM +0800, Jisheng Zhang wrote:
> > This is unsafe, as the runtime PM callbacks are called from the PM
> > workqueue, so this may deadlock when handling an i2c attached clock,
> > which may already hold the clk_prepare mutex from another context.
>
> Can you be more specific? What is the actual issue in practice?
> Do you have traces and lockdep warnings?

Assume we use i2c designware to control any i2c based clks, e.g the
clk-si5351.c driver. In its .clk_prepare, we'll get the prepare_lock
mutex, then we call i2c adapter to operate the regs, to runtime resume
the i2c adapter, we call clk_prepare_enable() which will try to get
the prepare_lock mutex again.

Regards.

>
> AFAICS it seems related to the bus recovery mechanism. Is this what you have in
> mind?
>
> --
> With Best Regards,
> Andy Shevchenko
>
>