Skip to content

Commit d5e3241

Browse files
Thomas-fourierkuba-moo
authored andcommitted
ethernet: ionic: Fix DMA mapping tests
Change error values of `ionic_tx_map_single()` and `ionic_tx_map_frag()` from 0 to `DMA_MAPPING_ERROR` to prevent collision with 0 as a valid address. This also fixes the use of `dma_mapping_error()` to test against 0 in `ionic_xdp_post_frame()` Fixes: 0f3154e ("ionic: Add Tx and Rx handling") Fixes: 56e41ee ("ionic: better dma-map error handling") Fixes: ac8813c ("ionic: convert Rx queue buffers to use page_pool") Signed-off-by: Thomas Fourier <[email protected]> Reviewed-by: Brett Creeley <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f599020 commit d5e3241

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/net/ethernet/pensando/ionic/ionic_txrx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
321321
len, DMA_TO_DEVICE);
322322
} else /* XDP_REDIRECT */ {
323323
dma_addr = ionic_tx_map_single(q, frame->data, len);
324-
if (!dma_addr)
324+
if (dma_addr == DMA_MAPPING_ERROR)
325325
return -EIO;
326326
}
327327

@@ -357,7 +357,7 @@ static int ionic_xdp_post_frame(struct ionic_queue *q, struct xdp_frame *frame,
357357
} else {
358358
dma_addr = ionic_tx_map_frag(q, frag, 0,
359359
skb_frag_size(frag));
360-
if (dma_mapping_error(q->dev, dma_addr)) {
360+
if (dma_addr == DMA_MAPPING_ERROR) {
361361
ionic_tx_desc_unmap_bufs(q, desc_info);
362362
return -EIO;
363363
}
@@ -1083,7 +1083,7 @@ static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
10831083
net_warn_ratelimited("%s: DMA single map failed on %s!\n",
10841084
dev_name(dev), q->name);
10851085
q_to_tx_stats(q)->dma_map_err++;
1086-
return 0;
1086+
return DMA_MAPPING_ERROR;
10871087
}
10881088
return dma_addr;
10891089
}
@@ -1100,7 +1100,7 @@ static dma_addr_t ionic_tx_map_frag(struct ionic_queue *q,
11001100
net_warn_ratelimited("%s: DMA frag map failed on %s!\n",
11011101
dev_name(dev), q->name);
11021102
q_to_tx_stats(q)->dma_map_err++;
1103-
return 0;
1103+
return DMA_MAPPING_ERROR;
11041104
}
11051105
return dma_addr;
11061106
}
@@ -1116,7 +1116,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
11161116
int frag_idx;
11171117

11181118
dma_addr = ionic_tx_map_single(q, skb->data, skb_headlen(skb));
1119-
if (!dma_addr)
1119+
if (dma_addr == DMA_MAPPING_ERROR)
11201120
return -EIO;
11211121
buf_info->dma_addr = dma_addr;
11221122
buf_info->len = skb_headlen(skb);
@@ -1126,7 +1126,7 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,
11261126
nfrags = skb_shinfo(skb)->nr_frags;
11271127
for (frag_idx = 0; frag_idx < nfrags; frag_idx++, frag++) {
11281128
dma_addr = ionic_tx_map_frag(q, frag, 0, skb_frag_size(frag));
1129-
if (!dma_addr)
1129+
if (dma_addr == DMA_MAPPING_ERROR)
11301130
goto dma_fail;
11311131
buf_info->dma_addr = dma_addr;
11321132
buf_info->len = skb_frag_size(frag);

0 commit comments

Comments
 (0)