Skip to content

Commit d9676fa

Browse files
Evgeny Voevodinvineetgarc
authored andcommitted
ARCv2: Enable LOCKDEP
- The asm helpers for calling into irq tracer were missing - Add calls to above helpers in low level assembly entry code for ARCv2 - irq_save() uses CLRI to disable interrupts and returns the prev interrupt state (in STATUS32) in a specific encoding (and not the raw value of STATUS32). This is usable with SETI in irq_restore(). However save_flags() reads the raw value of STATUS32 which doesn't pair with irq_save/restore() and thus needs fixing. Signed-off-by: Evgeny Voevodin <evgeny.voevodin@intel.com> [vgupta: updated changelog and also added some comments] Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent c3b46c7 commit d9676fa

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

arch/arc/include/asm/irqflags-arcv2.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#define STATUS_AD_MASK (1<<STATUS_AD_BIT)
1919
#define STATUS_IE_MASK (1<<STATUS_IE_BIT)
2020

21+
/* status32 Bits as encoded/expected by CLRI/SETI */
22+
#define CLRI_STATUS_IE_BIT 4
23+
24+
#define CLRI_STATUS_E_MASK 0xF
25+
#define CLRI_STATUS_IE_MASK (1 << CLRI_STATUS_IE_BIT)
26+
2127
#define AUX_USER_SP 0x00D
2228
#define AUX_IRQ_CTRL 0x00E
2329
#define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */
@@ -100,6 +106,13 @@ static inline long arch_local_save_flags(void)
100106
:
101107
: "memory");
102108

109+
/* To be compatible with irq_save()/irq_restore()
110+
* encode the irq bits as expected by CLRI/SETI
111+
* (this was needed to make CONFIG_TRACE_IRQFLAGS work)
112+
*/
113+
temp = (1 << 5) |
114+
((!!(temp & STATUS_IE_MASK)) << CLRI_STATUS_IE_BIT) |
115+
(temp & CLRI_STATUS_E_MASK);
103116
return temp;
104117
}
105118

@@ -108,7 +121,7 @@ static inline long arch_local_save_flags(void)
108121
*/
109122
static inline int arch_irqs_disabled_flags(unsigned long flags)
110123
{
111-
return !(flags & (STATUS_IE_MASK));
124+
return !(flags & CLRI_STATUS_IE_MASK);
112125
}
113126

114127
static inline int arch_irqs_disabled(void)
@@ -128,11 +141,32 @@ static inline void arc_softirq_clear(int irq)
128141

129142
#else
130143

144+
#ifdef CONFIG_TRACE_IRQFLAGS
145+
146+
.macro TRACE_ASM_IRQ_DISABLE
147+
bl trace_hardirqs_off
148+
.endm
149+
150+
.macro TRACE_ASM_IRQ_ENABLE
151+
bl trace_hardirqs_on
152+
.endm
153+
154+
#else
155+
156+
.macro TRACE_ASM_IRQ_DISABLE
157+
.endm
158+
159+
.macro TRACE_ASM_IRQ_ENABLE
160+
.endm
161+
162+
#endif
131163
.macro IRQ_DISABLE scratch
132164
clri
165+
TRACE_ASM_IRQ_DISABLE
133166
.endm
134167

135168
.macro IRQ_ENABLE scratch
169+
TRACE_ASM_IRQ_ENABLE
136170
seti
137171
.endm
138172

arch/arc/kernel/entry-arcv2.S

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ ENTRY(handle_interrupt)
6969

7070
clri ; To make status32.IE agree with CPU internal state
7171

72-
lr r0, [ICAUSE]
72+
#ifdef CONFIG_TRACE_IRQFLAGS
73+
TRACE_ASM_IRQ_DISABLE
74+
#endif
7375

76+
lr r0, [ICAUSE]
7477
mov blink, ret_from_exception
7578

7679
b.d arch_do_IRQ
@@ -169,6 +172,11 @@ END(EV_TLBProtV)
169172

170173
.Lrestore_regs:
171174

175+
# Interrpts are actually disabled from this point on, but will get
176+
# reenabled after we return from interrupt/exception.
177+
# But irq tracer needs to be told now...
178+
TRACE_ASM_IRQ_ENABLE
179+
172180
ld r0, [sp, PT_status32] ; U/K mode at time of entry
173181
lr r10, [AUX_IRQ_ACT]
174182

arch/arc/kernel/entry-compact.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ END(call_do_page_fault)
341341

342342
.Lrestore_regs:
343343

344+
# Interrpts are actually disabled from this point on, but will get
345+
# reenabled after we return from interrupt/exception.
346+
# But irq tracer needs to be told now...
344347
TRACE_ASM_IRQ_ENABLE
345348

346349
lr r10, [status32]

0 commit comments

Comments
 (0)