Skip to content

Commit 0ec3b6a

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: fix for not unmapping TX buffer correctly
When a big TX buffer is sent using multi BD, the driver maps the whole TX buffer, and unmaps it using info in desc_cb corresponding to each BD, but only the info in the desc_cb of first BD is correct, other info in desc_cb is wrong, which causes TX unmapping problem when SMMU is on. Only set the mapping and freeing info in the desc_cb of first BD to fix this problem, because the TX buffer only need to be unmapped and freed once. Fixes: 1e8a797("net: hns3: add handling for big TX fragment") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Huzhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b0a4227 commit 0ec3b6a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,12 +1118,12 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11181118
return -ENOMEM;
11191119
}
11201120

1121+
desc_cb->priv = priv;
11211122
desc_cb->length = size;
1123+
desc_cb->dma = dma;
1124+
desc_cb->type = type;
11221125

11231126
if (likely(size <= HNS3_MAX_BD_SIZE)) {
1124-
desc_cb->priv = priv;
1125-
desc_cb->dma = dma;
1126-
desc_cb->type = type;
11271127
desc->addr = cpu_to_le64(dma);
11281128
desc->tx.send_size = cpu_to_le16(size);
11291129
desc->tx.bdtp_fe_sc_vld_ra_ri =
@@ -1140,13 +1140,6 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11401140

11411141
/* When frag size is bigger than hardware limit, split this frag */
11421142
for (k = 0; k < frag_buf_num; k++) {
1143-
/* The txbd's baseinfo of DESC_TYPE_PAGE & DESC_TYPE_SKB */
1144-
desc_cb->priv = priv;
1145-
desc_cb->dma = dma + HNS3_MAX_BD_SIZE * k;
1146-
desc_cb->type = ((type == DESC_TYPE_FRAGLIST_SKB ||
1147-
type == DESC_TYPE_SKB) && !k) ?
1148-
type : DESC_TYPE_PAGE;
1149-
11501143
/* now, fill the descriptor */
11511144
desc->addr = cpu_to_le64(dma + HNS3_MAX_BD_SIZE * k);
11521145
desc->tx.send_size = cpu_to_le16((k == frag_buf_num - 1) ?
@@ -1158,7 +1151,6 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
11581151
/* move ring pointer to next */
11591152
ring_ptr_move_fw(ring, next_to_use);
11601153

1161-
desc_cb = &ring->desc_cb[ring->next_to_use];
11621154
desc = &ring->desc[ring->next_to_use];
11631155
}
11641156

0 commit comments

Comments
 (0)