Lines Matching +full:thermal +full:- +full:zones

1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <linux/thermal.h>
42 /* Number of trip points in thermal zone. Currently it can't
66 static struct zone_device **zones; variable
93 * - cpu hotplug: Read serialized by cpu hotplug lock
96 * - Other callsites: Must hold pkg_temp_lock
103 return zones[id]; in pkg_temp_thermal_get_dev()
112 ret = intel_tcc_get_temp(zonedev->cpu, &val, true); in sys_get_curr_temp()
126 unsigned int trip_index = THERMAL_TRIP_PRIV_TO_INT(trip->priv); in sys_set_trip_temp()
130 tj_max = intel_tcc_get_tjmax(zonedev->cpu); in sys_set_trip_temp()
135 val = (tj_max - temp)/1000; in sys_set_trip_temp()
138 return -EINVAL; in sys_set_trip_temp()
140 ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, in sys_set_trip_temp()
166 return wrmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, in sys_set_trip_temp()
170 /* Thermal zone callback registry */
225 zonedev->work_scheduled = false; in pkg_temp_thermal_threshold_work_fn()
228 tzone = zonedev->tzone; in pkg_temp_thermal_threshold_work_fn()
263 if (zonedev && !zonedev->work_scheduled) { in pkg_thermal_notify()
264 zonedev->work_scheduled = true; in pkg_thermal_notify()
265 pkg_thermal_schedule_work(zonedev->cpu, &zonedev->work); in pkg_thermal_notify()
297 tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID; in pkg_temp_thermal_trips_init()
320 return -ENOMEM; in pkg_temp_thermal_device_add()
325 return -ENODEV; in pkg_temp_thermal_device_add()
335 return -ENOMEM; in pkg_temp_thermal_device_add()
341 INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn); in pkg_temp_thermal_device_add()
342 zonedev->cpu = cpu; in pkg_temp_thermal_device_add()
343 zonedev->tzone = thermal_zone_device_register_with_trips("x86_pkg_temp", in pkg_temp_thermal_device_add()
346 if (IS_ERR(zonedev->tzone)) { in pkg_temp_thermal_device_add()
347 err = PTR_ERR(zonedev->tzone); in pkg_temp_thermal_device_add()
350 err = thermal_zone_device_enable(zonedev->tzone); in pkg_temp_thermal_device_add()
354 /* Store MSR value for package thermal interrupt, to restore at exit */ in pkg_temp_thermal_device_add()
355 rdmsr(MSR_IA32_PACKAGE_THERM_INTERRUPT, zonedev->msr_pkg_therm_low, in pkg_temp_thermal_device_add()
356 zonedev->msr_pkg_therm_high); in pkg_temp_thermal_device_add()
358 cpumask_set_cpu(cpu, &zonedev->cpumask); in pkg_temp_thermal_device_add()
360 zones[id] = zonedev; in pkg_temp_thermal_device_add()
366 thermal_zone_device_unregister(zonedev->tzone); in pkg_temp_thermal_device_add()
381 target = cpumask_any_but(&zonedev->cpumask, cpu); in pkg_thermal_cpu_offline()
382 cpumask_clear_cpu(cpu, &zonedev->cpumask); in pkg_thermal_cpu_offline()
389 struct thermal_zone_device *tzone = zonedev->tzone; in pkg_thermal_cpu_offline()
398 zonedev->tzone = NULL; in pkg_thermal_cpu_offline()
412 was_target = zonedev->cpu == cpu; in pkg_thermal_cpu_offline()
413 zonedev->cpu = target; in pkg_thermal_cpu_offline()
422 zones[topology_logical_die_id(cpu)] = NULL; in pkg_thermal_cpu_offline()
425 zonedev->msr_pkg_therm_low, zonedev->msr_pkg_therm_high); in pkg_thermal_cpu_offline()
432 if (zonedev->work_scheduled && was_target) { in pkg_thermal_cpu_offline()
438 cancel_delayed_work_sync(&zonedev->work); in pkg_thermal_cpu_offline()
446 if (!lastcpu && zonedev->work_scheduled) in pkg_thermal_cpu_offline()
447 pkg_thermal_schedule_work(target, &zonedev->work); in pkg_thermal_cpu_offline()
466 return -ENODEV; in pkg_thermal_cpu_online()
470 cpumask_set_cpu(cpu, &zonedev->cpumask); in pkg_thermal_cpu_online()
487 return -ENODEV; in pkg_temp_thermal_init()
490 zones = kcalloc(max_id, sizeof(struct zone_device *), in pkg_temp_thermal_init()
492 if (!zones) in pkg_temp_thermal_init()
493 return -ENOMEM; in pkg_temp_thermal_init()
495 ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "thermal/x86_pkg:online", in pkg_temp_thermal_init()
511 kfree(zones); in pkg_temp_thermal_init()
523 kfree(zones); in module_init()
528 MODULE_DESCRIPTION("X86 PKG TEMP Thermal Driver");