Skip to contentSkip to conversation

media: platform: qcom: venus: possible ABBA deadlock in venus_event_notify() and venus_helper_vb2_buf_queue()

BUG Jia-Ju Bai 1 participant 1 message Aug 23, 2021

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

Hello,

My static analysis tool reports a possible ABBA deadlock in the venus driver in Linux 5.10:

venus_event_notify()
  mutex_lock(&core->lock); --> line 37 (Lock A) vdec_event_notify() --> via a function pointer "inst->ops->event_notify(...)" vdec_event_change()
    mutex_lock(&inst->lock); --> line 1301 (Lock B)

venus_helper_vb2_buf_queue()
  mutex_lock(&inst->lock); --> line 1346 (Lock B) session_process_buf()
    venus_pm_load_scale()
      load_scale_v4() via a function pointer "core->pm_ops->load_scale(...)" mutex_lock(&core->lock); --> line 966 (Lock A)

Besides, if "core->pm_ops->load_scale(...)" is load_scale_v1():
load_scale_v1()
  load_per_type()
    mutex_lock(&core->lock); --> line 150 (Lock A)

When venus_event_notify() and venus_helper_vb2_buf_queue() are concurrently executed, the deadlock can occur.

I am not quite sure whether this possible deadlock is real and how to fix it if it is real. Any feedback would be appreciated, thanks

Best wishes,
Jia-Ju Bai