]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gve: Fixes for napi_poll when budget is 0
authorZiwei Xiao <ziweixiao@google.com>
Tue, 14 Nov 2023 00:41:44 +0000 (16:41 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:54:53 +0000 (19:54 +0100)
commit 278a370c1766060d2144d6cf0b06c101e1043b6d upstream.

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: f5cedc84a30d ("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>
Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com>
Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/google/gve/gve_main.c
drivers/net/ethernet/google/gve/gve_rx.c
drivers/net/ethernet/google/gve/gve_tx.c

index d3f6ad586ba1be089958ea0e22640417878e5051..8771ccfc69b4249f9d3e19a725b3afe5a67306ac 100644 (file)
@@ -202,6 +202,10 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
 
        if (block->tx)
                reschedule |= gve_tx_poll(block, budget);
+
+       if (!budget)
+               return 0;
+
        if (block->rx) {
                work_done = gve_rx_poll(block, budget);
                reschedule |= work_done == budget;
@@ -242,6 +246,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;
index 021bbf308d685c40567e7b34fdeb69c1c755df21..639eb6848c7daa58b60a420581d34f9fb8a5846b 100644 (file)
@@ -778,10 +778,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);
 
index 5e11b823675454ab4f3c63951c80e3da4f45cec5..bf1ac0d1dc6f2c44a5c8d88e8bfb224c1747e64b 100644 (file)
@@ -725,10 +725,6 @@ bool gve_tx_poll(struct gve_notify_block *block, int budget)
        u32 nic_done;
        u32 to_do;
 
-       /* If budget is 0, do all the work */
-       if (budget == 0)
-               budget = INT_MAX;
-
        /* In TX path, it may try to clean completed pkts in order to xmit,
         * to avoid cleaning conflict, use spin_lock(), it yields better
         * concurrency between xmit/clean than netif's lock.