]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ACPI: GTDT: Parse information related to the EL2 virtual timer
authorMarc Zyngier <maz@kernel.org>
Sat, 23 May 2026 14:02:27 +0000 (15:02 +0100)
committerDaniel Lezcano <daniel.lezcano@kernel.org>
Wed, 3 Jun 2026 07:52:55 +0000 (09:52 +0200)
Now that we have a way to identify GTDTv3, allow the information
related to the EL2 virtual timer to be retrieved by the interface
used by the architected timer driver.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Link: https://patch.msgid.link/20260523140242.586031-3-maz@kernel.org
drivers/acpi/arm64/gtdt.c

index 950d5efdf85eac27756ef29e04d0032971dabd34..00158c8aa6d90be98bc525333d3f5929953efcfe 100644 (file)
@@ -41,6 +41,14 @@ struct gtdt_v3 {
 
 static struct acpi_gtdt_descriptor acpi_gtdt_desc __initdata;
 
+static __init struct acpi_gtdt_el2 *gtdt_to_el2_vtimer(struct acpi_table_gtdt *gtdt)
+{
+       if (gtdt->header.revision < 3)
+               return NULL;
+
+       return &container_of(gtdt, struct gtdt_v3, gtdt_v2)->el2_vtimer;
+}
+
 static __init bool platform_timer_valid(void *platform_timer)
 {
        struct acpi_gtdt_header *gh = platform_timer;
@@ -112,6 +120,7 @@ static int __init map_gt_gsi(u32 interrupt, u32 flags)
 int __init acpi_gtdt_map_ppi(int type)
 {
        struct acpi_table_gtdt *gtdt = acpi_gtdt_desc.gtdt;
+       struct acpi_gtdt_el2 *el2_vtimer = gtdt_to_el2_vtimer(gtdt);
 
        switch (type) {
        case ARCH_TIMER_PHYS_NONSECURE_PPI:
@@ -124,6 +133,12 @@ int __init acpi_gtdt_map_ppi(int type)
        case ARCH_TIMER_HYP_PPI:
                return map_gt_gsi(gtdt->non_secure_el2_interrupt,
                                  gtdt->non_secure_el2_flags);
+       case ARCH_TIMER_HYP_VIRT_PPI:
+               if (el2_vtimer && el2_vtimer->virtual_el2_timer_gsiv)
+                       return map_gt_gsi(el2_vtimer->virtual_el2_timer_gsiv,
+                                         el2_vtimer->virtual_el2_timer_flags);
+
+               return 0;
        default:
                pr_err("Failed to map timer interrupt: invalid type.\n");
        }
@@ -141,6 +156,7 @@ int __init acpi_gtdt_map_ppi(int type)
 bool __init acpi_gtdt_c3stop(int type)
 {
        struct acpi_table_gtdt *gtdt = acpi_gtdt_desc.gtdt;
+       struct acpi_gtdt_el2 *el2_vtimer = gtdt_to_el2_vtimer(gtdt);
 
        switch (type) {
        case ARCH_TIMER_PHYS_NONSECURE_PPI:
@@ -152,6 +168,10 @@ bool __init acpi_gtdt_c3stop(int type)
        case ARCH_TIMER_HYP_PPI:
                return !(gtdt->non_secure_el2_flags & ACPI_GTDT_ALWAYS_ON);
 
+       case ARCH_TIMER_HYP_VIRT_PPI:
+               return el2_vtimer && el2_vtimer->virtual_el2_timer_gsiv &&
+                      !(el2_vtimer->virtual_el2_timer_flags & ACPI_GTDT_ALWAYS_ON);
+
        default:
                pr_err("Failed to get c3stop info: invalid type.\n");
        }