From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v5 net-next 9/9] net: dsa: netc: add PTP one-step timestamping support
Date: Tue, 13 Oct 2026 09:59:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-169420@kernel.org> (raw)
In-Reply-To: <20261012095924.1129312-10-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dsa: torn read of jiffies_64 on 32-bit architectures
--
commit 0542eb3bb6feafa72e5bad3b8598c453a57cbc65
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 introduces a per-port queue that is drained
from a work handler to properly sequence one-step Sync frames.
> diff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c
> index 756c69a02064e..c3875bce80bc1 100644
> --- a/drivers/net/dsa/netc/netc_ptp.c
> +++ b/drivers/net/dsa/netc/netc_ptp.c
[ ... ]
> @@ -116,7 +418,8 @@ static void netc_port_onestep_work(struct work_struct *work)
[ ... ]
> + NETC_SKB_CB(skb)->tstamp = tstamp;
> + NETC_SKB_CB(skb)->ts_req_id = ts_req_id;
> + NETC_SKB_CB(skb)->ptp_flag = NETC_PTP_FLAG_ONESTEP;
> + NETC_SKB_CB(dummy_skb)->ts_req_id = ts_req_id;
> + NETC_SKB_CB(dummy_skb)->ptp_tx_time = jiffies_64;
[Severity: Medium]
Is it safe to read jiffies_64 directly here? On 32-bit architectures, a
direct read of this 64-bit variable performs two 32-bit loads without
synchronization.
If a timer tick updates jiffies_64 between the two loads, the read value
can tear and jump forward or backward significantly. Should this use
get_jiffies_64() to safely capture the transmit time?
> + NETC_SKB_CB(dummy_skb)->ptp_flag = NETC_PTP_FLAG_ONESTEP;
> + np->onestep_tx_time = NETC_SKB_CB(dummy_skb)->ptp_tx_time;
> + np->onestep_ts_req_id = ts_req_id;
[ ... ]
> +static bool netc_onestep_timeout(struct netc_port *np)
> +{
> + u64 expire_time;
> +
> + /* Use monotonic jiffies_64, as the PHC may be stepped backwards.
> + * Add one tick since the ns-to-jiffies conversion rounds down, so
> + * the software window is never shorter than the hardware window.
> + */
> + expire_time = np->onestep_tx_time + 1 +
> + nsecs_to_jiffies64(NETC_ONESTEP_VALID_WINDOW);
> + if (np->onestep_state == NETC_ONESTEP_IN_FLIGHT &&
> + time_after64(jiffies_64, expire_time))
[Severity: Medium]
Does the direct evaluation of jiffies_64 here risk a torn read on 32-bit
systems?
A torn read during this check could cause massive premature timeouts (which
would incorrectly abort the in-flight state of one-step frames) or missed
timeouts that leak request IDs.
Could we use get_jiffies_64() instead, similar to how it is handled in
netc_port_prepare_twostep()?
> + return true;
> +
> + return false;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012095924.1129312-1-wei.fang@oss.nxp.com?part=9
next prev parent reply other threads:[~2026-10-13 9:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 9:59 [PATCH v5 net-next 0/9] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-10-12 9:59 ` [PATCH v5 net-next 1/9] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-10-12 9:59 ` [PATCH v5 net-next 2/9] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-10-12 9:59 ` [PATCH v5 net-next 3/9] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-10-12 9:59 ` [PATCH v5 net-next 4/9] net: dsa: netc: tie setup resources and reset to DSA setup/teardown wei.fang
2026-10-13 9:59 ` sashiko-bot
2026-10-14 2:23 ` Wei Fang (OSS)
2026-10-13 10:57 ` netdev-bot+sashiko
2026-10-14 6:44 ` Wei Fang (OSS)
2026-10-12 9:59 ` [PATCH v5 net-next 5/9] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-10-13 9:59 ` sashiko-bot
2026-10-14 6:26 ` Wei Fang (OSS)
2026-10-12 9:59 ` [PATCH v5 net-next 6/9] net: dsa: netc: check return value of ntmp_ipft_delete_entry() wei.fang
2026-10-13 10:57 ` netdev-bot+sashiko
2026-10-12 9:59 ` [PATCH v5 net-next 7/9] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-10-12 9:59 ` [PATCH v5 net-next 8/9] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-10-13 9:59 ` sashiko-bot
2026-10-13 10:57 ` netdev-bot+sashiko
2026-10-12 9:59 ` [PATCH v5 net-next 9/9] net: dsa: netc: add PTP one-step " wei.fang
2026-10-13 9:59 ` sashiko-bot [this message]
2026-10-13 10:57 ` netdev-bot+sashiko
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=sashiko-outbox-169420@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