aba96e45500a15993d74a05be66bb5867b32f3d5
[openwrt/staging/981213.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 @@ -426,6 +426,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 @@ -3735,7 +3740,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);