Skip to contentSkip to conversation

device probe: add self triggered delayed work request

PATCH Shamir Rabinovitch 2 participants 4 messages Aug 8, 2016 – Aug 9, 2016

lore
Share & tools
lore
#0 lore raw

Hi Qing,

I suspect there is potential dead-lock with this patch:

cpu0 cpu1

driver_deferred_probe_add deferred_probe_work_func
... mutex_unlock(&deferred_probe_mutex)
mutex_lock(&deferred_probe_mutex) bus_probe_device(dev)
... device return -EPROBE_DEFER
... driver_deferred_probe_add
... mutex_lock(&deferred_probe_mutex)
... <deadlock!>
cancel_delayed_work(&deferred_probe_trigger_work)
<work will never end - deadlock!>

Please confirm if this scenario is possible.

BR, Shamir Rabinovitch

#1 lore raw
Quoted 6 lines · Shamir Rabinovitch

Hi Qing,

I suspect there is potential dead-lock with this patch:

cpu0 cpu1

Quoted 9 lines

driver_deferred_probe_add deferred_probe_work_func
... mutex_unlock(&deferred_probe_mutex)
mutex_lock(&deferred_probe_mutex) bus_probe_device(dev)
... device return -EPROBE_DEFER
... driver_deferred_probe_add
... mutex_lock(&deferred_probe_mutex)
... <deadlock!>
cancel_delayed_work(&deferred_probe_trigger_work)
<work will never end - deadlock!>

Not sure if I understood your scenario. Why there is a deadlock here?

Quoted 4 lines

Please confirm if this scenario is possible.

BR, Shamir Rabinovitch

#2 lore raw
Quoted 3 lines · Qing Huang

Not sure if I understood your scenario. Why there is a deadlock here?

CPU0 | CPU1
---------------------------------------------------------------------------------------------

 driver_deferred_probe_add                              | driver_deferred_probe_trigger_wrapper   
  mutex_lock(&deferred_probe_mutex)                     |  driver_deferred_probe_trigger
   cancel_delayed_work(&deferred_probe_trigger_work)    |   mutex_lock(&deferred_probe_mutex)
    wait for "driver_deferred_probe_trigger_wrapper"    |    wait for "deferred_probe_mutex"

is this possible scenario with this patch?

if yes then CPU0 will wait for CPU1 to finish the delayed work whith mutex deferred_probe_mutex held while CPU1 will try to finish the delayed work and will wait for the same mutex forever.

it seems like dead lock scenario to me.

please say if this scenario is possible.

BR, Shamir Rabinovitch

#3 lore raw
Quoted 10 lines · Shamir Rabinovitch
Quoted 2 lines · Qing Huang

Not sure if I understood your scenario. Why there is a deadlock here?

CPU0 | CPU1
---------------------------------------------------------------------------------------------

  driver_deferred_probe_add                              | driver_deferred_probe_trigger_wrapper
   mutex_lock(&deferred_probe_mutex)                     |  driver_deferred_probe_trigger
    cancel_delayed_work(&deferred_probe_trigger_work)    |   mutex_lock(&deferred_probe_mutex)
     wait for "driver_deferred_probe_trigger_wrapper"    |    wait for "deferred_probe_mutex"
Quoted 5 lines

is this possible scenario with this patch?

if yes then CPU0 will wait for CPU1 to finish the delayed work whith mutex deferred_probe_mutex held while CPU1 will try to finish the delayed work and will wait for the same mutex forever.

CPU0 will not wait for "driver_deferred_probe_trigger_wrapper" to finish, it simply puts the work request onto the queue and returns.

Qing

Quoted 6 lines

it seems like dead lock scenario to me.

please say if this scenario is possible.

BR, Shamir Rabinovitch