Skip to content

Commit 843ed93

Browse files
chenhuacaiKAGA-KOKO
authored andcommitted
LoongArch: Architectural preparation for AVEC irqchip
Add architectural preparation for AVEC irqchip, including: 1. CPUCFG feature bits definition for AVEC; 2. Detection of AVEC irqchip in cpu_probe(); 3. New IPI type definition (IPI_CLEAR_VECTOR) for AVEC; 4. Provide arch_probe_nr_irqs() for large NR_IRQS; 5. Other related changes about the number of interrupts. Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Tianyang Zhang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 06fac72 commit 843ed93

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

arch/loongarch/include/asm/cpu-features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@
6565
#define cpu_has_guestid cpu_opt(LOONGARCH_CPU_GUESTID)
6666
#define cpu_has_hypervisor cpu_opt(LOONGARCH_CPU_HYPERVISOR)
6767
#define cpu_has_ptw cpu_opt(LOONGARCH_CPU_PTW)
68+
#define cpu_has_avecint cpu_opt(LOONGARCH_CPU_AVECINT)
6869

6970
#endif /* __ASM_CPU_FEATURES_H */

arch/loongarch/include/asm/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ enum cpu_type_enum {
9999
#define CPU_FEATURE_GUESTID 24 /* CPU has GuestID feature */
100100
#define CPU_FEATURE_HYPERVISOR 25 /* CPU has hypervisor (running in VM) */
101101
#define CPU_FEATURE_PTW 26 /* CPU has hardware page table walker */
102+
#define CPU_FEATURE_AVECINT 27 /* CPU has avec interrupt */
102103

103104
#define LOONGARCH_CPU_CPUCFG BIT_ULL(CPU_FEATURE_CPUCFG)
104105
#define LOONGARCH_CPU_LAM BIT_ULL(CPU_FEATURE_LAM)
@@ -127,5 +128,6 @@ enum cpu_type_enum {
127128
#define LOONGARCH_CPU_GUESTID BIT_ULL(CPU_FEATURE_GUESTID)
128129
#define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR)
129130
#define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW)
131+
#define LOONGARCH_CPU_AVECINT BIT_ULL(CPU_FEATURE_AVECINT)
130132

131133
#endif /* _ASM_CPU_H */

arch/loongarch/include/asm/hardirq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
extern void ack_bad_irq(unsigned int irq);
1313
#define ack_bad_irq ack_bad_irq
1414

15-
#define NR_IPI 3
15+
#define NR_IPI 4
1616

1717
enum ipi_msg_type {
1818
IPI_RESCHEDULE,
1919
IPI_CALL_FUNCTION,
2020
IPI_IRQ_WORK,
21+
IPI_CLEAR_VECTOR,
2122
};
2223

2324
typedef struct {

arch/loongarch/include/asm/irq.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,22 @@ void spurious_interrupt(void);
3939

4040
#define NR_IRQS_LEGACY 16
4141

42+
/*
43+
* 256 Vectors Mapping for AVECINTC:
44+
*
45+
* 0 - 15: Mapping classic IPs, e.g. IP0-12.
46+
* 16 - 255: Mapping vectors for external IRQ.
47+
*
48+
*/
49+
#define NR_VECTORS 256
50+
#define NR_LEGACY_VECTORS 16
51+
#define IRQ_MATRIX_BITS NR_VECTORS
52+
4253
#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
4354
void arch_trigger_cpumask_backtrace(const struct cpumask *mask, int exclude_cpu);
4455

4556
#define MAX_IO_PICS 2
46-
#define NR_IRQS (64 + (256 * MAX_IO_PICS))
57+
#define NR_IRQS (64 + NR_VECTORS * (NR_CPUS + MAX_IO_PICS))
4758

4859
struct acpi_vector_group {
4960
int node;
@@ -65,7 +76,7 @@ extern struct acpi_vector_group msi_group[MAX_IO_PICS];
6576
#define LOONGSON_LPC_LAST_IRQ (LOONGSON_LPC_IRQ_BASE + 15)
6677

6778
#define LOONGSON_CPU_IRQ_BASE 16
68-
#define LOONGSON_CPU_LAST_IRQ (LOONGSON_CPU_IRQ_BASE + 14)
79+
#define LOONGSON_CPU_LAST_IRQ (LOONGSON_CPU_IRQ_BASE + 15)
6980

7081
#define LOONGSON_PCH_IRQ_BASE 64
7182
#define LOONGSON_PCH_ACPI_IRQ (LOONGSON_PCH_IRQ_BASE + 47)

arch/loongarch/include/asm/loongarch.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@
253253
#define CSR_ESTAT_EXC_WIDTH 6
254254
#define CSR_ESTAT_EXC (_ULCAST_(0x3f) << CSR_ESTAT_EXC_SHIFT)
255255
#define CSR_ESTAT_IS_SHIFT 0
256-
#define CSR_ESTAT_IS_WIDTH 14
257-
#define CSR_ESTAT_IS (_ULCAST_(0x3fff) << CSR_ESTAT_IS_SHIFT)
256+
#define CSR_ESTAT_IS_WIDTH 15
257+
#define CSR_ESTAT_IS (_ULCAST_(0x7fff) << CSR_ESTAT_IS_SHIFT)
258258

259259
#define LOONGARCH_CSR_ERA 0x6 /* ERA */
260260

@@ -649,6 +649,13 @@
649649

650650
#define LOONGARCH_CSR_CTAG 0x98 /* TagLo + TagHi */
651651

652+
#define LOONGARCH_CSR_ISR0 0xa0
653+
#define LOONGARCH_CSR_ISR1 0xa1
654+
#define LOONGARCH_CSR_ISR2 0xa2
655+
#define LOONGARCH_CSR_ISR3 0xa3
656+
657+
#define LOONGARCH_CSR_IRR 0xa4
658+
652659
#define LOONGARCH_CSR_PRID 0xc0
653660

654661
/* Shadow MCSR : 0xc0 ~ 0xff */
@@ -1011,7 +1018,7 @@
10111018
/*
10121019
* CSR_ECFG IM
10131020
*/
1014-
#define ECFG0_IM 0x00001fff
1021+
#define ECFG0_IM 0x00005fff
10151022
#define ECFGB_SIP0 0
10161023
#define ECFGF_SIP0 (_ULCAST_(1) << ECFGB_SIP0)
10171024
#define ECFGB_SIP1 1
@@ -1054,6 +1061,7 @@
10541061
#define IOCSRF_EIODECODE BIT_ULL(9)
10551062
#define IOCSRF_FLATMODE BIT_ULL(10)
10561063
#define IOCSRF_VM BIT_ULL(11)
1064+
#define IOCSRF_AVEC BIT_ULL(15)
10571065

10581066
#define LOONGARCH_IOCSR_VENDOR 0x10
10591067

@@ -1065,6 +1073,7 @@
10651073
#define IOCSR_MISC_FUNC_SOFT_INT BIT_ULL(10)
10661074
#define IOCSR_MISC_FUNC_TIMER_RESET BIT_ULL(21)
10671075
#define IOCSR_MISC_FUNC_EXT_IOI_EN BIT_ULL(48)
1076+
#define IOCSR_MISC_FUNC_AVEC_EN BIT_ULL(51)
10681077

10691078
#define LOONGARCH_IOCSR_CPUTEMP 0x428
10701079

@@ -1387,9 +1396,10 @@ __BUILD_CSR_OP(tlbidx)
13871396
#define INT_TI 11 /* Timer */
13881397
#define INT_IPI 12
13891398
#define INT_NMI 13
1399+
#define INT_AVEC 14
13901400

13911401
/* ExcCodes corresponding to interrupts */
1392-
#define EXCCODE_INT_NUM (INT_NMI + 1)
1402+
#define EXCCODE_INT_NUM (INT_AVEC + 1)
13931403
#define EXCCODE_INT_START 64
13941404
#define EXCCODE_INT_END (EXCCODE_INT_START + EXCCODE_INT_NUM - 1)
13951405

arch/loongarch/include/asm/smp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ extern int __cpu_logical_map[NR_CPUS];
7070
#define ACTION_RESCHEDULE 1
7171
#define ACTION_CALL_FUNCTION 2
7272
#define ACTION_IRQ_WORK 3
73+
#define ACTION_CLEAR_VECTOR 4
7374
#define SMP_BOOT_CPU BIT(ACTION_BOOT_CPU)
7475
#define SMP_RESCHEDULE BIT(ACTION_RESCHEDULE)
7576
#define SMP_CALL_FUNCTION BIT(ACTION_CALL_FUNCTION)
7677
#define SMP_IRQ_WORK BIT(ACTION_IRQ_WORK)
78+
#define SMP_CLEAR_VECTOR BIT(ACTION_CLEAR_VECTOR)
7779

7880
struct secondary_data {
7981
unsigned long stack;

arch/loongarch/kernel/cpu-probe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
106106
elf_hwcap |= HWCAP_LOONGARCH_CRC32;
107107
}
108108

109-
110109
config = read_cpucfg(LOONGARCH_CPUCFG2);
111110
if (config & CPUCFG2_LAM) {
112111
c->options |= LOONGARCH_CPU_LAM;
@@ -174,6 +173,8 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c)
174173
c->options |= LOONGARCH_CPU_FLATMODE;
175174
if (config & IOCSRF_EIODECODE)
176175
c->options |= LOONGARCH_CPU_EIODECODE;
176+
if (config & IOCSRF_AVEC)
177+
c->options |= LOONGARCH_CPU_AVECINT;
177178
if (config & IOCSRF_VM)
178179
c->options |= LOONGARCH_CPU_HYPERVISOR;
179180

arch/loongarch/kernel/irq.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ static void __init init_vec_parent_group(void)
8787
acpi_table_parse(ACPI_SIG_MCFG, early_pci_mcfg_parse);
8888
}
8989

90+
int __init arch_probe_nr_irqs(void)
91+
{
92+
int nr_io_pics = bitmap_weight(loongson_sysconf.cores_io_master, NR_CPUS);
93+
94+
if (!cpu_has_avecint)
95+
nr_irqs = (64 + NR_VECTORS * nr_io_pics);
96+
else
97+
nr_irqs = (64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
98+
99+
return NR_IRQS_LEGACY;
100+
}
101+
90102
void __init init_IRQ(void)
91103
{
92104
int i;

0 commit comments

Comments
 (0)