From b42194c6063f64d59fe1c360fa4ae4edd85ad2f3 Mon Sep 17 00:00:00 2001 From: Bill Hoffa Date: Wed, 13 Jan 2016 14:06:31 -0600 Subject: Doorbell Interrupt Base Support for Core/Thread Wakeup This change includes: - Implementation of a generic KernelWorkItem Class - Kernel functionality for doorbell send to specific PIRs - Kernel changes to send core/thread Wakeup doorbells using doorbell_send() + placing KernelWorkItems on a cpu stack obj to be executed during doorbell wakeup - Kernel Interrupt Message handler changes to send wakeup msgs - Interrupt Resource Provider (INTRRP) Changes to handle wakeup msgs and monitor for timeouts - Changes to the IPL flow to invoke proper Core/Thread Wakeup - A basic outline (commented out) for how IPC messages can be implemented in the future Change-Id: I547fb8719bac657def561565ae11ab18cde72096 CMVC-Prereq: 992722 RTC:137564 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22815 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: Andrew J. Geissler Reviewed-by: Prachi Gupta Reviewed-by: Daniel M. Crowell --- src/include/kernel/cpu.H | 8 ++++- src/include/kernel/doorbell.H | 23 +++++++++++++ src/include/kernel/intmsghandler.H | 13 ++++---- src/include/kernel/workitem.H | 68 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 src/include/kernel/workitem.H (limited to 'src/include/kernel') diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H index 963063b34..b967c1319 100644 --- a/src/include/kernel/cpu.H +++ b/src/include/kernel/cpu.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2010,2014 */ +/* Contributors Listed Below - COPYRIGHT 2010,2016 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -29,9 +31,11 @@ #define __KERNEL_CPU_H #include +#include #include #include #include +#include // See BookIV PIR definition. #define KERNEL_MAX_SUPPORTED_NODES 8 @@ -97,6 +101,8 @@ struct cpu_t /** Sequence ID of CPU initialization. */ uint64_t cpu_start_seqid; + /** Stack of WorkItems to be executed during doorbell wakeup */ + Util::Lockfree::Stack doorbell_actions; }; /** @fn getCpuId diff --git a/src/include/kernel/doorbell.H b/src/include/kernel/doorbell.H index d0c65be2c..8275c4fc7 100644 --- a/src/include/kernel/doorbell.H +++ b/src/include/kernel/doorbell.H @@ -38,4 +38,27 @@ void doorbell_broadcast(); */ void doorbell_clear(); +/** Send a doorbell exception to the given pir + * + * @param i_pir - PIR to send doorbell exception to + */ +void doorbell_send(uint64_t i_pir); + +/** Initiate a thread/core wakeup using a doorbell + * + * @param i_pir - PIR to send doorbell to wakeup + */ +void send_doorbell_wakeup(uint64_t i_pir); + +/* TODO RTC 150861 + * send_doorbell_ipc + * + * void send_doorbell_ipc(cpu_t *i_cpu, uint64_t pir); +**/ + +enum +{ + _DOORBELL_MSG_TYPE = 0x0000000028000000, /// Comes from the ISA. +}; + #endif diff --git a/src/include/kernel/intmsghandler.H b/src/include/kernel/intmsghandler.H index 8fd4e34b6..8f7c08559 100644 --- a/src/include/kernel/intmsghandler.H +++ b/src/include/kernel/intmsghandler.H @@ -145,14 +145,15 @@ class InterruptMsgHdlr : public MessageHandler static void addCpuCore(uint64_t i_pir); /** - * Issue an IPI to the core. + * Send message to interrupt resource provider (intrrp) in userspace to + * indicate a wakeup occurred for core/thread indicated by given pir. + * The intrrp monitors the expected cores/threads wakeup and will issue + * a timeout/error in the event that not all expected cores/threads + * send this message * - * @param[in] i_pir - The PIR of the CPU to send IPI at. - * @param[in] i_favor - How favored the interrupt is; 0 = most favored - * 254 = least favored, 255 = no interrupt - * Default 0x1 - IPI from kernel side (wakeup) + * @param[in] i_pir - The PIR of the CPU to send doorbell to. */ - static void sendIPI(uint64_t i_pir, uint8_t i_favor = 0x1); + static void sendThreadWakeupMsg(uint64_t i_pir); /** * Issue the sbe/mailbox workaround (issue a mbox EOI to mailbox) diff --git a/src/include/kernel/workitem.H b/src/include/kernel/workitem.H new file mode 100644 index 000000000..3a41cc526 --- /dev/null +++ b/src/include/kernel/workitem.H @@ -0,0 +1,68 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/kernel/workitem.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#ifndef __KERNEL_WORKITEM_H +#define __KERNEL_WORKITEM_H + +//The WorkItem class is a generic base class for a work item. +class KernelWorkItem +{ + public: + //Virtual operator to be defined by child classes to define proper + // behavior in that situation + virtual void operator() (void); + + /** Default destructor */ + virtual ~KernelWorkItem() = default; + + //Next Pointer is needed to be used with the lockfree::Stack container + KernelWorkItem* next; +}; + +//A work item to be created/executed during a CPU core/thread +// wakeup scenario +class CpuWakeupDoorbellWorkItem : public KernelWorkItem +{ + public: + //Implement operator() function + void operator() (void); + + //No data to clean up, use default destructor + ~CpuWakeupDoorbellWorkItem() = default; +}; + + +/* TODO RTC 150861 + +//A work item to be created/executed during an IPC scenario +class IPCDoorbellWorkItem : public KernelWorkItem +{ + public: + //Implement operator() function + void operator() (void); +}; +**/ +#endif + -- cgit v1.2.3