bfe1c991bc348e7ef79ff34c3df168119f4911f8
[openwrt/staging/pepe2k.git] /
1 From 65b91d9a2af917b88d5381cd6a3d7bc92723c0f6 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] 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 | 13 ++++++++++++-
15 1 file changed, 12 insertions(+), 1 deletion(-)
16
17 --- a/drivers/net/usb/lan78xx.c
18 +++ b/drivers/net/usb/lan78xx.c
19 @@ -454,6 +454,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;
31 @@ -4148,7 +4153,13 @@ 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 +
43 maxp = usb_maxpacket(dev->udev, dev->pipe_intr, 0);
44 buf = kmalloc(maxp, GFP_KERNEL);
45 if (buf) {