mirror of
https://github.com/Dasharo/skiboot.git
synced 2026-03-06 14:50:44 -08:00
SBE: create processor-independent timer APIs
Rather than have code call processor-specific SBE routines depending on version, hide those details in SBE APIs. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [ clg: Fixed run-timer test ] Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
committed by
Cédric Le Goater
parent
a6816a42c1
commit
0475a94b2f
+2
-3
@@ -16,8 +16,7 @@
|
||||
#include <device.h>
|
||||
#include <ccan/str/str.h>
|
||||
#include <timer.h>
|
||||
#include <sbe-p8.h>
|
||||
#include <sbe-p9.h>
|
||||
#include <sbe.h>
|
||||
#include <xive.h>
|
||||
|
||||
/* ICP registers */
|
||||
@@ -491,7 +490,7 @@ static int64_t opal_handle_interrupt(uint32_t isn, __be64 *outstanding_event_mas
|
||||
is->ops->interrupt(is, isn);
|
||||
|
||||
/* Check timers if SBE timer isn't working */
|
||||
if (!p8_sbe_timer_ok() && !p9_sbe_timer_ok())
|
||||
if (!sbe_timer_ok())
|
||||
check_timers(true);
|
||||
|
||||
/* Update output events */
|
||||
|
||||
@@ -55,15 +55,15 @@ static void expiry(struct timer *t, void *data, uint64_t now)
|
||||
count--;
|
||||
}
|
||||
|
||||
void p8_sbe_update_timer_expiry(uint64_t new_target)
|
||||
void sbe_update_timer_expiry(uint64_t new_target)
|
||||
{
|
||||
(void)new_target;
|
||||
/* FIXME: do intersting SLW timer sim */
|
||||
}
|
||||
|
||||
void p9_sbe_update_timer_expiry(uint64_t new_target)
|
||||
bool sbe_timer_ok(void)
|
||||
{
|
||||
(void)new_target;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
+4
-9
@@ -15,8 +15,7 @@
|
||||
#include <fsp.h>
|
||||
#include <device.h>
|
||||
#include <opal.h>
|
||||
#include <sbe-p8.h>
|
||||
#include <sbe-p9.h>
|
||||
#include <sbe.h>
|
||||
|
||||
#ifdef __TEST__
|
||||
#define this_cpu() ((void *)-1)
|
||||
@@ -36,10 +35,8 @@ static uint64_t timer_poll_gen;
|
||||
|
||||
static inline void update_timer_expiry(uint64_t target)
|
||||
{
|
||||
if (proc_gen < proc_gen_p9)
|
||||
p8_sbe_update_timer_expiry(target);
|
||||
else
|
||||
p9_sbe_update_timer_expiry(target);
|
||||
if (sbe_timer_ok())
|
||||
sbe_update_timer_expiry(target);
|
||||
}
|
||||
|
||||
void init_timer(struct timer *t, timer_func_t expiry, void *data)
|
||||
@@ -287,9 +284,7 @@ void late_init_timers(void)
|
||||
*/
|
||||
if (platform.heartbeat_time) {
|
||||
heartbeat = platform.heartbeat_time();
|
||||
} else if (p9_sbe_timer_ok()) {
|
||||
heartbeat = HEARTBEAT_DEFAULT_MS * 10;
|
||||
} else if (p8_sbe_timer_ok()) {
|
||||
} else if (sbe_timer_ok()) {
|
||||
heartbeat = HEARTBEAT_DEFAULT_MS * 10;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# -*-Makefile-*-
|
||||
SUBDIRS += hw
|
||||
HW_OBJS = xscom.o chiptod.o lpc.o lpc-uart.o psi.o
|
||||
HW_OBJS = xscom.o chiptod.o lpc.o lpc-uart.o psi.o sbe.o
|
||||
HW_OBJS += homer.o slw.o occ.o fsi-master.o centaur.o imc.o
|
||||
HW_OBJS += nx.o nx-rng.o nx-crypto.o nx-compress.o nx-842.o nx-gzip.o
|
||||
HW_OBJS += sfc-ctrl.o fake-rtc.o bt.o p8-i2c.o prd.o
|
||||
|
||||
+2
-7
@@ -6,13 +6,13 @@
|
||||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <sbe.h>
|
||||
#include <sbe-p8.h>
|
||||
#include <skiboot.h>
|
||||
#include <timebase.h>
|
||||
#include <xscom.h>
|
||||
|
||||
/* SLW timer related stuff */
|
||||
static bool sbe_has_timer;
|
||||
static uint64_t sbe_timer_inc;
|
||||
static uint64_t sbe_timer_target;
|
||||
static uint32_t sbe_timer_chip;
|
||||
@@ -65,7 +65,7 @@ void p8_sbe_update_timer_expiry(uint64_t new_target)
|
||||
uint64_t count, gen, gen2, req, now;
|
||||
int64_t rc;
|
||||
|
||||
if (!sbe_has_timer || new_target == sbe_timer_target)
|
||||
if (new_target == sbe_timer_target)
|
||||
return;
|
||||
|
||||
sbe_timer_target = new_target;
|
||||
@@ -162,11 +162,6 @@ void p8_sbe_update_timer_expiry(uint64_t new_target)
|
||||
prlog(PR_TRACE, "SLW: gen: %llx\n", gen);
|
||||
}
|
||||
|
||||
bool p8_sbe_timer_ok(void)
|
||||
{
|
||||
return sbe_has_timer;
|
||||
}
|
||||
|
||||
void p8_sbe_init_timer(void)
|
||||
{
|
||||
struct dt_node *np;
|
||||
|
||||
+2
-7
@@ -41,6 +41,7 @@
|
||||
#include <lock.h>
|
||||
#include <opal.h>
|
||||
#include <opal-dump.h>
|
||||
#include <sbe.h>
|
||||
#include <sbe-p9.h>
|
||||
#include <skiboot.h>
|
||||
#include <timebase.h>
|
||||
@@ -73,7 +74,6 @@ struct p9_sbe {
|
||||
static int sbe_default_chip_id = -1;
|
||||
|
||||
/* Is SBE timer running? */
|
||||
static bool sbe_has_timer = false;
|
||||
static bool sbe_timer_in_progress = false;
|
||||
static bool has_new_target = false;
|
||||
|
||||
@@ -843,7 +843,7 @@ static void p9_sbe_timer_schedule(void)
|
||||
*/
|
||||
void p9_sbe_update_timer_expiry(uint64_t new_target)
|
||||
{
|
||||
if (!sbe_has_timer || new_target == sbe_timer_target)
|
||||
if (new_target == sbe_timer_target)
|
||||
return;
|
||||
|
||||
lock(&sbe_timer_lock);
|
||||
@@ -874,11 +874,6 @@ static void p9_sbe_timer_init(void)
|
||||
prlog(PR_INFO, "Timer facility on chip %x\n", sbe_default_chip_id);
|
||||
}
|
||||
|
||||
bool p9_sbe_timer_ok(void)
|
||||
{
|
||||
return sbe_has_timer;
|
||||
}
|
||||
|
||||
static void p9_sbe_stash_chipop_resp(struct p9_sbe_msg *msg)
|
||||
{
|
||||
int rc = p9_sbe_get_primary_rc(msg->resp);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
|
||||
/*
|
||||
* SBE communication driver (common code)
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "SBE: " fmt
|
||||
|
||||
#include <sbe.h>
|
||||
#include <sbe-p8.h>
|
||||
#include <sbe-p9.h>
|
||||
#include <skiboot.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool sbe_has_timer = false;
|
||||
|
||||
void sbe_update_timer_expiry(uint64_t target)
|
||||
{
|
||||
assert(sbe_timer_ok);
|
||||
|
||||
if (proc_gen == proc_gen_p9 || proc_gen == proc_gen_p10)
|
||||
p9_sbe_update_timer_expiry(target);
|
||||
|
||||
if (proc_gen == proc_gen_p8)
|
||||
p8_sbe_update_timer_expiry(target);
|
||||
}
|
||||
|
||||
bool sbe_timer_ok(void)
|
||||
{
|
||||
return sbe_has_timer;
|
||||
}
|
||||
+2
-3
@@ -4,12 +4,11 @@
|
||||
#ifndef __SBE_P8_H
|
||||
#define __SBE_P8_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* P8 SBE update timer function */
|
||||
extern void p8_sbe_update_timer_expiry(uint64_t new_target);
|
||||
|
||||
/* Is SBE timer available ? */
|
||||
extern bool p8_sbe_timer_ok(void);
|
||||
|
||||
/* Initialize SBE timer */
|
||||
extern void p8_sbe_init_timer(void);
|
||||
|
||||
|
||||
@@ -228,9 +228,6 @@ extern void p9_sbe_init(void);
|
||||
/* SBE interrupt */
|
||||
extern void p9_sbe_interrupt(uint32_t chip_id);
|
||||
|
||||
/* Is SBE timer available ? */
|
||||
extern bool p9_sbe_timer_ok(void);
|
||||
|
||||
/* Update SBE timer expiry */
|
||||
extern void p9_sbe_update_timer_expiry(uint64_t new_target);
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
/* Copyright 2017-2019 IBM Corp. */
|
||||
|
||||
#ifndef __SBE_H
|
||||
#define __SBE_H
|
||||
|
||||
#include <skiboot.h>
|
||||
|
||||
/* SBE update timer function */
|
||||
extern void sbe_update_timer_expiry(uint64_t target);
|
||||
|
||||
/* Is SBE timer available ? */
|
||||
extern bool sbe_timer_ok(void);
|
||||
|
||||
extern bool sbe_has_timer;
|
||||
|
||||
#endif /* __SBE_P9_H */
|
||||
Reference in New Issue
Block a user