bff441c5e0e50a80c3809c6f5377a6d46e84f31f
[openwrt/staging/luka.git] /
1 From 020ee4d0d438b830ee40da8d9d3414de156a11e7 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 298/806] 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 @@ -448,6 +448,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 @@ -3824,7 +3829,12 @@ static int lan78xx_probe(struct usb_inte
32 dev->pipe_intr = usb_rcvintpipe(dev->udev,
33 dev->ep_intr->desc.bEndpointAddress &
34 USB_ENDPOINT_NUMBER_MASK);
35 - period = dev->ep_intr->desc.bInterval;
36 + if (int_urb_interval_ms <= 0)
37 + period = dev->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);