From: "Rao, Nikhil" <nikhirao@amd.com>
To: netdev-bot+sashiko@kernel.org
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, nikhil.rao@amd.com
Subject: Re: [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a PCI reset
Date: Thu, 3 Dec 2026 09:46:48 -0800 [thread overview]
Message-ID: <1351cca0-816c-4bdf-960e-5f59cad0e641@amd.com> (raw)
In-Reply-To: <179625854521.3146.11030796304497825514@kernel.org>
On 12/2/2026 4:42 PM, netdev-bot+sashiko@kernel.org wrote:
> [ ... ]
> [Severity: Medium]
> Is the PCI reset the only path where this race happens? The firmware reset
> path does the same teardown, also without rtnl:
>
> ionic_lif_deferred_work()
> ionic_lif_handle_fw_down()
> mutex_lock(&lif->queue_lock);
> ionic_stop_queues(lif) <- clears IONIC_LIF_F_UP
> ionic_txrx_free(lif) <- devm_kfree(lif->rxqcqs[i]), sets it NULL
> ionic_qcqs_free(lif) <- frees the rxqcqs/txqcqs arrays
> mutex_unlock(&lif->queue_lock);
>
> Suppose an ionic_set_coalesce() call has already passed the
> test_bit(IONIC_LIF_F_UP) check. It would then read lif->rxqcqs[i]->flags
> after the qcq has been freed or set to NULL.
>
> The fw_down teardown dates from c672412f6172 ("ionic: remove lifs on fw
> reset"). ionic_lif_handle_fw_down() has held queue_lock since
> 2624d95972db ("ionic: widen queue_lock use around lif init and deinit").
> So this patch closes the firmware reset race as well.
v2 will describe both resets and add Fixes: c672412f6172 ("ionic: remove
lifs on fw reset").
> [Severity: High]
> This is a pre-existing issue, but does ionic_get_stats() have the same
> check-then-use race with PCI reset and firmware reset? It runs under rtnl
> only and tests the flag without any lock:
It does. It predates this series and is not a BAR access; I'll fix it
separately.
> [Severity: High]
> This isn't a bug introduced by this patch, but ionic_dim_work() also writes
> this coalesce register, and queue_lock doesn't serialize it. Can it run on
> a freed qcq after BAR0 has been unmapped?
>
> ionic_qcq_disable() cancels the DIM work before it masks the interrupt and
> disables NAPI:
>
> drivers/net/ethernet/pensando/ionic/ionic_lif.c:ionic_qcq_disable() {
> ...
> cancel_work_sync(&qcq->dim.work);
> ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
> IONIC_INTR_MASK_SET);
> synchronize_irq(qcq->intr.vector);
> ...
> napi_disable(&qcq->napi);
> ...
> }
>
> At the cancel, the queue is still enabled in hardware and the interrupt is
> still unmasked. A NAPI poll can complete between cancel_work_sync() and
> napi_disable() and queue the work again:
>
> ionic_rx_napi() / ionic_tx_napi() / ionic_txrx_napi()
> ionic_dim_update()
> net_dim()
> dim->state = DIM_APPLY_NEW_PROFILE;
> schedule_work(&dim->work);
>
> DIM is on by default, since ionic_lif_alloc() sets IONIC_LIF_F_RX_DIM_INTR
> and IONIC_LIF_F_TX_DIM_INTR. Nothing cancels or flushes dim.work after
> this point.
>
> ionic_stop(), ionic_reset_prepare() and ionic_lif_handle_fw_down() then
> call ionic_txrx_free(). It devm_kfree()s the qcq that contains the still
> queued work_struct.
>
> When ionic_dim_work() runs later, it does this on the freed qcq:
>
> ionic_intr_coal_init(lif->ionic->idev.intr_ctrl,
> intr->index, intr->dim_coal_hw);
>
> In the PCI reset case, ionic_reset_prepare() has also called
> ionic_dev_teardown() and ionic_clear_pci() by then. That would make this
> iowrite32 hit the unmapped BAR0.
>
> This ordering seems to date back to 04a834592bf5 ("ionic: dynamic
> interrupt moderation"). Should cancel_work_sync(&qcq->dim.work) be moved
> after napi_disable()?
Yes, v2 adds a patch that cancels it after napi_disable().
prev parent reply other threads:[~2026-12-03 17:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 0:38 [PATCH net 0/4] ionic: fix register reads racing the BAR unmap on PCI reset Nikhil P. Rao
2026-12-02 0:38 ` [PATCH net 1/4] ionic: fix devcmds " Nikhil P. Rao
2026-12-03 0:42 ` netdev-bot+sashiko
2026-12-02 0:38 ` [PATCH net 2/4] ionic: fix device info register reads " Nikhil P. Rao
2026-12-02 0:38 ` [PATCH net 3/4] ionic: fix PHC " Nikhil P. Rao
2026-12-02 0:38 ` [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a " Nikhil P. Rao
2026-12-03 0:42 ` netdev-bot+sashiko
2026-12-03 17:46 ` Rao, Nikhil [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351cca0-816c-4bdf-960e-5f59cad0e641@amd.com \
--to=nikhirao@amd.com \
--cc=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eric.joyner@amd.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox