Hello,
I discovered a deadlock while using the Toshiba TC358746 MIPI bridge.
In tc358746_link_validate() an attempt is made to get the state lock of
the subdev [1] - but since this lock is already held by the calling
function v4l2_subdev_link_validate() [2], this leads to a deadlock.
Another problem is that an attempt is made to query the link frequency
of the source [3]. Since some image sensors use the lock of the v4l2
control handler as state lock (e.g. [4]), which is already held at this
point, a deadlock can also occur here.
I noticed that very few drivers implement (v4l2_subdev_pad_ops)
link_validate and if they do, the state is not needed there.
This driver therefore seems to be an exception here.
Some MIPI receivers that also have to query the link frequency of the
source usually do this in s_stream.
Therefore, the most obvious workaround seems to move the problematic
parts from tc358746_link_validate() to s_stream.
Although this works, the question is whether this is the right solution
or whether it should work differently.
I would be interested in your input on this.
Thanks
~Matthias
[1]
https://elixir.bootlin.com/linux/v6.12-rc6/source/drivers/media/i2c/tc358746.c#L906
[2]
https://elixir.bootlin.com/linux/v6.12-rc6/source/drivers/media/v4l2-core/v4l2-subdev.c#L1502
[3]
https://elixir.bootlin.com/linux/v6.12-rc6/source/drivers/media/i2c/tc358746.c#L913
[4]
https://elixir.bootlin.com/linux/v6.12-rc6/source/drivers/media/i2c/imx283.c#L1565