Patch "r8152: break the loop when the budget is exhausted" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    r8152: break the loop when the budget is exhausted

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     r8152-break-the-loop-when-the-budget-is-exhausted.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a0e946f97f11a8a84c9e284e3f5f3b45a61b9d85
Author: Hayes Wang <hayeswang@xxxxxxxxxxx>
Date:   Tue Sep 26 19:17:13 2023 +0800

    r8152: break the loop when the budget is exhausted
    
    [ Upstream commit 2cf51f931797d9a47e75d999d0993a68cbd2a560 ]
    
    A bulk transfer of the USB may contain many packets. And, the total
    number of the packets in the bulk transfer may be more than budget.
    
    Originally, only budget packets would be handled by napi_gro_receive(),
    and the other packets would be queued in the driver for next schedule.
    
    This patch would break the loop about getting next bulk transfer, when
    the budget is exhausted. That is, only the current bulk transfer would
    be handled, and the other bulk transfers would be queued for next
    schedule. Besides, the packets which are more than the budget in the
    current bulk trasnfer would be still queued in the driver, as the
    original method.
    
    In addition, a bulk transfer wouldn't contain more than 400 packets, so
    the check of queue length is unnecessary. Therefore, I replace it with
    WARN_ON_ONCE().
    
    Fixes: cf74eb5a5bc8 ("eth: r8152: try to use a normal budget")
    Signed-off-by: Hayes Wang <hayeswang@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230926111714.9448-433-nic_swsd@xxxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index afb20c0ed688d..be18d72cefcce 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2543,7 +2543,7 @@ static int rx_bottom(struct r8152 *tp, int budget)
 		}
 	}
 
-	if (list_empty(&tp->rx_done))
+	if (list_empty(&tp->rx_done) || work_done >= budget)
 		goto out1;
 
 	clear_bit(RX_EPROTO, &tp->flags);
@@ -2559,6 +2559,15 @@ static int rx_bottom(struct r8152 *tp, int budget)
 		struct urb *urb;
 		u8 *rx_data;
 
+		/* A bulk transfer of USB may contain may packets, so the
+		 * total packets may more than the budget. Deal with all
+		 * packets in current bulk transfer, and stop to handle the
+		 * next bulk transfer until next schedule, if budget is
+		 * exhausted.
+		 */
+		if (work_done >= budget)
+			break;
+
 		list_del_init(cursor);
 
 		agg = list_entry(cursor, struct rx_agg, list);
@@ -2578,9 +2587,7 @@ static int rx_bottom(struct r8152 *tp, int budget)
 			unsigned int pkt_len, rx_frag_head_sz;
 			struct sk_buff *skb;
 
-			/* limit the skb numbers for rx_queue */
-			if (unlikely(skb_queue_len(&tp->rx_queue) >= 1000))
-				break;
+			WARN_ON_ONCE(skb_queue_len(&tp->rx_queue) >= 1000);
 
 			pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK;
 			if (pkt_len < ETH_ZLEN)
@@ -2658,9 +2665,10 @@ static int rx_bottom(struct r8152 *tp, int budget)
 		}
 	}
 
+	/* Splice the remained list back to rx_done for next schedule */
 	if (!list_empty(&rx_queue)) {
 		spin_lock_irqsave(&tp->rx_lock, flags);
-		list_splice_tail(&rx_queue, &tp->rx_done);
+		list_splice(&rx_queue, &tp->rx_done);
 		spin_unlock_irqrestore(&tp->rx_lock, flags);
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux