Skip to content

Commit

Permalink
mt76: add unlikely() for dma_mapping_error() check
Browse files Browse the repository at this point in the history
In the tx/rx fastpath, the funciton dma_map_single() rarely fails.
This adds unlikely() optimization to this error check conditional.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
ryderlee1110 authored and nbd168 committed Apr 25, 2019
1 parent 334b4ce commit edb2a00
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ mt76_dma_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid,

addr = dma_map_single(dev->dev, skb->data, skb->len,
DMA_TO_DEVICE);
if (dma_mapping_error(dev->dev, addr))
if (unlikely(dma_mapping_error(dev->dev, addr)))
return -ENOMEM;

buf.addr = addr;
Expand Down Expand Up @@ -307,7 +307,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,

len = skb_headlen(skb);
addr = dma_map_single(dev->dev, skb->data, len, DMA_TO_DEVICE);
if (dma_mapping_error(dev->dev, addr))
if (unlikely(dma_mapping_error(dev->dev, addr)))
goto free;

tx_info.buf[n].addr = t->dma_addr;
Expand All @@ -321,7 +321,7 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,

addr = dma_map_single(dev->dev, iter->data, iter->len,
DMA_TO_DEVICE);
if (dma_mapping_error(dev->dev, addr))
if (unlikely(dma_mapping_error(dev->dev, addr)))
goto unmap;

tx_info.buf[n].addr = addr;
Expand Down Expand Up @@ -379,7 +379,7 @@ mt76_dma_rx_fill(struct mt76_dev *dev, struct mt76_queue *q)
break;

addr = dma_map_single(dev->dev, buf, len, DMA_FROM_DEVICE);
if (dma_mapping_error(dev->dev, addr)) {
if (unlikely(dma_mapping_error(dev->dev, addr))) {
skb_free_frag(buf);
break;
}
Expand Down

0 comments on commit edb2a00

Please sign in to comment.