Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "A. Sverdlin" <alexander.sverdlin@siemens.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH net-next v2] net: fec: support RX flushing via an ethtool private flag
Date: Wed, 02 Sep 2026 07:47:55 +0000	[thread overview]
Message-ID: <20260902074756.1AFC01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901074732.113791-1-alexander.sverdlin@siemens.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] fec_enet_get_sset_count() triggers WARN_ON_ONCE by returning 0 instead of -EOPNOTSUPP for ETH_SS_PRIV_FLAGS on unsupported hardware.
- [Medium] Data race on fep->rx_flush_mask due to lockless write in fec_enet_set_priv_flags().
--

commit 0779caeb36f03b70108effeec07b7cd6055f53f4
Author: Alexander Sverdlin <alexander.sverdlin@siemens.com>

net: fec: support RX flushing via an ethtool private flag

This commit adds support for flushing the RX FIFO of an individual receive
queue via an ethtool private flag. It exposes a per-queue rx-flush-qN capability
for controllers with the FEC_QUIRK_HAS_MULTI_QUEUES quirk.

> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 794ec427b0ee6..e5c1d04a665c4 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
[ ... ]
> @@ -3576,11 +3603,67 @@ static int fec_enet_get_sset_count(struct net_device *dev, int sset)
>  
>  	case ETH_SS_TEST:
>  		return net_selftest_get_count();
> +	case ETH_SS_PRIV_FLAGS:
> +		if (fep->quirks & FEC_QUIRK_HAS_MULTI_QUEUES)
> +			return min(fep->num_rx_queues, fep->num_tx_queues);
> +		return 0;

[Severity: High]
Should this return -EOPNOTSUPP instead of 0 when the hardware doesn't support
multi-queues? Returning 0 for unsupported private flags violates the ethtool API
contract and can trigger a WARN_ON_ONCE(!ret) in ethtool_get_strings().

>  	default:
>  		return -EOPNOTSUPP;
>  	}
>  }
[ ... ]
> +static int fec_enet_set_priv_flags(struct net_device *ndev, u32 flags)
> +{
> +	struct fec_enet_private *fep = netdev_priv(ndev);
> +	u32 mask = 0;
> +	int i;
[ ... ]
> +	for (i = 0; i < fep->num_rx_queues; i++)
> +		if (flags & BIT(i))
> +			mask |= QOS_RX_FLUSH(i);
> +
> +	if (mask == fep->rx_flush_mask)
> +		return 0;
> +
> +	fep->rx_flush_mask = mask;

[Severity: Medium]
Does this assignment need to be protected by fep->qos_lock?

It appears fep->rx_flush_mask is read concurrently under fep->qos_lock in
fec_enet_set_rx_flush():

	guard(spinlock)(&fep->qos_lock);
	val = readl(fep->hwp + FEC_QOS_SCHEME);
	val &= ~QOS_RX_FLUSH_MASK;
	writel(val | fep->rx_flush_mask, fep->hwp + FEC_QOS_SCHEME);

Could this lockless write lead to a data race if userspace modifies the flags
while the PHY state machine adjusts the link in the background?

> +
> +	if (!netif_running(ndev))
> +		return 0;
> +
> +	fec_enet_set_rx_flush(fep);
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901074732.113791-1-alexander.sverdlin@siemens.com?part=1

  reply	other threads:[~2026-09-02  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  7:47 [PATCH net-next v2] net: fec: support RX flushing via an ethtool private flag A. Sverdlin
2026-09-02  7:47 ` sashiko-bot [this message]
2026-09-02  8:19   ` Sverdlin, Alexander
2026-09-03  1:58 ` 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=20260902074756.1AFC01F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexander.sverdlin@siemens.com \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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