From 8a8acb9274692c1cc5446fa3238d6fa4ffe59033 Mon Sep 17 00:00:00 2001 From: NicJA Date: Mon, 27 Feb 2017 02:16:51 +0000 Subject: [PATCH] move the ipi allocation/init to smp_init, where it is protected against being used when kb_API is not set, and only allocated if there are additional cores to use. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@53924 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-pc/kernel/platform_post.c | 28 ---------------------------- arch/all-pc/kernel/smp.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/arch/all-pc/kernel/platform_post.c b/arch/all-pc/kernel/platform_post.c index 6c8e23bfa9..3c445e7102 100644 --- a/arch/all-pc/kernel/platform_post.c +++ b/arch/all-pc/kernel/platform_post.c @@ -142,11 +142,8 @@ static AROS_UFH3 (APTR, KernelPost, { AROS_USERFUNC_INIT - int number_of_ipi_messages = 0; struct KernelBase *KernelBase; struct PlatformData *pdata; - struct IPIHook *hooks; - int i; KernelBase = (struct KernelBase *)OpenResource("kernel.resource"); if (!KernelBase) @@ -166,31 +163,6 @@ static AROS_UFH3 (APTR, KernelPost, krnAddSysCallHandler(pdata, &x86_SCRebootHandler, TRUE, FALSE); krnAddSysCallHandler(pdata, &x86_SCChangePMStateHandler, TRUE, FALSE); - D(bug("[Kernel] %s: Initializing Lists for IPI messages ...\n", __func__)); - NEWLIST(&pdata->kb_FreeIPIHooks); - NEWLIST(&pdata->kb_BusyIPIHooks); - KrnSpinInit(&pdata->kb_FreeIPIHooksLock); - KrnSpinInit(&pdata->kb_BusyIPIHooksLock); - - number_of_ipi_messages = pdata->kb_APIC->apic_count * 10; - D(bug("[Kernel] %s: Allocating %d IPI CALL_HOOK messages ...\n", __func__, number_of_ipi_messages)); - hooks = AllocMem(sizeof(struct IPIHook) * number_of_ipi_messages, MEMF_PUBLIC | MEMF_CLEAR); - if (hooks) - { - for (i=0; i < number_of_ipi_messages; i++) - { - hooks[i].ih_CPUDone = KrnAllocCPUMask(); - hooks[i].ih_CPURequested = KrnAllocCPUMask(); - KrnSpinInit(&hooks[i].ih_Lock); - - ADDHEAD(&pdata->kb_FreeIPIHooks, &hooks[i]); - } - } - else - { - bug("[Kernel] %s: Failed to get IPI slots!\n", __func__); - } - D(bug("[Kernel] %s: Attempting to bring up aditional cores ...\n", __func__)); smp_Initialize(); diff --git a/arch/all-pc/kernel/smp.c b/arch/all-pc/kernel/smp.c index d001dc10c0..8d5bc31876 100644 --- a/arch/all-pc/kernel/smp.c +++ b/arch/all-pc/kernel/smp.c @@ -18,6 +18,7 @@ #include "kernel_globals.h" #include "kernel_intern.h" #include "kernel_syscall.h" +#include "kernel_ipi.h" #include "smp.h" #define D(x) @@ -327,10 +328,39 @@ int smp_Initialize(void) if (pdata->kb_APIC && (pdata->kb_APIC->apic_count > 1)) { + int number_of_ipi_messages = 0; + struct IPIHook *hooks; + int i; + #if defined(__AROSEXEC_SMP__) cpu_PrepareExec(SysBase); #endif + D(bug("[Kernel:SMP] %s: Initializing Lists for IPI messages ...\n", __func__)); + NEWLIST(&pdata->kb_FreeIPIHooks); + NEWLIST(&pdata->kb_BusyIPIHooks); + KrnSpinInit(&pdata->kb_FreeIPIHooksLock); + KrnSpinInit(&pdata->kb_BusyIPIHooksLock); + + number_of_ipi_messages = pdata->kb_APIC->apic_count * 10; + D(bug("[Kernel:SMP] %s: Allocating %d IPI CALL_HOOK messages ...\n", __func__, number_of_ipi_messages)); + hooks = AllocMem(sizeof(struct IPIHook) * number_of_ipi_messages, MEMF_PUBLIC | MEMF_CLEAR); + if (hooks) + { + for (i=0; i < number_of_ipi_messages; i++) + { + hooks[i].ih_CPUDone = KrnAllocCPUMask(); + hooks[i].ih_CPURequested = KrnAllocCPUMask(); + KrnSpinInit(&hooks[i].ih_Lock); + + ADDHEAD(&pdata->kb_FreeIPIHooks, &hooks[i]); + } + } + else + { + bug("[Kernel:SMP] %s: Failed to get IPI slots!\n", __func__); + } + if (!smp_Setup(KernelBase)) { D(bug("[Kernel:SMP] Failed to prepare the environment!\n")); -- 2.11.4.GIT