Skip to content

Commit 4e1ad31

Browse files
author
Paolo Abeni
committed
Merge branch 'ena-driver-bug-fixes'
David Arinzon says: ==================== ENA driver bug fixes From: David Arinzon <[email protected]> This patchset contains multiple bug fixes for the ENA driver. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents fe3eb40 + 36a1ca0 commit 4e1ad31

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
351351
ENA_COM_BOUNCE_BUFFER_CNTRL_CNT;
352352
io_sq->bounce_buf_ctrl.next_to_use = 0;
353353

354-
size = io_sq->bounce_buf_ctrl.buffer_size *
354+
size = (size_t)io_sq->bounce_buf_ctrl.buffer_size *
355355
io_sq->bounce_buf_ctrl.buffers_num;
356356

357357
dev_node = dev_to_node(ena_dev->dmadev);

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,11 @@ void ena_unmap_tx_buff(struct ena_ring *tx_ring,
718718
static void ena_free_tx_bufs(struct ena_ring *tx_ring)
719719
{
720720
bool print_once = true;
721+
bool is_xdp_ring;
721722
u32 i;
722723

724+
is_xdp_ring = ENA_IS_XDP_INDEX(tx_ring->adapter, tx_ring->qid);
725+
723726
for (i = 0; i < tx_ring->ring_size; i++) {
724727
struct ena_tx_buffer *tx_info = &tx_ring->tx_buffer_info[i];
725728

@@ -739,10 +742,15 @@ static void ena_free_tx_bufs(struct ena_ring *tx_ring)
739742

740743
ena_unmap_tx_buff(tx_ring, tx_info);
741744

742-
dev_kfree_skb_any(tx_info->skb);
745+
if (is_xdp_ring)
746+
xdp_return_frame(tx_info->xdpf);
747+
else
748+
dev_kfree_skb_any(tx_info->skb);
743749
}
744-
netdev_tx_reset_queue(netdev_get_tx_queue(tx_ring->netdev,
745-
tx_ring->qid));
750+
751+
if (!is_xdp_ring)
752+
netdev_tx_reset_queue(netdev_get_tx_queue(tx_ring->netdev,
753+
tx_ring->qid));
746754
}
747755

748756
static void ena_free_all_tx_bufs(struct ena_adapter *adapter)
@@ -3481,10 +3489,11 @@ static void check_for_missing_completions(struct ena_adapter *adapter)
34813489
{
34823490
struct ena_ring *tx_ring;
34833491
struct ena_ring *rx_ring;
3484-
int i, budget, rc;
3492+
int qid, budget, rc;
34853493
int io_queue_count;
34863494

34873495
io_queue_count = adapter->xdp_num_queues + adapter->num_io_queues;
3496+
34883497
/* Make sure the driver doesn't turn the device in other process */
34893498
smp_rmb();
34903499

@@ -3497,27 +3506,29 @@ static void check_for_missing_completions(struct ena_adapter *adapter)
34973506
if (adapter->missing_tx_completion_to == ENA_HW_HINTS_NO_TIMEOUT)
34983507
return;
34993508

3500-
budget = ENA_MONITORED_TX_QUEUES;
3509+
budget = min_t(u32, io_queue_count, ENA_MONITORED_TX_QUEUES);
35013510

3502-
for (i = adapter->last_monitored_tx_qid; i < io_queue_count; i++) {
3503-
tx_ring = &adapter->tx_ring[i];
3504-
rx_ring = &adapter->rx_ring[i];
3511+
qid = adapter->last_monitored_tx_qid;
3512+
3513+
while (budget) {
3514+
qid = (qid + 1) % io_queue_count;
3515+
3516+
tx_ring = &adapter->tx_ring[qid];
3517+
rx_ring = &adapter->rx_ring[qid];
35053518

35063519
rc = check_missing_comp_in_tx_queue(adapter, tx_ring);
35073520
if (unlikely(rc))
35083521
return;
35093522

3510-
rc = !ENA_IS_XDP_INDEX(adapter, i) ?
3523+
rc = !ENA_IS_XDP_INDEX(adapter, qid) ?
35113524
check_for_rx_interrupt_queue(adapter, rx_ring) : 0;
35123525
if (unlikely(rc))
35133526
return;
35143527

35153528
budget--;
3516-
if (!budget)
3517-
break;
35183529
}
35193530

3520-
adapter->last_monitored_tx_qid = i % io_queue_count;
3531+
adapter->last_monitored_tx_qid = qid;
35213532
}
35223533

35233534
/* trigger napi schedule after 2 consecutive detections */

drivers/net/ethernet/amazon/ena/ena_xdp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int ena_xdp_xmit_frame(struct ena_ring *tx_ring,
8989

9090
rc = ena_xdp_tx_map_frame(tx_ring, tx_info, xdpf, &ena_tx_ctx);
9191
if (unlikely(rc))
92-
return rc;
92+
goto err;
9393

9494
ena_tx_ctx.req_id = req_id;
9595

@@ -112,7 +112,9 @@ int ena_xdp_xmit_frame(struct ena_ring *tx_ring,
112112

113113
error_unmap_dma:
114114
ena_unmap_tx_buff(tx_ring, tx_info);
115+
err:
115116
tx_info->xdpf = NULL;
117+
116118
return rc;
117119
}
118120

0 commit comments

Comments
 (0)