https://source.android.com/docs/security/bulletin/2023-03-01 CVE-2021-33655 * tag 'ASB-2023-03-05_4.19-stable' of https://android.googlesource.com/kernel/common: Linux 4.19.275 USB: core: Don't hold device lock while reading the "descriptors" sysfs file USB: serial: option: add support for VW/Skoda "Carstick LTE" dmaengine: sh: rcar-dmac: Check for error num after dma_set_max_seg_size vc_screen: don't clobber return value in vcs_read net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues(). IB/hfi1: Assign npages earlier btrfs: send: limit number of clones and allocated memory size ACPI: NFIT: fix a potential deadlock during NFIT teardown ARM: dts: rockchip: add power-domains property to dp node on rk3288 UPSTREAM: selinux: check return value of sel_make_avc_files UPSTREAM: lib/test_meminit: destroy cache in kmem_cache_alloc_bulk() test UPSTREAM: wireguard: ratelimiter: use kvcalloc() instead of kvzalloc() UPSTREAM: wireguard: receive: drop handshakes if queue lock is contended UPSTREAM: wireguard: receive: use ring buffer for incoming handshakes UPSTREAM: wireguard: device: reset peer src endpoint when netns exits UPSTREAM: wireguard: selftests: actually test for routing loops UPSTREAM: kasan: fix tag for large allocations when using CONFIG_SLAB UPSTREAM: usb: musb: select GENERIC_PHY instead of depending on it UPSTREAM: driver core: Reject pointless SYNC_STATE_ONLY device links BACKPORT: PM: EM: Fix inefficient states detection UPSTREAM: cfg80211: scan: fix RCU in cfg80211_add_nontrans_list() UPSTREAM: thermal/core: Fix thermal_cooling_device_register() prototype UPSTREAM: PM: EM: Increase energy calculation precision UPSTREAM: lib/test_stackinit: Fix static initializer test BACKPORT: userfaultfd: do not untag user pointers UPSTREAM: net/xfrm/compat: Copy xfrm_spdattr_type_t atributes UPSTREAM: sched/uclamp: Ignore max aggregation if rq is idle UPSTREAM: net: xfrm: fix memory leak in xfrm_user_rcv_msg UPSTREAM: f2fs: Advertise encrypted casefolding in sysfs UPSTREAM: fuse: ignore PG_workingset after stealing BACKPORT: loop: Fix missing discard support when using LOOP_CONFIGURE BACKPORT: nvmem: core: add a missing of_node_put UPSTREAM: usb: typec: mux: Fix copy-paste mistake in typec_mux_match Linux 4.19.274 bpf: add missing header file include ext4: Fix function prototype mismatch for ext4_feat_ktype wifi: mwifiex: Add missing compatible string for SD8787 uaccess: Add speculation barrier to copy_from_user() mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh drm/i915/gvt: fix double free bug in split_2MB_gtt_entry alarmtimer: Prevent starvation by small intervals and SIG_IGN powerpc: dts: t208x: Disable 10G on MAC1 and MAC2 can: kvaser_usb: hydra: help gcc-13 to figure out cmd_len random: always mix cycle counter in add_latent_entropy() powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G wifi: rtl8xxxu: gen2: Turn on the rate control BACKPORT: fscrypt: fix derivation of SipHash keys on big endian CPUs UPSTREAM: wireguard: allowedips: free empty intermediate nodes when removing single node BACKPORT: wireguard: allowedips: allocate nodes in kmem_cache Linux 4.19.273 net: phy: meson-gxl: Add generic dummy stubs for MMD register access nilfs2: fix underflow in second superblock position calculations kvm: initialize all of the kvm_debugregs structure before sending it to userspace i40e: Add checking for null for nlmsg_find_attr() ipv6: Fix tcp socket connection with DSCP. ipv6: Fix datagram socket connection with DSCP. net: mpls: fix stale pointer if allocation fails during device rename net: stmmac: Restrict warning on disabling DMA store and fwd mode bnxt_en: Fix mqprio and XDP ring checking logic net: stmmac: fix order of dwmac5 FlexPPS parametrization sequence net/usb: kalmia: Don't pass act_len in usb_bulk_msg error path dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions. net: bgmac: fix BCM5358 support by setting correct flags i40e: add double of VLAN header when computing the max MTU revert "squashfs: harden sanity check in squashfs_read_xattr_id_table" hugetlb: check for undefined shift on 32 bit architectures ALSA: hda/realtek - fixed wrong gpio assigned ALSA: hda/conexant: add a new hda codec SN6180 mmc: sdio: fix possible resource leaks in some error paths Revert "x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN" netfilter: nft_tproxy: restrict to prerouting hook aio: fix mremap after fork null-deref nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association net/rose: Fix to not accept on connected socket tools/virtio: fix the vringh test for virtio ring changes ASoC: cs42l56: fix DT probe migrate: hugetlb: check for hugetlb shared PMD in node migration bpf: Always return target ifindex in bpf_fib_lookup arm64: dts: meson-axg: Make mmc host controller interrupts level-sensitive arm64: dts: meson-gx: Make mmc host controller interrupts level-sensitive riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte usb: typec: altmodes/displayport: Fix probe pin assign check usb: core: add quirk for Alcor Link AK9563 smartcard reader net: USB: Fix wrong-direction WARNING in plusb.c pinctrl: intel: Restore the pins that used to be in Direct IRQ mode pinctrl: intel: Convert unsigned to unsigned int pinctrl: single: fix potential NULL dereference pinctrl: aspeed: Fix confusing types in return value ALSA: pci: lx6464es: fix a debug loop selftests: forwarding: lib: quote the sysctl values rds: rds_rm_zerocopy_callback() use list_first_entry() net: phy: meson-gxl: use MMD access dummy stubs for GXL, internal PHY net: phy: meson-gxl: add g12a support net: phy: add macros for PHYID matching IB/hfi1: Restore allocated resources on failed copyout ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() btrfs: limit device extents to the device size iio:adc:twl6030: Enable measurement of VAC thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type() serial: 8250_dma: Fix DMA Rx rearm race serial: 8250_dma: Fix DMA Rx completion race Squashfs: fix handling and sanity checking of xattr_ids count mm/swapfile: add cond_resched() in get_swap_pages() mm: hugetlb: proc: check for hugetlb shared PMD in /proc/PID/smaps riscv: disable generation of unwind tables parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case parisc: Fix return code of pdc_iodc_print() iio:adc:twl6030: Enable measurements of VUSB, VBAT and others iio: adc: berlin2-adc: Add missing of_node_put() in error path iio: hid: fix the retval in accel_3d_capture_sample efi: Accept version 2 of memory attributes table watchdog: diag288_wdt: fix __diag288() inline assembly watchdog: diag288_wdt: do not use stack buffers for hardware data fbcon: Check font dimension limits thermal: intel: int340x: Protect trip temperature from concurrent updates KVM: x86/vmx: Do not skip segment attributes if unusable bit is set KVM: VMX: Move caching of MSR_IA32_XSS to hardware_setup() KVM: VMX: Move VMX specific files to a "vmx" subdirectory nVMX x86: Check VMX-preemption timer controls on vmentry of L2 guests Input: i8042 - add Clevo PCX0DX to i8042 quirk table Input: i8042 - add TUXEDO devices to i8042 quirk tables Input: i8042 - merge quirk tables Input: i8042 - move __initconst to fix code styling warning vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF usb: gadget: f_fs: Fix unbalanced spinlock in __ffs_ep0_queue_wait usb: dwc3: qcom: enable vbus override when in OTG dr-mode usb: dwc3: dwc3-qcom: Fix typo in the dwc3 vbus override API iio: adc: stm32-dfsdm: fill module aliases net/x25: Fix to not accept on connected socket i2c: rk3x: fix a bunch of kernel-doc warnings scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress scsi: target: core: Fix warning on RT kernels net: openvswitch: fix flow memory leak in ovs_flow_cmd_new ata: libata: Fix sata_down_spd_limit() when no link speed is reported squashfs: harden sanity check in squashfs_read_xattr_id_table netrom: Fix use-after-free caused by accept on already connected socket ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() bus: sunxi-rsb: Fix error handling in sunxi_rsb_init() firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region UPSTREAM: wireguard: allowedips: remove nodes in O(1) UPSTREAM: wireguard: allowedips: initialize list head in selftest UPSTREAM: wireguard: use synchronize_net rather than synchronize_rcu UPSTREAM: wireguard: do not use -O3 UPSTREAM: wireguard: selftests: make sure rp_filter is disabled on vethc BACKPORT: wireguard: selftests: remove old conntrack kconfig value BACKPORT: usb: typec: mux: Fix matching with typec_altmode_desc UPSTREAM: sched/uclamp: Fix locking around cpu_util_update_eff() UPSTREAM: sched/uclamp: Fix wrong implementation of cpu.uclamp.min UPSTREAM: usb: musb: Fix an error message UPSTREAM: arm64: doc: Add brk/mmap/mremap() to the Tagged Address ABI Exceptions BACKPORT: selinux: add proper NULL termination to the secclass_map permissions UPSTREAM: crypto: arm/curve25519 - Move '.fpu' after '.arch' UPSTREAM: libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC UPSTREAM: of: property: fw_devlink: do not link ".*,nr-gpios" UPSTREAM: xfrm/compat: Cleanup WARN()s that can be user-triggered UPSTREAM: wireguard: selftests: test multiple parallel streams UPSTREAM: crypto: mips: add poly1305-core.S to .gitignore BACKPORT: arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL UPSTREAM: crypto: mips/poly1305 - enable for all MIPS processors UPSTREAM: kbuild: do not include include/config/auto.conf from adjust_autoksyms.sh UPSTREAM: wireguard: kconfig: use arm chacha even with no neon UPSTREAM: wireguard: queueing: get rid of per-peer ring buffers UPSTREAM: wireguard: device: do not generate ICMP for non-IP packets BACKPORT: mac80211_hwsim: notify wmediumd of used MAC addresses BACKPORT: mac80211_hwsim: add concurrent channels scanning support over virtio BACKPORT: perf_event_open: switch to copy_struct_from_user() BACKPORT: sched_setattr: switch to copy_struct_from_user() Conflicts: kernel/power/energy_model.c net/wireless/scan.c Change-Id: I55c29a161fd214642259ddfb19fb749a416babb2
635 lines
22 KiB
C
635 lines
22 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* thermal.h ($Revision: 0 $)
|
|
*
|
|
* Copyright (C) 2008 Intel Corp
|
|
* Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
|
|
* Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
|
|
*/
|
|
|
|
#ifndef __THERMAL_H__
|
|
#define __THERMAL_H__
|
|
|
|
#include <linux/of.h>
|
|
#include <linux/idr.h>
|
|
#include <linux/device.h>
|
|
#include <linux/sysfs.h>
|
|
#include <linux/workqueue.h>
|
|
#include <uapi/linux/thermal.h>
|
|
|
|
#define THERMAL_TRIPS_NONE -1
|
|
#define THERMAL_MAX_TRIPS 12
|
|
|
|
/* invalid cooling state */
|
|
#define THERMAL_CSTATE_INVALID -1UL
|
|
|
|
/* No upper/lower limit requirement */
|
|
#define THERMAL_NO_LIMIT ((u32)~0)
|
|
|
|
/* upper limit requirement */
|
|
#define THERMAL_MAX_LIMIT (THERMAL_NO_LIMIT - 1)
|
|
|
|
/* Default weight of a bound cooling device */
|
|
#define THERMAL_WEIGHT_DEFAULT 0
|
|
|
|
/* Max sensors that can be used for a single virtual thermalzone */
|
|
#define THERMAL_MAX_VIRT_SENSORS 10
|
|
|
|
/* use value, which < 0K, to indicate an invalid/uninitialized temperature */
|
|
#define THERMAL_TEMP_INVALID -274000
|
|
|
|
/*
|
|
* use a high value for low temp tracking zone,
|
|
* to indicate an invalid/uninitialized temperature
|
|
*/
|
|
#define THERMAL_TEMP_INVALID_LOW 274000
|
|
|
|
/* Unit conversion macros */
|
|
#define DECI_KELVIN_TO_CELSIUS(t) ({ \
|
|
long _t = (t); \
|
|
((_t-2732 >= 0) ? (_t-2732+5)/10 : (_t-2732-5)/10); \
|
|
})
|
|
#define CELSIUS_TO_DECI_KELVIN(t) ((t)*10+2732)
|
|
#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100)
|
|
#define DECI_KELVIN_TO_MILLICELSIUS(t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732)
|
|
#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, off) (((t) / 100) + (off))
|
|
#define MILLICELSIUS_TO_DECI_KELVIN(t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732)
|
|
|
|
/* Default Thermal Governor */
|
|
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
|
|
#define DEFAULT_THERMAL_GOVERNOR "step_wise"
|
|
#elif defined(CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE)
|
|
#define DEFAULT_THERMAL_GOVERNOR "fair_share"
|
|
#elif defined(CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE)
|
|
#define DEFAULT_THERMAL_GOVERNOR "user_space"
|
|
#elif defined(CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR)
|
|
#define DEFAULT_THERMAL_GOVERNOR "power_allocator"
|
|
#endif
|
|
|
|
struct thermal_zone_device;
|
|
struct thermal_cooling_device;
|
|
struct thermal_instance;
|
|
|
|
enum thermal_device_mode {
|
|
THERMAL_DEVICE_DISABLED = 0,
|
|
THERMAL_DEVICE_ENABLED,
|
|
};
|
|
|
|
enum thermal_trip_type {
|
|
THERMAL_TRIP_ACTIVE = 0,
|
|
THERMAL_TRIP_PASSIVE,
|
|
THERMAL_TRIP_HOT,
|
|
THERMAL_TRIP_CRITICAL,
|
|
THERMAL_TRIP_CONFIGURABLE_HI,
|
|
THERMAL_TRIP_CONFIGURABLE_LOW,
|
|
THERMAL_TRIP_CRITICAL_LOW,
|
|
};
|
|
|
|
enum thermal_trend {
|
|
THERMAL_TREND_STABLE, /* temperature is stable */
|
|
THERMAL_TREND_RAISING, /* temperature is raising */
|
|
THERMAL_TREND_DROPPING, /* temperature is dropping */
|
|
THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
|
|
THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
|
|
};
|
|
|
|
/* Thermal notification reason */
|
|
enum thermal_notify_event {
|
|
THERMAL_EVENT_UNSPECIFIED, /* Unspecified event */
|
|
THERMAL_EVENT_TEMP_SAMPLE, /* New Temperature sample */
|
|
THERMAL_TRIP_VIOLATED, /* TRIP Point violation */
|
|
THERMAL_TRIP_CHANGED, /* TRIP Point temperature changed */
|
|
THERMAL_DEVICE_DOWN, /* Thermal device is down */
|
|
THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
|
|
THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
|
|
THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
|
|
};
|
|
|
|
struct thermal_zone_device_ops {
|
|
int (*bind) (struct thermal_zone_device *,
|
|
struct thermal_cooling_device *);
|
|
int (*unbind) (struct thermal_zone_device *,
|
|
struct thermal_cooling_device *);
|
|
int (*get_temp) (struct thermal_zone_device *, int *);
|
|
int (*set_trips) (struct thermal_zone_device *, int, int);
|
|
int (*get_mode) (struct thermal_zone_device *,
|
|
enum thermal_device_mode *);
|
|
int (*set_mode) (struct thermal_zone_device *,
|
|
enum thermal_device_mode);
|
|
int (*get_trip_type) (struct thermal_zone_device *, int,
|
|
enum thermal_trip_type *);
|
|
int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
|
|
int (*set_trip_temp) (struct thermal_zone_device *, int, int);
|
|
int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
|
|
int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
|
|
int (*get_crit_temp) (struct thermal_zone_device *, int *);
|
|
int (*set_emul_temp) (struct thermal_zone_device *, int);
|
|
int (*get_trend) (struct thermal_zone_device *, int,
|
|
enum thermal_trend *);
|
|
int (*notify) (struct thermal_zone_device *, int,
|
|
enum thermal_trip_type);
|
|
bool (*is_wakeable)(struct thermal_zone_device *);
|
|
int (*set_polling_delay)(struct thermal_zone_device *, int);
|
|
int (*set_passive_delay)(struct thermal_zone_device *, int);
|
|
};
|
|
|
|
struct thermal_cooling_device_ops {
|
|
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
|
|
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
|
|
int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
|
|
int (*set_min_state)(struct thermal_cooling_device *cdev,
|
|
unsigned long target);
|
|
int (*get_min_state)(struct thermal_cooling_device *cdev,
|
|
unsigned long *target);
|
|
int (*get_requested_power)(struct thermal_cooling_device *,
|
|
struct thermal_zone_device *, u32 *);
|
|
int (*state2power)(struct thermal_cooling_device *,
|
|
struct thermal_zone_device *, unsigned long, u32 *);
|
|
int (*power2state)(struct thermal_cooling_device *,
|
|
struct thermal_zone_device *, u32, unsigned long *);
|
|
};
|
|
|
|
struct thermal_cooling_device {
|
|
int id;
|
|
char type[THERMAL_NAME_LENGTH];
|
|
struct device device;
|
|
struct device_node *np;
|
|
void *devdata;
|
|
void *stats;
|
|
const struct thermal_cooling_device_ops *ops;
|
|
bool updated; /* true if the cooling device does not need update */
|
|
struct mutex lock; /* protect thermal_instances list */
|
|
struct list_head thermal_instances;
|
|
struct list_head node;
|
|
unsigned long sysfs_cur_state_req;
|
|
unsigned long sysfs_min_state_req;
|
|
};
|
|
|
|
struct thermal_attr {
|
|
struct device_attribute attr;
|
|
char name[THERMAL_NAME_LENGTH];
|
|
};
|
|
|
|
/**
|
|
* struct thermal_zone_device - structure for a thermal zone
|
|
* @id: unique id number for each thermal zone
|
|
* @type: the thermal zone device type
|
|
* @device: &struct device for this thermal zone
|
|
* @trip_temp_attrs: attributes for trip points for sysfs: trip temperature
|
|
* @trip_type_attrs: attributes for trip points for sysfs: trip type
|
|
* @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
|
|
* @devdata: private pointer for device private data
|
|
* @trips: number of trip points the thermal zone supports
|
|
* @trips_disabled; bitmap for disabled trips
|
|
* @passive_delay: number of milliseconds to wait between polls when
|
|
* performing passive cooling.
|
|
* @polling_delay: number of milliseconds to wait between polls when
|
|
* checking whether trip points have been crossed (0 for
|
|
* interrupt driven systems)
|
|
* @temperature: current temperature. This is only for core code,
|
|
* drivers should use thermal_zone_get_temp() to get the
|
|
* current temperature
|
|
* @last_temperature: previous temperature read
|
|
* @emul_temperature: emulated temperature when using CONFIG_THERMAL_EMULATION
|
|
* @passive: 1 if you've crossed a passive trip point, 0 otherwise.
|
|
* @prev_low_trip: the low current temperature if you've crossed a passive
|
|
trip point.
|
|
* @prev_high_trip: the above current temperature if you've crossed a
|
|
passive trip point.
|
|
* @forced_passive: If > 0, temperature at which to switch on all ACPI
|
|
* processor cooling devices. Currently only used by the
|
|
* step-wise governor.
|
|
* @need_update: if equals 1, thermal_zone_device_update needs to be invoked.
|
|
* @ops: operations this &thermal_zone_device supports
|
|
* @tzp: thermal zone parameters
|
|
* @governor: pointer to the governor for this thermal zone
|
|
* @governor_data: private pointer for governor data
|
|
* @thermal_instances: list of &struct thermal_instance of this thermal zone
|
|
* @ida: &struct ida to generate unique id for this zone's cooling
|
|
* devices
|
|
* @lock: lock to protect thermal_instances list
|
|
* @node: node in thermal_tz_list (in thermal_core.c)
|
|
* @poll_queue: delayed work for polling
|
|
* @notify_event: Last notification event
|
|
*/
|
|
struct thermal_zone_device {
|
|
int id;
|
|
char type[THERMAL_NAME_LENGTH];
|
|
struct device device;
|
|
struct attribute_group trips_attribute_group;
|
|
struct thermal_attr *trip_temp_attrs;
|
|
struct thermal_attr *trip_type_attrs;
|
|
struct thermal_attr *trip_hyst_attrs;
|
|
void *devdata;
|
|
int trips;
|
|
unsigned long trips_disabled; /* bitmap for disabled trips */
|
|
int passive_delay;
|
|
int polling_delay;
|
|
int temperature;
|
|
int last_temperature;
|
|
int emul_temperature;
|
|
int passive;
|
|
int prev_low_trip;
|
|
int prev_high_trip;
|
|
unsigned int forced_passive;
|
|
atomic_t need_update;
|
|
struct thermal_zone_device_ops *ops;
|
|
struct thermal_zone_params *tzp;
|
|
struct thermal_governor *governor;
|
|
void *governor_data;
|
|
struct list_head thermal_instances;
|
|
struct ida ida;
|
|
struct mutex lock;
|
|
struct list_head node;
|
|
struct delayed_work poll_queue;
|
|
enum thermal_notify_event notify_event;
|
|
};
|
|
|
|
/**
|
|
* struct thermal_governor - structure that holds thermal governor information
|
|
* @name: name of the governor
|
|
* @bind_to_tz: callback called when binding to a thermal zone. If it
|
|
* returns 0, the governor is bound to the thermal zone,
|
|
* otherwise it fails.
|
|
* @unbind_from_tz: callback called when a governor is unbound from a
|
|
* thermal zone.
|
|
* @throttle: callback called for every trip point even if temperature is
|
|
* below the trip point temperature
|
|
* @governor_list: node in thermal_governor_list (in thermal_core.c)
|
|
*/
|
|
struct thermal_governor {
|
|
char name[THERMAL_NAME_LENGTH];
|
|
int (*bind_to_tz)(struct thermal_zone_device *tz);
|
|
void (*unbind_from_tz)(struct thermal_zone_device *tz);
|
|
int (*throttle)(struct thermal_zone_device *tz, int trip);
|
|
struct list_head governor_list;
|
|
int min_state_throttle;
|
|
};
|
|
|
|
/* Structure that holds binding parameters for a zone */
|
|
struct thermal_bind_params {
|
|
struct thermal_cooling_device *cdev;
|
|
|
|
/*
|
|
* This is a measure of 'how effectively these devices can
|
|
* cool 'this' thermal zone. It shall be determined by
|
|
* platform characterization. This value is relative to the
|
|
* rest of the weights so a cooling device whose weight is
|
|
* double that of another cooling device is twice as
|
|
* effective. See Documentation/thermal/sysfs-api.txt for more
|
|
* information.
|
|
*/
|
|
int weight;
|
|
|
|
/*
|
|
* This is a bit mask that gives the binding relation between this
|
|
* thermal zone and cdev, for a particular trip point.
|
|
* See Documentation/thermal/sysfs-api.txt for more information.
|
|
*/
|
|
int trip_mask;
|
|
|
|
/*
|
|
* This is an array of cooling state limits. Must have exactly
|
|
* 2 * thermal_zone.number_of_trip_points. It is an array consisting
|
|
* of tuples <lower-state upper-state> of state limits. Each trip
|
|
* will be associated with one state limit tuple when binding.
|
|
* A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
|
|
* on all trips.
|
|
*/
|
|
unsigned long *binding_limits;
|
|
int (*match) (struct thermal_zone_device *tz,
|
|
struct thermal_cooling_device *cdev);
|
|
};
|
|
|
|
/* Structure to define Thermal Zone parameters */
|
|
struct thermal_zone_params {
|
|
char governor_name[THERMAL_NAME_LENGTH];
|
|
|
|
/*
|
|
* a boolean to indicate if the thermal to hwmon sysfs interface
|
|
* is required. when no_hwmon == false, a hwmon sysfs interface
|
|
* will be created. when no_hwmon == true, nothing will be done
|
|
*/
|
|
bool no_hwmon;
|
|
|
|
int num_tbps; /* Number of tbp entries */
|
|
struct thermal_bind_params *tbp;
|
|
|
|
/*
|
|
* Sustainable power (heat) that this thermal zone can dissipate in
|
|
* mW
|
|
*/
|
|
u32 sustainable_power;
|
|
|
|
/*
|
|
* Proportional parameter of the PID controller when
|
|
* overshooting (i.e., when temperature is below the target)
|
|
*/
|
|
s32 k_po;
|
|
|
|
/*
|
|
* Proportional parameter of the PID controller when
|
|
* undershooting
|
|
*/
|
|
s32 k_pu;
|
|
|
|
/* Integral parameter of the PID controller */
|
|
s32 k_i;
|
|
|
|
/* Derivative parameter of the PID controller */
|
|
s32 k_d;
|
|
|
|
/* threshold below which the error is no longer accumulated */
|
|
s32 integral_cutoff;
|
|
|
|
/*
|
|
* @slope: slope of a linear temperature adjustment curve.
|
|
* Used by thermal zone drivers.
|
|
*/
|
|
int slope;
|
|
/*
|
|
* @offset: offset of a linear temperature adjustment curve.
|
|
* Used by thermal zone drivers (default 0).
|
|
*/
|
|
int offset;
|
|
|
|
/*
|
|
* @tracks_low: Indicates that the thermal zone params are for
|
|
* temperatures falling below the thresholds.
|
|
*/
|
|
bool tracks_low;
|
|
};
|
|
|
|
struct thermal_genl_event {
|
|
u32 orig;
|
|
enum events event;
|
|
};
|
|
|
|
/**
|
|
* struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
|
|
*
|
|
* Mandatory:
|
|
* @get_temp: a pointer to a function that reads the sensor temperature.
|
|
*
|
|
* Optional:
|
|
* @get_trend: a pointer to a function that reads the sensor temperature trend.
|
|
* @set_trips: a pointer to a function that sets a temperature window. When
|
|
* this window is left the driver must inform the thermal core via
|
|
* thermal_zone_device_update.
|
|
* @set_emul_temp: a pointer to a function that sets sensor emulated
|
|
* temperature.
|
|
* @set_trip_temp: a pointer to a function that sets the trip temperature on
|
|
* hardware.
|
|
* @get_trip_temp: a pointer to a function that gets the trip temperature on
|
|
* hardware.
|
|
*/
|
|
struct thermal_zone_of_device_ops {
|
|
int (*get_temp)(void *, int *);
|
|
int (*get_trend)(void *, int, enum thermal_trend *);
|
|
int (*set_trips)(void *, int, int);
|
|
int (*set_emul_temp)(void *, int);
|
|
int (*set_trip_temp)(void *data, int trip, int temp);
|
|
int (*get_trip_temp)(void *data, int trip, int *temp);
|
|
};
|
|
|
|
/**
|
|
* struct thermal_trip - representation of a point in temperature domain
|
|
* @np: pointer to struct device_node that this trip point was created from
|
|
* @temperature: temperature value in miliCelsius
|
|
* @hysteresis: relative hysteresis in miliCelsius
|
|
* @type: trip point type
|
|
*/
|
|
|
|
struct thermal_trip {
|
|
struct device_node *np;
|
|
int temperature;
|
|
int hysteresis;
|
|
enum thermal_trip_type type;
|
|
};
|
|
|
|
/* Different aggregation logic supported for virtual sensors */
|
|
enum aggregation_logic {
|
|
VIRT_WEIGHTED_AVG,
|
|
VIRT_MAXIMUM,
|
|
VIRT_MINIMUM,
|
|
VIRT_AGGREGATION_NR,
|
|
};
|
|
|
|
/*
|
|
* struct virtual_sensor_data - Data structure used to provide
|
|
* information about the virtual zone.
|
|
* @virt_zone_name - Virtual thermal zone name
|
|
* @num_sensors - Number of sensors this virtual zone uses to compute
|
|
* temperature
|
|
* @sensor_names - Array of sensor names
|
|
* @logic - Temperature aggregation logic to be used
|
|
* @coefficients - Coefficients to be used for weighted average logic
|
|
* @coefficient_ct - number of coefficients provided as input
|
|
* @avg_offset - offset value to be used for the weighted aggregation logic
|
|
* @avg_denominator - denominator value to be used for the weighted aggregation
|
|
* logic
|
|
*/
|
|
struct virtual_sensor_data {
|
|
int num_sensors;
|
|
char virt_zone_name[THERMAL_NAME_LENGTH];
|
|
char *sensor_names[THERMAL_MAX_VIRT_SENSORS];
|
|
enum aggregation_logic logic;
|
|
int coefficients[THERMAL_MAX_VIRT_SENSORS];
|
|
int coefficient_ct;
|
|
int avg_offset;
|
|
int avg_denominator;
|
|
};
|
|
|
|
/* Function declarations */
|
|
#ifdef CONFIG_THERMAL_OF
|
|
struct thermal_zone_device *
|
|
thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
|
|
const struct thermal_zone_of_device_ops *ops);
|
|
void thermal_zone_of_sensor_unregister(struct device *dev,
|
|
struct thermal_zone_device *tz);
|
|
struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
|
|
struct device *dev, int id, void *data,
|
|
const struct thermal_zone_of_device_ops *ops);
|
|
void devm_thermal_zone_of_sensor_unregister(struct device *dev,
|
|
struct thermal_zone_device *tz);
|
|
struct thermal_zone_device *devm_thermal_of_virtual_sensor_register(
|
|
struct device *dev,
|
|
const struct virtual_sensor_data *sensor_data);
|
|
#else
|
|
static inline struct thermal_zone_device *
|
|
thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
|
|
const struct thermal_zone_of_device_ops *ops)
|
|
{
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
|
|
static inline
|
|
void thermal_zone_of_sensor_unregister(struct device *dev,
|
|
struct thermal_zone_device *tz)
|
|
{
|
|
}
|
|
|
|
static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
|
|
struct device *dev, int id, void *data,
|
|
const struct thermal_zone_of_device_ops *ops)
|
|
{
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
|
|
static inline
|
|
void devm_thermal_zone_of_sensor_unregister(struct device *dev,
|
|
struct thermal_zone_device *tz)
|
|
{
|
|
}
|
|
|
|
static inline
|
|
struct thermal_zone_device *devm_thermal_of_virtual_sensor_register(
|
|
struct device *dev,
|
|
const struct virtual_sensor_data *sensor_data)
|
|
{
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
|
|
#endif
|
|
|
|
#if IS_ENABLED(CONFIG_THERMAL)
|
|
static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
|
|
{
|
|
return cdev->ops->get_requested_power && cdev->ops->state2power &&
|
|
cdev->ops->power2state;
|
|
}
|
|
|
|
int power_actor_get_max_power(struct thermal_cooling_device *,
|
|
struct thermal_zone_device *tz, u32 *max_power);
|
|
int power_actor_get_min_power(struct thermal_cooling_device *,
|
|
struct thermal_zone_device *tz, u32 *min_power);
|
|
int power_actor_set_power(struct thermal_cooling_device *,
|
|
struct thermal_instance *, u32);
|
|
struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
|
|
void *, struct thermal_zone_device_ops *,
|
|
struct thermal_zone_params *, int, int);
|
|
void thermal_zone_device_unregister(struct thermal_zone_device *);
|
|
|
|
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
|
|
struct thermal_cooling_device *,
|
|
unsigned long, unsigned long,
|
|
unsigned int);
|
|
int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
|
|
struct thermal_cooling_device *);
|
|
void thermal_zone_device_update(struct thermal_zone_device *,
|
|
enum thermal_notify_event);
|
|
void thermal_zone_device_update_temp(struct thermal_zone_device *tz,
|
|
enum thermal_notify_event event, int temp);
|
|
void thermal_zone_set_trips(struct thermal_zone_device *);
|
|
|
|
struct thermal_cooling_device *thermal_cooling_device_register(const char *,
|
|
void *, const struct thermal_cooling_device_ops *);
|
|
struct thermal_cooling_device *
|
|
thermal_of_cooling_device_register(struct device_node *np, const char *, void *,
|
|
const struct thermal_cooling_device_ops *);
|
|
void thermal_cooling_device_unregister(struct thermal_cooling_device *);
|
|
struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
|
|
struct thermal_cooling_device *thermal_zone_get_cdev_by_name(const char *name);
|
|
int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
|
|
int thermal_zone_get_slope(struct thermal_zone_device *tz);
|
|
int thermal_zone_get_offset(struct thermal_zone_device *tz);
|
|
|
|
int get_tz_trend(struct thermal_zone_device *, int);
|
|
struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
|
|
struct thermal_cooling_device *, int);
|
|
void thermal_cdev_update(struct thermal_cooling_device *);
|
|
void thermal_notify_framework(struct thermal_zone_device *, int);
|
|
#else
|
|
static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
|
|
{ return false; }
|
|
static inline int power_actor_get_max_power(struct thermal_cooling_device *cdev,
|
|
struct thermal_zone_device *tz, u32 *max_power)
|
|
{ return 0; }
|
|
static inline int power_actor_get_min_power(struct thermal_cooling_device *cdev,
|
|
struct thermal_zone_device *tz,
|
|
u32 *min_power)
|
|
{ return -ENODEV; }
|
|
static inline int power_actor_set_power(struct thermal_cooling_device *cdev,
|
|
struct thermal_instance *tz, u32 power)
|
|
{ return 0; }
|
|
static inline struct thermal_zone_device *thermal_zone_device_register(
|
|
const char *type, int trips, int mask, void *devdata,
|
|
struct thermal_zone_device_ops *ops,
|
|
struct thermal_zone_params *tzp,
|
|
int passive_delay, int polling_delay)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline void thermal_zone_device_unregister(
|
|
struct thermal_zone_device *tz)
|
|
{ }
|
|
static inline int thermal_zone_bind_cooling_device(
|
|
struct thermal_zone_device *tz, int trip,
|
|
struct thermal_cooling_device *cdev,
|
|
unsigned long upper, unsigned long lower,
|
|
unsigned int weight)
|
|
{ return -ENODEV; }
|
|
static inline int thermal_zone_unbind_cooling_device(
|
|
struct thermal_zone_device *tz, int trip,
|
|
struct thermal_cooling_device *cdev)
|
|
{ return -ENODEV; }
|
|
static inline void thermal_zone_device_update(struct thermal_zone_device *tz,
|
|
enum thermal_notify_event event)
|
|
{ }
|
|
static inline void thermal_zone_device_update_temp(
|
|
struct thermal_zone_device *tz, enum thermal_notify_event event,
|
|
int temp)
|
|
{ }
|
|
static inline void thermal_zone_set_trips(struct thermal_zone_device *tz)
|
|
{ }
|
|
static inline struct thermal_cooling_device *
|
|
thermal_cooling_device_register(const char *type, void *devdata,
|
|
const struct thermal_cooling_device_ops *ops)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline struct thermal_cooling_device *
|
|
thermal_of_cooling_device_register(struct device_node *np,
|
|
const char *type, void *devdata,
|
|
const struct thermal_cooling_device_ops *ops)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline void thermal_cooling_device_unregister(
|
|
struct thermal_cooling_device *cdev)
|
|
{ }
|
|
static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
|
|
const char *name)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline struct thermal_cooling_device *thermal_zone_get_cdev_by_name(
|
|
const char *name)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline int thermal_zone_get_temp(
|
|
struct thermal_zone_device *tz, int *temp)
|
|
{ return -ENODEV; }
|
|
static inline int thermal_zone_get_slope(
|
|
struct thermal_zone_device *tz)
|
|
{ return -ENODEV; }
|
|
static inline int thermal_zone_get_offset(
|
|
struct thermal_zone_device *tz)
|
|
{ return -ENODEV; }
|
|
static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
|
|
{ return -ENODEV; }
|
|
static inline struct thermal_instance *
|
|
get_thermal_instance(struct thermal_zone_device *tz,
|
|
struct thermal_cooling_device *cdev, int trip)
|
|
{ return ERR_PTR(-ENODEV); }
|
|
static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
|
|
{ }
|
|
static inline void thermal_notify_framework(struct thermal_zone_device *tz,
|
|
int trip)
|
|
{ }
|
|
#endif /* CONFIG_THERMAL */
|
|
|
|
#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
|
|
extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
|
|
enum events event);
|
|
#else
|
|
static inline int thermal_generate_netlink_event(struct thermal_zone_device *tz,
|
|
enum events event)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* __THERMAL_H__ */
|