From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, richardcochran@gmail.com,
vladimir.oltean@nxp.com, viro@zeniv.linux.org.uk,
atenart@kernel.org, quentin.schulz@bootlin.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] phy: mscc: Stop taking ts_lock for tx_queue and use its own lock
Date: Mon, 1 Sep 2025 11:19:44 +0100 [thread overview]
Message-ID: <dbc50956-4aa6-4484-be32-0b091d494bc1@linux.dev> (raw)
In-Reply-To: <20250901092304.1312787-1-horatiu.vultur@microchip.com>
On 01/09/2025 10:23, Horatiu Vultur wrote:
> When transmitting a PTP frame which is timestamp using 2 step, the
> following warning appears if CONFIG_PROVE_LOCKING is enabled:
> =============================
> [ BUG: Invalid wait context ]
> 6.17.0-rc1-00326-ge6160462704e #427 Not tainted
> -----------------------------
> ptp4l/119 is trying to lock:
> c2a44ed4 (&vsc8531->ts_lock){+.+.}-{3:3}, at: vsc85xx_txtstamp+0x50/0xac
> other info that might help us debug this:
> context-{4:4}
> 4 locks held by ptp4l/119:
> #0: c145f068 (rcu_read_lock_bh){....}-{1:2}, at: __dev_queue_xmit+0x58/0x1440
> #1: c29df974 (dev->qdisc_tx_busylock ?: &qdisc_tx_busylock){+...}-{2:2}, at: __dev_queue_xmit+0x5c4/0x1440
> #2: c2aaaad0 (_xmit_ETHER#2){+.-.}-{2:2}, at: sch_direct_xmit+0x108/0x350
> #3: c2aac170 (&lan966x->tx_lock){+.-.}-{2:2}, at: lan966x_port_xmit+0xd0/0x350
> stack backtrace:
> CPU: 0 UID: 0 PID: 119 Comm: ptp4l Not tainted 6.17.0-rc1-00326-ge6160462704e #427 NONE
> Hardware name: Generic DT based system
> Call trace:
> unwind_backtrace from show_stack+0x10/0x14
> show_stack from dump_stack_lvl+0x7c/0xac
> dump_stack_lvl from __lock_acquire+0x8e8/0x29dc
> __lock_acquire from lock_acquire+0x108/0x38c
> lock_acquire from __mutex_lock+0xb0/0xe78
> __mutex_lock from mutex_lock_nested+0x1c/0x24
> mutex_lock_nested from vsc85xx_txtstamp+0x50/0xac
> vsc85xx_txtstamp from lan966x_fdma_xmit+0xd8/0x3a8
> lan966x_fdma_xmit from lan966x_port_xmit+0x1bc/0x350
> lan966x_port_xmit from dev_hard_start_xmit+0xc8/0x2c0
> dev_hard_start_xmit from sch_direct_xmit+0x8c/0x350
> sch_direct_xmit from __dev_queue_xmit+0x680/0x1440
> __dev_queue_xmit from packet_sendmsg+0xfa4/0x1568
> packet_sendmsg from __sys_sendto+0x110/0x19c
> __sys_sendto from sys_send+0x18/0x20
> sys_send from ret_fast_syscall+0x0/0x1c
> Exception stack(0xf0b05fa8 to 0xf0b05ff0)
> 5fa0: 00000001 0000000e 0000000e 0004b47a 0000003a 00000000
> 5fc0: 00000001 0000000e 00000000 00000121 0004af58 00044874 00000000 00000000
> 5fe0: 00000001 bee9d420 00025a10 b6e75c7c
>
> So, instead of using the ts_lock for tx_queue, use the spinlock that
> skb_buff_head has.
>
> Fixes: 7d272e63e0979d ("net: phy: mscc: timestamping and PHC support")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
>
> ---
> v1->v2:
> - initialize tx_queue in ptp_probe
> - purge the tx_queue when the driver is removed or when TX timestamping
> is OFF
> ---
> drivers/net/phy/mscc/mscc_ptp.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/phy/mscc/mscc_ptp.c b/drivers/net/phy/mscc/mscc_ptp.c
> index 72847320cb652..e866a1d865f8b 100644
> --- a/drivers/net/phy/mscc/mscc_ptp.c
> +++ b/drivers/net/phy/mscc/mscc_ptp.c
> @@ -461,7 +461,7 @@ static void vsc85xx_dequeue_skb(struct vsc85xx_ptp *ptp)
> return;
>
> while (len--) {
> - skb = __skb_dequeue(&ptp->tx_queue);
> + skb = skb_dequeue(&ptp->tx_queue);
Now as you switched to use spinlock of tx_queue, it is technically
correct to change skb_queue_len(&ptp->tx_queue) to
skb_queue_len_lockless(&ptp->tx_queue) a couple of lines above this
chunk.
Otherwise LGTM, once skb_queue_len fixed you can add
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Thanks!
> if (!skb)
> return;
>
> @@ -486,7 +486,7 @@ static void vsc85xx_dequeue_skb(struct vsc85xx_ptp *ptp)
> * packet in the FIFO right now, reschedule it for later
> * packets.
> */
> - __skb_queue_tail(&ptp->tx_queue, skb);
> + skb_queue_tail(&ptp->tx_queue, skb);
next prev parent reply other threads:[~2025-09-01 10:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 9:23 Horatiu Vultur
2025-09-01 10:19 ` Vadim Fedorenko [this message]
2025-09-02 6:50 ` Horatiu Vultur
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=dbc50956-4aa6-4484-be32-0b091d494bc1@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quentin.schulz@bootlin.com \
--cc=richardcochran@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=vladimir.oltean@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
all inboxes | Powered by JetHome®