The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=e1f4a8cb8656e64a1fe2b1ab519821b14c4985a0
commit e1f4a8cb8656e64a1fe2b1ab519821b14c4985a0 Author: Olivier Certner <[email protected]> AuthorDate: 2026-07-02 13:05:09 +0000 Commit: Olivier Certner <[email protected]> CommitDate: 2026-07-07 16:34:07 +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 --- 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 66d53bbf7e5d..54ea5bc655e5 100644 --- a/sys/x86/include/apicvar.h +++ b/sys/x86/include/apicvar.h @@ -199,7 +199,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); @@ -215,6 +214,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); @@ -234,7 +236,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 08748a1fe7c2..9e1c1d70aea7 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, @@ -1642,13 +1642,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(); } @@ -1664,7 +1664,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. */ @@ -1672,9 +1672,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; @@ -1698,7 +1698,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); }
