linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Regulator Potential Deadlock
@ 2019-04-03 13:55 Charles Keepax
  0 siblings, 0 replies; only message in thread
From: Charles Keepax @ 2019-04-03 13:55 UTC (permalink / raw)
  To: broonie, digetx, l.stach; +Cc: lgirdwood, linux-kernel

Hi Guys,

Was testing some of my hardware and hit this potential lockup:

Possible unsafe locking scenario:

CPU0                    CPU1
----                    ----
lock((work_completion)(&(&rdev->disable_work)->work));
                        lock(regulator_list_mutex);
                        lock((work_completion)(&(&rdev->disable_work)->work));
lock(regulator_list_mutex);

***
DEADLOCK
***

Looks like it comes from this patch:

commit f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking")

The basic problem appears to be that regulator_unregister takes
the regulator_list_mutex and then calls flush_work on
disable_work. But regulator_disable_work calls
regulator_lock_dependent which will also take the
regulator_list_mutex. Resulting in a deadlock if the flush_work
call actually needs to flush the work.

The locking appears to have got quite complex since last time I
looked at it and I am having a little difficulty working out
exactly is protecting what.

I am wondering if the flush_work can just be moved outside the
regulator_list_mutex in regulator_unregister since that mutex
doesn't seem to protect the against the work being queued anyway?
I will keep looking into this over the next couple of days,
any pointers or ideas anyone has would be greatly appreciated.
Finally, as it looks like it might take a couple of days to
figure out the locking, I am leaving on holiday on Saturday
so if you don't see a fix from my by then it might be a couple
of weeks before I can look at it again.

Thanks,
Charles

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-03 13:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 13:55 Regulator Potential Deadlock Charles Keepax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).