Skip to content

Commit 5b40d10

Browse files
committed
Merge branch 'ena-fixes'
Arthur Kiyanovski says: ==================== ENA driver bug fixes Patchset V2 chages: ------------------- Updated SHA1 of Fixes tag in patch 3/3 to be 12 digits long Original cover letter: ---------------------- ENA driver bug fixes ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ae81de7 + 5055dc0 commit 5b40d10

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

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

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,26 +1288,22 @@ static int handle_invalid_req_id(struct ena_ring *ring, u16 req_id,
12881288

12891289
static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id)
12901290
{
1291-
struct ena_tx_buffer *tx_info = NULL;
1291+
struct ena_tx_buffer *tx_info;
12921292

1293-
if (likely(req_id < tx_ring->ring_size)) {
1294-
tx_info = &tx_ring->tx_buffer_info[req_id];
1295-
if (likely(tx_info->skb))
1296-
return 0;
1297-
}
1293+
tx_info = &tx_ring->tx_buffer_info[req_id];
1294+
if (likely(tx_info->skb))
1295+
return 0;
12981296

12991297
return handle_invalid_req_id(tx_ring, req_id, tx_info, false);
13001298
}
13011299

13021300
static int validate_xdp_req_id(struct ena_ring *xdp_ring, u16 req_id)
13031301
{
1304-
struct ena_tx_buffer *tx_info = NULL;
1302+
struct ena_tx_buffer *tx_info;
13051303

1306-
if (likely(req_id < xdp_ring->ring_size)) {
1307-
tx_info = &xdp_ring->tx_buffer_info[req_id];
1308-
if (likely(tx_info->xdpf))
1309-
return 0;
1310-
}
1304+
tx_info = &xdp_ring->tx_buffer_info[req_id];
1305+
if (likely(tx_info->xdpf))
1306+
return 0;
13111307

13121308
return handle_invalid_req_id(xdp_ring, req_id, tx_info, true);
13131309
}
@@ -1332,9 +1328,14 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
13321328

13331329
rc = ena_com_tx_comp_req_id_get(tx_ring->ena_com_io_cq,
13341330
&req_id);
1335-
if (rc)
1331+
if (rc) {
1332+
if (unlikely(rc == -EINVAL))
1333+
handle_invalid_req_id(tx_ring, req_id, NULL,
1334+
false);
13361335
break;
1336+
}
13371337

1338+
/* validate that the request id points to a valid skb */
13381339
rc = validate_tx_req_id(tx_ring, req_id);
13391340
if (rc)
13401341
break;
@@ -1427,6 +1428,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
14271428
u16 *next_to_clean)
14281429
{
14291430
struct ena_rx_buffer *rx_info;
1431+
struct ena_adapter *adapter;
14301432
u16 len, req_id, buf = 0;
14311433
struct sk_buff *skb;
14321434
void *page_addr;
@@ -1439,8 +1441,14 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
14391441
rx_info = &rx_ring->rx_buffer_info[req_id];
14401442

14411443
if (unlikely(!rx_info->page)) {
1442-
netif_err(rx_ring->adapter, rx_err, rx_ring->netdev,
1443-
"Page is NULL\n");
1444+
adapter = rx_ring->adapter;
1445+
netif_err(adapter, rx_err, rx_ring->netdev,
1446+
"Page is NULL. qid %u req_id %u\n", rx_ring->qid, req_id);
1447+
ena_increase_stat(&rx_ring->rx_stats.bad_req_id, 1, &rx_ring->syncp);
1448+
adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID;
1449+
/* Make sure reset reason is set before triggering the reset */
1450+
smp_mb__before_atomic();
1451+
set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
14441452
return NULL;
14451453
}
14461454

@@ -1896,9 +1904,14 @@ static int ena_clean_xdp_irq(struct ena_ring *xdp_ring, u32 budget)
18961904

18971905
rc = ena_com_tx_comp_req_id_get(xdp_ring->ena_com_io_cq,
18981906
&req_id);
1899-
if (rc)
1907+
if (rc) {
1908+
if (unlikely(rc == -EINVAL))
1909+
handle_invalid_req_id(xdp_ring, req_id, NULL,
1910+
true);
19001911
break;
1912+
}
19011913

1914+
/* validate that the request id points to a valid xdp_frame */
19021915
rc = validate_xdp_req_id(xdp_ring, req_id);
19031916
if (rc)
19041917
break;
@@ -4013,10 +4026,6 @@ static u32 ena_calc_max_io_queue_num(struct pci_dev *pdev,
40134026
max_num_io_queues = min_t(u32, max_num_io_queues, io_tx_cq_num);
40144027
/* 1 IRQ for mgmnt and 1 IRQs for each IO direction */
40154028
max_num_io_queues = min_t(u32, max_num_io_queues, pci_msix_vec_count(pdev) - 1);
4016-
if (unlikely(!max_num_io_queues)) {
4017-
dev_err(&pdev->dev, "The device doesn't have io queues\n");
4018-
return -EFAULT;
4019-
}
40204029

40214030
return max_num_io_queues;
40224031
}

0 commit comments

Comments
 (0)