From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95
Date: Sat, 06 Jun 2026 07:24:42 +0000 [thread overview]
Message-ID: <20260606072442.AFEED1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260605065550.3038579-13-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `pf->msg_lock` mutex is used uninitialized on standalone ENETC devices, leading to a panic or lockdep splat during RX mode configuration.
- [High] ENETC4 VF driver data uses `enetc_vf_ethtool_ops` which unconditionally reads ENETC 1.0 specific registers via `ethtool -d`, triggering out-of-bounds/reserved accesses.
--
commit aabc7a8de39df35b07517a53cac397ac5c0fb902
Author: Wei Fang <wei.fang@nxp.com>
net: enetc: add VF support for i.MX94 and i.MX95
This patch adds VF support for i.MX94 and i.MX95 platforms. Compared to
the LS1028A ENETC, the VF device ID has been updated to 0xef00.
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index aa8a87124b103..fdceaf36daa72 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -3745,6 +3745,13 @@ static const struct enetc_drvdata enetc_vf_data = {
> .eth_ops = &enetc_vf_ethtool_ops,
> };
>
> +static const struct enetc_drvdata enetc4_vf_data = {
> + .sysclk_freq = ENETC_CLK_333M,
> + .tx_csum = true,
> + .max_frags = ENETC4_MAX_SKB_FRAGS,
> + .eth_ops = &enetc_vf_ethtool_ops,
[Severity: High]
Does this safely support ENETC v4 hardware? The enetc_vf_ethtool_ops
implements the get_regs callback using enetc_get_regs(), which
unconditionally reads registers defined in the enetc_si_regs array.
This array includes ENETC 1.0 specific Control Ring (CBDR) registers like
ENETC_SICBDRMR. Since ENETC v4 hardware uses NTMP instead of CBDR, these
register offsets are invalid or reserved on i.MX94/i.MX95.
Reading reserved memory regions via ethtool -d can trigger a synchronous
external abort or kernel panic on some architectures. Should the driver
define an ENETC4-specific ethtool_ops for the VF or check hardware
revisions before reading these registers?
> +};
> +
[ ... ]
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> index 15c8b704b2b75..868ed694e1200 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> @@ -314,11 +314,15 @@ static const struct enetc_pf_ops enetc4_pf_ops = {
> static int enetc4_pf_struct_init(struct enetc_si *si)
> {
> struct enetc_pf *pf = enetc_si_priv(si);
> + int err;
>
> pf->si = si;
> - pf->total_vfs = pci_sriov_get_totalvfs(si->pdev);
> pf->ops = &enetc4_pf_ops;
>
> + err = enetc_init_sriov_resources(pf);
[Severity: High]
Can this lead to an uninitialized mutex being used on standalone ENETC v4
devices that do not support VFs?
In enetc_init_sriov_resources(), there is an early return if pf->total_vfs
is 0:
int enetc_init_sriov_resources(struct enetc_pf *pf)
{
...
pf->total_vfs = pci_sriov_get_totalvfs(pf->si->pdev);
if (!pf->total_vfs)
return 0;
...
mutex_init(&pf->msg_lock);
return 0;
}
If total_vfs is 0 (as is the case for standalone i.MX94 ENETC),
the msg_lock is not initialized. Later, when the network interface is
brought up or the promiscuous mode changes, enetc4_psi_do_set_rx_mode()
unconditionally locks this uninitialized mutex:
mutex_lock(&pf->msg_lock);
enetc4_pf_set_si_mac_promisc(hw, 0, UC, uc_promisc);
...
mutex_unlock(&pf->msg_lock);
Would it be better to initialize the mutex unconditionally, or condition
the locking on the device capabilities?
> + if (err)
> + return err;
> +
> enetc4_get_port_caps(pf);
> enetc4_get_psi_hw_features(si);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260605065550.3038579-1-wei.fang@oss.nxp.com?part=12
next prev parent reply other threads:[~2026-06-06 7:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 6:55 [PATCH net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support wei.fang
2026-06-05 6:55 ` [PATCH net-next 01/15] net: enetc: add trusted " wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-06 13:37 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 02/15] net: enetc: move msg_task and msg_int_name to struct enetc_si wei.fang
2026-06-05 6:55 ` [PATCH net-next 03/15] net: enetc: add link status message support to PF driver wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-06 14:05 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 04/15] net: enetc: add link speed " wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 05/15] net: enetc: use enetc_set_si_hw_addr() to set VF MAC address wei.fang
2026-06-05 6:55 ` [PATCH net-next 06/15] net: enetc: relocate enetc_pf_set_vf_mac() for common PF support wei.fang
2026-06-05 6:55 ` [PATCH net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver wei.fang
2026-06-05 6:55 ` [PATCH net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-07 2:52 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4 wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 10/15] net: enetc: simplify and rename PSIIER enable/disable helpers wei.fang
2026-06-05 6:55 ` [PATCH net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4 wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95 wei.fang
2026-06-06 7:24 ` sashiko-bot [this message]
2026-06-07 3:53 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 13/15] net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VF wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-07 4:01 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 14/15] net: enetc: add PSI-to-VSI link status notification support for VF wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 15/15] net: enetc: add ndo_get_vf_config() support wei.fang
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=20260606072442.AFEED1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@oss.nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.