regulator: core: Make locks re-entrant
Setting voltage, enabling/disabling regulators requires operations on all regulators related with the regulator being changed. Therefore, all of them should be locked for the whole operation. With the current locking implementation, adding additional dependency (regulators coupling) causes deadlocks in some cases. Introduce a possibility to attempt to lock a mutex multiple times by the same task without waiting on a mutex. This should handle all reasonable coupling-supplying combinations, especially when two coupled regulators share common supplies. The only situation that should be forbidden is simultaneous coupling and supplying between a pair of regulators. The idea is based on clk core. Signed-off-by: Maciej Purski <m.purski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:

committed by
Mark Brown

parent
0369e02b75
commit
66cf9a7e01
@@ -434,6 +434,8 @@ struct regulator_dev {
|
||||
|
||||
struct blocking_notifier_head notifier;
|
||||
struct mutex mutex; /* consumer lock */
|
||||
struct task_struct *mutex_owner;
|
||||
int ref_cnt;
|
||||
struct module *owner;
|
||||
struct device dev;
|
||||
struct regulation_constraints *constraints;
|
||||
|
Reference in New Issue
Block a user