Fix backtrace warnings from bad notifier chain calls
Subsystems (3)
cover Fix backtrace warnings from bad notifier chain calls
Hi Mark,
This patch-set fixes a WARN_ON_ONCE() backtrace call caused by not locking the mutex from the function call regulator_notifier_call_chain(). It does this for thirteen regulator drivers by adding a mutex lock surrounding the notifier calls.
This missing mutex lock has been around for a while, but the API I have used used here to fix it (i.e. regulator_lock()/regulator_unlock()) has only been in the kernel since v4.18. Therefore as this fix stands, the patches do not port back very far in kernel history.
Regards,
Steve
Steve Twiss (13):
regulator: da9055: Fix notifier mutex lock warning
regulator: da9062: Fix notifier mutex lock warning
regulator: da9063: Fix notifier mutex lock warning
regulator: da9211: Fix notifier mutex lock warning
regulator: lp8755: Fix notifier mutex lock warning
regulator: ltc3589: Fix notifier mutex lock warning
regulator: ltc3676: Fix notifier mutex lock warning
regulator: pv88060: Fix notifier mutex lock warning
regulator: pv88080: Fix notifier mutex lock warning
regulator: pv88090: Fix notifier mutex lock warning
regulator: wm831x: Fix notifier mutex lock warning
regulator: wm831x isink: Fix notifier mutex lock warning
regulator: wm831x ldo: Fix notifier mutex lock warning
drivers/regulator/da9055-regulator.c | 2 ++ drivers/regulator/da9062-regulator.c | 2 ++ drivers/regulator/da9063-regulator.c | 5 ++++- drivers/regulator/da9211-regulator.c | 4 ++++ drivers/regulator/lp8755.c | 15 ++++++++++++--- drivers/regulator/ltc3589.c | 10 ++++++++-- drivers/regulator/ltc3676.c | 10 ++++++++-- drivers/regulator/pv88060-regulator.c | 4 ++++ drivers/regulator/pv88080-regulator.c | 4 ++++ drivers/regulator/pv88090-regulator.c | 4 ++++ drivers/regulator/wm831x-dcdc.c | 4 ++++ drivers/regulator/wm831x-isink.c | 2 ++ drivers/regulator/wm831x-ldo.c | 2 ++ 13 files changed, 60 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/13 regulator: da9055: Fix notifier mutex lock warning
The mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/da9055-regulator.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/da9055-regulator.c +2 -0
@@ -515,8 +515,10 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data) {struct da9055_regulator *regulator = data; +regulator_lock (regulator->rdev);regulator_notifier_call_chain (regulator->rdev,REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (regulator->rdev);return IRQ_HANDLED ; }
Signature · 1 line
1.9.3
PATCH 2/13 regulator: da9062: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/da9062-regulator.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/da9062-regulator.c +2 -0
@@ -974,8 +974,10 @@ static irqreturn_t da9062_ldo_lim_event(int irq, void *data)continue ;if (BIT (regl->info->oc_event.lsb) & bits) { +regulator_lock (regl->rdev);regulator_notifier_call_chain (regl->rdev,REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (regl->rdev); handled =IRQ_HANDLED ; } }
Signature · 1 line
1.9.3
PATCH 3/13 regulator: da9063: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/da9063-regulator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/da9063-regulator.c +4 -1
@@ -615,9 +615,12 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data)if (regl->info->oc_event.reg !=DA9063_REG_STATUS_D )continue ; -if (BIT (regl->info->oc_event.lsb) & bits) +if (BIT (regl->info->oc_event.lsb) & bits) { +regulator_lock (regl->rdev);regulator_notifier_call_chain (regl->rdev,REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (regl->rdev); + } }return IRQ_HANDLED ;
Signature · 1 line
1.9.3
PATCH 4/13 regulator: da9211: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/da9211-regulator.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/da9211-regulator.c +4 -0
@@ -322,8 +322,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) goto error_i2c;if (reg_val &DA9211_E_OV_CURR_A ) { +regulator_lock (chip->rdev[0 ]);regulator_notifier_call_chain (chip->rdev[0 ],REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (chip->rdev[0 ]); err =regmap_write (chip->regmap,DA9211_REG_EVENT_B ,DA9211_E_OV_CURR_A );
@@ -334,8 +336,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) }if (reg_val &DA9211_E_OV_CURR_B ) { +regulator_lock (chip->rdev[1 ]);regulator_notifier_call_chain (chip->rdev[1 ],REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (chip->rdev[1 ]); err =regmap_write (chip->regmap,DA9211_REG_EVENT_B ,DA9211_E_OV_CURR_B );
Signature · 1 line
1.9.3
PATCH 5/13 regulator: lp8755: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/lp8755.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/regulator/lp8755.c +12 -3
@@ -372,10 +372,13 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)for (icnt =0 ; icnt <LP8755_BUCK_MAX ; icnt++)if ((flag0 & (0x4 << icnt)) && (pchip->irqmask & (0x04 << icnt)) - && (pchip->rdev[icnt] !=NULL )) + && (pchip->rdev[icnt] !=NULL )) { +regulator_lock (pchip->rdev[icnt]);regulator_notifier_call_chain (pchip->rdev[icnt],LP8755_EVENT_PWR_FAULT ,NULL ); +regulator_unlock (pchip->rdev[icnt]); + }/* read flag1 register */ ret =lp8755_read (pchip,0x0E , &flag1);
@@ -389,18 +392,24 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)/* send OCP event to all regualtor devices */ if ((flag1 &0x01 ) && (pchip->irqmask &0x01 ))for (icnt =0 ; icnt <LP8755_BUCK_MAX ; icnt++) -if (pchip->rdev[icnt] !=NULL ) +if (pchip->rdev[icnt] !=NULL ) { +regulator_lock (pchip->rdev[icnt]);regulator_notifier_call_chain (pchip->rdev[icnt],LP8755_EVENT_OCP ,NULL ); +regulator_unlock (pchip->rdev[icnt]); + }/* send OVP event to all regualtor devices */ if ((flag1 &0x02 ) && (pchip->irqmask &0x02 ))for (icnt =0 ; icnt <LP8755_BUCK_MAX ; icnt++) -if (pchip->rdev[icnt] !=NULL ) +if (pchip->rdev[icnt] !=NULL ) { +regulator_lock (pchip->rdev[icnt]);regulator_notifier_call_chain (pchip->rdev[icnt],LP8755_EVENT_OVP ,NULL ); +regulator_unlock (pchip->rdev[icnt]); + }return IRQ_HANDLED ; err_i2c:
Signature · 1 line
1.9.3
PATCH 6/13 regulator: ltc3589: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/ltc3589.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/regulator/ltc3589.c +8 -2
@@ -419,16 +419,22 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id)if (irqstat <C3589_IRQSTAT_THERMAL_WARN ) { event =REGULATOR_EVENT_OVER_TEMP ; -for (i =0 ; i <LTC3589_NUM_REGULATORS ; i++) +for (i =0 ; i <LTC3589_NUM_REGULATORS ; i++) { +regulator_lock (ltc3589->regulators[i]);regulator_notifier_call_chain (ltc3589->regulators[i], event,NULL ); +regulator_unlock (ltc3589->regulators[i]); + } }if (irqstat <C3589_IRQSTAT_UNDERVOLT_WARN ) { event =REGULATOR_EVENT_UNDER_VOLTAGE ; -for (i =0 ; i <LTC3589_NUM_REGULATORS ; i++) +for (i =0 ; i <LTC3589_NUM_REGULATORS ; i++) { +regulator_lock (ltc3589->regulators[i]);regulator_notifier_call_chain (ltc3589->regulators[i], event,NULL ); +regulator_unlock (ltc3589->regulators[i]); + } }/* Clear warning condition */
Signature · 1 line
1.9.3
PATCH 7/13 regulator: ltc3676: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/ltc3676.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/regulator/ltc3676.c +8 -2
@@ -338,17 +338,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id)if (irqstat <C3676_IRQSTAT_THERMAL_WARN ) {dev_warn (dev,"Over-temperature Warning\n" ); event =REGULATOR_EVENT_OVER_TEMP ; -for (i =0 ; i <LTC3676_NUM_REGULATORS ; i++) +for (i =0 ; i <LTC3676_NUM_REGULATORS ; i++) { +regulator_lock (ltc3676->regulators[i]);regulator_notifier_call_chain (ltc3676->regulators[i], event,NULL ); +regulator_unlock (ltc3676->regulators[i]); + } }if (irqstat <C3676_IRQSTAT_UNDERVOLT_WARN ) {dev_info (dev,"Undervoltage Warning\n" ); event =REGULATOR_EVENT_UNDER_VOLTAGE ; -for (i =0 ; i <LTC3676_NUM_REGULATORS ; i++) +for (i =0 ; i <LTC3676_NUM_REGULATORS ; i++) { +regulator_lock (ltc3676->regulators[i]);regulator_notifier_call_chain (ltc3676->regulators[i], event,NULL ); +regulator_unlock (ltc3676->regulators[i]); + } }/* Clear warning condition */
Signature · 1 line
1.9.3
PATCH 8/13 regulator: pv88060: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/pv88060-regulator.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/pv88060-regulator.c +4 -0
@@ -276,9 +276,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)if (reg_val &PV88060_E_VDD_FLT ) {for (i =0 ; i <PV88060_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_UNDER_VOLTAGE ,NULL ); +regulator_unlock (chip->rdev[i]); } }
@@ -293,9 +295,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data)if (reg_val &PV88060_E_OVER_TEMP ) {for (i =0 ; i <PV88060_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_OVER_TEMP ,NULL ); +regulator_unlock (chip->rdev[i]); } }
Signature · 1 line
1.9.3
PATCH 9/13 regulator: pv88080: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/pv88080-regulator.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/pv88080-regulator.c +4 -0
@@ -384,9 +384,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data)if (reg_val &PV88080_E_VDD_FLT ) {for (i =0 ; i <PV88080_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_UNDER_VOLTAGE ,NULL ); +regulator_unlock (chip->rdev[i]); } }
@@ -401,9 +403,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data)if (reg_val &PV88080_E_OVER_TEMP ) {for (i =0 ; i <PV88080_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_OVER_TEMP ,NULL ); +regulator_unlock (chip->rdev[i]); } }
Signature · 1 line
1.9.3
PATCH 10/13 regulator: pv88090: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/pv88090-regulator.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/pv88090-regulator.c +4 -0
@@ -274,9 +274,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data)if (reg_val &PV88090_E_VDD_FLT ) {for (i =0 ; i <PV88090_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_UNDER_VOLTAGE ,NULL ); +regulator_unlock (chip->rdev[i]); } }
@@ -291,9 +293,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data)if (reg_val &PV88090_E_OVER_TEMP ) {for (i =0 ; i <PV88090_MAX_REGULATORS ; i++) {if (chip->rdev[i] !=NULL ) { +regulator_lock (chip->rdev[i]);regulator_notifier_call_chain (chip->rdev[i],REGULATOR_EVENT_OVER_TEMP ,NULL ); +regulator_unlock (chip->rdev[i]); } }
Signature · 1 line
1.9.3
PATCH 11/13 regulator: wm831x: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/wm831x-dcdc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/wm831x-dcdc.c +4 -0
@@ -183,9 +183,11 @@ static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data) {struct wm831x_dcdc *dcdc = data; +regulator_lock (dcdc->regulator);regulator_notifier_call_chain (dcdc->regulator,REGULATOR_EVENT_UNDER_VOLTAGE ,NULL ); +regulator_unlock (dcdc->regulator);return IRQ_HANDLED ; }
@@ -194,9 +196,11 @@ static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data) {struct wm831x_dcdc *dcdc = data; +regulator_lock (dcdc->regulator);regulator_notifier_call_chain (dcdc->regulator,REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (dcdc->regulator);return IRQ_HANDLED ; }
Signature · 1 line
1.9.3
Re: [PATCH 11/13] regulator: wm831x: Fix notifier mutex lock warning
Quoted 9 lines · Steve Twiss
The mutex for the
regulator_devmust be controlled by the caller of theregulator_notifier_call_chain(), as described in the comment for that function.Failure to mutex lock and unlock surrounding the notifier call results in a kernel
WARN_ON_ONCE()which will dump a backtrace for theregulator_notifier_call_chain()when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
Quoted 4 lines
Fixes e4ee831f949a ("regulator: Add WM831x DC-DC buck convertor support")Suggested-by Adam Thomson <[email protected]>Signed-off-by Steve Twiss <[email protected]>---
Thanks,
Charles
PATCH 12/13 regulator: wm831x isink: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/wm831x-isink.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/wm831x-isink.c +2 -0
@@ -140,9 +140,11 @@ static irqreturn_t wm831x_isink_irq(int irq, void *data) {struct wm831x_isink *isink = data; +regulator_lock (isink->regulator);regulator_notifier_call_chain (isink->regulator,REGULATOR_EVENT_OVER_CURRENT ,NULL ); +regulator_unlock (isink->regulator);return IRQ_HANDLED ; }
Signature · 1 line
1.9.3
Re: [PATCH 12/13] regulator: wm831x isink: Fix notifier mutex lock warning
Quoted 9 lines · Steve Twiss
The mutex for the
regulator_devmust be controlled by the caller of theregulator_notifier_call_chain(), as described in the comment for that function.Failure to mutex lock and unlock surrounding the notifier call results in a kernel
WARN_ON_ONCE()which will dump a backtrace for theregulator_notifier_call_chain()when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
Quoted 4 lines
Fixes d4d6b722e780 ("regulator: Add WM831x ISINK support")Suggested-by Adam Thomson <[email protected]>Signed-off-by Steve Twiss <[email protected]>---
Thanks,
Charles
PATCH 13/13 regulator: wm831x ldo: Fix notifier mutex lock warning
In reply to Steve TwissThe mutex for the regulator_dev must be controlled by the caller of the regulator_notifier_call_chain(), as described in the comment for that function.
Failure to mutex lock and unlock surrounding the notifier call results in a kernel WARN_ON_ONCE() which will dump a backtrace for the regulator_notifier_call_chain() when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
--- drivers/regulator/wm831x-ldo.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/wm831x-ldo.c +2 -0
@@ -51,9 +51,11 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) {struct wm831x_ldo *ldo = data; +regulator_lock (ldo->regulator);regulator_notifier_call_chain (ldo->regulator,REGULATOR_EVENT_UNDER_VOLTAGE ,NULL ); +regulator_unlock (ldo->regulator);return IRQ_HANDLED ; }
Signature · 1 line
1.9.3
Re: [PATCH 13/13] regulator: wm831x ldo: Fix notifier mutex lock warning
Quoted 9 lines · Steve Twiss
The mutex for the
regulator_devmust be controlled by the caller of theregulator_notifier_call_chain(), as described in the comment for that function.Failure to mutex lock and unlock surrounding the notifier call results in a kernel
WARN_ON_ONCE()which will dump a backtrace for theregulator_notifier_call_chain()when that function call is first made. The mutex can be controlled using the regulator_lock/unlock() API.
Quoted 4 lines
Fixes d1c6b4fe668b ("regulator: Add WM831x LDO support")Suggested-by Adam Thomson <[email protected]>Signed-off-by Steve Twiss <[email protected]>---
Thanks,
Charles