* [PATCH 0/2] regulator: freeze delayed hardware access during suspend @ 2026-10-16 10:05 Jiale Yao 2026-10-16 10:05 ` [PATCH 1/2] regulator: core: freeze deferred disable work " Jiale Yao 2026-10-16 10:05 ` [PATCH 2/2] regulator: irq: freeze deferred hardware access " Jiale Yao 0 siblings, 2 replies; 5+ messages in thread From: Jiale Yao @ 2026-10-16 10:05 UTC (permalink / raw) To: Liam Girdwood, Mark Brown, Matti Vaittinen, linux-kernel; +Cc: Jiale Yao Deferred regulator disable and IRQ recovery callbacks can perform hardware access after a caller-provided delay. Their current workqueues remain active while devices are being suspended, allowing the callbacks to reach a regulator after its backing bus has been suspended. Move deferred disable to the freezable power-efficient workqueue. Move IRQ helper callbacks to a freezable workqueue as well, while retaining the high-priority property for users that request it. Each patch is independent and can be applied separately. Jiale Yao (2): regulator: core: freeze deferred disable work during suspend regulator: irq: freeze deferred hardware access during suspend drivers/regulator/core.c | 3 ++- drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 17 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] regulator: core: freeze deferred disable work during suspend 2026-10-16 10:05 [PATCH 0/2] regulator: freeze delayed hardware access during suspend Jiale Yao @ 2026-10-16 10:05 ` Jiale Yao 2026-10-17 7:21 ` jiale yao 2026-10-16 10:05 ` [PATCH 2/2] regulator: irq: freeze deferred hardware access " Jiale Yao 1 sibling, 1 reply; 5+ messages in thread From: Jiale Yao @ 2026-10-16 10:05 UTC (permalink / raw) To: Liam Girdwood, Mark Brown, linux-kernel; +Cc: Jiale Yao regulator_disable_deferred() schedules hardware access after a caller-provided delay. The power-efficient system workqueue remains active during system suspend, so deferred regulator operations can reach a bus after its controller has been suspended. Use the freezable power-efficient workqueue to preserve the existing power policy while deferring regulator access until devices have resumed. Signed-off-by: Jiale Yao <yaojiale02@163.com> --- drivers/regulator/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6a4008f387b5..317f02696e47 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3465,7 +3465,8 @@ int regulator_disable_deferred(struct regulator *regulator, int ms) regulator_lock(rdev); regulator->deferred_disables++; - mod_delayed_work(system_power_efficient_wq, &rdev->disable_work, + mod_delayed_work(system_freezable_power_efficient_wq, + &rdev->disable_work, msecs_to_jiffies(ms)); regulator_unlock(rdev); -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:[PATCH 1/2] regulator: core: freeze deferred disable work during suspend 2026-10-16 10:05 ` [PATCH 1/2] regulator: core: freeze deferred disable work " Jiale Yao @ 2026-10-17 7:21 ` jiale yao 0 siblings, 0 replies; 5+ messages in thread From: jiale yao @ 2026-10-17 7:21 UTC (permalink / raw) To: Liam Girdwood, Mark Brown, linux-kernel At 2026-10-16 18:05:21, "Jiale Yao" <yaojiale02@163.com> wrote: >regulator_disable_deferred() schedules hardware access after a >caller-provided delay. The power-efficient system workqueue remains >active during system suspend, so deferred regulator operations can reach >a bus after its controller has been suspended. > >Use the freezable power-efficient workqueue to preserve the existing >power policy while deferring regulator access until devices have resumed. > Fixes: da07ecd93b19 ("regulator: Implement deferred disable support") >Signed-off-by: Jiale Yao <yaojiale02@163.com> >--- > drivers/regulator/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c >index 6a4008f387b5..317f02696e47 100644 >--- a/drivers/regulator/core.c >+++ b/drivers/regulator/core.c >@@ -3465,7 +3465,8 @@ int regulator_disable_deferred(struct regulator *regulator, int ms) > > regulator_lock(rdev); > regulator->deferred_disables++; >- mod_delayed_work(system_power_efficient_wq, &rdev->disable_work, >+ mod_delayed_work(system_freezable_power_efficient_wq, >+ &rdev->disable_work, > msecs_to_jiffies(ms)); > regulator_unlock(rdev); > >-- >2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] regulator: irq: freeze deferred hardware access during suspend 2026-10-16 10:05 [PATCH 0/2] regulator: freeze delayed hardware access during suspend Jiale Yao 2026-10-16 10:05 ` [PATCH 1/2] regulator: core: freeze deferred disable work " Jiale Yao @ 2026-10-16 10:05 ` Jiale Yao 2026-10-17 7:23 ` jiale yao 1 sibling, 1 reply; 5+ messages in thread From: Jiale Yao @ 2026-10-16 10:05 UTC (permalink / raw) To: Matti Vaittinen, Liam Girdwood, Mark Brown, linux-kernel; +Cc: Jiale Yao The regulator IRQ helper delays status checks and recovery callbacks on non-freezable workqueues. Those callbacks may access regulator hardware after the backing bus has been suspended. Use system_freezable_wq for normal-priority callbacks. Allocate a freezable high-priority workqueue when requested so the high_prio contract is preserved while hardware access is frozen across suspend. Signed-off-by: Jiale Yao <yaojiale02@163.com> --- drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/regulator/irq_helpers.c b/drivers/regulator/irq_helpers.c index 5b3cfac28667..cdbd170d2b15 100644 --- a/drivers/regulator/irq_helpers.c +++ b/drivers/regulator/irq_helpers.c @@ -15,6 +15,7 @@ #include <linux/regmap.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/workqueue.h> #include <linux/regulator/driver.h> #include "internal.h" @@ -27,6 +28,7 @@ struct regulator_irq { int irq; int retry_cnt; struct delayed_work isr_work; + struct workqueue_struct *wq; }; /* @@ -145,12 +147,7 @@ static void regulator_notifier_isr_work(struct work_struct *work) return; reschedule: - if (!d->high_prio) - mod_delayed_work(system_dfl_wq, &h->isr_work, - msecs_to_jiffies(tmo)); - else - mod_delayed_work(system_highpri_wq, &h->isr_work, - msecs_to_jiffies(tmo)); + mod_delayed_work(h->wq, &h->isr_work, msecs_to_jiffies(tmo)); } static irqreturn_t regulator_notifier_isr(int irq, void *data) @@ -248,13 +245,8 @@ static irqreturn_t regulator_notifier_isr(int irq, void *data) } if (d->irq_off_ms) { - if (!d->high_prio) - schedule_delayed_work(&h->isr_work, - msecs_to_jiffies(d->irq_off_ms)); - else - mod_delayed_work(system_highpri_wq, - &h->isr_work, - msecs_to_jiffies(d->irq_off_ms)); + mod_delayed_work(h->wq, &h->isr_work, + msecs_to_jiffies(d->irq_off_ms)); } return IRQ_HANDLED; @@ -363,13 +355,25 @@ void *regulator_irq_helper(struct device *dev, init_rdev_errors(h); - if (h->desc.irq_off_ms) + if (h->desc.irq_off_ms) { + if (h->desc.high_prio) { + h->wq = alloc_workqueue("regulator_irq_highpri", + WQ_FREEZABLE | WQ_HIGHPRI, 0); + if (!h->wq) + return ERR_PTR(-ENOMEM); + } else { + h->wq = system_freezable_wq; + } + INIT_DELAYED_WORK(&h->isr_work, regulator_notifier_isr_work); + } ret = request_threaded_irq(h->irq, NULL, regulator_notifier_isr, IRQF_ONESHOT | irq_flags, h->desc.name, h); if (ret) { dev_err(dev, "Failed to request IRQ %d\n", irq); + if (h->desc.irq_off_ms && h->desc.high_prio) + destroy_workqueue(h->wq); return ERR_PTR(ret); } @@ -393,8 +397,11 @@ void regulator_irq_helper_cancel(void **handle) struct regulator_irq *h = *handle; free_irq(h->irq, h); - if (h->desc.irq_off_ms) + if (h->desc.irq_off_ms) { cancel_delayed_work_sync(&h->isr_work); + if (h->desc.high_prio) + destroy_workqueue(h->wq); + } h = NULL; } @@ -441,4 +448,3 @@ int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid, return 0; } EXPORT_SYMBOL_GPL(regulator_irq_map_event_simple); - -- 2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:[PATCH 2/2] regulator: irq: freeze deferred hardware access during suspend 2026-10-16 10:05 ` [PATCH 2/2] regulator: irq: freeze deferred hardware access " Jiale Yao @ 2026-10-17 7:23 ` jiale yao 0 siblings, 0 replies; 5+ messages in thread From: jiale yao @ 2026-10-17 7:23 UTC (permalink / raw) To: Matti Vaittinen, Liam Girdwood, Mark Brown, linux-kernel At 2026-10-16 18:05:22, "Jiale Yao" <yaojiale02@163.com> wrote: >The regulator IRQ helper delays status checks and recovery callbacks on >non-freezable workqueues. Those callbacks may access regulator hardware >after the backing bus has been suspended. > >Use system_freezable_wq for normal-priority callbacks. Allocate a >freezable high-priority workqueue when requested so the high_prio >contract is preserved while hardware access is frozen across suspend. > Fixes: 7111c6d1b31b ("regulator: IRQ based event/error notification helpers") >Signed-off-by: Jiale Yao <yaojiale02@163.com> >--- > drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- > 1 file changed, 22 insertions(+), 16 deletions(-) > >diff --git a/drivers/regulator/irq_helpers.c b/drivers/regulator/irq_helpers.c >index 5b3cfac28667..cdbd170d2b15 100644 >--- a/drivers/regulator/irq_helpers.c >+++ b/drivers/regulator/irq_helpers.c >@@ -15,6 +15,7 @@ > #include <linux/regmap.h> > #include <linux/slab.h> > #include <linux/spinlock.h> >+#include <linux/workqueue.h> > #include <linux/regulator/driver.h> > > #include "internal.h" >@@ -27,6 +28,7 @@ struct regulator_irq { > int irq; > int retry_cnt; > struct delayed_work isr_work; >+ struct workqueue_struct *wq; > }; > > /* >@@ -145,12 +147,7 @@ static void regulator_notifier_isr_work(struct work_struct *work) > return; > > reschedule: >- if (!d->high_prio) >- mod_delayed_work(system_dfl_wq, &h->isr_work, >- msecs_to_jiffies(tmo)); >- else >- mod_delayed_work(system_highpri_wq, &h->isr_work, >- msecs_to_jiffies(tmo)); >+ mod_delayed_work(h->wq, &h->isr_work, msecs_to_jiffies(tmo)); > } > > static irqreturn_t regulator_notifier_isr(int irq, void *data) >@@ -248,13 +245,8 @@ static irqreturn_t regulator_notifier_isr(int irq, void *data) > } > > if (d->irq_off_ms) { >- if (!d->high_prio) >- schedule_delayed_work(&h->isr_work, >- msecs_to_jiffies(d->irq_off_ms)); >- else >- mod_delayed_work(system_highpri_wq, >- &h->isr_work, >- msecs_to_jiffies(d->irq_off_ms)); >+ mod_delayed_work(h->wq, &h->isr_work, >+ msecs_to_jiffies(d->irq_off_ms)); > } > > return IRQ_HANDLED; >@@ -363,13 +355,25 @@ void *regulator_irq_helper(struct device *dev, > > init_rdev_errors(h); > >- if (h->desc.irq_off_ms) >+ if (h->desc.irq_off_ms) { >+ if (h->desc.high_prio) { >+ h->wq = alloc_workqueue("regulator_irq_highpri", >+ WQ_FREEZABLE | WQ_HIGHPRI, 0); >+ if (!h->wq) >+ return ERR_PTR(-ENOMEM); >+ } else { >+ h->wq = system_freezable_wq; >+ } >+ > INIT_DELAYED_WORK(&h->isr_work, regulator_notifier_isr_work); >+ } > > ret = request_threaded_irq(h->irq, NULL, regulator_notifier_isr, > IRQF_ONESHOT | irq_flags, h->desc.name, h); > if (ret) { > dev_err(dev, "Failed to request IRQ %d\n", irq); >+ if (h->desc.irq_off_ms && h->desc.high_prio) >+ destroy_workqueue(h->wq); > > return ERR_PTR(ret); > } >@@ -393,8 +397,11 @@ void regulator_irq_helper_cancel(void **handle) > struct regulator_irq *h = *handle; > > free_irq(h->irq, h); >- if (h->desc.irq_off_ms) >+ if (h->desc.irq_off_ms) { > cancel_delayed_work_sync(&h->isr_work); >+ if (h->desc.high_prio) >+ destroy_workqueue(h->wq); >+ } > > h = NULL; > } >@@ -441,4 +448,3 @@ int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid, > return 0; > } > EXPORT_SYMBOL_GPL(regulator_irq_map_event_simple); >- >-- >2.34.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-17 7:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-10-16 10:05 [PATCH 0/2] regulator: freeze delayed hardware access during suspend Jiale Yao 2026-10-16 10:05 ` [PATCH 1/2] regulator: core: freeze deferred disable work " Jiale Yao 2026-10-17 7:21 ` jiale yao 2026-10-16 10:05 ` [PATCH 2/2] regulator: irq: freeze deferred hardware access " Jiale Yao 2026-10-17 7:23 ` jiale yao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®