Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 May 2023 15:45:53 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ed88e5b2fc75 - stable/13 - Limit where we disable the Arm generic timer
Message-ID:  <202305151545.34FFjrFN073350@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=ed88e5b2fc75f18085ba7c3f1ccac3dc1c9381ce

commit ed88e5b2fc75f18085ba7c3f1ccac3dc1c9381ce
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-02-02 16:26:25 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-05-15 07:59:43 +0000

    Limit where we disable the Arm generic timer
    
    Only disable the Arm generic timer on arm64 when entering the kernel
    through EL2. There is no guarantee it will be enabled if we are running
    under a hypervisor.
    
    Sponsored by:   Arm Ltd
    
    (cherry picked from commit 22e4897422a055b7a15be5984fbc4bb97f432e79)
---
 sys/arm/arm/generic_timer.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c
index 5b4972017c2d..cdc60ba469a4 100644
--- a/sys/arm/arm/generic_timer.c
+++ b/sys/arm/arm/generic_timer.c
@@ -54,15 +54,13 @@ __FBSDID("$FreeBSD$");
 #include <sys/smp.h>
 #include <sys/vdso.h>
 #include <sys/watchdog.h>
+
 #include <machine/bus.h>
 #include <machine/cpu.h>
 #include <machine/intr.h>
+#include <machine/machdep.h>
 #include <machine/md_var.h>
 
-#if defined(__arm__)
-#include <machine/machdep.h> /* For arm_set_delay */
-#endif
-
 #ifdef FDT
 #include <dev/ofw/openfirm.h>
 #include <dev/ofw/ofw_bus.h>
@@ -134,11 +132,13 @@ static struct timecounter arm_tmr_timecount = {
 #define	get_el1(x)	cp15_## x ##_get()
 #define	set_el0(x, val)	cp15_## x ##_set(val)
 #define	set_el1(x, val)	cp15_## x ##_set(val)
+#define	HAS_PHYS	true
 #else /* __aarch64__ */
 #define	get_el0(x)	READ_SPECIALREG(x ##_el0)
 #define	get_el1(x)	READ_SPECIALREG(x ##_el1)
 #define	set_el0(x, val)	WRITE_SPECIALREG(x ##_el0, val)
 #define	set_el1(x, val)	WRITE_SPECIALREG(x ##_el1, val)
+#define	HAS_PHYS	has_hyp()
 #endif
 
 static int
@@ -475,8 +475,8 @@ arm_tmr_attach(device_t dev)
 	if (sc->res[GT_VIRT] != NULL)
 		arm_tmr_disable(false);
 	/* And the physical */
-	if (sc->res[GT_PHYS_SECURE] != NULL ||
-	    sc->res[GT_PHYS_NONSECURE] != NULL)
+	if ((sc->res[GT_PHYS_SECURE] != NULL ||
+	    sc->res[GT_PHYS_NONSECURE] != NULL) && HAS_PHYS)
 		arm_tmr_disable(true);
 
 	arm_tmr_timecount.tc_frequency = sc->clkfreq;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305151545.34FFjrFN073350>