android_kernel_oneplus_msm8998/drivers/regulator
Tirupathi Reddy 493d8a74b6 regulator: core: fix a possible race in disable_work handling
A race condition between queueing and processing the disable_work
instances results in having a work instance in the queue and the
deferred_disables variable of regulator device structure having a
value '0'. If no new regulator_disable_deferred() call later from
clients, the deferred_disables variable value remains '0' and hits
BUG() in regulator_disable_work() when the queued instance scheduled
for processing the work.

The race occurs as below:

	Core-0					     Core-1
	.....	       /* deferred_disables = 2 */   .....
	.....	       /* disable_work is queued */  .....
	.....					     .....
regulator_disable_deferred: 		regulator_disable_work:
   mutex_lock(&rdev->mutex);			     .....
   rdev->deferred_disables++;		    mutex_lock(&rdev->mutex);
   mutex_unlock(&rdev->mutex);			     .....
   queue_delayed_work(...)		    count =rdev->deferred_disables;
	.....				    rdev->deferred_disables = 0;
	.....					     .....
	.....				    mutex_unlock(&rdev->mutex);
	.....					     .....
	.....				    return;
	.....					     .....
	/* No new regulator_disable_deferred() calls from clients */
	/* The newly queued instance is scheduled for processing */
	.....					     .....
regulator_disable_work:
	.....
   mutex_lock(&rdev->mutex);
   BUG_ON(!rdev->deferred_disables); /* deferred_disables = 0 */

The race is fixed by removing the work instance that is queued while
processing the previous queued instance. Cancel the newly queued instance
from disable_work() handler just after reset the deferred_disables variable
to value '0'. Also move the work queueing step before mutex_unlock in
regulator_disable_deferred().

Also use mod_delayed_work() in the pace of queue_delayed_work() as
queue_delayed_work() always uses the delay requested in the first call
when multiple consumers call regulator_disable_deferred() close in time
and does not guarantee the semantics of regulator_disable_deferred().

CRs-Fixed: 2064610
Change-Id: Iacaddc5e2f5c9998c4d038bdc10c4587cbf4812e
Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
2017-07-06 20:02:49 -07:00
..
88pm800.c Merge branch 'fix/88pm800' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-88pm800 2015-07-17 12:42:48 +01:00
88pm8607.c regulator: 88pm8607: Constify platform_device_id 2015-05-01 17:44:55 +01:00
aat2870-regulator.c
ab3100.c
ab8500-ext.c
ab8500.c
act8865-regulator.c regulator: act8865: support output voltage by VSET2[] bits 2015-10-02 17:53:24 +01:00
ad5398.c regulator: ad5398: Remove unnecessary MODULE_ALIAS() 2015-08-30 12:21:01 +01:00
anatop-regulator.c regulator: anatop: allow regulator to be in bypass mode 2016-09-15 08:27:54 +02:00
arizona-ldo1.c regulator: arizona-ldo1: Fix handling of GPIO 0 2015-10-16 15:48:39 +01:00
arizona-micsupp.c == Changes to existing drivers == 2015-04-14 17:29:55 -07:00
as3711-regulator.c
as3722-regulator.c
axp20x-regulator.c Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
bcm590xx-regulator.c regulator: bcm590xx: Remove unneeded semicolon 2015-09-14 19:48:34 +01:00
core.c regulator: core: fix a possible race in disable_work handling 2017-07-06 20:02:49 -07:00
cpr-regulator.c msm: thermal: Maintain state in the mitigation device monitor 2016-06-29 15:00:39 -07:00
cpr2-gfx-regulator.c qpnp: Add snapshot of some qpnp, regulator and charger drivers 2016-03-01 12:22:31 -08:00
cpr3-hmss-regulator.c drivers: Warning fixes to disable CC_OPTIMIZE_FOR_SIZE 2017-05-31 16:51:47 -07:00
cpr3-mmss-regulator.c Merge "regulator: cpr3-mmss: Increase fuse combo count" 2017-03-21 21:30:03 -07:00
cpr3-regulator.c drivers: Warning fixes to disable CC_OPTIMIZE_FOR_SIZE 2017-05-31 16:51:47 -07:00
cpr3-regulator.h regulator: cpr3: Use scaled gate count for aging measurements 2017-03-17 14:47:40 +05:30
cpr3-util.c regulator: cpr3: Use default step_quot during corner switch 2017-02-13 09:32:57 +05:30
cpr4-apss-regulator.c regulator: cpr3-regulator: correct various coding style issues 2017-02-03 11:48:09 -08:00
cpr4-mmss-ldo-regulator.c regulator: cpr4-mmss-ldo: Correct the GFX LDO CPR sensor count for sdm630 2017-02-16 11:38:22 +05:30
cprh-kbss-regulator.c drivers: Warning fixes to disable CC_OPTIMIZE_FOR_SIZE 2017-05-31 16:51:47 -07:00
da903x.c
da9052-regulator.c regulator: da9053: Update regulator for DA9053 BC silicon support 2015-10-16 15:36:01 +01:00
da9055-regulator.c
da9062-regulator.c regulator: da9062: Drop owner assignment from platform_driver 2015-07-14 18:48:19 +01:00
da9063-regulator.c regulator: da9063: Remove unneeded semicolon 2015-09-14 19:48:48 +01:00
da9210-regulator.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
da9210-regulator.h
da9211-regulator.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
da9211-regulator.h regulator: da9211: support da9215 2015-07-13 19:11:24 +01:00
db8500-prcmu.c
dbx500-prcmu.c regulator: dbx500: Remove use of seq_puts/seq_printf return value 2015-02-24 17:16:14 +09:00
dbx500-prcmu.h
devres.c regulator: core: Add devres versions of notifier registration 2015-03-05 16:42:14 +00:00
dummy.c
dummy.h
fan53555.c regulator: fan53555: add support to disable suspend voltage configuration 2016-03-23 21:23:08 -07:00
fixed-helper.c
fixed.c
gpio-regulator.c regulator: gpio: Fix module autoload for OF platform driver 2015-09-19 07:54:20 -07:00
helpers.c regulator: Fix the function name in documentation 2015-04-19 13:23:07 +01:00
hi6421-regulator.c
internal.h regulator: debugfs: Adding debugfs functions into regulator framework 2016-03-01 12:22:35 -08:00
isl6271a-regulator.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
isl9305.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
Kconfig regulator: max20010: Add max20010 regulator driver 2017-06-16 15:18:48 +05:30
kryo-regulator.c regulator: kryo-regulator: correct various coding style issues 2017-02-03 11:50:14 -08:00
lp872x.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
lp3971.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
lp3972.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
lp8755.c regulator: lp8755: Convert to devm_request_threaded_irq 2015-06-02 15:35:17 +01:00
lp8788-buck.c
lp8788-ldo.c
ltc3589.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
Makefile regulator: max20010: Add max20010 regulator driver 2017-06-16 15:18:48 +05:30
max1586.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
max8649.c
max8660.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
max8907-regulator.c
max8925-regulator.c
max8952.c
max8973-regulator.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
max8997.c
max8998.c
max14577.c regulator: max14577: Reduce duplication of regulator_desc initializers 2015-04-27 18:57:57 +01:00
max20010-regulator.c regulator: max20010: Add max20010 regulator driver 2017-06-16 15:18:48 +05:30
max77686.c regulator: max77686: fix gpio_enabled shift wrapping bug 2015-05-20 19:09:51 +01:00
max77693.c regulators: max77693: register driver earlier to avoid deferred probe 2015-08-21 09:07:45 -07:00
max77802.c drivers/regulator: include <module.h> for modular max77802 code 2015-06-16 14:12:26 -04:00
mc13xxx-regulator-core.c
mc13xxx.h
mc13783-regulator.c
mc13892-regulator.c
mem-acc-regulator.c regulator: mem-acc-regulator: correct various coding style issues 2017-02-03 11:57:47 -08:00
msm_gfx_ldo.c Merge "regulator: gfx-ldo: Add GFX LDO support for sdm630" 2017-02-09 03:11:13 -08:00
mt6311-regulator.c regulator: mt6311: fix platform_no_drv_owner.cocci warnings 2015-08-30 14:34:50 +01:00
mt6311-regulator.h regulator: mt6311: Add support for mt6311 regulator 2015-07-24 12:30:49 +01:00
mt6397-regulator.c
of_regulator.c regulator: Introduce property to flag set-load support 2015-09-17 12:14:12 +01:00
onsemi-ncp6335d.c regulator: onsemi-ncp6335d: Add is_enabled API support 2017-05-04 14:33:41 +05:30
palmas-regulator.c regulator: palmas: Add has_regen3 check for TPS659038 2015-03-17 12:21:15 +00:00
pbias-regulator.c Merge remote-tracking branches 'regulator/fix/anatop', 'regulator/fix/gpio', 'regulator/fix/pbias', 'regulator/fix/tpx65218' and 'regulator/fix/vexpress' into regulator-linus 2015-09-21 14:16:09 -07:00
pcap-regulator.c
pcf50633-regulator.c
pfuze100-regulator.c Merge remote-tracking branches 'regulator/topic/mt6311', 'regulator/topic/ocp', 'regulator/topic/owner', 'regulator/topic/pfuze100' and 'regulator/topic/pwm' into regulator-next 2015-08-30 14:39:48 +01:00
proxy-consumer.c regulator: proxy-consumer: replace set_optimum_mode with set_load 2016-03-01 12:22:42 -08:00
pwm-regulator.c regulator: pwm: implement ->enable(), ->disable() and ->is_enabled methods 2015-09-21 14:11:18 -07:00
qcom_rpm-regulator.c regulator: qcom: Tidy up probe() 2015-04-08 12:22:55 +01:00
qcom_smd-regulator.c regulator: qcom_smd: Fix voltage ranges for pm8x41 2016-10-07 15:23:43 +02:00
qcom_spmi-regulator.c regulator: qcom_spmi: Update mvs1/mvs2 switches on pm8941 2016-10-07 15:23:43 +02:00
qpnp-labibb-regulator.c regulator: qpnp-labibb-regulator: Restart LAB/IBB after SC fault 2017-05-23 15:15:50 +05:30
qpnp-lcdb-regulator.c regulator: qpnp-lcdb: Add a WA to toggle SC before module_enable 2017-04-01 06:47:53 +05:30
qpnp-oledb-regulator.c Merge "ARM: dts: msm: Add PBS trigger support for OLEDB for PM660A" 2017-04-20 04:40:55 -07:00
qpnp-regulator.c regulator: qpnp: check min/max voltages against HW configuration 2017-05-29 09:52:46 +05:30
rc5t583-regulator.c
rk808-regulator.c regulator: rk808: make better use of the gpiod API 2015-07-21 17:11:30 +01:00
rn5t618-regulator.c
rpm-smd-regulator.c regulator: rpm-smd-regulator: add support for load based mode control 2017-06-05 11:38:34 +05:30
rt5033-regulator.c
s2mpa01.c
s2mps11.c Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
s5m8767.c Revert "Merge remote-tracking branch 'msm-4.4/tmp-510d0a3f' into msm-4.4" 2016-08-26 14:34:05 -07:00
sky81452-regulator.c
spm-regulator.c regulator: spm: check min/max voltages against HW configuration 2017-06-05 13:54:32 +05:30
stub-regulator.c regulator: msm: Add snapshot of the stub regulator driver 2016-03-23 20:09:42 -07:00
stw481x-vmmc.c regulator: stw481x-vmmc: fix ages old enable error 2017-01-09 08:07:43 +01:00
ti-abb-regulator.c
tps6105x-regulator.c mfd: tps6105x: Use i2c regmap to access registers 2015-10-05 10:38:22 +01:00
tps6507x-regulator.c
tps6524x-regulator.c spi: Drop owner assignment from spi_drivers 2015-10-28 10:30:17 +09:00
tps6586x-regulator.c regulator: tps6586x: silence pointer-to-int-cast 2015-07-23 15:58:33 +01:00
tps51632-regulator.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
tps62360-regulator.c regulator: drivers: Drop owner assignment from i2c_driver 2015-07-14 18:53:01 +01:00
tps65023-regulator.c regulator: tps65023: Fix inverted core enable logic. 2017-05-25 14:30:09 +02:00
tps65090-regulator.c
tps65217-regulator.c
tps65218-regulator.c regulator: tps65218: Fix missing zero typo 2015-09-16 20:59:09 +01:00
tps65910-regulator.c regulator: tps65910: Work around silicon erratum SWCZ010 2016-10-28 03:01:25 -04:00
tps65912-regulator.c
tps80031-regulator.c
twl-regulator.c
userspace-consumer.c
vexpress.c regulator: vexpress: Fix module autoload for OF platform driver 2015-09-19 07:55:12 -07:00
virtual.c
wm831x-dcdc.c regulator: wm831x: Pass the IRQF_ONESHOT flag 2015-06-02 11:53:59 +01:00
wm831x-isink.c regulator: wm831x: Pass the IRQF_ONESHOT flag 2015-06-02 11:53:59 +01:00
wm831x-ldo.c regulator: wm831x: Pass the IRQF_ONESHOT flag 2015-06-02 11:53:59 +01:00
wm8350-regulator.c regulator: wm8350: Remove unused variable 2015-03-05 17:56:12 +00:00
wm8400-regulator.c
wm8994-regulator.c