From 3c2597393c090cf931c4c12de55c28bb5905b47b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 1 Dec 2021 17:16:57 -0500 Subject: [PATCH] kernel/int: Allow arch_int_assign_to_cpu to make its own decisions. For now this is used on RISCV64 to indicate that interrupts will always be on CPU 0. However, in the future, some architectures may want or require interrupts to be "steered" in various ways, and this also paves the way for that. Change-Id: Iec79870cf5c4898d102d0e624de19602271ae772 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4721 Reviewed-by: waddlesplash Reviewed-by: Alex von Gluck IV Tested-by: Commit checker robot --- headers/private/kernel/arch/int.h | 2 +- src/system/kernel/arch/arm/arch_int.cpp | 6 ++++-- src/system/kernel/arch/arm64/arch_int.cpp | 5 +++-- src/system/kernel/arch/m68k/arch_int.cpp | 5 +++-- src/system/kernel/arch/ppc/arch_int.cpp | 4 +++- src/system/kernel/arch/riscv64/arch_int.cpp | 5 +++-- src/system/kernel/arch/sparc/arch_int.cpp | 4 +++- src/system/kernel/arch/x86/arch_int.cpp | 3 ++- src/system/kernel/int.cpp | 7 +++---- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/headers/private/kernel/arch/int.h b/headers/private/kernel/arch/int.h index 6d4afc6f67..0bfd94febb 100644 --- a/headers/private/kernel/arch/int.h +++ b/headers/private/kernel/arch/int.h @@ -34,7 +34,7 @@ void arch_int_enable_io_interrupt(int irq); void arch_int_disable_io_interrupt(int irq); void arch_int_configure_io_interrupt(int irq, uint32 config); bool arch_int_are_interrupts_enabled(void); -void arch_int_assign_to_cpu(int32 irq, int32 cpu); +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu); #ifdef __cplusplus } diff --git a/src/system/kernel/arch/arm/arch_int.cpp b/src/system/kernel/arch/arm/arch_int.cpp index 3bb5c2c80a..67aabe845e 100644 --- a/src/system/kernel/arch/arm/arch_int.cpp +++ b/src/system/kernel/arch/arm/arch_int.cpp @@ -84,12 +84,14 @@ arch_int_disable_io_interrupt(int irq) /* arch_int_*_interrupts() and friends are in arch_asm.S */ -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { - // intentionally left blank; no SMP support (yet) + // Not yet supported. + return 0; } + static void print_iframe(const char *event, struct iframe *frame) { diff --git a/src/system/kernel/arch/arm64/arch_int.cpp b/src/system/kernel/arch/arm64/arch_int.cpp index 23d5c7f8bf..34c452adeb 100644 --- a/src/system/kernel/arch/arm64/arch_int.cpp +++ b/src/system/kernel/arch/arm64/arch_int.cpp @@ -39,10 +39,11 @@ arch_int_disable_io_interrupt(int irq) } -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { - // intentionally left blank; no SMP support (yet) + // Not yet supported. + return 0; } diff --git a/src/system/kernel/arch/m68k/arch_int.cpp b/src/system/kernel/arch/m68k/arch_int.cpp index 6583b75253..e7c995b4e3 100644 --- a/src/system/kernel/arch/m68k/arch_int.cpp +++ b/src/system/kernel/arch/m68k/arch_int.cpp @@ -95,10 +95,11 @@ arch_int_disable_io_interrupt(int irq) /* arch_int_*_interrupts() and friends are in arch_asm.S */ -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { - // intentionally left blank; no SMP support (yet) + // Not yet supported. + return 0; } diff --git a/src/system/kernel/arch/ppc/arch_int.cpp b/src/system/kernel/arch/ppc/arch_int.cpp index 5e5ce87a9f..9c358d443d 100644 --- a/src/system/kernel/arch/ppc/arch_int.cpp +++ b/src/system/kernel/arch/ppc/arch_int.cpp @@ -571,7 +571,9 @@ ppc_set_current_cpu_exception_context(struct ppc_cpu_exception_context *context) } -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { + // Not yet supported. + return 0; } diff --git a/src/system/kernel/arch/riscv64/arch_int.cpp b/src/system/kernel/arch/riscv64/arch_int.cpp index cbcf90137e..de42b07532 100644 --- a/src/system/kernel/arch/riscv64/arch_int.cpp +++ b/src/system/kernel/arch/riscv64/arch_int.cpp @@ -549,8 +549,9 @@ arch_int_disable_io_interrupt(int irq) } -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { - // SMP not yet supported + // Not yet supported. + return 0; } diff --git a/src/system/kernel/arch/sparc/arch_int.cpp b/src/system/kernel/arch/sparc/arch_int.cpp index 885044d2aa..5abdffdd82 100644 --- a/src/system/kernel/arch/sparc/arch_int.cpp +++ b/src/system/kernel/arch/sparc/arch_int.cpp @@ -50,7 +50,9 @@ arch_int_disable_io_interrupt(int irq) } -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { + // Not yet supported. + return 0; } diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index 416e9d21c4..025d431dd6 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -424,7 +424,7 @@ arch_int_are_interrupts_enabled(void) } -void +int32 arch_int_assign_to_cpu(int32 irq, int32 cpu) { switch (sVectorSources[irq]) { @@ -440,6 +440,7 @@ arch_int_assign_to_cpu(int32 irq, int32 cpu) default: break; } + return cpu; } diff --git a/src/system/kernel/int.cpp b/src/system/kernel/int.cpp index 1cd125538b..13c1569967 100644 --- a/src/system/kernel/int.cpp +++ b/src/system/kernel/int.cpp @@ -468,7 +468,7 @@ install_io_interrupt_handler(long vector, interrupt_handler handler, void *data, && sVectors[vector].assigned_cpu->cpu == -1) { int32 cpuID = assign_cpu(); - arch_int_assign_to_cpu(vector, cpuID); + cpuID = arch_int_assign_to_cpu(vector, cpuID); sVectors[vector].assigned_cpu->cpu = cpuID; cpu_ent* cpu = &gCPU[cpuID]; @@ -743,10 +743,9 @@ void assign_io_interrupt_to_cpu(long vector, int32 newCPU) list_remove_item(&cpu->irqs, sVectors[vector].assigned_cpu); locker.Unlock(); + newCPU = arch_int_assign_to_cpu(vector, newCPU); + sVectors[vector].assigned_cpu->cpu = newCPU; cpu = &gCPU[newCPU]; locker.SetTo(cpu->irqs_lock, false); - sVectors[vector].assigned_cpu->cpu = newCPU; - arch_int_assign_to_cpu(vector, newCPU); list_add_item(&cpu->irqs, sVectors[vector].assigned_cpu); } -