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); } /*