All of lore.kernel.org
 help / color / mirror / Atom feed
* Race in rcar-v4l2.c
@ 2024-09-06  9:57 Tomi Valkeinen
  2024-09-06 10:14 ` Niklas Söderlund
  0 siblings, 1 reply; 9+ messages in thread
From: Tomi Valkeinen @ 2024-09-06  9:57 UTC (permalink / raw)
  To: niklas.soderlund; +Cc: linux-media

Hi Niklas,

There seems to be a race in rcar-v4l2.c, causing
WARN_ON(entity->use_count < 0) in pipeline_pm_power_one().

If my understanding is correct, the VIN v4l2 nodes are being created 
(rvin_v4l2_register), meaning they are userspace accessible, but the 
media pipeline as a whole is not ready yet (e.g. media links).

So what happens is that after some video nodes have been created, the 
userspace opens them (I think it's udevd checking the new device nodes), 
causing rvin_open(). rvin_open() goes through the media graph and does 
some PM enabling (I'm not familiar with the legacy 
v4l2_pipeline_pm_get()). However, as the links are not there, it doesn't 
really enable much at all.

Then the driver goes forward and finishes with the media graph.

Then the userspace closes the opened video nodes, rvin_release() gets 
called and it goes through the media graph, which now contains all the 
entities, and powers them down. As the entities were never powered up, 
we hit the use_count warning.

This happens quite often to me when loading the modules, but I think it 
can be made to happen more often by adding msleep(1000) to the beginning 
of rvin_release(), thus ensuring that the graph setup is finished before 
the rvin_release() proceeds (and hoping that the graph setup was not 
ready when rvin_open() was called).

  Tomi


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-09-06 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06  9:57 Race in rcar-v4l2.c Tomi Valkeinen
2024-09-06 10:14 ` Niklas Söderlund
2024-09-06 11:14   ` Tomi Valkeinen
2024-09-06 11:27     ` Tomi Valkeinen
2024-09-06 12:28       ` Tomi Valkeinen
2024-09-06 13:46         ` Niklas Söderlund
2024-09-06 14:13           ` Tomi Valkeinen
2024-09-06 15:18             ` Niklas Söderlund
2024-09-06 15:45               ` Tomi Valkeinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.