Re: [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded

From: netdev-bot+sashiko

Date: Sat Nov 28 2026 - 04:30:35 EST


Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch moves the early ice_service_task_stop() only in
ice_remove().
- [High] The patch handles the "last run re-arms the service timer after
the stop, and the timer fires after the PF is freed" race only in the…
- [Medium] The early ice_service_task_stop() in ice_remove()
(ice_main.c:5390) does not stop the service work from being queued…

--

ice: stop the service task before the PF is unloaded

This patch moves ice_service_task_stop() and ice_aq_cancel_waiting_tasks()
in ice_remove() back to right after ice_free_vfs(). The service task is then
stopped before the aRFS filters, netdev, LAG and VSIs are freed. The stop
in ice_deinit_dev() is kept so that it deletes a timer re-armed by the last
run.

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 47c6798c97e8f..6dede87b78944 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)
> ice_free_vfs(pf);
> }
>
> + ice_service_task_stop(pf);
> + ice_aq_cancel_waiting_tasks(pf);
> +

[Severity: High]
The same ordering problem seems to remain on the other paths that unload
the PF. ice_devlink_reinit_down() in devlink/devlink.c does:

ice_unload(pf);
rtnl_lock();
ice_vsi_decfg(ice_get_main_vsi(pf));
rtnl_unlock();
ice_deinit_pf(pf);
ice_deinit_hw(&pf->hw);
ice_deinit_dev(pf);

Nothing sets ICE_SERVICE_DIS before ice_deinit_dev(), so the service timer
keeps queueing serv_task during this whole sequence:

- ice_unload()->ice_decfg_netdev() calls free_netdev(vsi->netdev).
- ice_deinit_pf() destroys sw_mutex, tc_mutex and lag_mutex, frees the
avail_txqs/avail_rxqs bitmaps and frees the misc IRQ.
- ice_deinit_hw() destroys the control queues.

Can a run of ice_sync_fltr_subtask()->ice_vsi_sync_fltr() that has already
read vsi->netdev keep using netdev->flags and netif_addr_lock_bh(netdev)
after free_netdev()?

A devlink dev reload with action driver_reinit can trigger this while a
filter sync is pending, for example after a promisc or multicast change
through ice_set_rx_mode().

The probe error unwind in ice_probe() looks similar:

unroll_load:
ice_unload(pf);
unroll_init:
devl_unlock(priv_to_devlink(pf));
ice_deinit(pf);
[ ... ]
unroll_hw_init:
ice_deinit_hw(hw);
if (need_dev_deinit)
ice_deinit_dev(pf);

When this unwind runs, ice_init() has already cleared ICE_SERVICE_DIS and
armed serv_tmr. ice_load() has also queued serv_task through
ice_service_task_restart().

ice_deinit() only sets ICE_SERVICE_DIS, which does not wait for a running
work item, and then ice_dealloc_vsis() frees pf->vsi. After that come
ice_adapter_put() and ice_deinit_hw(), and only then the stop in
ice_deinit_dev().

Commit 8a37f9e2ff40, named in the Fixes: tag, is also the commit that moved
ice_deinit_dev() after ice_deinit_hw() in this unwind. Should
ice_devlink_reinit_down() and the probe unwind also stop the service task
before they tear down the PF? Neither path seems to change later in the
series.

[Severity: Medium]
Does a single ice_service_task_stop() here prevent serv_task from being
queued again before ice_remove_arfs(), ice_unload() and ice_deinit() run?

ice_service_task_schedule() tests ICE_SERVICE_DIS without a lock and only
calls queue_work() afterwards:

if (!test_bit(ICE_SERVICE_DIS, pf->state) &&
!test_and_set_bit(ICE_SERVICE_SCHED, pf->state) &&
!test_bit(ICE_NEEDS_RESTART, pf->state))
queue_work(ice_wq, &pf->serv_task);

Also, ice_service_task() does not check ICE_SERVICE_DIS when it starts.

At this point the netdev is still registered and the misc IRQ is still
live. That means ice_set_rx_mode(), ice_rx_flow_steer(), ice_misc_intr()
and the VF fdir handlers can all still reach ice_service_task_schedule().

One possible interleaving:

CPU0 (ice_set_rx_mode) CPU1 (ice_remove)
set ICE_FLAG_FLTR_SYNC
test_bit(ICE_SERVICE_DIS) == 0
ice_service_task_stop()
test_and_set_bit(ICE_SERVICE_DIS)
timer_delete_sync()
cancel_work_sync() /* idle */
clear_bit(ICE_SERVICE_SCHED)
queue_work(ice_wq, &pf->serv_task)
ice_remove_arfs()
ice_unload() /* free_netdev() */
ice_deinit() /* ice_dealloc_vsis() */

The worker would then run ice_sync_fltr_subtask(), ice_sync_arfs_fltrs()
and the other subtasks against the state being freed. The second stop in
ice_deinit_dev() only runs after the VSIs are already gone.

The window is only a few instructions wide. Would a check of
ICE_SERVICE_DIS at the start of ice_service_task(), or quiescing these
scheduling sources first, be needed to close it?

> if (!ice_is_safe_mode(pf))
> ice_remove_arfs(pf);
>
> @@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)
> ice_deinit_hw(&pf->hw);
>
> ice_deinit_dev(pf);
> - ice_aq_cancel_waiting_tasks(pf);
> set_bit(ICE_DOWN, pf->state);
> }

[Severity: High]
The commit message says the stop in ice_deinit_dev() "stays and deletes a
timer armed by the last run". The ordering inside ice_service_task_stop()
has not changed, though:

ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state);

if (pf->serv_tmr.function)
timer_delete_sync(&pf->serv_tmr);
if (pf->serv_task.func)
cancel_work_sync(&pf->serv_task);

A work item that is running during the stop can re-arm the timer after
timer_delete_sync():

- ice_service_task() calls mod_timer(&pf->serv_tmr, jiffies) at its tail
when a run was long or an *_EVENT_PENDING bit is set.
- ice_service_task_recovery_mode() always calls
mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100)).

Once that happens, ice_service_timer() keeps re-arming itself.

Some paths still stop only once. The first is the recovery-mode branch
of ice_remove():

if (ice_is_recovery_mode(&pf->hw)) {
ice_service_task_stop(pf);
scoped_guard(devl, priv_to_devlink(pf)) {
ice_deinit_devlink(pf);
}
return;
}

After this, devres frees the PF (the devlink priv), and the recovery-mode
work re-arms every 100ms. Can serv_tmr then fire on freed memory, or, after
rmmod, on unloaded module text?

The probe error unwind also calls ice_deinit_dev() only once before devres
frees the PF.

In ice_devlink_reinit_down(), the single stop in ice_deinit_dev() is
followed by ice_devlink_reinit_up()->ice_init_dev()->
ice_start_service_task(). That calls timer_setup(&pf->serv_tmr, ...) on a
timer that may still be enqueued. Could this corrupt the timer wheel list
once mod_timer() enqueues it again?

Would it be better to fix this inside ice_service_task_stop()? One option
is a second timer_delete_sync() after cancel_work_sync(). Another is to
skip the tail mod_timer() calls when ICE_SERVICE_DIS is set. Either would
avoid relying on a double stop at the call site.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127085714.1207361-1-poros%40redhat.com