From nobody Mon Jun 12 13:50:25 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QftNy0gBPz4cGgL; Mon, 12 Jun 2023 13:50:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QftNx73Fjz47dP; Mon, 12 Jun 2023 13:50:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686577826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=54H/QY6PTpFGIEqvBjZZ1QyXqeL9G8Hb1Y/v14l2uR0=; b=BwHWB2TPraCScftAWb33LJ2S8cl4QQcMTpfeUyerHcE8+NB7DY54gpWsEqDED3xByRjEJg d0TUs8Oqn7fJC4auIiZVIw+Z/IFhKN/Oh2tGVrDxV2kGg8aGXfROwXigB9iPZ8IZrxe7CY iOxZdowl6uwzmWGkmafaQdUs6NfajovBIbp2UnrFKG/b5cMFNCLQx8arAeo0SIHLdAN9wx j3f7I4Op5RDid7aUDM/9HgOJFJ4O467afkch/wfOAr6OsQ3cYLnx5NiHn1/R1hYJY4zjRY o49qbZKSvbhG69zZnNmR2YXRGTcxMUcFk8q+xHknNUT52EWk3rtfES/lJA3fhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686577826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=54H/QY6PTpFGIEqvBjZZ1QyXqeL9G8Hb1Y/v14l2uR0=; b=KjGYIHQ+7+pEhPSeAkLvAmXt6BhlFQlvGOF0arf1uVHJUhaQin0HngI56/x9DPbDIcZ5ON dtSN6em6Uqmr5R0Zyn8qY166kO2t4I5hDW306bPSNuGgNL/skgfA4yAX+3LgFaCCiYEQ/h Sd/fvl6TlOE0WVjTSMLWHhXHRhxWTqQ8txng4Hktn2I3CrRuAYLFasnRn8dfI9x68JVENt iyx3Q/Y8bD3vjJ5eiZXA/0CnEPwpMXVlskJTs/9b9Id6V+XcWLcFvioiZmYCEfGib00fI0 NBLKrjjSx1eIsoasBZP/O35QVoUPfnesPb96FdENXHckTB60R9xcn5NG9dxSgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686577826; a=rsa-sha256; cv=none; b=UZIhWCFtucjpvA4MmPCzV5OqOwbnT+POL9VdV5FFOxEBomQIHjhdIAFHDtvseYQl8xc+La 7khiQOmF1neeRI+LJ/UANW3VcsE2Afr7bOpVwcfoCaOMvHE7PFjIxvvJb9jBNYwdc9C387 d/2CmtmnyKJsclWkQ0t+vfKKZ0TpFCGzq/DybjZbuEiaggC3Tir8oVrT5oxw2lwKcrMGTB Xay/I4pOHm8eqwJqhdVyNvX/vrb7PbFOO6MS35FTiC+CTeCzBT8v3ewTXG1xaH819zda+3 SMTIiQs6MQt6ad3GNCdrI3xBZ58iemTsqtk2yRBVkPZSK3sTVak1GKqX3qdTdg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QftNx5L2yzj2t; Mon, 12 Jun 2023 13:50:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35CDoPqu089448; Mon, 12 Jun 2023 13:50:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35CDoPhk089447; Mon, 12 Jun 2023 13:50:25 GMT (envelope-from git) Date: Mon, 12 Jun 2023 13:50:25 GMT Message-Id: <202306121350.35CDoPhk089447@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 9834e0f2767a - stable/13 - riscv timer: use stimecmp CSR when available List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9834e0f2767a27d237e6820ecd67b24e65323ece Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9834e0f2767a27d237e6820ecd67b24e65323ece commit 9834e0f2767a27d237e6820ecd67b24e65323ece Author: Mitchell Horne AuthorDate: 2023-05-25 17:07:49 +0000 Commit: Mitchell Horne CommitDate: 2023-06-12 13:49:55 +0000 riscv timer: use stimecmp CSR when available The Sstc extension defines a new stimecmp CSR, allowing supervisor software to set the timer, rather than just read it. When supported, using this avoids the frequent trips through the SBI every time the CPU's timer expires. Reviewed by: jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40241 (cherry picked from commit cadaabcc720bb20d6d604c4792acb29072d2882d) --- sys/riscv/riscv/timer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/riscv/riscv/timer.c b/sys/riscv/riscv/timer.c index 9c333b42059e..1df8fb246309 100644 --- a/sys/riscv/riscv/timer.c +++ b/sys/riscv/riscv/timer.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -84,6 +85,16 @@ get_timecount(void) return (rdtime()); } +static inline void +set_timecmp(uint64_t timecmp) +{ + + if (has_sstc) + csr_write(stimecmp, timecmp); + else + sbi_set_timer(timecmp); +} + static u_int riscv_timer_tc_get_timecount(struct timecounter *tc __unused) { @@ -107,7 +118,7 @@ riscv_timer_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period) if (first != 0) { counts = ((uint32_t)et->et_frequency * first) >> 32; - sbi_set_timer(get_timecount() + counts); + set_timecmp(get_timecount() + counts); csr_set(sie, SIE_STIE); return (0);