git: 019f643bc0a7 - stable/14 - x86/local_apic.c: Thermal interrupt support: Additional style fixes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Jul 2026 10:01:13 UTC
The branch stable/14 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=019f643bc0a7d19dba53ff728e1d458e9dc689a9
commit 019f643bc0a7d19dba53ff728e1d458e9dc689a9
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-07-02 13:05:09 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-07-23 09:59:15 +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 0c205c0701b2..d9957409cfae 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_pmc(void);
void lapic_disable_pmc(void);
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 5712f7b3ff2b..83783effad36 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -211,8 +211,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;
SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"APIC options");
@@ -1497,13 +1497,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();
}
@@ -1519,7 +1519,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. */
@@ -1527,9 +1527,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;
@@ -1553,7 +1553,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);
}