mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-04-28 11:43:56 +00:00
This patch can fetch the thermal lvt irq and propagate it to VM. At this stage we support the case that there is only one VM governing thermal. And we pass the hardware thermal irq to this VM. First, we register the handler for thermal lvt interrupt, its irq vector is THERMAL_VECTOR and the handler is thermal_irq_handler(). Then, when a thermal irq occurs, it flags the SOFTIRQ_THERMAL bit of softirq_pending, This bit triggers the thermal_softirq() function. And this function will inject the virtual thermal irq to VM. Tracked-On: #8595 Signed-off-by: Zhangwei6 <wei6.zhang@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
36 lines
634 B
C
36 lines
634 B
C
/*
|
|
* Copyright (C) 2023 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <types.h>
|
|
#include <softirq.h>
|
|
#include <trace.h>
|
|
#include <asm/guest/virq.h>
|
|
#include <hw/hw_thermal.h>
|
|
|
|
static void thermal_softirq(uint16_t pcpu_id)
|
|
{
|
|
struct acrn_vcpu *vcpu;
|
|
uint32_t idx;
|
|
|
|
for (idx = 0; idx < CONFIG_MAX_VM_NUM; idx++) {
|
|
vcpu = per_cpu(vcpu_array, pcpu_id)[idx];
|
|
if (vcpu != NULL) {
|
|
vcpu_inject_thermal_interrupt(vcpu);
|
|
}
|
|
}
|
|
}
|
|
|
|
void thermal_init(void)
|
|
{
|
|
uint16_t pcpu_id = get_pcpu_id();
|
|
|
|
if (pcpu_id == BSP_CPU_ID) {
|
|
register_softirq(SOFTIRQ_THERMAL, thermal_softirq);
|
|
}
|
|
|
|
init_hw_thermal();
|
|
}
|