Skip to content

Commit

Permalink
Restore Timebase on Master Core Threads 1-3 after Sleep/Winkle
Browse files Browse the repository at this point in the history
Change-Id: I329dd64345f2474cb0dad628ccc2244d85be86c2
CQ: SW429364
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/63147
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Prachi Gupta <pragupta@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
wghoffa authored and dcrowell77 committed Jul 24, 2018
1 parent 923ed59 commit 331b4bf
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/include/kernel/cpu.H
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ struct cpu_t
/** Sequence ID of CPU initialization. */
uint64_t cpu_start_seqid;

/** Timebase Restore Value (used during core wakeup) */
uint64_t cpu_restore_tb;

/** Stack of WorkItems to be executed during doorbell wakeup */
Util::Lockfree::Stack<KernelWorkItem> doorbell_actions;
};
Expand Down
7 changes: 7 additions & 0 deletions src/include/kernel/doorbell.H
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ void send_doorbell_wakeup(uint64_t i_pir);
*/
void send_doorbell_ipc(uint64_t i_pir);

/** Send a doorbell and also restore the thread's timebase
*
* @param i_pir - PIR to send doorbell to wakeup
* @param i_tb - Timebase value to restore during wakeup
*/
void send_doorbell_restore_tb(uint64_t i_pir, uint64_t i_tb);

enum
{
_DOORBELL_MSG_TYPE = 0x0000000028000000, /// Comes from the ISA.
Expand Down
12 changes: 12 additions & 0 deletions src/include/kernel/workitem.H
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ class CpuWakeupDoorbellWorkItem : public KernelWorkItem
~CpuWakeupDoorbellWorkItem() = default;
};

//A work item to be created/executed during a Master CPU
// wakeup scenario, it will also restore the timebase
// on the threads being woken up
class CpuTbRestoreDoorbellWorkItem : public KernelWorkItem
{
public:
//Implement operator() function
void operator() (void);

//No data to clean up, use default destructor
~CpuTbRestoreDoorbellWorkItem() = default;
};

#endif

1 change: 1 addition & 0 deletions src/kernel/cpumgr.C
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ void CpuManager::startCPU(ssize_t i)
cpu->idle_task = TaskManager::createIdleTask();
cpu->idle_task->cpu = cpu;
cpu->periodic_count = 0;
cpu->cpu_restore_tb = 0;

// Call TimeManager setup for a CPU.
TimeManager::init_cpu(cpu);
Expand Down
14 changes: 14 additions & 0 deletions src/kernel/doorbell.C
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ void send_doorbell_wakeup(uint64_t i_pir)
doorbell_send(i_pir);
}

void send_doorbell_restore_tb(uint64_t i_pir, uint64_t i_tb)
{
cpu_t *l_cpu = CpuManager::getCpu(i_pir);
l_cpu->cpu_restore_tb = i_tb;

printkd("send_doorbell_restore_tb to pir: %lx\n", i_pir);
//Create WorkItem and put on the stack to be executed during doorbell
// execution
KernelWorkItem* l_work = new CpuTbRestoreDoorbellWorkItem();
l_cpu->doorbell_actions.push(l_work);
//Send doorbell to wakeup core/thread
doorbell_send(i_pir);
}

void send_doorbell_ipc(uint64_t i_pir)
{
printk("send_doorbell_ipc to pir: %lx\n", i_pir);
Expand Down
4 changes: 1 addition & 3 deletions src/kernel/misc.C
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ namespace KernelMisc
// NOTE: The deferred work container verifies master core
// threads 1-3 wake up so a direct doorbell can be sent. For
// threads on other cores send_doorbell_wakeup() is used.
doorbell_send(l_pir + i);
send_doorbell_restore_tb(l_pir + i, iv_timebase);
}
}

Expand All @@ -358,7 +358,6 @@ namespace KernelMisc
{
cpu->scheduler->setNextRunnable();
}

}

void WinkleCore::masterPostWork()
Expand Down Expand Up @@ -465,7 +464,6 @@ namespace KernelMisc
{
cpu->scheduler->setNextRunnable();
}

}

void WinkleAll::masterPostWork()
Expand Down
15 changes: 15 additions & 0 deletions src/kernel/workitem.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <kernel/workitem.H>
#include <kernel/console.H>
#include <kernel/intmsghandler.H>
#include <kernel/cpumgr.H>

//Define the desired behavior for a CPU core/thread
// wakeup scenario
Expand All @@ -40,3 +41,17 @@ void CpuWakeupDoorbellWorkItem::operator() (void)
InterruptMsgHdlr::sendThreadWakeupMsg(pir);
return;
}

void CpuTbRestoreDoorbellWorkItem::operator() (void)
{
size_t pir = getPIR();
cpu_t *l_cpu = CpuManager::getCpu(pir);

uint64_t l_restore_tb = l_cpu->cpu_restore_tb;
printkd("pir:%ld tb:0x%0x\n", pir, l_restore_tb);
if (l_restore_tb > getTB())
{
setTB(l_restore_tb);
}
return;
}

0 comments on commit 331b4bf

Please sign in to comment.