1 From c9426cce5b2d967299248c6e20d89361e5ee9154 Mon Sep 17 00:00:00 2001
2 From: Vineet Gupta <vgupta@synopsys.com>
3 Date: Tue, 7 May 2019 10:45:24 -0700
4 Subject: ARC: fix build warnings
6 [ Upstream commit 89c92142f75eb80064f5b9f1111484b1b4d81790 ]
8 | arch/arc/mm/tlb.c:914:2: warning: variable length array 'pd0' is used [-Wvla]
9 | arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used [-Wunused-value]
11 Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
12 Signed-off-by: Sasha Levin <sashal@kernel.org>
14 arch/arc/include/asm/cmpxchg.h | 14 ++++++++++----
15 arch/arc/mm/tlb.c | 13 ++++++++-----
16 2 files changed, 18 insertions(+), 9 deletions(-)
18 diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h
19 index d819de1c5d10..3ea4112c8302 100644
20 --- a/arch/arc/include/asm/cmpxchg.h
21 +++ b/arch/arc/include/asm/cmpxchg.h
22 @@ -92,8 +92,11 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new)
24 #endif /* CONFIG_ARC_HAS_LLSC */
26 -#define cmpxchg(ptr, o, n) ((typeof(*(ptr)))__cmpxchg((ptr), \
27 - (unsigned long)(o), (unsigned long)(n)))
28 +#define cmpxchg(ptr, o, n) ({ \
29 + (typeof(*(ptr)))__cmpxchg((ptr), \
30 + (unsigned long)(o), \
31 + (unsigned long)(n)); \
35 * atomic_cmpxchg is same as cmpxchg
36 @@ -198,8 +201,11 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr,
37 return __xchg_bad_pointer();
40 -#define xchg(ptr, with) ((typeof(*(ptr)))__xchg((unsigned long)(with), (ptr), \
42 +#define xchg(ptr, with) ({ \
43 + (typeof(*(ptr)))__xchg((unsigned long)(with), \
48 #endif /* CONFIG_ARC_PLAT_EZNPS */
50 diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c
51 index 8ceefbf72fb0..e5817b9b2c3f 100644
52 --- a/arch/arc/mm/tlb.c
53 +++ b/arch/arc/mm/tlb.c
54 @@ -902,9 +902,11 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
57 struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu;
58 - unsigned int pd0[mmu->ways];
61 + int set, n_ways = mmu->ways;
63 + n_ways = min(n_ways, 4);
64 + BUG_ON(mmu->ways > 4);
66 local_irq_save(flags);
68 @@ -912,9 +914,10 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
69 for (set = 0; set < mmu->sets; set++) {
72 + unsigned int pd0[4];
74 /* read out all the ways of current set */
75 - for (way = 0, is_valid = 0; way < mmu->ways; way++) {
76 + for (way = 0, is_valid = 0; way < n_ways; way++) {
77 write_aux_reg(ARC_REG_TLBINDEX,
78 SET_WAY_TO_IDX(mmu, set, way));
79 write_aux_reg(ARC_REG_TLBCOMMAND, TLBRead);
80 @@ -928,14 +931,14 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
83 /* Scan the set for duplicate ways: needs a nested loop */
84 - for (way = 0; way < mmu->ways - 1; way++) {
85 + for (way = 0; way < n_ways - 1; way++) {
92 - for (n = way + 1; n < mmu->ways; n++) {
93 + for (n = way + 1; n < n_ways; n++) {
94 if (pd0[way] != pd0[n])