提交 f3a0d0d2 编写于 作者: N Netanel Belgazal 提交者: Yang Yingliang

net: ena: fix napi handler misbehavior when the napi budget is zero

[ Upstream commit 24dee0c7478d1a1e00abdf5625b7f921467325dc ]

In netpoll the napi handler could be called with budget equal to zero.
Current ENA napi handler doesn't take that into consideration.

The napi handler handles Rx packets in a do-while loop.
Currently, the budget check happens only after decrementing the
budget, therefore the napi handler, in rare cases, could run over
MAX_INT packets.

In addition to that, this moves all budget related variables to int
calculation and stop mixing u32 to avoid ambiguity

Fixes: 1738cd3e ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: NNetanel Belgazal <netanel@amazon.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 8754f6bf
...@@ -1197,8 +1197,8 @@ static int ena_io_poll(struct napi_struct *napi, int budget) ...@@ -1197,8 +1197,8 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi); struct ena_napi *ena_napi = container_of(napi, struct ena_napi, napi);
struct ena_ring *tx_ring, *rx_ring; struct ena_ring *tx_ring, *rx_ring;
u32 tx_work_done; int tx_work_done;
u32 rx_work_done; int rx_work_done = 0;
int tx_budget; int tx_budget;
int napi_comp_call = 0; int napi_comp_call = 0;
int ret; int ret;
...@@ -1215,7 +1215,11 @@ static int ena_io_poll(struct napi_struct *napi, int budget) ...@@ -1215,7 +1215,11 @@ static int ena_io_poll(struct napi_struct *napi, int budget)
} }
tx_work_done = ena_clean_tx_irq(tx_ring, tx_budget); tx_work_done = ena_clean_tx_irq(tx_ring, tx_budget);
rx_work_done = ena_clean_rx_irq(rx_ring, napi, budget); /* On netpoll the budget is zero and the handler should only clean the
* tx completions.
*/
if (likely(budget))
rx_work_done = ena_clean_rx_irq(rx_ring, napi, budget);
/* If the device is about to reset or down, avoid unmask /* If the device is about to reset or down, avoid unmask
* the interrupt and return 0 so NAPI won't reschedule * the interrupt and return 0 so NAPI won't reschedule
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册