From: netdev-bot+sashiko@kernel.org
To: oss.patchbox@gmail.com
Cc: sgoutham@marvell.com, gakula@marvell.com, rkannoth@marvell.com,
sbhatta@marvell.com, bbhushan2@marvell.com, hkelam@marvell.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
jacob.e.keller@intel.com, netdev@vger.kernel.org
Subject: Re: [PATCH net] octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails
Date: Thu, 26 Nov 2026 07:00:52 +0000 [thread overview]
Message-ID: <179567645260.3135.1714589619526936893@kernel.org> (raw)
In-Reply-To: <20261124190046.415260-2-oss.patchbox@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · 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).
- [Medium] If otx2_qos_ctx_disable() fails, the new early return in
otx2_qos_disable_sq() (qos_sq.c:316-322) leaves all the queue state in…
- [Low] The commit message says otx2_free_hw_resources() frees the kept
memory 'after the SQ and NPA contexts of the whole LF have been…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
otx2_qos_sq_free_sqbs() (qos_sq.c:116-148), called on every successful…
--
octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails
This patch makes otx2_qos_disable_sq() check the return value of
otx2_qos_ctx_disable(). If the AF mailbox request fails, it now logs an
error and returns without freeing the SQBs, the pool stack and the aura
flow-control buffer, which the hardware may still reference.
> If the disable fails, log an error and keep the memory: leaking it is
> safer than freeing memory the hardware may still access. If the queue
> is not set up again, otx2_free_hw_resources() frees it later with the
> other queues when the interface goes down, after the SQ and NPA
> contexts of the whole LF have been disabled.
[Severity: Low]
Is this ordering accurate? otx2_free_hw_resources() calls
otx2_free_sq_res(). That function frees the SQB pages of every queue,
QoS queues included, right after a best-effort SQ disable:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:otx2_free_sq_res() {
...
/* Disable SQs */
otx2_ctx_disable(&pf->mbox, NIX_AQ_CTYPE_SQ, false);
/* Free SQB pointers */
otx2_sq_free_sqbs(pf);
...
}
otx2_ctx_disable() returns void and only logs a mailbox failure. The NPA
pool and aura contexts are disabled later, in otx2_free_hw_resources():
/* Disable NPA Pool and Aura hw context */
otx2_ctx_disable(mbox, NPA_AQ_CTYPE_POOL, true);
otx2_ctx_disable(mbox, NPA_AQ_CTYPE_AURA, true);
otx2_aura_pool_free(pf);
So the SQB pages are freed before the NPA contexts are disabled. Only
pool->stack and pool->fc_addr are freed after that. If the AF mailbox is
still broken at ifdown, the memory kept by this patch gets freed anyway,
with no check of the result.
Could the commit message be reworded to match this?
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
> index 683efce519af0..e9ca884cfb4d5 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
[ ... ]
> @@ -311,8 +311,16 @@ void otx2_qos_disable_sq(struct otx2_nic *pfvf, int qidx)
> otx2_cleanup_tx_cqes(pfvf, cq);
>
> mutex_lock(&pfvf->mbox.lock);
> - otx2_qos_ctx_disable(pfvf, sq_idx, pool_id);
> + err = otx2_qos_ctx_disable(pfvf, sq_idx, pool_id);
> mutex_unlock(&pfvf->mbox.lock);
> + if (err) {
> + /* The SQ, aura and pool may still be enabled, so don't free
> + * the memory they point to.
> + */
> + netdev_err(pfvf->netdev,
> + "Failed to disable QoS SQ %d (%d)\n", sq_idx, err);
> + return;
> + }
[Severity: Medium]
otx2_qos_disable_sq() still returns void, so callers can't tell that the
disable failed. When the same qid is set up again right afterwards, are
the kept SQB pages and queue buffers leaked?
otx2_qos_enadis_sq() re-enables the qid straight after the disable:
drivers/net/ethernet/marvell/octeontx2/nic/qos.c:otx2_qos_enadis_sq() {
if (pfvf->qos.qid_to_sqmap[qid] != OTX2_QOS_INVALID_SQ)
otx2_qos_disable_sq(pfvf, qid);
pfvf->qos.qid_to_sqmap[qid] = node->schq;
otx2_qos_txschq_config(pfvf, node);
otx2_qos_enable_sq(pfvf, qid);
}
otx2_qos_leaf_del() works the same way. It disables node->qid and later
calls otx2_qos_enable_sq(pfvf, qid) for the moved leaf.
otx2_qos_leaf_to_inner() and otx2_qos_leaf_del_last() pass the qid to a
child or parent. That node is then enabled through
push_txschq_cfg()->otx2_qos_enadis_sq().
The setup path overwrites the kept pointers without checking them:
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c:otx2_qos_sq_aura_pool_init() {
...
sq->sqb_count = 0;
sq->sqb_ptrs = kzalloc_objs(*sq->sqb_ptrs, num_sqbs);
...
}
In the same way, otx2_pool_aq_init() always calls qmem_alloc() for
pool->stack. otx2_sq_init() also reallocates sq->sqe, sq->sqe_ring,
sq->cpt_resp and sq->sg.
After that, the old SQB pages stay DMA mapped and keep their page
references. The old qmem buffers are never freed, because
otx2_free_hw_resources() only sees the new pointers. pool->fc_addr is
fine, since otx2_aura_aq_init() reuses it when it is non-NULL.
With default ring sizes this comes to roughly 2 MiB each time. The
commit message only covers the case where the queue is not set up again.
In the common callers the queue is set up again in the same call.
Could otx2_qos_disable_sq() return the error so callers can avoid
reusing the qid? Alternatively, otx2_qos_enable_sq() could refuse, or
retry the disable and free first, while sq->sqb_ptrs is still set.
>
> otx2_qos_sq_free_sqbs(pfvf, sq_idx);
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Does
otx2_qos_sq_free_sqbs() leak sq->sqe_ring and sq->cpt_resp on every
successful disable?
otx2_sq_init() allocates both buffers for every SQ, QoS SQs included,
with no qidx condition. Those allocations came in with commit
6a77a158848a ("cn10k-ipsec: Process outbound ipsec crypto offload").
otx2_qos_sq_free_sqbs() frees the other buffers and then clears the
struct:
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c:otx2_qos_sq_free_sqbs() {
...
qmem_free(pfvf->dev, sq->sqe);
qmem_free(pfvf->dev, sq->tso_hdrs);
kfree(sq->sg);
kfree(sq->sqb_ptrs);
qmem_free(pfvf->dev, sq->timestamps);
memset((void *)sq, 0, sizeof(*sq));
}
The only other place that frees them is otx2_free_sq_res(). It only does
so when sq->sqe is set, and the memset above has already cleared it:
if (sq->sqe) {
qmem_free(pf->dev, sq->sqe);
qmem_free(pf->dev, sq->sqe_ring);
qmem_free(pf->dev, sq->cpt_resp);
The qmem buffers come from otx2_dma_alloc_coherent(), which uses
kzalloc() and dma_map_single(), so they are not devm managed.
With the default sqe_cnt of 4096, each HTB leaf delete, leaf-to-inner,
leaf delete-last, or re-config through otx2_qos_enadis_sq() would leak
about 1 MiB for sqe_ring and 256 KiB for cpt_resp, plus their DMA
mappings. This happens on the normal success path and can be repeated.
> otx2_qos_aura_pool_free(pfvf, pool_id);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124190046.415260-2-oss.patchbox%40gmail.com
prev parent reply other threads:[~2026-11-26 7:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 19:00 [PATCH net] octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails Yuho Choi
2026-11-24 19:02 ` netdev-bot+sinfo
2026-11-26 2:11 ` Ratheesh Kannoth
2026-11-26 7:00 ` netdev-bot+sashiko [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=179567645260.3135.1714589619526936893@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bbhushan2@marvell.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss.patchbox@gmail.com \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.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