Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v4 net-next 8/8] net: dsa: netc: add PTP one-step timestamping support
Date: Sat, 19 Sep 2026 07:26:21 +0000	[thread overview]
Message-ID: <20260919072621.D09DE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918072852.501420-9-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: dsa: netc: skb_clone causes downstream buffer unsharing penalties and ownership violation
--

commit e1617e58a8399b2727842b7a8a9daba5929f414b
Author: Wei Fang <wei.fang@nxp.com>

net: dsa: netc: add PTP one-step timestamping support

This commit adds one-step Sync offload for NETC switch ports and advertises
HWTSTAMP_TX_ONESTEP_SYNC. It uses a deferred work mechanism and queue to
transmit one-step Sync frames, allowing hardware to compute the correction
field.

> diff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c
> index 2e743443ca030..1bc0f09562062 100644
> --- a/drivers/net/dsa/netc/netc_ptp.c
> +++ b/drivers/net/dsa/netc/netc_ptp.c

[ ... ]

> @@ -68,12 +77,276 @@ static int netc_get_ts_req_id(struct netc_port *np)

[ ... ]

> +static void netc_port_program_onestep(struct netc_port *np,
> +				      struct sk_buff *skb)
> +{

[ ... ]

> +		old_sec_h = __get_unaligned_t(__be16, hdr + tstamp_offset);
> +		old_sec_l = __get_unaligned_t(__be32, hdr + tstamp_offset + 2);
> +		old_ns = __get_unaligned_t(__be32, hdr + tstamp_offset + 6);
> +		inet_proto_csum_replace2(&uh->check, skb, old_sec_h,
> +					 new_sec_h, false);

[Severity: Medium]
Does modifying the payload of a cloned SKB here violate the networking core SKB
buffer ownership guidelines?

The original SKB was cloned earlier in netc_port_onestep_work(), making its
data buffer shared (skb_cloned(skb) evaluates to true). Bypassing standard
buffer ownership rules and directly modifying the shared payload triggers an
expensive reallocation and copy (pskb_expand_head) in downstream conduit drivers
that check skb_cloned() before padding or modifying the frame, which could
severely degrade one-step PTP performance.

[ ... ]

> +static void netc_port_onestep_work(struct work_struct *work)
> +{
> +	struct netc_port *np = container_of(work, struct netc_port,
> +					    onestep_work);

[ ... ]

> +skb_dequeue:
> +	skb = __skb_dequeue(&np->onestep_queue);
> +	if (!skb)
> +		goto set_onestep_state_idle;
> +
> +	/* Clone is a ts_req_id token only; its payload is never read, so
> +	 * sharing the buffer with the mutated original is fine.
> +	 */
> +	clone = skb_clone(skb, GFP_ATOMIC);

[Severity: Medium]
Could this clone operation lead to the downstream buffer unsharing penalties
described above?

Since the clone is only used as a timeout token and its payload is never read,
would allocating a dummy lightweight SKB via alloc_skb(0, GFP_ATOMIC)
exclusively to hold the token avoid these performance penalties and
architectural ownership violations?

> +	if (unlikely(!clone)) {
> +		kfree_skb(skb);
> +		goto skb_dequeue;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260918072852.501420-1-wei.fang@oss.nxp.com?part=8

  reply	other threads:[~2026-09-19  7:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  7:28 [PATCH v4 net-next 0/8] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-09-18  7:28 ` [PATCH v4 net-next 1/8] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-09-30 13:26   ` Linus Walleij
2026-09-18  7:28 ` [PATCH v4 net-next 2/8] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-09-18  7:28 ` [PATCH v4 net-next 3/8] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-09-22  8:25   ` netdev-bot+sashiko
2026-09-22  9:48     ` Wei Fang
2026-09-18  7:28 ` [PATCH v4 net-next 4/8] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-09-18  7:28 ` [PATCH v4 net-next 5/8] net: dsa: netc: check return value of ntmp_ipft_delete_entry() wei.fang
2026-09-22  8:25   ` netdev-bot+sashiko
2026-09-22 10:34     ` Wei Fang
2026-09-18  7:28 ` [PATCH v4 net-next 6/8] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-09-18  7:28 ` [PATCH v4 net-next 7/8] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-09-22  8:25   ` netdev-bot+sashiko
2026-09-23  2:43     ` Wei Fang
2026-09-18  7:28 ` [PATCH v4 net-next 8/8] net: dsa: netc: add PTP one-step " wei.fang
2026-09-19  7:26   ` sashiko-bot [this message]
2026-09-21  2:31     ` Wei Fang (OSS)
2026-09-22  8:25   ` netdev-bot+sashiko
2026-09-23  6:11     ` 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=20260919072621.D09DE1F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox