From: Jacob Keller <jacob.e.keller@intel.com>
To: Jiawen Wu <jiawenwu@trustnetic.com>, <netdev@vger.kernel.org>
Cc: Mengyuan Lou <mengyuanlou@net-swift.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
Kees Cook <kees@kernel.org>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
"Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH net v2] net: libwx: fix races in Tx timestamp handling
Date: Tue, 15 Sep 2026 16:51:25 -0700 [thread overview]
Message-ID: <37ddac74-f30b-4143-966f-3c26cc9db323@intel.com> (raw)
In-Reply-To: <73D0D3F5D96A6928+20260914080020.211580-1-jiawenwu@trustnetic.com>
On 9/14/2026 1:00 AM, Jiawen Wu wrote:
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index ed5aad7857bd..940ba2c6150f 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -1677,19 +1682,34 @@ static netdev_tx_t wx_xmit_frame_ring(struct sk_buff *skb,
> wx->atr(tx_ring, first, ptype);
>
> if (wx_tx_map(tx_ring, first, hdr_len))
> - goto cleanup_tx_tstamp;
> + goto out_drop;
>
> return NETDEV_TX_OK;
> out_drop:
> - dev_kfree_skb_any(first->skb);
> - first->skb = NULL;
> -cleanup_tx_tstamp:
> + /* The hardware will never report a timestamp for a frame it did not
> + * transmit, so drop the request. Only do so if it is still ours: the
> + * PTP worker may already have completed it and a concurrent transmit
> + * may have submitted a new one.
> + */
Could you explain this a bit more? The hardware doesn't report a
timestamp if the frame didn't transmit.. but you say here the PTP worker
may have already cleaned this up? How goes that work here? I guess
clean_tx_tstamp label may execute even if the timestamp has actually
happened and already completed? I'm not quite following this logic.
> if (unlikely(tx_flags & WX_TX_FLAGS_TSTAMP)) {
> - dev_kfree_skb_any(wx->ptp_tx_skb);
> - wx->ptp_tx_skb = NULL;
> - wx->tx_hwtstamp_errors++;
> - clear_bit_unlock(WX_STATE_PTP_TX_IN_PROGRESS, wx->state);
> + struct sk_buff *ptp_tx_skb = NULL;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&wx->ptp_tx_lock, flags);
> + if (wx->ptp_tx_skb == skb) {
> + ptp_tx_skb = wx->ptp_tx_skb;
> + wx->ptp_tx_skb = NULL;
> + clear_bit(WX_STATE_PTP_TX_IN_PROGRESS, wx->state);
> + }
> + spin_unlock_irqrestore(&wx->ptp_tx_lock, flags);
> +
> + if (ptp_tx_skb) {
> + dev_kfree_skb_any(ptp_tx_skb);
> + wx->tx_hwtstamp_errors++;
> + }
> }
> + dev_kfree_skb_any(first->skb);
> + first->skb = NULL;
>
> return NETDEV_TX_OK;
> }
next prev parent reply other threads:[~2026-09-15 23:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 8:00 [PATCH net v2] net: libwx: fix races in Tx timestamp handling Jiawen Wu
2026-09-15 23:51 ` Jacob Keller [this message]
2026-09-16 2:33 ` Jiawen Wu
2026-09-17 20:02 ` 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=37ddac74-f30b-4143-966f-3c26cc9db323@intel.com \
--to=jacob.e.keller@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiawenwu@trustnetic.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sashiko-bot@kernel.org \
--cc=vadim.fedorenko@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