From patchwork Tue Sep 3 04:06:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=F2Hkb8KY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=SeJzqsgg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WyXDM4nPkz1yh2 for ; Tue, 3 Sep 2024 14:08:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GqZs083zM1Y1m2N8QYjhMKmLS9MJBvrrMXfFyJITkTI=; b=F2Hkb8KYMlNRX6 AJUvcbzAchRNBoV0fef9VDyMiIbBf6T+TqiyTD3jLfDI08H/ywGPMJ/9dzGSf/yf778HqJ/9WiHrS syv5jcAcspniGHPNHEQJkVZS3YWtpbefboTRHgxkaynQIdKHTfypKPNK79p/k61yO9K/muSb+Ktzt RcQl6YgDmJORrezXwYWNlX1Gi7om1cpMDPRTyE3cIUI8AgiTpCZEUS4Eu661+gEBVE+Uk/lM5GNzs S55k85DgmC2Y8/NOUIISZT6WTo7jXHxq6nY/+fhhdTTXqu+VjhncP0kJIDnRH3wGWvwUZq5M8B/0t 4d+58OhgZBDu7YhKmRMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slKq5-0000000GFVk-2MLb; Tue, 03 Sep 2024 04:08:21 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slKq2-0000000GFUj-49Q1 for opensbi@lists.infradead.org; Tue, 03 Sep 2024 04:08:20 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-7091558067eso1768782a34.3 for ; Mon, 02 Sep 2024 21:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725336497; x=1725941297; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BfsxyeLdQPd9h/hla5CZCPbqCM14lfs1Kp4GhUN+hxc=; b=SeJzqsgg1xOZwr7aDxRIKiHYH6fpX6XpND4gPGTkBekGcI7jPu1Aq2sUJwtTMBh5YP b8Eihj4ieJvk+0bdCedxjkhMUimYEf1bSRZFDHwnXY2rhC/C8lRIEtfQjswZVa6yzgkK kd5yQkHEJ5dueRYsW1jOCNG15SjkpD3vWDCqFh9urcq+33uYXT+2SeF76Z5DlaBqDm2K PP/dubnX1JpsVfhLc086/R/9j0G6HI6wIQTecIv5R5kCDoYnx7/KDwg2Jlrutp3uD0e8 4tl99oSOWqu2jowa/nZ1qk6Bx39vShzTBNhIBi5nt9/JKp+2UIJkvP/wq376ZCRHpZAl de+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725336497; x=1725941297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BfsxyeLdQPd9h/hla5CZCPbqCM14lfs1Kp4GhUN+hxc=; b=aw/Ef81pPYaxo4fu8NCTi4UEa2Y29KtRRVdFLdeTu1v/3Ct1WNrKFHkya9PoplsmmQ e1mqZS5qKmfbBzorZfcfVg2vREu9mnYGILyxQa2K/++90BWv1+qXIy2yRYsWggkjwRIP jNDBmZ1fyMyfqbdor8XjiU8fDfVvvyKnzTxfflo7pamPmd6zehPsZJUd3CJq8WkHfOGY DU731yhKtMgTjHE0fUIi+RYtJHGfhF1ErOR4eE0tk7+GLwnwqvWJxj9z2bkSFqWk/yXf ZtG2vvoBA/IkpWPjKj+x9IPrSDQ32JLFHcWo2CX7Syfi2aEW9+Oq4hBo6jKNpV4BSW8X T1Mw== X-Gm-Message-State: AOJu0Yz+M2VJBlcTW63D2TJ6lMc5tMYSs0whT2rSHqHC6LflgAXkXDc6 mHAogza2j2FT8ht5va91S5r/2N4KTd6JbFKdG954QoQwuXq8MIvhIYpJnzgh4zxTOB+dn/LhMNj VwqxDfeYkiZoMgWhHVhm2H/mZGTW66xuhV1z53Uxak++fV1DAtfxnyS+69Hy0/TdutZpxJB6VZC cEVsFkbeyAXYI87QvN5k9hUxgYvYwwvbvO6bFPhFPfzRSnQWoxfuo= X-Google-Smtp-Source: AGHT+IF0Bn5j0XxzzbVq6KjYp++Qmeuvmy+DDrFo61TAJjx/PgOiD2V9XVa9BikQnTZ7zN4p23wPWw== X-Received: by 2002:a05:6358:9107:b0:1ac:ef2e:5316 with SMTP id e5c5f4694b2df-1b603cd4fdfmr1971877155d.26.1725336497274; Mon, 02 Sep 2024 21:08:17 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e557723fsm7570563b3a.42.2024.09.02.21.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 21:08:16 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 1/2] lib: sbi_timer: Call driver warm_init from SBI core Date: Mon, 2 Sep 2024 21:06:49 -0700 Message-ID: <20240903040814.622145-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240903040814.622145-1-samuel.holland@sifive.com> References: <20240903040814.622145-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_210819_053416_44168E18 X-CRM114-Status: GOOD ( 21.56 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Currently, the platform's timer device is tracked in two places: the core SBI implementation has `timer_dev`, and the FDT timer layer has `current_driver`. The latter is used for warm initialization o [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:335 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently, the platform's timer device is tracked in two places: the core SBI implementation has `timer_dev`, and the FDT timer layer has `current_driver`. The latter is used for warm initialization of the timer device. However, this warm init is not specific to FDT-based platforms; other platforms call exactly the same functions from the same point in the boot sequence. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_timer.h | 3 +++ include/sbi_utils/timer/aclint_mtimer.h | 2 -- include/sbi_utils/timer/andes_plmt.h | 1 - lib/sbi/sbi_timer.c | 13 ++++++++++++- lib/utils/timer/aclint_mtimer.c | 3 ++- lib/utils/timer/andes_plmt.c | 23 ++++++++++++----------- lib/utils/timer/fdt_timer_mtimer.c | 2 +- lib/utils/timer/fdt_timer_plmt.c | 2 +- platform/fpga/ariane/platform.c | 2 +- platform/fpga/openpiton/platform.c | 2 +- platform/kendryte/k210/platform.c | 2 +- platform/nuclei/ux600/platform.c | 2 +- platform/template/platform.c | 2 +- 13 files changed, 36 insertions(+), 23 deletions(-) diff --git a/include/sbi/sbi_timer.h b/include/sbi/sbi_timer.h index ac48e2b8..64df9dfa 100644 --- a/include/sbi/sbi_timer.h +++ b/include/sbi/sbi_timer.h @@ -28,6 +28,9 @@ struct sbi_timer_device { /** Stop timer event for current HART */ void (*timer_event_stop)(void); + + /** Initialize timer device for current HART */ + int (*warm_init)(void); }; struct sbi_scratch; diff --git a/include/sbi_utils/timer/aclint_mtimer.h b/include/sbi_utils/timer/aclint_mtimer.h index 6ab8799c..a245e13e 100644 --- a/include/sbi_utils/timer/aclint_mtimer.h +++ b/include/sbi_utils/timer/aclint_mtimer.h @@ -47,8 +47,6 @@ void aclint_mtimer_sync(struct aclint_mtimer_data *mt); void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt, struct aclint_mtimer_data *ref); -int aclint_mtimer_warm_init(void); - int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, struct aclint_mtimer_data *reference); diff --git a/include/sbi_utils/timer/andes_plmt.h b/include/sbi_utils/timer/andes_plmt.h index 08bce332..119f1b44 100644 --- a/include/sbi_utils/timer/andes_plmt.h +++ b/include/sbi_utils/timer/andes_plmt.h @@ -24,6 +24,5 @@ struct plmt_data { }; int plmt_cold_timer_init(struct plmt_data *plmt); -int plmt_warm_timer_init(void); #endif /* __TIMER_ANDES_PLMT_H__ */ diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c index 7b618de1..466e81e5 100644 --- a/lib/sbi/sbi_timer.c +++ b/lib/sbi/sbi_timer.c @@ -182,6 +182,7 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) { u64 *time_delta; const struct sbi_platform *plat = sbi_platform_ptr(scratch); + int ret; if (cold_boot) { time_delta_off = sbi_scratch_alloc_offset(sizeof(*time_delta)); @@ -198,7 +199,17 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) time_delta = sbi_scratch_offset_ptr(scratch, time_delta_off); *time_delta = 0; - return sbi_platform_timer_init(plat, cold_boot); + ret = sbi_platform_timer_init(plat, cold_boot); + if (ret) + return ret; + + if (timer_dev && timer_dev->warm_init) { + ret = timer_dev->warm_init(); + if (ret) + return ret; + } + + return 0; } void sbi_timer_exit(struct sbi_scratch *scratch) diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index 9acb26eb..3db3c3be 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -143,7 +143,7 @@ void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt, mt->time_delta_computed = 0; } -int aclint_mtimer_warm_init(void) +static int aclint_mtimer_warm_init(void) { u64 *mt_time_cmp; u32 target_hart = current_hartid(); @@ -260,6 +260,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, } mtimer.timer_freq = mt->mtime_freq; + mtimer.warm_init = aclint_mtimer_warm_init; sbi_timer_set_device(&mtimer); return 0; diff --git a/lib/utils/timer/andes_plmt.c b/lib/utils/timer/andes_plmt.c index 6e4bfafe..d034feb9 100644 --- a/lib/utils/timer/andes_plmt.c +++ b/lib/utils/timer/andes_plmt.c @@ -67,12 +67,23 @@ static void plmt_timer_event_start(u64 next_event) #endif } +static int plmt_warm_timer_init(void) +{ + if (!plmt.time_val) + return SBI_ENODEV; + + plmt_timer_event_stop(); + + return 0; +} + static struct sbi_timer_device plmt_timer = { .name = "andes_plmt", .timer_freq = DEFAULT_AE350_PLMT_FREQ, .timer_value = plmt_timer_value, .timer_event_start = plmt_timer_event_start, - .timer_event_stop = plmt_timer_event_stop + .timer_event_stop = plmt_timer_event_stop, + .warm_init = plmt_warm_timer_init, }; int plmt_cold_timer_init(struct plmt_data *plmt) @@ -95,13 +106,3 @@ int plmt_cold_timer_init(struct plmt_data *plmt) return 0; } - -int plmt_warm_timer_init(void) -{ - if (!plmt.time_val) - return SBI_ENODEV; - - plmt_timer_event_stop(); - - return 0; -} diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index 458e8881..eff50417 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -165,6 +165,6 @@ static const struct fdt_match timer_mtimer_match[] = { struct fdt_timer fdt_timer_mtimer = { .match_table = timer_mtimer_match, .cold_init = timer_mtimer_cold_init, - .warm_init = aclint_mtimer_warm_init, + .warm_init = NULL, .exit = NULL, }; diff --git a/lib/utils/timer/fdt_timer_plmt.c b/lib/utils/timer/fdt_timer_plmt.c index 88a42e2a..87e634bd 100644 --- a/lib/utils/timer/fdt_timer_plmt.c +++ b/lib/utils/timer/fdt_timer_plmt.c @@ -46,6 +46,6 @@ static const struct fdt_match timer_plmt_match[] = { struct fdt_timer fdt_timer_plmt = { .match_table = timer_plmt_match, .cold_init = fdt_plmt_cold_timer_init, - .warm_init = plmt_warm_timer_init, + .warm_init = NULL, .exit = NULL, }; diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index ec0584ab..c895cb47 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -159,7 +159,7 @@ static int ariane_timer_init(bool cold_boot) return ret; } - return aclint_mtimer_warm_init(); + return 0; } /* diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 81cc48f4..ea0a4799 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -190,7 +190,7 @@ static int openpiton_timer_init(bool cold_boot) return ret; } - return aclint_mtimer_warm_init(); + return 0; } /* diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 2f3f7079..82dd0809 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -169,7 +169,7 @@ static int k210_timer_init(bool cold_boot) return rc; } - return aclint_mtimer_warm_init(); + return 0; } const struct sbi_platform_operations platform_ops = { diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 5610e7c7..b17c1df2 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -225,7 +225,7 @@ static int ux600_timer_init(bool cold_boot) return rc; } - return aclint_mtimer_warm_init(); + return 0; } const struct sbi_platform_operations platform_ops = { diff --git a/platform/template/platform.c b/platform/template/platform.c index b4d30a57..1238a8d6 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -129,7 +129,7 @@ static int platform_timer_init(bool cold_boot) return ret; } - return aclint_mtimer_warm_init(); + return 0; } /* From patchwork Tue Sep 3 04:06:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=MiFwpHxc; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=mMPPkoMr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WyXDM4gkqz1ygj for ; Tue, 3 Sep 2024 14:08:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0P5tbBtkFJhSSALx/cfBY6b78rKQajsPrlunzzKy8IU=; b=MiFwpHxcNPbLXZ nv1kQ9mYBGULOLcGLOgtvfRNEsRwQI+XV494jsVvGy59Ujz51KstOIA8QFsRPlbo08PUWtPm9byxW sNsr5haR0H4rtjZh60Gj7l1sRl8xvtUv0SJemzHvsU2bgrTSd+GydfFAdofqU9pztn/a7RcRoFnPw 3pNcUgKSHoeBfNT2wji36aySKGK3yAUwI5h2loqVwThK2yuWc9w5Gonu2N7uDpzfQXVbf6JDHNKhZ AV0NCx186PmOl1uIxHPU09v5l+bAWgQWYh5G2/kdftxvm8nobWEOr1sBP6VW7q+F7nj44xf7EoYSf PDmydpDJjlYXKgU+fq4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slKq7-0000000GFW6-0EOI; Tue, 03 Sep 2024 04:08:23 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slKq3-0000000GFV1-47vY for opensbi@lists.infradead.org; Tue, 03 Sep 2024 04:08:21 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7142a30e3bdso4210516b3a.0 for ; Mon, 02 Sep 2024 21:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725336499; x=1725941299; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E5M2usOxDCjUXRM5u5zDugyXWpj1410HH5T2NhcVyjw=; b=mMPPkoMrxf4ThgLPVhsgyvAI66oH9uuMUifIoflhUHOO7bMGZbZfnl9xt0TAcYG2Te C/teArOzXcipuvVb25BpUJNsrg/JszF+L5M/hTJo2le4nfw5vX6Ix4Bf+YgifBC8r4Ny LjyK47DzJjz1qnXohY1r8adB0P4AGAyEjxmrcMh3y6xGRPKjaRXA1f4oYE6ev/0hcqD5 icu3U11VRFWH9CK91F1khCYFydOTXmiQM57cS/ZvxZZLQnHhYRj21RyrApHZs9fyJBV1 d0CYl0DP97LtzC1e2GY8IG6w/Fsdd849+IWC7d5/YGMia7JUAbxSqKKxchXAHqvORZrA C7Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725336499; x=1725941299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E5M2usOxDCjUXRM5u5zDugyXWpj1410HH5T2NhcVyjw=; b=LF1rIwbDmibvL/I/SXL5ZP/EIj1I228OGotHA74DvqjxYoUFj6CBmqUPnbKXaol/bs OerC3K1FU7wsWqoEOxolYulW/yBm4fS4xnNHT6axW0swj14SdPJWvsClyP70CS1AvNAc 2Ktli443ec205BWfrPZFvml2wStFUqznjgGes0GMZwaT4i8S5n8Pg7Kt5Tu9o5t3z09R 7exXLq3BcNnpRbWe/IEgZuitv6ggu+abF/xuenaxor7UgSgehmrNZfIajuAzvvIy1AkN q9IwTewc5Rvn80fRWm+o1BzliTR+Xfc3+igJ7OqQZ96+1Ab4Jqx9XjRvSRE07tCr0rOF dwPQ== X-Gm-Message-State: AOJu0Yyew/nSMGNMxyxDz9r/js9e7HzeJhkASkjUI6iPqbKhzD8W2M+C azHSW9xonYhz/bnnR9TpH+NjQsICP3LtLYshAKj1FmwoxUsUC6rRFUzKU9NRb1w8oRflSujfjEQ wq+6VrmoUHQNEkcX83T7Xcsa9HGxFZtEoR7GAQrebeOMexrFguT+30wSCPqW3ZJAax/B69z3lMM 1QvU+efCTdlJch/vTTWxhoMIRCZ1SLAM3jcrFlet+2HxwvpvWFhoQ= X-Google-Smtp-Source: AGHT+IFjkq8lNwU3igRM/540YWdF21VAgJHvikFGXZaInEeMqvVg52geJ0x5L7LaB+fVCAtJsbsSIA== X-Received: by 2002:a05:6a21:1690:b0:1ca:ccfc:edc8 with SMTP id adf61e73a8af0-1ccee8874a3mr18102883637.22.1725336498446; Mon, 02 Sep 2024 21:08:18 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e557723fsm7570563b3a.42.2024.09.02.21.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 21:08:18 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 2/2] platform: Drop timer warm init and exit hooks Date: Mon, 2 Sep 2024 21:06:50 -0700 Message-ID: <20240903040814.622145-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240903040814.622145-1-samuel.holland@sifive.com> References: <20240903040814.622145-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240902_210820_052469_F316AEF5 X-CRM114-Status: GOOD ( 21.06 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Now that driver lifecycle is managed from within the SBI timer core, platforms need only to initialize the driver once during cold init. Remove the remaining platform hooks that are no longer used. Signed-off-by: Samuel Holland --- Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42d listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Now that driver lifecycle is managed from within the SBI timer core, platforms need only to initialize the driver once during cold init. Remove the remaining platform hooks that are no longer used. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_platform.h | 25 +++++------------------ include/sbi_utils/timer/fdt_timer.h | 9 ++------- lib/sbi/sbi_timer.c | 10 ++++------ lib/utils/timer/fdt_timer.c | 31 +---------------------------- lib/utils/timer/fdt_timer_mtimer.c | 2 -- lib/utils/timer/fdt_timer_plmt.c | 2 -- platform/fpga/ariane/platform.c | 14 +++---------- platform/fpga/openpiton/platform.c | 14 +++---------- platform/generic/platform.c | 1 - platform/kendryte/k210/platform.c | 12 ++--------- platform/nuclei/ux600/platform.c | 12 ++--------- platform/template/platform.c | 14 +++---------- 12 files changed, 25 insertions(+), 121 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 7b3ac4bf..d7af3093 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -127,10 +127,8 @@ struct sbi_platform_operations { /** Get tlb fifo num entries*/ u32 (*get_tlb_num_entries)(void); - /** Initialize platform timer for current HART */ - int (*timer_init)(bool cold_boot); - /** Exit platform timer for current HART */ - void (*timer_exit)(void); + /** Initialize platform timer during cold boot */ + int (*timer_init)(void); /** Check if SBI vendor extension is implemented or not */ bool (*vendor_ext_check)(void); @@ -601,32 +599,19 @@ static inline void sbi_platform_ipi_exit(const struct sbi_platform *plat) } /** - * Initialize the platform timer for current HART + * Initialize the platform timer during cold boot * * @param plat pointer to struct sbi_platform - * @param cold_boot whether cold boot (true) or warm_boot (false) * * @return 0 on success and negative error code on failure */ -static inline int sbi_platform_timer_init(const struct sbi_platform *plat, - bool cold_boot) +static inline int sbi_platform_timer_init(const struct sbi_platform *plat) { if (plat && sbi_platform_ops(plat)->timer_init) - return sbi_platform_ops(plat)->timer_init(cold_boot); + return sbi_platform_ops(plat)->timer_init(); return 0; } -/** - * Exit the platform timer for current HART - * - * @param plat pointer to struct sbi_platform - */ -static inline void sbi_platform_timer_exit(const struct sbi_platform *plat) -{ - if (plat && sbi_platform_ops(plat)->timer_exit) - sbi_platform_ops(plat)->timer_exit(); -} - /** * Check if SBI vendor extension is implemented or not. * diff --git a/include/sbi_utils/timer/fdt_timer.h b/include/sbi_utils/timer/fdt_timer.h index 555ebcba..8f0469da 100644 --- a/include/sbi_utils/timer/fdt_timer.h +++ b/include/sbi_utils/timer/fdt_timer.h @@ -17,18 +17,13 @@ struct fdt_timer { const struct fdt_match *match_table; int (*cold_init)(const void *fdt, int nodeoff, const struct fdt_match *match); - int (*warm_init)(void); - void (*exit)(void); }; -void fdt_timer_exit(void); - -int fdt_timer_init(bool cold_boot); +int fdt_timer_init(void); #else -static inline void fdt_timer_exit(void) { } -static inline int fdt_timer_init(bool cold_boot) { return 0; } +static inline int fdt_timer_init(void) { return 0; } #endif diff --git a/lib/sbi/sbi_timer.c b/lib/sbi/sbi_timer.c index 466e81e5..fca56a04 100644 --- a/lib/sbi/sbi_timer.c +++ b/lib/sbi/sbi_timer.c @@ -191,6 +191,10 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) if (sbi_hart_has_extension(scratch, SBI_HART_EXT_ZICNTR)) get_time_val = get_ticks; + + ret = sbi_platform_timer_init(plat); + if (ret) + return ret; } else { if (!time_delta_off) return SBI_ENOMEM; @@ -199,10 +203,6 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot) time_delta = sbi_scratch_offset_ptr(scratch, time_delta_off); *time_delta = 0; - ret = sbi_platform_timer_init(plat, cold_boot); - if (ret) - return ret; - if (timer_dev && timer_dev->warm_init) { ret = timer_dev->warm_init(); if (ret) @@ -219,6 +219,4 @@ void sbi_timer_exit(struct sbi_scratch *scratch) csr_clear(CSR_MIP, MIP_STIP); csr_clear(CSR_MIE, MIP_MTIP); - - sbi_platform_timer_exit(sbi_platform_ptr(scratch)); } diff --git a/lib/utils/timer/fdt_timer.c b/lib/utils/timer/fdt_timer.c index aa0494e4..37965f5e 100644 --- a/lib/utils/timer/fdt_timer.c +++ b/lib/utils/timer/fdt_timer.c @@ -16,22 +16,7 @@ extern struct fdt_timer *fdt_timer_drivers[]; extern unsigned long fdt_timer_drivers_size; -static struct fdt_timer *current_driver = NULL; - -void fdt_timer_exit(void) -{ - if (current_driver && current_driver->exit) - current_driver->exit(); -} - -static int fdt_timer_warm_init(void) -{ - if (current_driver && current_driver->warm_init) - return current_driver->warm_init(); - return 0; -} - -static int fdt_timer_cold_init(void) +int fdt_timer_init(void) { int pos, noff, rc; struct fdt_timer *drv; @@ -56,7 +41,6 @@ static int fdt_timer_cold_init(void) continue; if (rc) return rc; - current_driver = drv; /* * We will have multiple timer devices on multi-die or @@ -71,16 +55,3 @@ static int fdt_timer_cold_init(void) */ return 0; } - -int fdt_timer_init(bool cold_boot) -{ - int rc; - - if (cold_boot) { - rc = fdt_timer_cold_init(); - if (rc) - return rc; - } - - return fdt_timer_warm_init(); -} diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c index eff50417..e752ddc5 100644 --- a/lib/utils/timer/fdt_timer_mtimer.c +++ b/lib/utils/timer/fdt_timer_mtimer.c @@ -165,6 +165,4 @@ static const struct fdt_match timer_mtimer_match[] = { struct fdt_timer fdt_timer_mtimer = { .match_table = timer_mtimer_match, .cold_init = timer_mtimer_cold_init, - .warm_init = NULL, - .exit = NULL, }; diff --git a/lib/utils/timer/fdt_timer_plmt.c b/lib/utils/timer/fdt_timer_plmt.c index 87e634bd..459a1190 100644 --- a/lib/utils/timer/fdt_timer_plmt.c +++ b/lib/utils/timer/fdt_timer_plmt.c @@ -46,6 +46,4 @@ static const struct fdt_match timer_plmt_match[] = { struct fdt_timer fdt_timer_plmt = { .match_table = timer_plmt_match, .cold_init = fdt_plmt_cold_timer_init, - .warm_init = NULL, - .exit = NULL, }; diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index c895cb47..dfe170f9 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -147,19 +147,11 @@ static int ariane_ipi_init(bool cold_boot) } /* - * Initialize ariane timer for current HART. + * Initialize ariane timer during cold boot. */ -static int ariane_timer_init(bool cold_boot) +static int ariane_timer_init(void) { - int ret; - - if (cold_boot) { - ret = aclint_mtimer_cold_init(&mtimer, NULL); - if (ret) - return ret; - } - - return 0; + return aclint_mtimer_cold_init(&mtimer, NULL); } /* diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index ea0a4799..2bfc15ce 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -178,19 +178,11 @@ static int openpiton_ipi_init(bool cold_boot) } /* - * Initialize openpiton timer for current HART. + * Initialize openpiton timer during cold boot. */ -static int openpiton_timer_init(bool cold_boot) +static int openpiton_timer_init(void) { - int ret; - - if (cold_boot) { - ret = aclint_mtimer_cold_init(&mtimer, NULL); - if (ret) - return ret; - } - - return 0; + return aclint_mtimer_cold_init(&mtimer, NULL); } /* diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 49d877d0..921c494c 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -405,7 +405,6 @@ const struct sbi_platform_operations platform_ops = { .get_tlbr_flush_limit = generic_tlbr_flush_limit, .get_tlb_num_entries = generic_tlb_num_entries, .timer_init = fdt_timer_init, - .timer_exit = fdt_timer_exit, .vendor_ext_check = generic_vendor_ext_check, .vendor_ext_provider = generic_vendor_ext_provider, }; diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 82dd0809..06b7eb74 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -159,17 +159,9 @@ static int k210_ipi_init(bool cold_boot) return aclint_mswi_warm_init(); } -static int k210_timer_init(bool cold_boot) +static int k210_timer_init(void) { - int rc; - - if (cold_boot) { - rc = aclint_mtimer_cold_init(&mtimer, NULL); - if (rc) - return rc; - } - - return 0; + return aclint_mtimer_cold_init(&mtimer, NULL); } const struct sbi_platform_operations platform_ops = { diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index b17c1df2..d4f309aa 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -215,17 +215,9 @@ static int ux600_ipi_init(bool cold_boot) return aclint_mswi_warm_init(); } -static int ux600_timer_init(bool cold_boot) +static int ux600_timer_init(void) { - int rc; - - if (cold_boot) { - rc = aclint_mtimer_cold_init(&mtimer, NULL); - if (rc) - return rc; - } - - return 0; + return aclint_mtimer_cold_init(&mtimer, NULL); } const struct sbi_platform_operations platform_ops = { diff --git a/platform/template/platform.c b/platform/template/platform.c index 1238a8d6..1fc7b7bb 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -116,20 +116,12 @@ static int platform_ipi_init(bool cold_boot) } /* - * Initialize platform timer for current HART. + * Initialize platform timer during cold boot. */ -static int platform_timer_init(bool cold_boot) +static int platform_timer_init(void) { - int ret; - /* Example if the generic ACLINT driver is used */ - if (cold_boot) { - ret = aclint_mtimer_cold_init(&mtimer, NULL); - if (ret) - return ret; - } - - return 0; + return aclint_mtimer_cold_init(&mtimer, NULL); } /*