kernel: split 82574L patch into multiple files
[openwrt/staging/jow.git] / target / linux / generic / pending-4.9 / 190-5-5-e1000e-Avoid-receiver-overrun-interrupt-bursts.patch
1 From patchwork Fri Jul 21 18:36:27 2017
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: [5/5] e1000e: Avoid receiver overrun interrupt bursts
6 From: Benjamin Poirier <bpoirier@suse.com>
7 X-Patchwork-Id: 9857493
8 Message-Id: <20170721183627.13373-5-bpoirier@suse.com>
9 To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
10 Cc: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>,
11 intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
12 linux-kernel@vger.kernel.org
13 Date: Fri, 21 Jul 2017 11:36:27 -0700
14
15 When e1000e_poll() is not fast enough to keep up with incoming traffic, the
16 adapter (when operating in msix mode) raises the Other interrupt to signal
17 Receiver Overrun.
18
19 This is a double problem because 1) at the moment e1000_msix_other()
20 assumes that it is only called in case of Link Status Change and 2) if the
21 condition persists, the interrupt is repeatedly raised again in quick
22 succession.
23
24 Ideally we would configure the Other interrupt to not be raised in case of
25 receiver overrun but this doesn't seem possible on this adapter. Instead,
26 we handle the first part of the problem by reverting to the practice of
27 reading ICR in the other interrupt handler, like before commit 16ecba59bc33
28 ("e1000e: Do not read ICR in Other interrupt"). Thanks to commit
29 0a8047ac68e5 ("e1000e: Fix msi-x interrupt automask") which cleared IAME
30 from CTRL_EXT, reading ICR doesn't interfere with RxQ0, TxQ0 interrupts
31 anymore. We handle the second part of the problem by not re-enabling the
32 Other interrupt right away when there is overrun. Instead, we wait until
33 traffic subsides, napi polling mode is exited and interrupts are
34 re-enabled.
35
36 Reported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
37 Fixes: 16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt")
38 Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
39 ---
40 drivers/net/ethernet/intel/e1000e/defines.h | 1 +
41 drivers/net/ethernet/intel/e1000e/netdev.c | 33 +++++++++++++++++++++++------
42 2 files changed, 27 insertions(+), 7 deletions(-)
43
44 --- a/drivers/net/ethernet/intel/e1000e/defines.h
45 +++ b/drivers/net/ethernet/intel/e1000e/defines.h
46 @@ -398,6 +398,7 @@
47 #define E1000_ICR_LSC 0x00000004 /* Link Status Change */
48 #define E1000_ICR_RXSEQ 0x00000008 /* Rx sequence error */
49 #define E1000_ICR_RXDMT0 0x00000010 /* Rx desc min. threshold (0) */
50 +#define E1000_ICR_RXO 0x00000040 /* Receiver Overrun */
51 #define E1000_ICR_RXT0 0x00000080 /* Rx timer intr (ring 0) */
52 #define E1000_ICR_ECCER 0x00400000 /* Uncorrectable ECC Error */
53 /* If this bit asserted, the driver should claim the interrupt */
54 --- a/drivers/net/ethernet/intel/e1000e/netdev.c
55 +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
56 @@ -1905,12 +1905,30 @@ static irqreturn_t e1000_msix_other(int
57 struct net_device *netdev = data;
58 struct e1000_adapter *adapter = netdev_priv(netdev);
59 struct e1000_hw *hw = &adapter->hw;
60 + u32 icr;
61 + bool enable = true;
62
63 - hw->mac.get_link_status = true;
64 + icr = er32(ICR);
65 + if (icr & E1000_ICR_RXO) {
66 + ew32(ICR, E1000_ICR_RXO);
67 + enable = false;
68 + /* napi poll will re-enable Other, make sure it runs */
69 + if (napi_schedule_prep(&adapter->napi)) {
70 + adapter->total_rx_bytes = 0;
71 + adapter->total_rx_packets = 0;
72 + __napi_schedule(&adapter->napi);
73 + }
74 + }
75 + if (icr & E1000_ICR_LSC) {
76 + ew32(ICR, E1000_ICR_LSC);
77 + hw->mac.get_link_status = true;
78 + /* guard against interrupt when we're going down */
79 + if (!test_bit(__E1000_DOWN, &adapter->state)) {
80 + mod_timer(&adapter->watchdog_timer, jiffies + 1);
81 + }
82 + }
83
84 - /* guard against interrupt when we're going down */
85 - if (!test_bit(__E1000_DOWN, &adapter->state)) {
86 - mod_timer(&adapter->watchdog_timer, jiffies + 1);
87 + if (enable && !test_bit(__E1000_DOWN, &adapter->state)) {
88 ew32(IMS, E1000_IMS_OTHER);
89 }
90
91 @@ -2683,7 +2701,8 @@ static int e1000e_poll(struct napi_struc
92 napi_complete_done(napi, work_done);
93 if (!test_bit(__E1000_DOWN, &adapter->state)) {
94 if (adapter->msix_entries)
95 - ew32(IMS, adapter->rx_ring->ims_val);
96 + ew32(IMS, adapter->rx_ring->ims_val |
97 + E1000_IMS_OTHER);
98 else
99 e1000_irq_enable(adapter);
100 }
101 @@ -4178,7 +4197,7 @@ static void e1000e_trigger_lsc(struct e1
102 struct e1000_hw *hw = &adapter->hw;
103
104 if (adapter->msix_entries)
105 - ew32(ICS, E1000_ICS_OTHER);
106 + ew32(ICS, E1000_ICS_LSC | E1000_ICS_OTHER);
107 else
108 ew32(ICS, E1000_ICS_LSC);
109 }