mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 07:23:14 +00:00
net: mscc: ocelot: fix race condition with TX timestamping
The TX-timestampable skb is added late to the ocelot_port->tx_skbs. It
is in a race with the TX timestamp IRQ, which checks that queue trying
to match the timestamp with the skb by the ts_id. The skb should be
added to the queue before the IRQ can fire.
Fixes: 4e3b0468e6
("net: mscc: PTP Hardware Clock (PHC) support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5f6857e808
commit
9dda66acdd
@ -330,6 +330,7 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
u8 grp = 0; /* Send everything on CPU group 0 */
|
||||
unsigned int i, count, last;
|
||||
int port = priv->chip_port;
|
||||
bool do_tstamp;
|
||||
|
||||
val = ocelot_read(ocelot, QS_INJ_STATUS);
|
||||
if (!(val & QS_INJ_STATUS_FIFO_RDY(BIT(grp))) ||
|
||||
@ -344,10 +345,14 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
info.vid = skb_vlan_tag_get(skb);
|
||||
|
||||
/* Check if timestamping is needed */
|
||||
do_tstamp = (ocelot_port_add_txtstamp_skb(ocelot_port, skb) == 0);
|
||||
|
||||
if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP) {
|
||||
info.rew_op = ocelot_port->ptp_cmd;
|
||||
if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP)
|
||||
if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
|
||||
info.rew_op |= (ocelot_port->ts_id % 4) << 3;
|
||||
ocelot_port->ts_id++;
|
||||
}
|
||||
}
|
||||
|
||||
ocelot_gen_ifh(ifh, &info);
|
||||
@ -380,12 +385,9 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
dev->stats.tx_packets++;
|
||||
dev->stats.tx_bytes += skb->len;
|
||||
|
||||
if (!ocelot_port_add_txtstamp_skb(ocelot_port, skb)) {
|
||||
ocelot_port->ts_id++;
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
if (!do_tstamp)
|
||||
dev_kfree_skb_any(skb);
|
||||
|
||||
dev_kfree_skb_any(skb);
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user