Skip to content

Commit 350db8a

Browse files
shinas-marvelldavem330
authored andcommitted
octeon_ep: fix tx dma unmap len values in SG
Lengths of SG pointers are kept in the following order in the SG entries in hardware. 63 48|47 32|31 16|15 0 ----------------------------------------- | Len 0 | Len 1 | Len 2 | Len 3 | ----------------------------------------- | Ptr 0 | ----------------------------------------- | Ptr 1 | ----------------------------------------- | Ptr 2 | ----------------------------------------- | Ptr 3 | ----------------------------------------- Dma pointers have to be unmapped based on their respective lengths given in this format. Fixes: 37d79d0 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Shinas Rasheed <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e0b65f9 commit 350db8a

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,13 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb,
734734
dma_map_sg_err:
735735
if (si > 0) {
736736
dma_unmap_single(iq->dev, sglist[0].dma_ptr[0],
737-
sglist[0].len[0], DMA_TO_DEVICE);
738-
sglist[0].len[0] = 0;
737+
sglist[0].len[3], DMA_TO_DEVICE);
738+
sglist[0].len[3] = 0;
739739
}
740740
while (si > 1) {
741741
dma_unmap_page(iq->dev, sglist[si >> 2].dma_ptr[si & 3],
742-
sglist[si >> 2].len[si & 3], DMA_TO_DEVICE);
743-
sglist[si >> 2].len[si & 3] = 0;
742+
sglist[si >> 2].len[3 - (si & 3)], DMA_TO_DEVICE);
743+
sglist[si >> 2].len[3 - (si & 3)] = 0;
744744
si--;
745745
}
746746
tx_buffer->gather = 0;

drivers/net/ethernet/marvell/octeon_ep/octep_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget)
6969
compl_sg++;
7070

7171
dma_unmap_single(iq->dev, tx_buffer->sglist[0].dma_ptr[0],
72-
tx_buffer->sglist[0].len[0], DMA_TO_DEVICE);
72+
tx_buffer->sglist[0].len[3], DMA_TO_DEVICE);
7373

7474
i = 1; /* entry 0 is main skb, unmapped above */
7575
while (frags--) {
7676
dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3],
77-
tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE);
77+
tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE);
7878
i++;
7979
}
8080

@@ -131,13 +131,13 @@ static void octep_iq_free_pending(struct octep_iq *iq)
131131

132132
dma_unmap_single(iq->dev,
133133
tx_buffer->sglist[0].dma_ptr[0],
134-
tx_buffer->sglist[0].len[0],
134+
tx_buffer->sglist[0].len[3],
135135
DMA_TO_DEVICE);
136136

137137
i = 1; /* entry 0 is main skb, unmapped above */
138138
while (frags--) {
139139
dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3],
140-
tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE);
140+
tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE);
141141
i++;
142142
}
143143

drivers/net/ethernet/marvell/octeon_ep/octep_tx.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@
1717
#define TX_BUFTYPE_NET_SG 2
1818
#define NUM_TX_BUFTYPES 3
1919

20-
/* Hardware format for Scatter/Gather list */
20+
/* Hardware format for Scatter/Gather list
21+
*
22+
* 63 48|47 32|31 16|15 0
23+
* -----------------------------------------
24+
* | Len 0 | Len 1 | Len 2 | Len 3 |
25+
* -----------------------------------------
26+
* | Ptr 0 |
27+
* -----------------------------------------
28+
* | Ptr 1 |
29+
* -----------------------------------------
30+
* | Ptr 2 |
31+
* -----------------------------------------
32+
* | Ptr 3 |
33+
* -----------------------------------------
34+
*/
2135
struct octep_tx_sglist_desc {
2236
u16 len[4];
2337
dma_addr_t dma_ptr[4];

0 commit comments

Comments
 (0)