a4fa444f9a43fc938646f0a6c4cc45d1c9c48e3d
[openwrt/staging/mkresin.git] /
1 From a242ba451fd64f0b9f07605ff0d8f6981aa6e955 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 @@ -434,6 +434,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 @@ -3768,7 +3773,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) {