kernel: backport a MIPS SMP icache flush fix
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 094-MIPS-c-r4k-Fix-size-calc-when-avoiding-IPIs-for-smal.patch
1 From: Paul Burton <paul.burton@imgtec.com>
2 Date: Mon, 5 Sep 2016 15:24:54 +0100
3 Subject: [PATCH] MIPS: c-r4k: Fix size calc when avoiding IPIs for small
4 icache flushes
5
6 Commit f70ddc07b637 ("MIPS: c-r4k: Avoid small flush_icache_range SMP
7 calls") adds checks to force use of hit-type cache ops for small icache
8 flushes where they are globalised & index-type cache ops aren't, in
9 order to avoid the overhead of IPIs in those cases. However it
10 calculated the size of the region being flushed incorrectly, subtracting
11 the end address from the start address rather than the reverse. This
12 would have led to an overflow with size wrapping round to some large
13 value, and likely to the special case for avoiding IPIs not actually
14 being hit.
15
16 Signed-off-by: Paul Burton <paul.burton@imgtec.com>
17 Cc: James Hogan <james.hogan@imgtec.com>
18 Fixes: f70ddc07b637 ("MIPS: c-r4k: Avoid small flush_icache_range SMP calls")
19 Reviewed-by: James Hogan <james.hogan@imgtec.com>
20 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
21 Cc: Huacai Chen <chenhc@lemote.com>
22 Cc: linux-mips@linux-mips.org
23 Cc: linux-kernel@vger.kernel.org
24 Patchwork: https://patchwork.linux-mips.org/patch/14211/
25 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
26 ---
27
28 --- a/arch/mips/mm/c-r4k.c
29 +++ b/arch/mips/mm/c-r4k.c
30 @@ -781,7 +781,7 @@ static void r4k_flush_icache_range(unsig
31 * If address-based cache ops are globalized, then we may be
32 * able to avoid the IPI for small flushes.
33 */
34 - size = start - end;
35 + size = end - start;
36 cache_size = icache_size;
37 if (!cpu_has_ic_fills_f_dc) {
38 size *= 2;