]> git.baikalelectronics.ru Git - kernel.git/commit
enetc: fix locking for one-step timestamping packet transfer
authorYangbo Lu <yangbo.lu@nxp.com>
Fri, 23 Apr 2021 09:33:55 +0000 (17:33 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Apr 2021 20:52:30 +0000 (13:52 -0700)
commit2b7fb8780c1f892512205cac0c345a449c176fc0
tree44f3bdb810e0bd93cee77bcb92f64949155331ad
parent5b649f8ca9f6aa8a1d0d918744b649815c326431
enetc: fix locking for one-step timestamping packet transfer

The previous patch to support PTP Sync packet one-step timestamping
described one-step timestamping packet handling logic as below in
commit message:

- Trasmit packet immediately if no other one in transfer, or queue to
  skb queue if there is already one in transfer.
  The test_and_set_bit_lock() is used here to lock and check state.
- Start a work when complete transfer on hardware, to release the bit
  lock and to send one skb in skb queue if has.

There was not problem of the description, but there was a mistake in
implementation. The locking/test_and_set_bit_lock() should be put in
enetc_start_xmit() which may be called by worker, rather than in
enetc_xmit(). Otherwise, the worker calling enetc_start_xmit() after
bit lock released is not able to lock again for transfer.

Fixes: c063a2f3e240 ("enetc: support PTP Sync packet one-step timestamping")
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/enetc/enetc.c