soc: qcom: pil: Add support to load PIL blobs in parallel
Loading of the subsystem firmware blobs into the memory is
one of the major bottlenecks during the subsystem's boot
operation. Hence, optimizing the path such that the blobs
are loaded in parallel and making the operation faster.
Fix use-after-free issue when loading firmware images.
Currently, the function pil_load_segs() allocates memory, creates
kthreads, and calls wait_for_completion_interruptible() to synchronize
the threads. However, if the completion received a terminate signal,
the allocated memory that is being used by the threads (under execution)
is freed. When the thread(s) tries to access this memory, it leads to
a use-after-free issue.
As a solution, replace the kthreads and completions with work items
as this provides an implicit synchronization. After spawning the
work items, we simply now call flush_work() which waits until
the thread's execution is finished, thus avoiding the use-after-free
issue. The PIL code creates it own high priority & unbounded workqueue
to schedule the work items.
Change-Id: I6a28f46a53c05e16e5f29ad975879e336a16f0cd
Signed-off-by:
Sanjay Dwivedi <sanjaykd@codeaurora.org>
Loading
Please register or sign in to comment