tools: mkimage: provide dtc path during build
[openwrt/staging/wigyori.git] / target / linux / mvebu / patches-4.4 / 038-net-mvneta-Fix-the-CPU-choice-in-mvneta_percpu_elect.patch
1 From: Gregory CLEMENT <gregory.clement@free-electrons.com>
2 Date: Thu, 4 Feb 2016 22:09:24 +0100
3 Subject: [PATCH] net: mvneta: Fix the CPU choice in mvneta_percpu_elect
4
5 When passing to the management of multiple RX queue, the
6 mvneta_percpu_elect function was broken. The use of the modulo can lead
7 to elect the wrong cpu. For example with rxq_def=2, if the CPU 2 goes
8 offline and then online, we ended with the third RX queue activated in
9 the same time on CPU 0 and CPU2, which lead to a kernel crash.
10
11 With this fix, we don't try to get "the closer" CPU if the default CPU is
12 gone, now we just use CPU 0 which always be there. Thanks to this, the
13 code becomes more readable, easier to maintain and more predicable.
14
15 Cc: stable@vger.kernel.org
16 Fixes: 2dcf75e2793c ("net: mvneta: Associate RX queues with each CPU")
17 Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 ---
20
21 --- a/drivers/net/ethernet/marvell/mvneta.c
22 +++ b/drivers/net/ethernet/marvell/mvneta.c
23 @@ -2851,9 +2851,14 @@ static void mvneta_percpu_disable(void *
24
25 static void mvneta_percpu_elect(struct mvneta_port *pp)
26 {
27 - int online_cpu_idx, max_cpu, cpu, i = 0;
28 + int elected_cpu = 0, max_cpu, cpu, i = 0;
29 +
30 + /* Use the cpu associated to the rxq when it is online, in all
31 + * the other cases, use the cpu 0 which can't be offline.
32 + */
33 + if (cpu_online(pp->rxq_def))
34 + elected_cpu = pp->rxq_def;
35
36 - online_cpu_idx = pp->rxq_def % num_online_cpus();
37 max_cpu = num_present_cpus();
38
39 for_each_online_cpu(cpu) {
40 @@ -2864,7 +2869,7 @@ static void mvneta_percpu_elect(struct m
41 if ((rxq % max_cpu) == cpu)
42 rxq_map |= MVNETA_CPU_RXQ_ACCESS(rxq);
43
44 - if (i == online_cpu_idx)
45 + if (cpu == elected_cpu)
46 /* Map the default receive queue queue to the
47 * elected CPU
48 */
49 @@ -2875,7 +2880,7 @@ static void mvneta_percpu_elect(struct m
50 * the CPU bound to the default RX queue
51 */
52 if (txq_number == 1)
53 - txq_map = (i == online_cpu_idx) ?
54 + txq_map = (cpu == elected_cpu) ?
55 MVNETA_CPU_TXQ_ACCESS(1) : 0;
56 else
57 txq_map = mvreg_read(pp, MVNETA_CPU_MAP(cpu)) &