Commit 922b4b9
net: renesas: rswitch: rework ts tags management
The existing linked list based implementation of how ts tags are
assigned and managed is unsafe against concurrency and corner cases:
- element addition in tx processing can race against element removal
in ts queue completion,
- element removal in ts queue completion can race against element
removal in device close,
- if a large number of frames gets added to tx queue without ts queue
completions in between, elements with duplicate tag values can get
added.
Use a different implementation, based on per-port used tags bitmaps and
saved skb arrays.
Safety for addition in tx processing vs removal in ts completion is
provided by:
tag = find_first_zero_bit(...);
smp_mb();
<write rdev->ts_skb[tag]>
set_bit(...);
vs
<read rdev->ts_skb[tag]>
smp_mb();
clear_bit(...);
Safety for removal in ts completion vs removal in device close is
provided by using atomic read-and-clear for rdev->ts_skb[tag]:
ts_skb = xchg(&rdev->ts_skb[tag], NULL);
if (ts_skb)
<handle it>
Fixes: 33f5d73 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Link: https://patch.msgid.link/20241212062558.436455-1-nikita.yoush@cogentembedded.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent cb85f2b commit 922b4b9
2 files changed
+42
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
551 | 550 | | |
552 | 551 | | |
553 | 552 | | |
| |||
1003 | 1002 | | |
1004 | 1003 | | |
1005 | 1004 | | |
1006 | | - | |
1007 | 1005 | | |
1008 | 1006 | | |
| 1007 | + | |
| 1008 | + | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
| |||
1015 | 1015 | | |
1016 | 1016 | | |
1017 | 1017 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1034 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1035 | 1040 | | |
1036 | 1041 | | |
1037 | 1042 | | |
| |||
1576 | 1581 | | |
1577 | 1582 | | |
1578 | 1583 | | |
1579 | | - | |
| 1584 | + | |
1580 | 1585 | | |
| 1586 | + | |
1581 | 1587 | | |
1582 | 1588 | | |
1583 | 1589 | | |
| |||
1594 | 1600 | | |
1595 | 1601 | | |
1596 | 1602 | | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
1603 | 1610 | | |
1604 | 1611 | | |
1605 | 1612 | | |
| |||
1612 | 1619 | | |
1613 | 1620 | | |
1614 | 1621 | | |
1615 | | - | |
| 1622 | + | |
1616 | 1623 | | |
1617 | | - | |
1618 | | - | |
| 1624 | + | |
| 1625 | + | |
1619 | 1626 | | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1620 | 1630 | | |
1621 | 1631 | | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
1625 | | - | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
| 1632 | + | |
1629 | 1633 | | |
1630 | 1634 | | |
1631 | 1635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | | - | |
983 | 975 | | |
984 | 976 | | |
985 | 977 | | |
| |||
989 | 981 | | |
990 | 982 | | |
991 | 983 | | |
992 | | - | |
993 | 984 | | |
994 | 985 | | |
995 | 986 | | |
996 | 987 | | |
997 | 988 | | |
998 | 989 | | |
999 | 990 | | |
| 991 | + | |
1000 | 992 | | |
1001 | 993 | | |
1002 | 994 | | |
1003 | 995 | | |
1004 | 996 | | |
1005 | 997 | | |
1006 | 998 | | |
1007 | | - | |
| 999 | + | |
| 1000 | + | |
1008 | 1001 | | |
1009 | 1002 | | |
1010 | 1003 | | |
| |||
0 commit comments