]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: replace use of system_wq with system_percpu_wq
authorMarco Crivellari <marco.crivellari@suse.com>
Fri, 5 Sep 2025 09:06:40 +0000 (11:06 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 8 Sep 2025 22:53:12 +0000 (00:53 +0200)
Currently if a user enqueue a work item using schedule_delayed_work() the
used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use
WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to
schedule_work() that is using system_wq and queue_work(), that makes use
again of WORK_CPU_UNBOUND.

This lack of consistentcy cannot be addressed without refactoring the API.

system_unbound_wq should be the default workqueue so as not to enforce
locality constraints for random work whenever it's not required.

Adding system_dfl_wq to encourage its use when unbound work should be used.

queue_work() / queue_delayed_work() / mod_delayed_work() will now use the
new unbound wq: whether the user still use the old wq a warn will be
printed along with a wq redirect to the new one.

The old system_unbound_wq will be kept for a few release cycles.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Link: https://lore.kernel.org/r/20250905090641.106297-2-marco.crivellari@suse.com
[rebased patch to cover recent changes]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/adc-battery-helper.c
drivers/power/supply/bq2415x_charger.c
drivers/power/supply/bq24190_charger.c
drivers/power/supply/bq27xxx_battery.c
drivers/power/supply/rk817_charger.c
drivers/power/supply/ucs1002_power.c

index 229b49fef8ad1cade45b47b0f2e7db29ec82fa5e..6e0f5b6d73d7c11c3d9fa265edda1c9c7a0133a5 100644 (file)
@@ -181,7 +181,7 @@ static void adc_battery_helper_work(struct work_struct *work)
        help->intern_res_avg_mohm /= win_size;
 
 out:
-       queue_delayed_work(system_wq, &help->work,
+       queue_delayed_work(system_percpu_wq, &help->work,
                           (help->poll_count <= INIT_POLL_COUNT) ?
                                        INIT_POLL_TIME : POLL_TIME);
 
@@ -251,7 +251,7 @@ void adc_battery_helper_external_power_changed(struct power_supply *psy)
        struct adc_battery_helper *help = power_supply_get_drvdata(psy);
 
        dev_dbg(help->psy->dev.parent, "external power changed\n");
-       mod_delayed_work(system_wq, &help->work, SETTLE_TIME);
+       mod_delayed_work(system_percpu_wq, &help->work, SETTLE_TIME);
 }
 EXPORT_SYMBOL_GPL(adc_battery_helper_external_power_changed);
 
@@ -260,7 +260,7 @@ static void adc_battery_helper_start_work(struct adc_battery_helper *help)
        help->poll_count = 0;
        help->ocv_avg_index = 0;
 
-       queue_delayed_work(system_wq, &help->work, 0);
+       queue_delayed_work(system_percpu_wq, &help->work, 0);
        flush_delayed_work(&help->work);
 }
 
index 843957548fb9bc5c7889ead1d49b420249228447..b50a28b9dd38671c3d460d92ffa3bf90bc88e1f4 100644 (file)
@@ -842,7 +842,7 @@ static int bq2415x_notifier_call(struct notifier_block *nb,
        if (bq->automode < 1)
                return NOTIFY_OK;
 
-       mod_delayed_work(system_wq, &bq->work, 0);
+       mod_delayed_work(system_percpu_wq, &bq->work, 0);
 
        return NOTIFY_OK;
 }
index e1510c7fdab3bb4312cc8df7f8eed6cd1cc2cef1..ed0ceae8d90b148992e087415fd53b5c256d6b57 100644 (file)
@@ -1467,7 +1467,7 @@ static void bq24190_charger_external_power_changed(struct power_supply *psy)
         * too low default 500mA iinlim. Delay setting the input-current-limit
         * for 300ms to avoid this.
         */
-       queue_delayed_work(system_wq, &bdi->input_current_limit_work,
+       queue_delayed_work(system_percpu_wq, &bdi->input_current_limit_work,
                           msecs_to_jiffies(300));
 }
 
index 9f243005fab6ec87246f6685d707d8ddae2dde5b..3df95e0d4fa2261476705d7c1719673ab2ff1932 100644 (file)
@@ -1127,7 +1127,7 @@ static int poll_interval_param_set(const char *val, const struct kernel_param *k
 
        mutex_lock(&bq27xxx_list_lock);
        list_for_each_entry(di, &bq27xxx_battery_devices, list)
-               mod_delayed_work(system_wq, &di->work, 0);
+               mod_delayed_work(system_percpu_wq, &di->work, 0);
        mutex_unlock(&bq27xxx_list_lock);
 
        return ret;
@@ -1945,7 +1945,7 @@ static void bq27xxx_battery_update_unlocked(struct bq27xxx_device_info *di)
        di->last_update = jiffies;
 
        if (!di->removed && poll_interval > 0)
-               mod_delayed_work(system_wq, &di->work, poll_interval * HZ);
+               mod_delayed_work(system_percpu_wq, &di->work, poll_interval * HZ);
 }
 
 void bq27xxx_battery_update(struct bq27xxx_device_info *di)
@@ -2221,7 +2221,7 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)
        struct bq27xxx_device_info *di = power_supply_get_drvdata(psy);
 
        /* After charger plug in/out wait 0.5s for things to stabilize */
-       mod_delayed_work(system_wq, &di->work, HZ / 2);
+       mod_delayed_work(system_percpu_wq, &di->work, HZ / 2);
 }
 
 int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
index 1251022eb052c1fdc76c45102b5517710e3692df..9436c6bbf51fb40ba417cf4acb2cc72935a1b7d9 100644 (file)
@@ -1046,7 +1046,7 @@ static void rk817_charging_monitor(struct work_struct *work)
        rk817_read_props(charger);
 
        /* Run every 8 seconds like the BSP driver did. */
-       queue_delayed_work(system_wq, &charger->work, msecs_to_jiffies(8000));
+       queue_delayed_work(system_percpu_wq, &charger->work, msecs_to_jiffies(8000));
 }
 
 static void rk817_cleanup_node(void *data)
@@ -1206,7 +1206,7 @@ static int rk817_charger_probe(struct platform_device *pdev)
                return ret;
 
        /* Force the first update immediately. */
-       mod_delayed_work(system_wq, &charger->work, 0);
+       mod_delayed_work(system_percpu_wq, &charger->work, 0);
 
        return 0;
 }
@@ -1226,7 +1226,7 @@ static int __maybe_unused rk817_resume(struct device *dev)
        struct rk817_charger *charger = dev_get_drvdata(dev);
 
        /* force an immediate update */
-       mod_delayed_work(system_wq, &charger->work, 0);
+       mod_delayed_work(system_percpu_wq, &charger->work, 0);
 
        return 0;
 }
index d32a7633f9e7d725cecf6659ed5b49c4fe2accd5..fe94435340de6585e1557ece3825563f0281b349 100644 (file)
@@ -493,7 +493,7 @@ static irqreturn_t ucs1002_alert_irq(int irq, void *data)
 {
        struct ucs1002_info *info = data;
 
-       mod_delayed_work(system_wq, &info->health_poll, 0);
+       mod_delayed_work(system_percpu_wq, &info->health_poll, 0);
 
        return IRQ_HANDLED;
 }