Skip to content

Commit

Permalink
gve: Fixes for napi_poll when budget is 0
Browse files Browse the repository at this point in the history
[ Upstream commit 278a370 ]

Netpoll will explicilty pass the polling call with a budget of 0 to
indicate it's clearing the Tx path only. For the gve_rx_poll and
gve_xdp_poll, they were mistakenly taking the 0 budget as the indication
to do all the work. Add check to avoid the rx path and xdp path being
called when budget is 0. And also avoid napi_complete_done being called
when budget is 0 for netpoll.

Fixes: f5cedc8 ("gve: Add transmit and receive support")
Signed-off-by: Ziwei Xiao <ziweixiao@google.com>
Link: https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ziweixiao authored and gregkh committed Nov 28, 2023
1 parent cb9e450 commit a533c97
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 7 additions & 1 deletion drivers/net/ethernet/google/gve/gve_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
if (block->tx) {
if (block->tx->q_num < priv->tx_cfg.num_queues)
reschedule |= gve_tx_poll(block, budget);
else
else if (budget)
reschedule |= gve_xdp_poll(block, budget);
}

if (!budget)
return 0;

if (block->rx) {
work_done = gve_rx_poll(block, budget);
reschedule |= work_done == budget;
Expand Down Expand Up @@ -299,6 +302,9 @@ static int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
if (block->tx)
reschedule |= gve_tx_poll_dqo(block, /*do_clean=*/true);

if (!budget)
return 0;

if (block->rx) {
work_done = gve_rx_poll_dqo(block, budget);
reschedule |= work_done == budget;
Expand Down
4 changes: 0 additions & 4 deletions drivers/net/ethernet/google/gve/gve_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,6 @@ int gve_rx_poll(struct gve_notify_block *block, int budget)

feat = block->napi.dev->features;

/* If budget is 0, do all the work */
if (budget == 0)
budget = INT_MAX;

if (budget > 0)
work_done = gve_clean_rx_done(rx, budget, feat);

Expand Down
4 changes: 0 additions & 4 deletions drivers/net/ethernet/google/gve/gve_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,10 +925,6 @@ bool gve_xdp_poll(struct gve_notify_block *block, int budget)
bool repoll;
u32 to_do;

/* If budget is 0, do all the work */
if (budget == 0)
budget = INT_MAX;

/* Find out how much work there is to be done */
nic_done = gve_tx_load_event_counter(priv, tx);
to_do = min_t(u32, (nic_done - tx->done), budget);
Expand Down

0 comments on commit a533c97

Please sign in to comment.