Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jul 2024 12:38:16 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: d7385a251abf - stable/13 - arm64/gicv3: Check if the hardware supports LPIs
Message-ID:  <202407151238.46FCcGrJ060498@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=d7385a251abffa8313f0c5c981d397bb64e1a683

commit d7385a251abffa8313f0c5c981d397bb64e1a683
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-04-23 11:28:23 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-07-15 12:34:29 +0000

    arm64/gicv3: Check if the hardware supports LPIs
    
    Some simulators have the ITS in the DTB passed to the kernel, however
    it is a runtime configuration option to enable it.
    
    Check the GICD_TYPER register to see if LPIs are enabled before
    attaching the ITS driver.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D44914
    
    (cherry picked from commit 4ab0f5ab3fd6dcd7f76c1ed1c9dc0dcd152fb64f)
---
 sys/arm64/arm64/gic_v3.c     | 4 ++++
 sys/arm64/arm64/gic_v3_var.h | 2 ++
 sys/arm64/arm64/gicv3_its.c  | 6 ++++++
 3 files changed, 12 insertions(+)

diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c
index e37c68aa8a5d..c90edc3ba14c 100644
--- a/sys/arm64/arm64/gic_v3.c
+++ b/sys/arm64/arm64/gic_v3.c
@@ -443,6 +443,10 @@ gic_v3_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
 	case GICV3_IVAR_REDIST:
 		*result = (uintptr_t)sc->gic_redists.pcpu[PCPU_GET(cpuid)];
 		return (0);
+	case GICV3_IVAR_SUPPORT_LPIS:
+		*result =
+		    (gic_d_read(sc, 4, GICD_TYPER) & GICD_TYPER_LPIS) != 0;
+		return (0);
 	case GIC_IVAR_HW_REV:
 		KASSERT(
 		    GICR_PIDR2_ARCH(sc->gic_pidr2) == GICR_PIDR2_ARCH_GICv3 ||
diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h
index d423e51453dc..1a4112a4b0ea 100644
--- a/sys/arm64/arm64/gic_v3_var.h
+++ b/sys/arm64/arm64/gic_v3_var.h
@@ -97,9 +97,11 @@ MALLOC_DECLARE(M_GIC_V3);
 #define	GICV3_IVAR_NIRQS	1000
 /* 1001 was GICV3_IVAR_REDIST_VADDR */
 #define	GICV3_IVAR_REDIST	1002
+#define	GICV3_IVAR_SUPPORT_LPIS	1003
 
 __BUS_ACCESSOR(gicv3, nirqs, GICV3, NIRQS, u_int);
 __BUS_ACCESSOR(gicv3, redist, GICV3, REDIST, void *);
+__BUS_ACCESSOR(gicv3, support_lpis, GICV3, SUPPORT_LPIS, bool);
 
 /* Device methods */
 int gic_v3_attach(device_t dev);
diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index 852db0054aa7..3acc1558cf1a 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -2018,6 +2018,9 @@ gicv3_its_fdt_probe(device_t dev)
 	if (!ofw_bus_is_compatible(dev, "arm,gic-v3-its"))
 		return (ENXIO);
 
+	if (!gicv3_get_support_lpis(dev))
+		return (ENXIO);
+
 	device_set_desc(dev, "ARM GIC Interrupt Translation Service");
 	return (BUS_PROBE_DEFAULT);
 }
@@ -2088,6 +2091,9 @@ gicv3_its_acpi_probe(device_t dev)
 	if (gic_get_hw_rev(dev) < 3)
 		return (EINVAL);
 
+	if (!gicv3_get_support_lpis(dev))
+		return (ENXIO);
+
 	device_set_desc(dev, "ARM GIC Interrupt Translation Service");
 	return (BUS_PROBE_DEFAULT);
 }



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