From: Simon Horman <horms@kernel.org>
To: sbhatta@marvell.com
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, gakula@marvell.com,
bbhushan2@marvell.com, sgoutham@marvell.com, pabeni@redhat.com,
lcherian@marvell.com, linux-kernel@vger.kernel.org,
edumazet@google.com, andrew+netdev@lunn.ch, kuba@kernel.org,
davem@davemloft.net
Subject: Re: [net-next,4/4] octeontx2-pf: cn20k: Use unified Halo context
Date: Wed, 18 Mar 2026 15:06:21 +0000 [thread overview]
Message-ID: <20260318150621.1905126-1-horms@kernel.org> (raw)
In-Reply-To: <1773665859-4036-5-git-send-email-sbhatta@marvell.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
octeontx2-pf: cn20k: Use unified Halo context
Use unified Halo context present in CN20K hardware for
octeontx2 netdevs instead of aura and pool contexts.
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c b/drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
> index a5a8f4558717..db2742588bf6 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
[ ... ]
> +int cn20k_npa_alloc_dpc(struct otx2_nic *nic)
> +{
> + struct npa_cn20k_dpc_alloc_req *req;
> + struct npa_cn20k_dpc_alloc_rsp *rsp;
> + int err;
> +
> + req = otx2_mbox_alloc_msg_npa_cn20k_dpc_alloc(&nic->mbox);
> + if (!req)
> + return -ENOMEM;
> +
> + /* Count successful ALLOC requests only */
> + req->dpc_conf = 1ULL << 4;
> +
> + err = otx2_sync_mbox_msg(&nic->mbox);
> + if (err)
> + return err;
> +
> + rsp = (struct npa_cn20k_dpc_alloc_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox,
> + 0, &req->hdr);
> +
> + nic->npa_dpc = rsp->cntr_id;
^^^^
Can this dereference crash? The otx2_mbox_get_rsp() call can return
ERR_PTR(-ENODEV) on error. In mbox.c, otx2_mbox_get_rsp() returns an error
pointer if there's a message count mismatch or ID mismatch:
drivers/net/ethernet/marvell/octeontx2/af/mbox.c:otx2_mbox_get_rsp() {
...
if (!mbox->dev->msgs_acked)
return ERR_PTR(-ENODEV);
...
if (msgs_acked != 1)
return ERR_PTR(-ENODEV);
...
}
Every other caller of otx2_mbox_get_rsp() in this driver checks IS_ERR()
before dereferencing:
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c:cn10k_alloc_leaf_profile() {
...
rsp = (struct nix_bandprof_get_hwinfo_rsp *)
otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
if (IS_ERR(rsp))
return PTR_ERR(rsp);
...
}
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c:__cn20k_tc_alloc_entry() {
...
rsp = (struct npc_mcam_alloc_entry_rsp *)otx2_mbox_get_rsp(...);
if (IS_ERR(rsp))
return PTR_ERR(rsp);
...
}
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c:otx2_alloc_mcam_entries() {
...
rsp = (struct npc_mcam_alloc_entry_rsp *)otx2_mbox_get_rsp(...);
if (IS_ERR(rsp)) {
...
return PTR_ERR(rsp);
}
...
}
> +
> + return 0;
> +}
> +
> +int cn20k_npa_free_dpc(struct otx2_nic *nic)
> +{
> + struct npa_cn20k_dpc_free_req *req;
> + int err;
> +
> + req = otx2_mbox_alloc_msg_npa_cn20k_dpc_free(&nic->mbox);
> + if (!req)
> + return -ENOMEM;
> +
> + req->cntr_id = nic->npa_dpc;
> +
> + err = otx2_sync_mbox_msg(&nic->mbox);
> +
> + return err;
> +}
Does this need the mbox lock? Every other function in
otx2_free_hw_resources() that performs mbox operations acquires the
mbox lock.
For example, otx2_ctx_disable() does:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c:otx2_ctx_disable() {
...
mutex_lock(&mbox->lock);
if (nixlf) {
...
otx2_sync_mbox_msg(mbox);
}
...
mutex_unlock(&mbox->lock);
}
And cn10k_free_all_ipolicers() does:
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c:cn10k_free_all_ipolicers() {
...
mutex_lock(&pfvf->mbox.lock);
...
otx2_sync_mbox_msg(&pfvf->mbox);
mutex_unlock(&pfvf->mbox.lock);
}
In contrast, cn20k_npa_alloc_dpc() is called from otx2_init_hw_resources()
under the mbox lock:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:otx2_init_hw_resources() {
...
mutex_lock(&pf->mbox.lock);
...
if (is_cn20k(pf->pdev))
cn20k_npa_alloc_dpc(pf);
...
mutex_unlock(&pf->mbox.lock);
}
Without the lock here in cn20k_npa_free_dpc(), could concurrent mbox access
from VF mbox forwarding corrupt the shared mbox buffer? VF mbox forwarding
runs from the mbox_pfvf_wq workqueue via otx2_forward_vf_mbox_msgs().
[ ... ]
next prev parent reply other threads:[~2026-03-18 15:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 12:57 [net-next PATCH 0/4] octeontx2: CN20K NPA Halo context support Subbaraya Sundeep
2026-03-16 12:57 ` [net-next PATCH 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support Subbaraya Sundeep
2026-03-18 15:21 ` [net-next,1/4] " Simon Horman
2026-03-16 12:57 ` [net-next PATCH 2/4] octeontx2-af: npa: cn20k: Add DPC support Subbaraya Sundeep
2026-03-18 15:20 ` [net-next,2/4] " Simon Horman
2026-03-16 12:57 ` [net-next PATCH 3/4] octeontx2-af: npa: cn20k: Add debugfs for Halo Subbaraya Sundeep
2026-03-18 15:18 ` Simon Horman
2026-03-16 12:57 ` [net-next PATCH 4/4] octeontx2-pf: cn20k: Use unified Halo context Subbaraya Sundeep
2026-03-18 15:06 ` Simon Horman [this message]
2026-03-18 15:12 ` Simon Horman
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=20260318150621.1905126-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bbhushan2@marvell.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=kuba@kernel.org \
--cc=lcherian@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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