Commit 9f11a0a
net: mvpp2: fix dma unmapping of TX buffers for fragments
commit 8354491c9d5b06709384cea91d13019bf5e61449 upstream.
Since commit 71ce391 ("net: mvpp2: enable proper per-CPU TX
buffers unmapping"), we are not correctly DMA unmapping TX buffers for
fragments.
Indeed, the mvpp2_txq_inc_put() function only stores in the
txq_cpu->tx_buffs[] array the physical address of the buffer to be
DMA-unmapped when skb != NULL. In addition, when DMA-unmapping, we use
skb_headlen(skb) to get the size to be unmapped. Both of this works fine
for TX descriptors that are associated directly to a SKB, but not the
ones that are used for fragments, with a NULL pointer as skb:
- We have a NULL physical address when calling DMA unmap
- skb_headlen(skb) crashes because skb is NULL
This causes random crashes when fragments are used.
To solve this problem, we need to:
- Store the physical address of the buffer to be unmapped
unconditionally, regardless of whether it is tied to a SKB or not.
- Store the length of the buffer to be unmapped, which requires a new
field.
Instead of adding a third array to store the length of the buffer to be
unmapped, and as suggested by David Miller, this commit refactors the
tx_buffs[] and tx_skb[] arrays of 'struct mvpp2_txq_pcpu' into a
separate structure 'mvpp2_txq_pcpu_buf', to which a 'size' field is
added. Therefore, instead of having three arrays to allocate/free, we
have a single one, which also improve data locality, reducing the
impact on the CPU cache.
Fixes: 71ce391 ("net: mvpp2: enable proper per-CPU TX buffers unmapping")
Reported-by: Raphael G <raphael.glon@corp.ovh.com>
Cc: Raphael G <raphael.glon@corp.ovh.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent d857273 commit 9f11a0a
1 file changed
Lines changed: 30 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
775 | 786 | | |
776 | 787 | | |
777 | 788 | | |
| |||
787 | 798 | | |
788 | 799 | | |
789 | 800 | | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
| 801 | + | |
| 802 | + | |
795 | 803 | | |
796 | 804 | | |
797 | 805 | | |
| |||
981 | 989 | | |
982 | 990 | | |
983 | 991 | | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
988 | 997 | | |
989 | 998 | | |
990 | 999 | | |
| |||
4403 | 4412 | | |
4404 | 4413 | | |
4405 | 4414 | | |
4406 | | - | |
4407 | | - | |
4408 | | - | |
| 4415 | + | |
| 4416 | + | |
4409 | 4417 | | |
4410 | 4418 | | |
4411 | 4419 | | |
4412 | | - | |
4413 | | - | |
4414 | | - | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
4415 | 4423 | | |
4416 | | - | |
| 4424 | + | |
4417 | 4425 | | |
4418 | 4426 | | |
4419 | 4427 | | |
| |||
4664 | 4672 | | |
4665 | 4673 | | |
4666 | 4674 | | |
4667 | | - | |
4668 | | - | |
4669 | | - | |
4670 | | - | |
4671 | | - | |
4672 | | - | |
4673 | | - | |
4674 | | - | |
4675 | | - | |
| 4675 | + | |
| 4676 | + | |
| 4677 | + | |
| 4678 | + | |
4676 | 4679 | | |
4677 | 4680 | | |
4678 | 4681 | | |
| |||
4686 | 4689 | | |
4687 | 4690 | | |
4688 | 4691 | | |
4689 | | - | |
4690 | | - | |
| 4692 | + | |
4691 | 4693 | | |
4692 | 4694 | | |
4693 | 4695 | | |
| |||
4706 | 4708 | | |
4707 | 4709 | | |
4708 | 4710 | | |
4709 | | - | |
4710 | | - | |
| 4711 | + | |
4711 | 4712 | | |
4712 | 4713 | | |
4713 | 4714 | | |
| |||
0 commit comments