Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jul 2026 04:35:10 +0000
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: de695c62190f - stable/15 - x86/local_apic.c: Thermal interrupt support: Additional style fixes
Message-ID:  <6a62eb7e.397ba.68839fa4@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by olce:

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

commit de695c62190f61f512a54a6140397a6bf1315e94
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-07-02 13:05:09 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-07-24 04:33:38 +0000

    x86/local_apic.c: Thermal interrupt support: Additional style fixes
    
    Rename handler function type 'lapic_thermal_handle_function' to the
    shorter 'lapic_thermal_handler_t'.  Move it closer to the function
    declaration block where it is used.  Make it a true function type (no
    pointer) and add explicit pointer marks on usage.
    
    Rename 'lapic_thermal_function_value' to the more immediately clear
    'lapic_thermal_function_arg'.  In lapic_thermal_enable(), use 'func_arg'
    as the argument name for the handler argument, which at least refers to
    function 'func', rather than the generic 'value'.
    
    Finally, rename the global handler variable from
    'lapic_thermal_function_ptr' to the shorter 'lapic_thermal_function'
    (dynamic functions can be referenced only through a pointer).
    
    MFC with:       87ba088fa310 ("x86/local_apic.c: Add support for installing a thermal interrupt handler")
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e1f4a8cb8656e64a1fe2b1ab519821b14c4985a0)
---
 sys/x86/include/apicvar.h |  6 ++++--
 sys/x86/x86/local_apic.c  | 22 +++++++++++-----------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h
index cf76977c959b..e0625a38d198 100644
--- a/sys/x86/include/apicvar.h
+++ b/sys/x86/include/apicvar.h
@@ -198,7 +198,6 @@ extern int *apic_cpuids;
 extern void (*ipi_vectored)(u_int, int);
 
 typedef struct ioapic *ioapic_drv_t;
-typedef void (*lapic_thermal_handle_function)(int, void *);
 
 void	apic_register_enumerator(struct apic_enumerator *enumerator);
 ioapic_drv_t	ioapic_create(vm_paddr_t addr, int32_t apic_id, int intbase);
@@ -214,6 +213,9 @@ int	ioapic_set_triggermode(ioapic_drv_t cookie, u_int pin,
 	    enum intr_trigger trigger);
 int	ioapic_set_smi(ioapic_drv_t cookie, u_int pin);
 
+/* First argument: 'cpuid' from 'struct pcpu', second: Opaque cookie. */
+typedef void lapic_thermal_handler_t(int, void *);
+
 void	lapic_create(u_int apic_id, int boot_cpu);
 void	lapic_init(vm_paddr_t addr);
 void	lapic_xapic_mode(void);
@@ -233,7 +235,7 @@ void	apic_enable_vector(u_int apic_id, u_int vector);
 void	apic_disable_vector(u_int apic_id, u_int vector);
 void	apic_free_vector(u_int apic_id, u_int vector, u_int irq);
 void	lapic_calibrate_timer(void);
-void	lapic_enable_thermal(lapic_thermal_handle_function thermfunc, void *value);
+void	lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg);
 void	lapic_disable_thermal(void);
 int	lapic_enable_pcint(void);
 void	lapic_disable_pcint(void);
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index f8810907127a..1c0132d81bff 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -314,8 +314,8 @@ static uint64_t lapic_ipi_wait_mult;
 static int __read_mostly lapic_ds_idle_timeout = 1000000;
 #endif
 unsigned int max_apic_id;
-static void *lapic_thermal_function_value;
-static lapic_thermal_handle_function lapic_thermal_function_ptr;
+static lapic_thermal_handler_t *lapic_thermal_function;
+static void *lapic_thermal_function_arg;
 static int pcint_refcnt = 0;
 
 SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
@@ -1623,13 +1623,13 @@ lapic_enable_mca_elvt(void)
 void
 lapic_handle_thermal(void)
 {
-	lapic_thermal_handle_function func;
+	lapic_thermal_handler_t *func;
 
-	func = (lapic_thermal_handle_function)atomic_load_acq_ptr(
-	    (void *)&lapic_thermal_function_ptr);
+	func = (lapic_thermal_handler_t *)atomic_load_acq_ptr(
+	    (uintptr_t *)&lapic_thermal_function);
 
 	if (func != NULL)
-		func(PCPU_GET(cpuid), lapic_thermal_function_value);
+		func(PCPU_GET(cpuid), lapic_thermal_function_arg);
 
 	lapic_eoi();
 }
@@ -1645,7 +1645,7 @@ lapic_update_thermal(void *dummy __unused)
 }
 
 void
-lapic_enable_thermal(lapic_thermal_handle_function thermfunc, void *value)
+lapic_enable_thermal(lapic_thermal_handler_t *func, void *func_arg)
 {
 #ifdef DEV_ATPIC
 	/* Fail if the local APIC is not present. */
@@ -1653,9 +1653,9 @@ lapic_enable_thermal(lapic_thermal_handle_function thermfunc, void *value)
 		return;
 #endif
 
-	lapic_thermal_function_value = value;
-	atomic_store_rel_ptr((uintptr_t *)&lapic_thermal_function_ptr,
-	    (uintptr_t)thermfunc);
+	lapic_thermal_function_arg = func_arg;
+	atomic_store_rel_ptr((uintptr_t *)&lapic_thermal_function,
+	    (uintptr_t)func);
 
 	lvts[APIC_LVT_THERMAL].lvt_masked = 0;
 
@@ -1679,7 +1679,7 @@ lapic_disable_thermal(void)
 #endif
 	smp_rendezvous(NULL, lapic_update_thermal, NULL, NULL);
 
-	atomic_store_rel_ptr((uintptr_t *)&lapic_thermal_function_ptr,
+	atomic_store_rel_ptr((uintptr_t *)&lapic_thermal_function,
 	    (uintptr_t)NULL);
 }
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a62eb7e.397ba.68839fa4>