Skip to content

Commit

Permalink
ibmvnic: Unmap DMA address of TX descriptor buffers after use
Browse files Browse the repository at this point in the history
There's no need to wait until a completion is received to unmap
TX descriptor buffers that have been passed to the hypervisor.
Instead unmap it when the hypervisor call has completed. This patch
avoids the possibility that a buffer will not be unmapped because
a TX completion is lost or mishandled.

Reported-by: Abdul Haleem <[email protected]>
Tested-by: Devesh K. Singh <[email protected]>
Signed-off-by: Thomas Falcon <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
tlfalcon authored and davem330 committed Aug 18, 2019
1 parent 37b0a73 commit 80f0fe0
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions drivers/net/ethernet/ibm/ibmvnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,8 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev)
lpar_rc = send_subcrq_indirect(adapter, handle_array[queue_num],
(u64)tx_buff->indir_dma,
(u64)num_entries);
dma_unmap_single(dev, tx_buff->indir_dma,
sizeof(tx_buff->indir_arr), DMA_TO_DEVICE);
} else {
tx_buff->num_entries = num_entries;
lpar_rc = send_subcrq(adapter, handle_array[queue_num],
Expand Down Expand Up @@ -2788,7 +2790,6 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,
union sub_crq *next;
int index;
int i, j;
u8 *first;

restart_loop:
while (pending_scrq(adapter, scrq)) {
Expand Down Expand Up @@ -2818,14 +2819,6 @@ static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter,

txbuff->data_dma[j] = 0;
}
/* if sub_crq was sent indirectly */
first = &txbuff->indir_arr[0].generic.first;
if (*first == IBMVNIC_CRQ_CMD) {
dma_unmap_single(dev, txbuff->indir_dma,
sizeof(txbuff->indir_arr),
DMA_TO_DEVICE);
*first = 0;
}

if (txbuff->last_frag) {
dev_kfree_skb_any(txbuff->skb);
Expand Down

0 comments on commit 80f0fe0

Please sign in to comment.