Article View: linux.kernel.netdev
Article #27540Re: [PATCH net v2 5/5] ionic: fix DIM work racing the queue teardown
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 23:06
Date: Sat, 05 Dec 2026 23:06
162 lines
14016 bytes
14016 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 Ā· High: 1 Ā· Medium: 0 Ā· Low: 1
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's stated claim, "Cancel the work once NAPI is
disabled, when no poll can queue it again", does not hold for ionic,ā¦
- [Low] When cancel_work_sync(&qcq->dim.work) in ionic_qcq_disable()
drops a pending ionic_dim_work(), the patch copies only the handler'sā¦
--
ionic: fix DIM work racing the queue teardown
This moves cancel_work_sync(&qcq->dim.work) in ionic_qcq_disable() so it
runs after napi_disable(). The goal is that a NAPI poll can no longer
requeue the DIM work on a queue that is about to be freed. It also resets
qcq->dim.state to DIM_START_MEASURE in place of a dropped work item.
Closes: https://lore.kernel.org/netdev/179625854521.3146.11030796304497825514@kernel.org/
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> index 339a3c4c5b432..909781f064967 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> @@ -358,13 +358,14 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int f
>
> if (lif->doorbell_wa)
> cancel_work_sync(&qcq->doorbell_napi_work);
> - cancel_work_sync(&qcq->dim.work);
> ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
> IONIC_INTR_MASK_SET);
> synchronize_irq(qcq->intr.vector);
> irq_set_affinity_notifier(qcq->intr.vector, NULL);
> irq_set_affinity_hint(qcq->intr.vector, NULL);
> napi_disable(&qcq->napi);
> + cancel_work_sync(&qcq->dim.work);
[Severity: High]
The commit message says:
Cancel the work once NAPI is disabled, when no poll can queue it again.
Does that hold for ionic? In ionic_tx_napi(), ionic_rx_napi() and
ionic_txrx_napi(), ionic_dim_update() is only called after
napi_complete_done() has returned true:
drivers/net/ethernet/pensando/ionic/ionic_txrx.c:ionic_tx_napi() {
...
if (work_done < budget && napi_complete_done(napi, work_done)) {
ionic_dim_update(qcq, IONIC_LIF_F_TX_DIM_INTR);
...
}
At that point napi_complete_done() has already cleared NAPIF_STATE_SCHED.
napi_disable_locked() only waits while NAPIF_STATE_SCHED or
NAPIF_STATE_NPSVC is set.
So napi_disable() can return while the poll is still running on another
CPU. That poll may not yet have reached ionic_dim_update()->net_dim(),
which calls schedule_work(&dim->work).
Could this interleaving happen?
CPU0 (NAPI poll) CPU1 (ionic_qcq_disable)
napi_complete_done()
clears NAPIF_STATE_SCHED
ionic_intr_mask()
synchronize_irq()
napi_disable() /* returns */
cancel_work_sync(&qcq->dim.work)
qcq->dim.state = DIM_START_MEASURE
ionic_dim_update()
net_dim()
dim->state = DIM_APPLY_NEW_PROFILE
schedule_work(&dim->work)
This is the only cancel of dim.work in the driver. Teardown then goes
through ionic_txrx_deinit()->ionic_lif_qcq_deinit(). There,
netif_napi_del() waits for the poll to return, but by then the work is
already queued.
After that, ionic_txrx_free()->ionic_qcq_free() and devm_kfree() free the
qcq that embeds dim.work.
On the PCI reset path, ionic_reset_prepare() also reaches
ionic_clear_pci(), which does:
ionic->idev.intr_ctrl = NULL;
synchronize_rcu();
ionic_unmap_bars(ionic);
A late ionic_dim_work() would then use container_of() to get back to the
freed qcq. It could also call ionic_intr_coal_init() through a NULL or
unmapped intr_ctrl.
Isn't that the same use-after-free and unmapped BAR write this patch is
meant to fix?
The window is short on non-RT kernels. A hardirq on CPU0 makes it wider,
and on PREEMPT_RT the NAPI poll can be preempted.
Would either of these close it?
- Cancel dim.work and reset the DIM state only once the poll is known to
have returned, for example after netif_napi_del() in
ionic_lif_qcq_deinit().
- Add synchronize_net() between napi_disable() and cancel_work_sync().
> + qcq->dim.state = DIM_START_MEASURE;
[Severity: Low]
When cancel_work_sync() drops a pending ionic_dim_work(), this line copies
only the handler's last step. Is resetting dim.state alone enough to keep
DIM consistent with the hardware?
net_dim_decision() has already moved dim->profile_ix forward before
net_dim() sets DIM_APPLY_NEW_PROFILE and queues the work.
ionic_dim_work() is the only place where profile_ix is written to the
hardware:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:ionic_dim_work() {
...
intr = &qcq->intr;
if (intr->dim_coal_hw != new_coal) {
intr->dim_coal_hw = new_coal;
ionic_intr_coal_init(lif->ionic->idev.intr_ctrl,
intr->index, intr->dim_coal_hw);
}
dim->state = DIM_START_MEASURE;
}
After the drop, the coalesce register and intr->dim_coal_hw still hold
the old profile's value, while profile_ix names the new profile.
The coalesce value is also not reapplied when the queues restart on the
same qcq. The path ionic_stop_queues(), then ionic_start_queues() and
ionic_qcq_enable(), never writes it.
If DIM then parks on top with steady traffic, it will not change profile
again. The hardware could stay on the value DIM decided to leave until
DIM changes profile again.
Would flush_work() here, or rolling profile_ix back, keep DIM in sync
with the hardware? flush_work() should still be safe at this point,
because ionic_intr_mask() earlier in the same block already writes
through intr_ctrl.
[ ... ]
--
Sashiko AI review Ā· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-b4-pr60-v2-0-9e0b5408a68e%40amd.com
Technical Details
Message-ID:
<179651196901.3148.6541276687307414833@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378177-linux-kernel-netdev=dewy.ruReferences:
<20261204-b4-pr60-v2-5-9e0b5408a68e@amd.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378177-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 5/5] ionic: fix DIM work racing the queue teardown Date: Sat, 05 Dec 2026 23:06:09 +0000 Organization: Usenet Network Message-ID: <179651196901.3148.6541276687307414833@kernel.org> References: <20261204-b4-pr60-v2-5-9e0b5408a68e@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3139656"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5N/Fnu+pLB7NBOIxkIaZA24/Wzw= sha256:crJDENznqZnjJdPp/iqTCJWicV8HTn0Cs919iBx7Qag= sha1:+TpoQ4xD5ehI+muIMVwPt5RMIUs= sha256:MVwYYNAh0IRZFi4+s+B2arUIgpJ7gBZNHmtGzkiXavo= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 64358117EE9; Sun, 6 Dec 2026 02:06:27 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.529 X-Spam-Status: No, score=-3.529 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HGsHCHmYK5YG; Sun, 6 Dec 2026 02:06:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378177-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 1320E10E0E9; Sun, 6 Dec 2026 02:06:15 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A8BD12EF46; Sat, 5 Dec 2026 23:06:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796511971; b=XY8SZ29wp8Alq5fpqGI9/3iL9NcLHqPohFoUCAvAaRupQlJ11dYeqaYQMNFDhT80Saep fmHNIXgjWWeXOo4uikSlInJhsPLjm59veS4gFNxgTWE9NeKLmTEhQB1XbwYsBO/pXPKyK O7xBu95lT45ys4HOfZ+HSVYrEktqHTuBNZ5uL3gSFOZ4V3zmWeju23tPoiVe3zRDLE4n/ 5qtLrSGD9sNH+zrMHbidXirVGoKWEM3IbnnoxlVmzU94WrNHVn7a9ScYcA2eiCoQdwRzR o64VGvitnHuFUJgoqlHnE3PCqilZq0KrRcAZOdoB8nhFbvcPJnoXjYl67vF0HBRvW+w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511971; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=T3EFFJx0MrOYk0JCYt/5JDatmyZPHalNJYGGdWZE2e4=; b=EfhF+HFy8NP89uJ2elMbcT0qH/qJXzPcLFerLWjewhOPk4khfKDS23Ve1Rfy+oYb3h2M 9Ymyg7OPMan5iEKJgZPrTzOUvVqJ6eAy6Sr4xiTH/uOqrgI4bDnNM3K0uUgjtpvNA8BIS T26pCP4YDKliulvDA8EAqe+XHpkiNS91pTPMlCq4xMiaBITwm3WIbQ1vCXfck6DktPSSW rIKLKrj2a7VHPRWHAfZJLOief2N4/0wiLNT3hvp2oM4OGXOBNXGfOdb7AcAczeMM2OvLU kdqmQX+E0vzkyNQDBPjsOW4vkkP97BQ22NhDkgJUwDJO5Ef7FCavLzFLwBVQj1+XWWg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hgVoa11m; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 819C5606A337; Sat, 5 Dec 2026 23:06:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hgVoa11m X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796511970; b=OxejEAGKRYelR/CFHRvY1TqdyFXn9skrvUfrKQckt9WiNf98rcebAiH9Vw+MNQBpKzoJ lb/tHXuuH09dN2uyhgx/nLWjVmLkm05Z//pYk6mnK468wPafuaUTEy5PK/L+SuYLD+5Uk Oqm1saEQMgB6rmfJwc8Vaz4Qtoxgw9amJFvn2HXkSN0bB9M54WFK8a5nFHhZ3L+Ybo4YH zMyv7oNsi2KPTHE7YxcTLEdfYUb0ii02UoEc20i6oKPY8wpc7j6q9nQWfmeIdqGQOY/Ak xaThZTMY0l8cVNm8/QMWoFQAtS/RYU58En+wxL9IUPazTZdziJ08xBHC8GgAMiB6tZQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511970; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=T3EFFJx0MrOYk0JCYt/5JDatmyZPHalNJYGGdWZE2e4=; b=Hx+rDogfOS0cESCviKATZfcevAutv07j8MlmtfdilGtjOVXndiRznUH4XEiiiz6ElzMf YudEBY681HFNi6PCye0Uyf4qkWXJmTQWK9CVGDO6nIohZWzwlZunAxnEQUPJBueEON0Dg 8qCS2jR3M9BV/yY3+1zMcS1JXFGH4Q2zkmWUBoWKVTwRyhF9nVq18bNk9LIMOT7Su6gRi s++7xjeAtHE9CYKAt0xG8Rcn2no+gTldGHmt5YgyMbvSUIE1OOc18td7GSUY9tGHBToh0 OHKzBZ0iSZf/Z1ZU+t8HQFL6OD00JhcqjIrPVKabhm0SaeS9hbRrWFq8GS5UmiDZC+Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hgVoa11m; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A10D9606A33C; Sat, 5 Dec 2026 23:06:10 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79B471F00936; Sat, 5 Dec 2026 23:06:09 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796511970; bh=T3EFFJx0MrOYk0JCYt/5JDatmyZPHalNJYGGdWZE2e4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=hgVoa11m4Uf9rij6rEKo89JMkQ4yeS7b9qO0aBr+krIFVRs0JAErlZm/ukDyVv4f/ Um1axRsxiZ2xtNSJrCKDZGJjO/iSDZrNsGQt2xJcCJABewoX/x5VamjAyapOf+MUAX YrlcIrVcQ/QFeSoDRbOWZzV37srkYy+JnSccfp/vj2ja4rUb71kKf4hQ5Ch3YJ2em5 tpGZGDWnMmAZUwswojl4hraXXECHeTtTQMc93I3BFhURZG9cMS9im5VhFlAk6rb9vI WnIDO3c10pQ3dYX9yaU6X6x49te6632btFerA9xOVWCVU18l8ZSieNHuwafixXyiHS cXkq/kumJoBwg== X-Cc: brett.creeley@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.joyner@amd.com, abhijit.gangurde@amd.com, allen.hubbe@amd.com X-In-Reply-To: <20261204-b4-pr60-v2-5-9e0b5408a68e@amd.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list