ba3927794fba189b02ecd5c038deffb857d6f718
[openwrt/openwrt.git] /
1 From 44c28420145101c846b445b8ae6159400909f69f Mon Sep 17 00:00:00 2001
2 From: Joshua Emele <jemele@acm.org>
3 Date: Wed, 7 Nov 2018 16:07:40 -0800
4 Subject: [PATCH 454/454] lan78xx: Debounce link events to minimize poll storm
5
6 The bInterval is set to 4 (i.e. 8 microframes => 1ms) and the only bit
7 that the driver pays attention to is "link was reset". If there's a
8 flapping status bit in that endpoint data, (such as if PHY negotiation
9 needs a few tries to get a stable link) then polling at a slower rate
10 would act as a de-bounce.
11
12 See: https://github.com/raspberrypi/linux/issues/2447
13 ---
14 drivers/net/usb/lan78xx.c | 12 +++++++++++-
15 1 file changed, 11 insertions(+), 1 deletion(-)
16
17 --- a/drivers/net/usb/lan78xx.c
18 +++ b/drivers/net/usb/lan78xx.c
19 @@ -422,6 +422,11 @@ static bool enable_tso;
20 module_param(enable_tso, bool, 0644);
21 MODULE_PARM_DESC(enable_tso, "Enables TCP segmentation offload");
22
23 +#define INT_URB_MICROFRAMES_PER_MS 8
24 +static int int_urb_interval_ms = 8;
25 +module_param(int_urb_interval_ms, int, 0);
26 +MODULE_PARM_DESC(int_urb_interval_ms, "Override usb interrupt urb interval");
27 +
28 static int lan78xx_read_reg(struct lan78xx_net *dev, u32 index, u32 *data)
29 {
30 u32 *buf = kmalloc(sizeof(u32), GFP_KERNEL);
31 @@ -3679,7 +3684,12 @@ static int lan78xx_probe(struct usb_inte
32 netdev->max_mtu = MAX_SINGLE_PACKET_SIZE;
33 netif_set_gso_max_size(netdev, MAX_SINGLE_PACKET_SIZE - MAX_HEADER);
34
35 - period = ep_intr->desc.bInterval;
36 + if (int_urb_interval_ms <= 0)
37 + period = ep_intr->desc.bInterval;
38 + else
39 + period = int_urb_interval_ms * INT_URB_MICROFRAMES_PER_MS;
40 +
41 + netif_notice(dev, probe, netdev, "int urb period %d\n", period);
42 maxp = usb_maxpacket(dev->udev, dev->pipe_intr, 0);
43 buf = kmalloc(maxp, GFP_KERNEL);
44 if (buf) {