[PATCH 6/6] backlight: qcom-wled: Avoid AB-BA deadlock in wled_module_enable()
From: Lee Jones
Date: Wed Nov 04 2026 - 14:12:50 EST
When disabling the WLED module (for example from wled_update_status() or
wled_short_irq_handler()), the caller holds wled->lock and invokes
wled_module_enable(wled, false), which calls disable_irq(wled->ovp_irq)
and blocks waiting for any executing OVP threaded interrupt handler to
complete.
If wled_ovp_irq_handler() is concurrently executing, it attempts to
acquire wled->lock before running wled_auto_string_detection(),
resulting in an AB-BA deadlock between wled->lock and IRQ completion.
Use disable_irq_nosync() instead of disable_irq() in
wled_module_enable() so that the OVP interrupt is masked without
synchronously waiting for the threaded handler while holding wled->lock.
Because wled_ovp_irq_handler() may already be waiting on wled->lock when
the module is disabled, verify under wled->lock that the module is still
enabled and not disabled by a short before running
wled_auto_string_detection().
Fixes: 8663c188beea ("backlight: qcom-wled: Add auto string detection logic")
Closes: https://sashiko.dev/#/bug/linux-3afa151c-7b8f-432c-8f85-8c43a83b964a
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
Cc: David Heidelberg <david@xxxxxxx>
Cc: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
drivers/video/backlight/qcom-wled.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index 06300d403f8f..6c0f631cc975 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -367,7 +367,7 @@ static int wled_module_enable(struct wled *wled, int val)
schedule_delayed_work(&wled->ovp_work, HZ / 100);
} else {
if (!cancel_delayed_work_sync(&wled->ovp_work))
- disable_irq(wled->ovp_irq);
+ disable_irq_nosync(wled->ovp_irq);
}
}
@@ -919,8 +919,15 @@ static irqreturn_t wled_ovp_irq_handler(int irq, void *_wled)
if (fault_sts & WLED3_CTRL_REG_OVP_FAULT_BIT) {
if (wled->wled_auto_detection_required &&
wled->wled_auto_detection_required(wled)) {
+ u32 val;
+
mutex_lock(&wled->lock);
- wled_auto_string_detection(wled);
+ if (!wled->disabled_by_short) {
+ rc = regmap_read(wled->regmap, wled->ctrl_addr +
+ WLED3_CTRL_REG_MOD_EN, &val);
+ if (!rc && (val & WLED3_CTRL_REG_MOD_EN_MASK))
+ wled_auto_string_detection(wled);
+ }
mutex_unlock(&wled->lock);
}
}
--
2.56.0.385.gac671c819a-goog