Skip to content

Commit d043c35

Browse files
committed
arch/tricore: use lasr register to get irq number
Read the irq number from the ICU LASR register of the current core instead of translating the SRPN through g_srpn_to_irq. LASR must be read before interrupts are re-enabled. Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
1 parent 87020bc commit d043c35

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎arch/tricore/include/tc3xx/irq.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#define TRICORE_SRC_BASE 0xf0038000 /* SRC_CPU0SB, IRQ 0 */
4545
#define TRICORE_SRC_GPSR_BASE 0xf0038990 /* SRC_GPSR0SR0 */
4646
#define TRICORE_INT_SRB_BASE 0xf0037010 /* INT_SRB0 */
47+
#define TRICORE_INT_LASR_BASE 0xf0037204 /* INT_LASR0 */
48+
#define TRICORE_INT_LASR_SPACING 0x10 /* INT_LASRn spacing */
4749

4850
#define TRICORE_SRC_SRPN_MASK 0xff /* Service request priority */
4951
#define TRICORE_SRC_SRE (1 << 10) /* Service request enable */

‎arch/tricore/include/tc4xx/irq.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#define TRICORE_SRC_BASE 0xf4432000 /* SRC_CPU0SB, IRQ 0 */
4545
#define TRICORE_SRC_GPSR_BASE 0xf4433460 /* SRC_GPSR0SR0 */
4646
#define TRICORE_INT_SRB_BASE 0xf4430b00 /* INT_SRB0 */
47+
#define TRICORE_INT_LASR_BASE 0xf4430c20 /* INT_LASR0 */
48+
#define TRICORE_INT_LASR_SPACING 0x34 /* INT_LASRn spacing */
4749

4850
#define TRICORE_SRC_SRPN_MASK 0xff /* Service request priority */
4951
#define TRICORE_SRC_VM_MASK (0x7 << 8) /* Virtual machine */

‎arch/tricore/src/common/tricore_doirq.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@
4141

4242
#include "tricore_internal.h"
4343

44+
/****************************************************************************
45+
* Private Functions
46+
****************************************************************************/
47+
48+
/****************************************************************************
49+
* Name: tricore_irq_from_lasr
50+
*
51+
* Description:
52+
* Get irq number from ICU's last acknowledged SRN register
53+
*
54+
****************************************************************************/
55+
56+
static inline_function int tricore_irq_from_lasr(void)
57+
{
58+
uintptr_t addr = TRICORE_INT_LASR_BASE +
59+
up_cpu_index() * TRICORE_INT_LASR_SPACING;
60+
61+
return (getreg32(addr) >> 16) & 0x7ff;
62+
}
63+
4464
/****************************************************************************
4565
* Public Functions
4666
****************************************************************************/
@@ -62,12 +82,10 @@ void tricore_irq_direct(void)
6282
{
6383
struct tcb_s **running_task = &g_running_tasks[this_cpu()];
6484
uintptr_t *regs = tricore_csa2addr(tricore_mfcr(TRICORE_CPU_PCXI));
65-
int ccpn = tricore_mfcr(TRICORE_CPU_ICR) & TRICORE_ICR_CCPN_MASK;
66-
int irq;
85+
int irq = tricore_irq_from_lasr();
6786

6887
up_irq_enable();
6988

70-
irq = tricore_srpn_to_irq(ccpn);
7189
tricore_ack_irq(irq);
7290
irq_dispatch(irq, regs);
7391

@@ -107,8 +125,7 @@ void tricore_irq_sched(void)
107125
uintptr_t *regs = tricore_csa2addr(tricore_mfcr(TRICORE_CPU_PCXI));
108126
struct tcb_s *tcb;
109127
#ifndef CONFIG_ARCH_IRQPRIO
110-
int ccpn = tricore_mfcr(TRICORE_CPU_ICR) & TRICORE_ICR_CCPN_MASK;
111-
int irq;
128+
int irq = tricore_irq_from_lasr();
112129
#endif
113130

114131
#ifdef CONFIG_ARCH_IRQPRIO
@@ -123,7 +140,6 @@ void tricore_irq_sched(void)
123140
board_autoled_on(LED_INIRQ);
124141

125142
#ifndef CONFIG_ARCH_IRQPRIO
126-
irq = tricore_srpn_to_irq(ccpn);
127143
tricore_ack_irq(irq);
128144
irq_dispatch(irq, regs);
129145
#endif

0 commit comments

Comments
 (0)