From patchwork Mon Dec 20 12:22:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1571013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mB4NoFma; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JHdzX1BrGz9sR4 for ; Mon, 20 Dec 2021 23:23:36 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JHdzX01b5z3064 for ; Mon, 20 Dec 2021 23:23:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mB4NoFma; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62d; helo=mail-pl1-x62d.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mB4NoFma; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JHdz65JYbz2yY7 for ; Mon, 20 Dec 2021 23:23:14 +1100 (AEDT) Received: by mail-pl1-x62d.google.com with SMTP id w24so7948363ply.12 for ; Mon, 20 Dec 2021 04:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GAp3V1+nftV/6jfjD7Exs4YCfPKGFbcHeGKhaDtYl1E=; b=mB4NoFma01RF5lFvOjJCQSne9FOJdADE6mAPATeBNg+CVMoLHDXoJrFIkjDyX/G/Lk krKenSbVA/l37Ce0D7dKEA5UmfVV0EDqnAzperfCkh2Y1xBBIWK9kDCx3qs3xNXG43xN +c3SaiYk6O8SZXznzc6ws750BmSHPxdVnyIG2vJRzZ07/kr4qHVjI10fgna6rQs35Aiu quC9ttHWvBGQe/9hH224WBi6JM6jfeWZoAcdw8Dw4oH5DGkmLAQaU8JsgVc+aBi0kloC csmODihD4cFiMlTu1gwFQUiw7bDMOQOFwyk2A82J922JHNbMzgLvH69YVbUymO+ZFd7n JieQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GAp3V1+nftV/6jfjD7Exs4YCfPKGFbcHeGKhaDtYl1E=; b=7LdqoHIasJCDHSNxQC4uPp0CUg8Hw++KQjLHRVR1oHmMda75+zr7sqsviRHrNtHB6h gi/5014VJLaxUUCn1PR17ShuwY13EEXOdh3jIQbMumrJBiW18rgozPpJVp32gZkDHBzl ax/08UqeLE3b3uvuMis+oG3ctabnBIJQVv93trsteUidMRXa9ZO5Ub/ciq8TZaDCFBQI S71k67gD+SET8LKo6YhnWYGKiMwIM9bbKUpfBsuyjGPxX/O7y327j1MAzu2SD7FsFSe2 kTeCa22MfjoSlY8vp3o+g0yMtwA+GZ6+8eW55VjOUTSMQ3mUO/3fQ4SqhltzSwMmTNzH C3dA== X-Gm-Message-State: AOAM531T3wFED7XmbrUFHfv7NHUUNoQUMh7dg7rc1YDLYoYyKBBYYVuA SsVQt2qbInw3upZSscCvMX1k8v0ID7g= X-Google-Smtp-Source: ABdhPJwnaMvOhdyR7EDZlWw+pU4Zk0+x+mWmV9Qy9ypKbuQ6ZSaTmN9N+4IVE+wFAlDPFimbYc8lwA== X-Received: by 2002:a17:90a:ba03:: with SMTP id s3mr21300131pjr.219.1640002992503; Mon, 20 Dec 2021 04:23:12 -0800 (PST) Received: from bobo.ozlabs.ibm.com (121-44-67-22.tpgi.com.au. [121.44.67.22]) by smtp.gmail.com with ESMTPSA id p17sm20661731pfh.86.2021.12.20.04.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 04:23:12 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Mon, 20 Dec 2021 22:22:47 +1000 Message-Id: <20211220122252.986542-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20211220122252.986542-1-npiggin@gmail.com> References: <20211220122252.986542-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH v5 4/9] SBE: create processor-independent timer APIs X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Rather than have code call processor-specific SBE routines depending on version, hide those details in SBE APIs. Signed-off-by: Nicholas Piggin --- core/interrupts.c | 5 ++--- core/timer.c | 13 ++++--------- hw/Makefile.inc | 2 +- hw/sbe-p8.c | 9 ++------- hw/sbe-p9.c | 9 ++------- hw/sbe.c | 31 +++++++++++++++++++++++++++++++ include/sbe-p8.h | 5 ++--- include/sbe-p9.h | 3 --- include/sbe.h | 17 +++++++++++++++++ 9 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 hw/sbe.c create mode 100644 include/sbe.h diff --git a/core/interrupts.c b/core/interrupts.c index c39c2801c..35571f289 100644 --- a/core/interrupts.c +++ b/core/interrupts.c @@ -16,8 +16,7 @@ #include #include #include -#include -#include +#include #include /* 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 */ diff --git a/core/timer.c b/core/timer.c index 43c388314..f803b7f28 100644 --- a/core/timer.c +++ b/core/timer.c @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #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; } diff --git a/hw/Makefile.inc b/hw/Makefile.inc index e273e898c..a6732b7bc 100644 --- a/hw/Makefile.inc +++ b/hw/Makefile.inc @@ -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 diff --git a/hw/sbe-p8.c b/hw/sbe-p8.c index 73fa5f1f2..70edec65e 100644 --- a/hw/sbe-p8.c +++ b/hw/sbe-p8.c @@ -6,13 +6,13 @@ */ #include +#include #include #include #include #include /* 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; diff --git a/hw/sbe-p9.c b/hw/sbe-p9.c index 898a1fb56..3b0f8b06e 100644 --- a/hw/sbe-p9.c +++ b/hw/sbe-p9.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/hw/sbe.c b/hw/sbe.c new file mode 100644 index 000000000..991485e5b --- /dev/null +++ b/hw/sbe.c @@ -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 +#include +#include +#include +#include + +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; +} diff --git a/include/sbe-p8.h b/include/sbe-p8.h index 66f702514..d6f0d3179 100644 --- a/include/sbe-p8.h +++ b/include/sbe-p8.h @@ -4,12 +4,11 @@ #ifndef __SBE_P8_H #define __SBE_P8_H +#include + /* 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); diff --git a/include/sbe-p9.h b/include/sbe-p9.h index 289c28ba5..5f236f02f 100644 --- a/include/sbe-p9.h +++ b/include/sbe-p9.h @@ -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); diff --git a/include/sbe.h b/include/sbe.h new file mode 100644 index 000000000..24d21fa0b --- /dev/null +++ b/include/sbe.h @@ -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 + +/* 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 */