Changes in 5.4.19
sparc32: fix struct ipc64_perm type definition
bnxt_en: Move devlink_register before registering netdev
cls_rsvp: fix rsvp_policy
gtp: use __GFP_NOWARN to avoid memalloc warning
l2tp: Allow duplicate session creation with UDP
net: hsr: fix possible NULL deref in hsr_handle_frame()
net_sched: fix an OOB access in cls_tcindex
net: stmmac: Delete txtimer in suspend()
bnxt_en: Fix TC queue mapping.
rxrpc: Fix use-after-free in rxrpc_put_local()
rxrpc: Fix insufficient receive notification generation
rxrpc: Fix missing active use pinning of rxrpc_local object
rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect
tcp: clear tp->total_retrans in tcp_disconnect()
tcp: clear tp->delivered in tcp_disconnect()
tcp: clear tp->data_segs{in|out} in tcp_disconnect()
tcp: clear tp->segs_{in|out} in tcp_disconnect()
ionic: fix rxq comp packet type mask
MAINTAINERS: correct entries for ISDN/mISDN section
netdevsim: fix stack-out-of-bounds in nsim_dev_debugfs_init()
bnxt_en: Fix logic that disables Bus Master during firmware reset.
media: uvcvideo: Avoid cyclic entity chains due to malformed USB descriptors
mfd: dln2: More sanity checking for endpoints
netfilter: ipset: fix suspicious RCU usage in find_set_and_id
ipc/msg.c: consolidate all xxxctl_down() functions
tracing/kprobes: Have uname use __get_str() in print_fmt
tracing: Fix sched switch start/stop refcount racy updates
rcu: Use *_ONCE() to protect lockless ->expmask accesses
rcu: Avoid data-race in rcu_gp_fqs_check_wake()
srcu: Apply *_ONCE() to ->srcu_last_gp_end
rcu: Use READ_ONCE() for ->expmask in rcu_read_unlock_special()
nvmet: Fix error print message at nvmet_install_queue function
nvmet: Fix controller use after free
Bluetooth: btusb: fix memory leak on fw
Bluetooth: btusb: Disable runtime suspend on Realtek devices
brcmfmac: Fix memory leak in brcmf_usbdev_qinit
usb: dwc3: gadget: Check END_TRANSFER completion
usb: dwc3: gadget: Delay starting transfer
usb: typec: tcpci: mask event interrupts when remove driver
objtool: Silence build output
usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
usb: gadget: legacy: set max_speed to super-speed
usb: gadget: f_ncm: Use atomic_t to track in-flight request
usb: gadget: f_ecm: Use atomic_t to track in-flight request
ALSA: usb-audio: Fix endianess in descriptor validation
ALSA: usb-audio: Annotate endianess in Scarlett gen2 quirk
ALSA: dummy: Fix PCM format loop in proc output
memcg: fix a crash in wb_workfn when a device disappears
mm/sparse.c: reset section's mem_map when fully deactivated
mmc: sdhci-pci: Make function amd_sdhci_reset static
utimes: Clamp the timestamps in notify_change()
mm/memory_hotplug: fix remove_memory() lockdep splat
mm: thp: don't need care deferred split queue in memcg charge move path
mm: move_pages: report the number of non-attempted pages
media/v4l2-core: set pages dirty upon releasing DMA buffers
media: v4l2-core: compat: ignore native command codes
media: v4l2-rect.h: fix v4l2_rect_map_inside() top/left adjustments
lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()
irqdomain: Fix a memory leak in irq_domain_push_irq()
x86/cpu: Update cached HLE state on write to TSX_CTRL_CPUID_CLEAR
platform/x86: intel_scu_ipc: Fix interrupt support
ALSA: hda: Apply aligned MMIO access only conditionally
ALSA: hda: Add Clevo W65_67SB the power_save blacklist
ALSA: hda: Add JasperLake PCI ID and codec vid
arm64: acpi: fix DAIF manipulation with pNMI
KVM: arm64: Correct PSTATE on exception entry
KVM: arm/arm64: Correct CPSR on exception entry
KVM: arm/arm64: Correct AArch32 SPSR on exception entry
KVM: arm64: Only sign-extend MMIO up to register width
MIPS: syscalls: fix indentation of the 'SYSNR' message
MIPS: fix indentation of the 'RELOCS' message
MIPS: boot: fix typo in 'vmlinux.lzma.its' target
s390/mm: fix dynamic pagetable upgrade for hugetlbfs
powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case
powerpc/ptdump: Fix W+X verification
powerpc/xmon: don't access ASDR in VMs
powerpc/pseries: Advance pfn if section is not present in lmb_is_removable()
powerpc/32s: Fix bad_kuap_fault()
powerpc/32s: Fix CPU wake-up from sleep mode
tracing: Fix now invalid var_ref_vals assumption in trace action
PCI: tegra: Fix return value check of pm_runtime_get_sync()
PCI: keystone: Fix outbound region mapping
PCI: keystone: Fix link training retries initiation
PCI: keystone: Fix error handling when "num-viewport" DT property is not populated
mmc: spi: Toggle SPI polarity, do not hardcode it
ACPI: video: Do not export a non working backlight interface on MSI MS-7721 boards
ACPI / battery: Deal with design or full capacity being reported as -1
ACPI / battery: Use design-cap for capacity calculations if full-cap is not available
ACPI / battery: Deal better with neither design nor full capacity not being reported
alarmtimer: Unregister wakeup source when module get fails
fscrypt: don't print name of busy file when removing key
ubifs: don't trigger assertion on invalid no-key filename
ubifs: Fix wrong memory allocation
ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
ubifs: Fix deadlock in concurrent bulk-read and writepage
mmc: sdhci-of-at91: fix memleak on clk_get failure
ASoC: SOF: core: free trace on errors
hv_balloon: Balloon up according to request page number
mfd: axp20x: Mark AXP20X_VBUS_IPSOUT_MGMT as volatile
nvmem: core: fix memory abort in cleanup path
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
crypto: ccree - fix backlog memory leak
crypto: ccree - fix AEAD decrypt auth fail
crypto: ccree - fix pm wrongful error reporting
crypto: ccree - fix FDE descriptor sequence
crypto: ccree - fix PM race condition
padata: Remove broken queue flushing
fs: allow deduplication of eof block into the end of the destination file
scripts/find-unused-docs: Fix massive false positives
erofs: fix out-of-bound read for shifted uncompressed block
scsi: megaraid_sas: Do not initiate OCR if controller is not in ready state
scsi: qla2xxx: Fix mtcp dump collection failure
cpupower: Revert library ABI changes from commit ae2917093f
power: supply: axp20x_ac_power: Fix reporting online status
power: supply: ltc2941-battery-gauge: fix use-after-free
ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
ovl: fix lseek overflow on 32bit
f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project()
f2fs: fix miscounted block limit in f2fs_statfs_project()
f2fs: code cleanup for f2fs_statfs_project()
f2fs: fix dcache lookup of !casefolded directories
f2fs: fix race conditions in ->d_compare() and ->d_hash()
PM: core: Fix handling of devices deleted during system-wide resume
cpufreq: Avoid creating excessively large stack frames
of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc
ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
dm zoned: support zone sizes smaller than 128MiB
dm space map common: fix to ensure new block isn't already in use
dm writecache: fix incorrect flush sequence when doing SSD mode commit
dm crypt: fix GFP flags passed to skcipher_request_alloc()
dm crypt: fix benbi IV constructor crash if used in authenticated mode
dm thin metadata: use pool locking at end of dm_pool_metadata_close
dm: fix potential for q->make_request_fn NULL pointer
scsi: qla2xxx: Fix stuck login session using prli_pend_timer
ASoC: SOF: Introduce state machine for FW boot
ASoC: SOF: core: release resources on errors in probe_continue
tracing: Annotate ftrace_graph_hash pointer with __rcu
tracing: Annotate ftrace_graph_notrace_hash pointer with __rcu
ftrace: Add comment to why rcu_dereference_sched() is open coded
ftrace: Protect ftrace_graph_hash with ftrace_sync
crypto: pcrypt - Avoid deadlock by using per-instance padata queues
btrfs: fix improper setting of scanned for range cyclic write cache pages
btrfs: Handle another split brain scenario with metadata uuid feature
riscv, bpf: Fix broken BPF tail calls
selftests/bpf: Fix perf_buffer test on systems w/ offline CPUs
bpf, devmap: Pass lockdep expression to RCU lists
libbpf: Fix realloc usage in bpf_core_find_cands
tc-testing: fix eBPF tests failure on linux fresh clones
samples/bpf: Don't try to remove user's homedir on clean
samples/bpf: Xdp_redirect_cpu fix missing tracepoint attach
selftests/bpf: Fix test_attach_probe
selftests/bpf: Skip perf hw events test if the setup disabled it
selftests: bpf: Use a temporary file in test_sockmap
selftests: bpf: Ignore FIN packets for reuseport tests
crypto: api - fix unexpectedly getting generic implementation
crypto: hisilicon - Use the offset fields in sqe to avoid need to split scatterlists
crypto: ccp - set max RSA modulus size for v3 platform devices as well
crypto: arm64/ghash-neon - bump priority to 150
crypto: pcrypt - Do not clear MAY_SLEEP flag in original request
crypto: atmel-aes - Fix counter overflow in CTR mode
crypto: api - Fix race condition in crypto_spawn_alg
crypto: picoxcell - adjust the position of tasklet_init and fix missed tasklet_kill
powerpc/futex: Fix incorrect user access blocking
scsi: qla2xxx: Fix unbound NVME response length
NFS: Fix memory leaks and corruption in readdir
NFS: Directory page cache pages need to be locked when read
nfsd: fix filecache lookup
jbd2_seq_info_next should increase position index
ext4: fix deadlock allocating crypto bounce page from mempool
ext4: fix race conditions in ->d_compare() and ->d_hash()
Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES
Btrfs: make deduplication with range including the last block work
Btrfs: fix infinite loop during fsync after rename operations
btrfs: set trans->drity in btrfs_commit_transaction
btrfs: drop log root for dropped roots
Btrfs: fix race between adding and putting tree mod seq elements and nodes
btrfs: flush write bio if we loop in extent_write_cache_pages
btrfs: Correctly handle empty trees in find_first_clear_extent_bit
ARM: tegra: Enable PLLP bypass during Tegra124 LP1
iwlwifi: don't throw error when trying to remove IGTK
mwifiex: fix unbalanced locking in mwifiex_process_country_ie()
sunrpc: expiry_time should be seconds not timeval
gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0
gfs2: move setting current->backing_dev_info
gfs2: fix O_SYNC write handling
drm: atmel-hlcdc: use double rate for pixel clock only if supported
drm: atmel-hlcdc: enable clock before configuring timing engine
drm: atmel-hlcdc: prefer a lower pixel-clock than requested
drm/rect: Avoid division by zero
media: iguanair: fix endpoint sanity check
media: rc: ensure lirc is initialized before registering input device
tools/kvm_stat: Fix kvm_exit filter name
xen/balloon: Support xend-based toolstack take two
watchdog: fix UAF in reboot notifier handling in watchdog core code
bcache: add readahead cache policy options via sysfs interface
eventfd: track eventfd_signal() recursion depth
aio: prevent potential eventfd recursion on poll
KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
KVM: x86: Refactor prefix decoding to prevent Spectre-v1/L1TF attacks
KVM: x86: Protect pmu_intel.c from Spectre-v1/L1TF attacks
KVM: x86: Protect DR-based index computations from Spectre-v1/L1TF attacks
KVM: x86: Protect kvm_lapic_reg_write() from Spectre-v1/L1TF attacks
KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks
KVM: x86: Protect ioapic_write_indirect() from Spectre-v1/L1TF attacks
KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks
KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks
KVM: x86: Protect MSR-based index computations from Spectre-v1/L1TF attacks in x86.c
KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks
KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks
KVM: x86: Fix potential put_fpu() w/o load_fpu() on MPX platform
KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails
KVM: PPC: Book3S PR: Free shared page if mmu initialization fails
kvm/svm: PKU not currently supported
x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
x86/kvm: Introduce kvm_(un)map_gfn()
x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
x86/kvm: Cache gfn to pfn translation
x86/KVM: Clean up host's steal time structure
KVM: VMX: Add non-canonical check on writes to RTIT address MSRs
KVM: x86: Don't let userspace set host-reserved cr4 bits
KVM: x86: Free wbinvd_dirty_mask if vCPU creation fails
KVM: x86: Handle TIF_NEED_FPU_LOAD in kvm_{load,put}_guest_fpu()
KVM: x86: Ensure guest's FPU state is loaded when accessing for emulation
KVM: x86: Revert "KVM: X86: Fix fpu state crash in kvm guest"
KVM: s390: do not clobber registers during guest reset/store status
ocfs2: fix oops when writing cloned file
mm/page_alloc.c: fix uninitialized memmaps on a partially populated last section
arm64: dts: qcom: qcs404-evb: Set vdd_apc regulator in high power mode
mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
clk: tegra: Mark fuse clock as critical
drm/amd/dm/mst: Ignore payload update failures
virtio-balloon: initialize all vq callbacks
virtio-pci: check name when counting MSI-X vectors
fix up iter on short count in fuse_direct_io()
broken ping to ipv6 linklocal addresses on debian buster
percpu: Separate decrypted varaibles anytime encryption can be enabled
ASoC: meson: axg-fifo: fix fifo threshold setup
scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type
scsi: csiostor: Adjust indentation in csio_device_reset
scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free
scsi: ufs: Recheck bkops level if bkops is disabled
mtd: spi-nor: Split mt25qu512a (n25q512a) entry into two
phy: qualcomm: Adjust indentation in read_poll_timeout
ext2: Adjust indentation in ext2_fill_super
powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize
drm: msm: mdp4: Adjust indentation in mdp4_dsi_encoder_enable
NFC: pn544: Adjust indentation in pn544_hci_check_presence
ppp: Adjust indentation into ppp_async_input
net: smc911x: Adjust indentation in smc911x_phy_configure
net: tulip: Adjust indentation in {dmfe, uli526x}_init_module
IB/mlx5: Fix outstanding_pi index for GSI qps
IB/core: Fix ODP get user pages flow
nfsd: fix delay timer on 32-bit architectures
nfsd: fix jiffies/time_t mixup in LRU list
nfsd: Return the correct number of bytes written to the file
virtio-balloon: Fix memory leak when unloading while hinting is in progress
virtio_balloon: Fix memory leaks on errors in virtballoon_probe()
ubi: fastmap: Fix inverted logic in seen selfcheck
ubi: Fix an error pointer dereference in error handling code
ubifs: Fix memory leak from c->sup_node
regulator: core: Add regulator_is_equal() helper
ASoC: sgtl5000: Fix VDDA and VDDIO comparison
bonding/alb: properly access headers in bond_alb_xmit()
devlink: report 0 after hitting end in region read
dpaa_eth: support all modes with rate adapting PHYs
net: dsa: b53: Always use dev->vlan_enabled in b53_configure_vlan()
net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port
net: dsa: microchip: enable module autoprobe
net: mvneta: move rx_dropped and rx_errors in per-cpu stats
net_sched: fix a resource leak in tcindex_set_parms()
net: stmmac: fix a possible endless loop
net: systemport: Avoid RBUF stuck in Wake-on-LAN mode
net/mlx5: IPsec, Fix esp modify function attribute
net/mlx5: IPsec, fix memory leak at mlx5_fpga_ipsec_delete_sa_ctx
net: macb: Remove unnecessary alignment check for TSO
net: macb: Limit maximum GEM TX length in TSO
taprio: Fix enabling offload with wrong number of traffic classes
taprio: Fix still allowing changing the flags during runtime
taprio: Add missing policy validation for flags
taprio: Use taprio_reset_tc() to reset Traffic Classes configuration
taprio: Fix dropping packets when using taprio + ETF offloading
ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
qed: Fix timestamping issue for L2 unicast ptp packets.
drop_monitor: Do not cancel uninitialized work item
net/mlx5: Fix deadlock in fs_core
net/mlx5: Deprecate usage of generic TLS HW capability bit
ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug
mfd: da9062: Fix watchdog compatible string
mfd: rn5t618: Mark ADC control register volatile
mfd: bd70528: Fix hour register mask
x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode
btrfs: use bool argument in free_root_pointers()
btrfs: free block groups after free'ing fs trees
drm/dp_mst: Remove VCPI while disabling topology mgr
KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM
KVM: x86: use CPUID to locate host page table reserved bits
KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
KVM: x86: fix overlap between SPTE_MMIO_MASK and generation
KVM: nVMX: vmread should not set rflags to specify success in case of #PF
KVM: Use vcpu-specific gva->hva translation when querying host page size
KVM: Play nice with read-only memslots when querying host page size
cifs: fail i/o on soft mounts if sessionsetup errors out
x86/apic/msi: Plug non-maskable MSI affinity race
clocksource: Prevent double add_timer_on() for watchdog_timer
perf/core: Fix mlock accounting in perf_mmap()
rxrpc: Fix service call disconnection
regulator fix for "regulator: core: Add regulator_is_equal() helper"
powerpc/kuap: Fix set direction in allow/prevent_user_access()
Linux 5.4.19
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ief6bae336b8e6931810e5b357c0d5e16fbf1c13e
1007 lines
30 KiB
C
1007 lines
30 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* linux/include/linux/cpufreq.h
|
|
*
|
|
* Copyright (C) 2001 Russell King
|
|
* (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
|
|
*/
|
|
#ifndef _LINUX_CPUFREQ_H
|
|
#define _LINUX_CPUFREQ_H
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/completion.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/pm_qos.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/sysfs.h>
|
|
|
|
/*********************************************************************
|
|
* CPUFREQ INTERFACE *
|
|
*********************************************************************/
|
|
/*
|
|
* Frequency values here are CPU kHz
|
|
*
|
|
* Maximum transition latency is in nanoseconds - if it's unknown,
|
|
* CPUFREQ_ETERNAL shall be used.
|
|
*/
|
|
|
|
#define CPUFREQ_ETERNAL (-1)
|
|
#define CPUFREQ_NAME_LEN 16
|
|
/* Print length for names. Extra 1 space for accommodating '\n' in prints */
|
|
#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)
|
|
|
|
struct cpufreq_governor;
|
|
|
|
enum cpufreq_table_sorting {
|
|
CPUFREQ_TABLE_UNSORTED,
|
|
CPUFREQ_TABLE_SORTED_ASCENDING,
|
|
CPUFREQ_TABLE_SORTED_DESCENDING
|
|
};
|
|
|
|
struct cpufreq_cpuinfo {
|
|
unsigned int max_freq;
|
|
unsigned int min_freq;
|
|
|
|
/* in 10^(-9) s = nanoseconds */
|
|
unsigned int transition_latency;
|
|
};
|
|
|
|
struct cpufreq_policy {
|
|
/* CPUs sharing clock, require sw coordination */
|
|
cpumask_var_t cpus; /* Online CPUs only */
|
|
cpumask_var_t related_cpus; /* Online + Offline CPUs */
|
|
cpumask_var_t real_cpus; /* Related and present */
|
|
|
|
unsigned int shared_type; /* ACPI: ANY or ALL affected CPUs
|
|
should set cpufreq */
|
|
unsigned int cpu; /* cpu managing this policy, must be online */
|
|
|
|
struct clk *clk;
|
|
struct cpufreq_cpuinfo cpuinfo;/* see above */
|
|
|
|
unsigned int min; /* in kHz */
|
|
unsigned int max; /* in kHz */
|
|
unsigned int cur; /* in kHz, only needed if cpufreq
|
|
* governors are used */
|
|
unsigned int restore_freq; /* = policy->cur before transition */
|
|
unsigned int suspend_freq; /* freq to set during suspend */
|
|
|
|
unsigned int policy; /* see above */
|
|
unsigned int last_policy; /* policy before unplug */
|
|
struct cpufreq_governor *governor; /* see below */
|
|
void *governor_data;
|
|
char last_governor[CPUFREQ_NAME_LEN]; /* last governor used */
|
|
|
|
struct work_struct update; /* if update_policy() needs to be
|
|
* called, but you're in IRQ context */
|
|
|
|
struct freq_constraints constraints;
|
|
struct freq_qos_request *min_freq_req;
|
|
struct freq_qos_request *max_freq_req;
|
|
|
|
struct cpufreq_frequency_table *freq_table;
|
|
enum cpufreq_table_sorting freq_table_sorted;
|
|
|
|
struct list_head policy_list;
|
|
struct kobject kobj;
|
|
struct completion kobj_unregister;
|
|
|
|
/*
|
|
* The rules for this semaphore:
|
|
* - Any routine that wants to read from the policy structure will
|
|
* do a down_read on this semaphore.
|
|
* - Any routine that will write to the policy structure and/or may take away
|
|
* the policy altogether (eg. CPU hotplug), will hold this lock in write
|
|
* mode before doing so.
|
|
*/
|
|
struct rw_semaphore rwsem;
|
|
|
|
/*
|
|
* Fast switch flags:
|
|
* - fast_switch_possible should be set by the driver if it can
|
|
* guarantee that frequency can be changed on any CPU sharing the
|
|
* policy and that the change will affect all of the policy CPUs then.
|
|
* - fast_switch_enabled is to be set by governors that support fast
|
|
* frequency switching with the help of cpufreq_enable_fast_switch().
|
|
*/
|
|
bool fast_switch_possible;
|
|
bool fast_switch_enabled;
|
|
|
|
/*
|
|
* Preferred average time interval between consecutive invocations of
|
|
* the driver to set the frequency for this policy. To be set by the
|
|
* scaling driver (0, which is the default, means no preference).
|
|
*/
|
|
unsigned int transition_delay_us;
|
|
|
|
/*
|
|
* Remote DVFS flag (Not added to the driver structure as we don't want
|
|
* to access another structure from scheduler hotpath).
|
|
*
|
|
* Should be set if CPUs can do DVFS on behalf of other CPUs from
|
|
* different cpufreq policies.
|
|
*/
|
|
bool dvfs_possible_from_any_cpu;
|
|
|
|
/* Cached frequency lookup from cpufreq_driver_resolve_freq. */
|
|
unsigned int cached_target_freq;
|
|
int cached_resolved_idx;
|
|
|
|
/* Synchronization for frequency transitions */
|
|
bool transition_ongoing; /* Tracks transition status */
|
|
spinlock_t transition_lock;
|
|
wait_queue_head_t transition_wait;
|
|
struct task_struct *transition_task; /* Task which is doing the transition */
|
|
|
|
/* cpufreq-stats */
|
|
struct cpufreq_stats *stats;
|
|
|
|
/* For cpufreq driver's internal use */
|
|
void *driver_data;
|
|
|
|
/* Pointer to the cooling device if used for thermal mitigation */
|
|
struct thermal_cooling_device *cdev;
|
|
|
|
struct notifier_block nb_min;
|
|
struct notifier_block nb_max;
|
|
};
|
|
|
|
/*
|
|
* Used for passing new cpufreq policy data to the cpufreq driver's ->verify()
|
|
* callback for sanitization. That callback is only expected to modify the min
|
|
* and max values, if necessary, and specifically it must not update the
|
|
* frequency table.
|
|
*/
|
|
struct cpufreq_policy_data {
|
|
struct cpufreq_cpuinfo cpuinfo;
|
|
struct cpufreq_frequency_table *freq_table;
|
|
unsigned int cpu;
|
|
unsigned int min; /* in kHz */
|
|
unsigned int max; /* in kHz */
|
|
};
|
|
|
|
struct cpufreq_freqs {
|
|
struct cpufreq_policy *policy;
|
|
unsigned int old;
|
|
unsigned int new;
|
|
u8 flags; /* flags of cpufreq_driver, see below. */
|
|
};
|
|
|
|
/* Only for ACPI */
|
|
#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
|
|
#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
|
|
#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
|
|
#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
|
|
|
|
#ifdef CONFIG_CPU_FREQ
|
|
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
|
|
struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
|
|
void cpufreq_cpu_put(struct cpufreq_policy *policy);
|
|
#else
|
|
static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline void cpufreq_cpu_put(struct cpufreq_policy *policy) { }
|
|
#endif
|
|
|
|
static inline bool policy_is_inactive(struct cpufreq_policy *policy)
|
|
{
|
|
return cpumask_empty(policy->cpus);
|
|
}
|
|
|
|
static inline bool policy_is_shared(struct cpufreq_policy *policy)
|
|
{
|
|
return cpumask_weight(policy->cpus) > 1;
|
|
}
|
|
|
|
/* /sys/devices/system/cpu/cpufreq: entry point for global variables */
|
|
extern struct kobject *cpufreq_global_kobject;
|
|
|
|
#ifdef CONFIG_CPU_FREQ
|
|
unsigned int cpufreq_get(unsigned int cpu);
|
|
unsigned int cpufreq_quick_get(unsigned int cpu);
|
|
unsigned int cpufreq_quick_get_max(unsigned int cpu);
|
|
void disable_cpufreq(void);
|
|
|
|
u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
|
|
|
|
struct cpufreq_policy *cpufreq_cpu_acquire(unsigned int cpu);
|
|
void cpufreq_cpu_release(struct cpufreq_policy *policy);
|
|
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
|
|
void refresh_frequency_limits(struct cpufreq_policy *policy);
|
|
void cpufreq_update_policy(unsigned int cpu);
|
|
void cpufreq_update_limits(unsigned int cpu);
|
|
bool have_governor_per_policy(void);
|
|
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
|
|
void cpufreq_enable_fast_switch(struct cpufreq_policy *policy);
|
|
void cpufreq_disable_fast_switch(struct cpufreq_policy *policy);
|
|
#else
|
|
static inline unsigned int cpufreq_get(unsigned int cpu)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline unsigned int cpufreq_quick_get(unsigned int cpu)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline unsigned int cpufreq_quick_get_max(unsigned int cpu)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void disable_cpufreq(void) { }
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_FREQ_STAT
|
|
void cpufreq_stats_create_table(struct cpufreq_policy *policy);
|
|
void cpufreq_stats_free_table(struct cpufreq_policy *policy);
|
|
void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
|
|
unsigned int new_freq);
|
|
#else
|
|
static inline void cpufreq_stats_create_table(struct cpufreq_policy *policy) { }
|
|
static inline void cpufreq_stats_free_table(struct cpufreq_policy *policy) { }
|
|
static inline void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
|
|
unsigned int new_freq) { }
|
|
#endif /* CONFIG_CPU_FREQ_STAT */
|
|
|
|
/*********************************************************************
|
|
* CPUFREQ DRIVER INTERFACE *
|
|
*********************************************************************/
|
|
|
|
#define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */
|
|
#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */
|
|
#define CPUFREQ_RELATION_C 2 /* closest frequency to target */
|
|
|
|
struct freq_attr {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct cpufreq_policy *, char *);
|
|
ssize_t (*store)(struct cpufreq_policy *, const char *, size_t count);
|
|
};
|
|
|
|
#define cpufreq_freq_attr_ro(_name) \
|
|
static struct freq_attr _name = \
|
|
__ATTR(_name, 0444, show_##_name, NULL)
|
|
|
|
#define cpufreq_freq_attr_ro_perm(_name, _perm) \
|
|
static struct freq_attr _name = \
|
|
__ATTR(_name, _perm, show_##_name, NULL)
|
|
|
|
#define cpufreq_freq_attr_rw(_name) \
|
|
static struct freq_attr _name = \
|
|
__ATTR(_name, 0644, show_##_name, store_##_name)
|
|
|
|
#define cpufreq_freq_attr_wo(_name) \
|
|
static struct freq_attr _name = \
|
|
__ATTR(_name, 0200, NULL, store_##_name)
|
|
|
|
#define define_one_global_ro(_name) \
|
|
static struct kobj_attribute _name = \
|
|
__ATTR(_name, 0444, show_##_name, NULL)
|
|
|
|
#define define_one_global_rw(_name) \
|
|
static struct kobj_attribute _name = \
|
|
__ATTR(_name, 0644, show_##_name, store_##_name)
|
|
|
|
|
|
struct cpufreq_driver {
|
|
char name[CPUFREQ_NAME_LEN];
|
|
u8 flags;
|
|
void *driver_data;
|
|
|
|
/* needed by all drivers */
|
|
int (*init)(struct cpufreq_policy *policy);
|
|
int (*verify)(struct cpufreq_policy_data *policy);
|
|
|
|
/* define one out of two */
|
|
int (*setpolicy)(struct cpufreq_policy *policy);
|
|
|
|
/*
|
|
* On failure, should always restore frequency to policy->restore_freq
|
|
* (i.e. old freq).
|
|
*/
|
|
int (*target)(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation); /* Deprecated */
|
|
int (*target_index)(struct cpufreq_policy *policy,
|
|
unsigned int index);
|
|
unsigned int (*fast_switch)(struct cpufreq_policy *policy,
|
|
unsigned int target_freq);
|
|
|
|
/*
|
|
* Caches and returns the lowest driver-supported frequency greater than
|
|
* or equal to the target frequency, subject to any driver limitations.
|
|
* Does not set the frequency. Only to be implemented for drivers with
|
|
* target().
|
|
*/
|
|
unsigned int (*resolve_freq)(struct cpufreq_policy *policy,
|
|
unsigned int target_freq);
|
|
|
|
/*
|
|
* Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION
|
|
* unset.
|
|
*
|
|
* get_intermediate should return a stable intermediate frequency
|
|
* platform wants to switch to and target_intermediate() should set CPU
|
|
* to to that frequency, before jumping to the frequency corresponding
|
|
* to 'index'. Core will take care of sending notifications and driver
|
|
* doesn't have to handle them in target_intermediate() or
|
|
* target_index().
|
|
*
|
|
* Drivers can return '0' from get_intermediate() in case they don't
|
|
* wish to switch to intermediate frequency for some target frequency.
|
|
* In that case core will directly call ->target_index().
|
|
*/
|
|
unsigned int (*get_intermediate)(struct cpufreq_policy *policy,
|
|
unsigned int index);
|
|
int (*target_intermediate)(struct cpufreq_policy *policy,
|
|
unsigned int index);
|
|
|
|
/* should be defined, if possible */
|
|
unsigned int (*get)(unsigned int cpu);
|
|
|
|
/* Called to update policy limits on firmware notifications. */
|
|
void (*update_limits)(unsigned int cpu);
|
|
|
|
/* optional */
|
|
int (*bios_limit)(int cpu, unsigned int *limit);
|
|
|
|
int (*online)(struct cpufreq_policy *policy);
|
|
int (*offline)(struct cpufreq_policy *policy);
|
|
int (*exit)(struct cpufreq_policy *policy);
|
|
void (*stop_cpu)(struct cpufreq_policy *policy);
|
|
int (*suspend)(struct cpufreq_policy *policy);
|
|
int (*resume)(struct cpufreq_policy *policy);
|
|
|
|
/* Will be called after the driver is fully initialized */
|
|
void (*ready)(struct cpufreq_policy *policy);
|
|
|
|
struct freq_attr **attr;
|
|
|
|
/* platform specific boost support code */
|
|
bool boost_enabled;
|
|
int (*set_boost)(int state);
|
|
};
|
|
|
|
/* flags */
|
|
|
|
/* driver isn't removed even if all ->init() calls failed */
|
|
#define CPUFREQ_STICKY BIT(0)
|
|
|
|
/* loops_per_jiffy or other kernel "constants" aren't affected by frequency transitions */
|
|
#define CPUFREQ_CONST_LOOPS BIT(1)
|
|
|
|
/* don't warn on suspend/resume speed mismatches */
|
|
#define CPUFREQ_PM_NO_WARN BIT(2)
|
|
|
|
/*
|
|
* This should be set by platforms having multiple clock-domains, i.e.
|
|
* supporting multiple policies. With this sysfs directories of governor would
|
|
* be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same
|
|
* governor with different tunables for different clusters.
|
|
*/
|
|
#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY BIT(3)
|
|
|
|
/*
|
|
* Driver will do POSTCHANGE notifications from outside of their ->target()
|
|
* routine and so must set cpufreq_driver->flags with this flag, so that core
|
|
* can handle them specially.
|
|
*/
|
|
#define CPUFREQ_ASYNC_NOTIFICATION BIT(4)
|
|
|
|
/*
|
|
* Set by drivers which want cpufreq core to check if CPU is running at a
|
|
* frequency present in freq-table exposed by the driver. For these drivers if
|
|
* CPU is found running at an out of table freq, we will try to set it to a freq
|
|
* from the table. And if that fails, we will stop further boot process by
|
|
* issuing a BUG_ON().
|
|
*/
|
|
#define CPUFREQ_NEED_INITIAL_FREQ_CHECK BIT(5)
|
|
|
|
/*
|
|
* Set by drivers to disallow use of governors with "dynamic_switching" flag
|
|
* set.
|
|
*/
|
|
#define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING BIT(6)
|
|
|
|
/*
|
|
* Set by drivers that want the core to automatically register the cpufreq
|
|
* driver as a thermal cooling device.
|
|
*/
|
|
#define CPUFREQ_IS_COOLING_DEV BIT(7)
|
|
|
|
int cpufreq_register_driver(struct cpufreq_driver *driver_data);
|
|
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
|
|
|
|
const char *cpufreq_get_current_driver(void);
|
|
void *cpufreq_get_driver_data(void);
|
|
|
|
static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv)
|
|
{
|
|
return IS_ENABLED(CONFIG_CPU_THERMAL) &&
|
|
(drv->flags & CPUFREQ_IS_COOLING_DEV);
|
|
}
|
|
|
|
static inline void cpufreq_verify_within_limits(struct cpufreq_policy_data *policy,
|
|
unsigned int min,
|
|
unsigned int max)
|
|
{
|
|
if (policy->min < min)
|
|
policy->min = min;
|
|
if (policy->max < min)
|
|
policy->max = min;
|
|
if (policy->min > max)
|
|
policy->min = max;
|
|
if (policy->max > max)
|
|
policy->max = max;
|
|
if (policy->min > policy->max)
|
|
policy->min = policy->max;
|
|
return;
|
|
}
|
|
|
|
static inline void
|
|
cpufreq_verify_within_cpu_limits(struct cpufreq_policy_data *policy)
|
|
{
|
|
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
|
|
policy->cpuinfo.max_freq);
|
|
}
|
|
|
|
#ifdef CONFIG_CPU_FREQ
|
|
void cpufreq_suspend(void);
|
|
void cpufreq_resume(void);
|
|
int cpufreq_generic_suspend(struct cpufreq_policy *policy);
|
|
#else
|
|
static inline void cpufreq_suspend(void) {}
|
|
static inline void cpufreq_resume(void) {}
|
|
#endif
|
|
|
|
/*********************************************************************
|
|
* CPUFREQ NOTIFIER INTERFACE *
|
|
*********************************************************************/
|
|
|
|
#define CPUFREQ_TRANSITION_NOTIFIER (0)
|
|
#define CPUFREQ_POLICY_NOTIFIER (1)
|
|
|
|
/* Transition notifiers */
|
|
#define CPUFREQ_PRECHANGE (0)
|
|
#define CPUFREQ_POSTCHANGE (1)
|
|
|
|
/* Policy Notifiers */
|
|
#define CPUFREQ_CREATE_POLICY (0)
|
|
#define CPUFREQ_REMOVE_POLICY (1)
|
|
|
|
#ifdef CONFIG_CPU_FREQ
|
|
int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
|
|
int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
|
|
|
|
void cpufreq_freq_transition_begin(struct cpufreq_policy *policy,
|
|
struct cpufreq_freqs *freqs);
|
|
void cpufreq_freq_transition_end(struct cpufreq_policy *policy,
|
|
struct cpufreq_freqs *freqs, int transition_failed);
|
|
|
|
#else /* CONFIG_CPU_FREQ */
|
|
static inline int cpufreq_register_notifier(struct notifier_block *nb,
|
|
unsigned int list)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int cpufreq_unregister_notifier(struct notifier_block *nb,
|
|
unsigned int list)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif /* !CONFIG_CPU_FREQ */
|
|
|
|
/**
|
|
* cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch
|
|
* safe)
|
|
* @old: old value
|
|
* @div: divisor
|
|
* @mult: multiplier
|
|
*
|
|
*
|
|
* new = old * mult / div
|
|
*/
|
|
static inline unsigned long cpufreq_scale(unsigned long old, u_int div,
|
|
u_int mult)
|
|
{
|
|
#if BITS_PER_LONG == 32
|
|
u64 result = ((u64) old) * ((u64) mult);
|
|
do_div(result, div);
|
|
return (unsigned long) result;
|
|
|
|
#elif BITS_PER_LONG == 64
|
|
unsigned long result = old * ((u64) mult);
|
|
result /= div;
|
|
return result;
|
|
#endif
|
|
}
|
|
|
|
/*********************************************************************
|
|
* CPUFREQ GOVERNORS *
|
|
*********************************************************************/
|
|
|
|
#define CPUFREQ_POLICY_UNKNOWN (0)
|
|
/*
|
|
* If (cpufreq_driver->target) exists, the ->governor decides what frequency
|
|
* within the limits is used. If (cpufreq_driver->setpolicy> exists, these
|
|
* two generic policies are available:
|
|
*/
|
|
#define CPUFREQ_POLICY_POWERSAVE (1)
|
|
#define CPUFREQ_POLICY_PERFORMANCE (2)
|
|
|
|
/*
|
|
* The polling frequency depends on the capability of the processor. Default
|
|
* polling frequency is 1000 times the transition latency of the processor. The
|
|
* ondemand governor will work on any processor with transition latency <= 10ms,
|
|
* using appropriate sampling rate.
|
|
*/
|
|
#define LATENCY_MULTIPLIER (1000)
|
|
|
|
struct cpufreq_governor {
|
|
char name[CPUFREQ_NAME_LEN];
|
|
int (*init)(struct cpufreq_policy *policy);
|
|
void (*exit)(struct cpufreq_policy *policy);
|
|
int (*start)(struct cpufreq_policy *policy);
|
|
void (*stop)(struct cpufreq_policy *policy);
|
|
void (*limits)(struct cpufreq_policy *policy);
|
|
ssize_t (*show_setspeed) (struct cpufreq_policy *policy,
|
|
char *buf);
|
|
int (*store_setspeed) (struct cpufreq_policy *policy,
|
|
unsigned int freq);
|
|
/* For governors which change frequency dynamically by themselves */
|
|
bool dynamic_switching;
|
|
struct list_head governor_list;
|
|
struct module *owner;
|
|
};
|
|
|
|
/* Pass a target to the cpufreq driver */
|
|
unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
|
|
unsigned int target_freq);
|
|
int cpufreq_driver_target(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation);
|
|
int __cpufreq_driver_target(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation);
|
|
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
|
|
unsigned int target_freq);
|
|
unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy);
|
|
int cpufreq_register_governor(struct cpufreq_governor *governor);
|
|
void cpufreq_unregister_governor(struct cpufreq_governor *governor);
|
|
|
|
struct cpufreq_governor *cpufreq_default_governor(void);
|
|
struct cpufreq_governor *cpufreq_fallback_governor(void);
|
|
|
|
static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
|
|
{
|
|
if (policy->max < policy->cur)
|
|
__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
|
|
else if (policy->min > policy->cur)
|
|
__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
|
|
}
|
|
|
|
/* Governor attribute set */
|
|
struct gov_attr_set {
|
|
struct kobject kobj;
|
|
struct list_head policy_list;
|
|
struct mutex update_lock;
|
|
int usage_count;
|
|
};
|
|
|
|
/* sysfs ops for cpufreq governors */
|
|
extern const struct sysfs_ops governor_sysfs_ops;
|
|
|
|
void gov_attr_set_init(struct gov_attr_set *attr_set, struct list_head *list_node);
|
|
void gov_attr_set_get(struct gov_attr_set *attr_set, struct list_head *list_node);
|
|
unsigned int gov_attr_set_put(struct gov_attr_set *attr_set, struct list_head *list_node);
|
|
|
|
/* Governor sysfs attribute */
|
|
struct governor_attr {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct gov_attr_set *attr_set, char *buf);
|
|
ssize_t (*store)(struct gov_attr_set *attr_set, const char *buf,
|
|
size_t count);
|
|
};
|
|
|
|
/*********************************************************************
|
|
* FREQUENCY TABLE HELPERS *
|
|
*********************************************************************/
|
|
|
|
/* Special Values of .frequency field */
|
|
#define CPUFREQ_ENTRY_INVALID ~0u
|
|
#define CPUFREQ_TABLE_END ~1u
|
|
/* Special Values of .flags field */
|
|
#define CPUFREQ_BOOST_FREQ (1 << 0)
|
|
|
|
struct cpufreq_frequency_table {
|
|
unsigned int flags;
|
|
unsigned int driver_data; /* driver specific data, not used by core */
|
|
unsigned int frequency; /* kHz - doesn't need to be in ascending
|
|
* order */
|
|
};
|
|
|
|
#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
|
|
int dev_pm_opp_init_cpufreq_table(struct device *dev,
|
|
struct cpufreq_frequency_table **table);
|
|
void dev_pm_opp_free_cpufreq_table(struct device *dev,
|
|
struct cpufreq_frequency_table **table);
|
|
#else
|
|
static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
|
|
struct cpufreq_frequency_table
|
|
**table)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline void dev_pm_opp_free_cpufreq_table(struct device *dev,
|
|
struct cpufreq_frequency_table
|
|
**table)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* cpufreq_for_each_entry - iterate over a cpufreq_frequency_table
|
|
* @pos: the cpufreq_frequency_table * to use as a loop cursor.
|
|
* @table: the cpufreq_frequency_table * to iterate over.
|
|
*/
|
|
|
|
#define cpufreq_for_each_entry(pos, table) \
|
|
for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)
|
|
|
|
/*
|
|
* cpufreq_for_each_entry_idx - iterate over a cpufreq_frequency_table
|
|
* with index
|
|
* @pos: the cpufreq_frequency_table * to use as a loop cursor.
|
|
* @table: the cpufreq_frequency_table * to iterate over.
|
|
* @idx: the table entry currently being processed
|
|
*/
|
|
|
|
#define cpufreq_for_each_entry_idx(pos, table, idx) \
|
|
for (pos = table, idx = 0; pos->frequency != CPUFREQ_TABLE_END; \
|
|
pos++, idx++)
|
|
|
|
/*
|
|
* cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table
|
|
* excluding CPUFREQ_ENTRY_INVALID frequencies.
|
|
* @pos: the cpufreq_frequency_table * to use as a loop cursor.
|
|
* @table: the cpufreq_frequency_table * to iterate over.
|
|
*/
|
|
|
|
#define cpufreq_for_each_valid_entry(pos, table) \
|
|
for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) \
|
|
if (pos->frequency == CPUFREQ_ENTRY_INVALID) \
|
|
continue; \
|
|
else
|
|
|
|
/*
|
|
* cpufreq_for_each_valid_entry_idx - iterate with index over a cpufreq
|
|
* frequency_table excluding CPUFREQ_ENTRY_INVALID frequencies.
|
|
* @pos: the cpufreq_frequency_table * to use as a loop cursor.
|
|
* @table: the cpufreq_frequency_table * to iterate over.
|
|
* @idx: the table entry currently being processed
|
|
*/
|
|
|
|
#define cpufreq_for_each_valid_entry_idx(pos, table, idx) \
|
|
cpufreq_for_each_entry_idx(pos, table, idx) \
|
|
if (pos->frequency == CPUFREQ_ENTRY_INVALID) \
|
|
continue; \
|
|
else
|
|
|
|
|
|
int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
|
|
struct cpufreq_frequency_table *table);
|
|
|
|
int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
|
|
struct cpufreq_frequency_table *table);
|
|
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy);
|
|
|
|
int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation);
|
|
int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy,
|
|
unsigned int freq);
|
|
|
|
ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf);
|
|
|
|
#ifdef CONFIG_CPU_FREQ
|
|
int cpufreq_boost_trigger_state(int state);
|
|
int cpufreq_boost_enabled(void);
|
|
int cpufreq_enable_boost_support(void);
|
|
bool policy_has_boost_freq(struct cpufreq_policy *policy);
|
|
|
|
/* Find lowest freq at or above target in a table in ascending order */
|
|
static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq >= target_freq)
|
|
return idx;
|
|
|
|
best = idx;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Find lowest freq at or above target in a table in descending order */
|
|
static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq == target_freq)
|
|
return idx;
|
|
|
|
if (freq > target_freq) {
|
|
best = idx;
|
|
continue;
|
|
}
|
|
|
|
/* No freq found above target_freq */
|
|
if (best == -1)
|
|
return idx;
|
|
|
|
return best;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Works only on sorted freq-tables */
|
|
static inline int cpufreq_table_find_index_l(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
target_freq = clamp_val(target_freq, policy->min, policy->max);
|
|
|
|
if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING)
|
|
return cpufreq_table_find_index_al(policy, target_freq);
|
|
else
|
|
return cpufreq_table_find_index_dl(policy, target_freq);
|
|
}
|
|
|
|
/* Find highest freq at or below target in a table in ascending order */
|
|
static inline int cpufreq_table_find_index_ah(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq == target_freq)
|
|
return idx;
|
|
|
|
if (freq < target_freq) {
|
|
best = idx;
|
|
continue;
|
|
}
|
|
|
|
/* No freq found below target_freq */
|
|
if (best == -1)
|
|
return idx;
|
|
|
|
return best;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Find highest freq at or below target in a table in descending order */
|
|
static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq <= target_freq)
|
|
return idx;
|
|
|
|
best = idx;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Works only on sorted freq-tables */
|
|
static inline int cpufreq_table_find_index_h(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
target_freq = clamp_val(target_freq, policy->min, policy->max);
|
|
|
|
if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING)
|
|
return cpufreq_table_find_index_ah(policy, target_freq);
|
|
else
|
|
return cpufreq_table_find_index_dh(policy, target_freq);
|
|
}
|
|
|
|
/* Find closest freq to target in a table in ascending order */
|
|
static inline int cpufreq_table_find_index_ac(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq == target_freq)
|
|
return idx;
|
|
|
|
if (freq < target_freq) {
|
|
best = idx;
|
|
continue;
|
|
}
|
|
|
|
/* No freq found below target_freq */
|
|
if (best == -1)
|
|
return idx;
|
|
|
|
/* Choose the closest freq */
|
|
if (target_freq - table[best].frequency > freq - target_freq)
|
|
return idx;
|
|
|
|
return best;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Find closest freq to target in a table in descending order */
|
|
static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
struct cpufreq_frequency_table *table = policy->freq_table;
|
|
struct cpufreq_frequency_table *pos;
|
|
unsigned int freq;
|
|
int idx, best = -1;
|
|
|
|
cpufreq_for_each_valid_entry_idx(pos, table, idx) {
|
|
freq = pos->frequency;
|
|
|
|
if (freq == target_freq)
|
|
return idx;
|
|
|
|
if (freq > target_freq) {
|
|
best = idx;
|
|
continue;
|
|
}
|
|
|
|
/* No freq found above target_freq */
|
|
if (best == -1)
|
|
return idx;
|
|
|
|
/* Choose the closest freq */
|
|
if (table[best].frequency - target_freq > target_freq - freq)
|
|
return idx;
|
|
|
|
return best;
|
|
}
|
|
|
|
return best;
|
|
}
|
|
|
|
/* Works only on sorted freq-tables */
|
|
static inline int cpufreq_table_find_index_c(struct cpufreq_policy *policy,
|
|
unsigned int target_freq)
|
|
{
|
|
target_freq = clamp_val(target_freq, policy->min, policy->max);
|
|
|
|
if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING)
|
|
return cpufreq_table_find_index_ac(policy, target_freq);
|
|
else
|
|
return cpufreq_table_find_index_dc(policy, target_freq);
|
|
}
|
|
|
|
static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
|
|
unsigned int target_freq,
|
|
unsigned int relation)
|
|
{
|
|
if (unlikely(policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED))
|
|
return cpufreq_table_index_unsorted(policy, target_freq,
|
|
relation);
|
|
|
|
switch (relation) {
|
|
case CPUFREQ_RELATION_L:
|
|
return cpufreq_table_find_index_l(policy, target_freq);
|
|
case CPUFREQ_RELATION_H:
|
|
return cpufreq_table_find_index_h(policy, target_freq);
|
|
case CPUFREQ_RELATION_C:
|
|
return cpufreq_table_find_index_c(policy, target_freq);
|
|
default:
|
|
pr_err("%s: Invalid relation: %d\n", __func__, relation);
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy *policy)
|
|
{
|
|
struct cpufreq_frequency_table *pos;
|
|
int count = 0;
|
|
|
|
if (unlikely(!policy->freq_table))
|
|
return 0;
|
|
|
|
cpufreq_for_each_valid_entry(pos, policy->freq_table)
|
|
count++;
|
|
|
|
return count;
|
|
}
|
|
#else
|
|
static inline int cpufreq_boost_trigger_state(int state)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int cpufreq_boost_enabled(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int cpufreq_enable_boost_support(void)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline bool policy_has_boost_freq(struct cpufreq_policy *policy)
|
|
{
|
|
return false;
|
|
}
|
|
#endif
|
|
|
|
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
|
|
void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
|
|
struct cpufreq_governor *old_gov);
|
|
#else
|
|
static inline void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
|
|
struct cpufreq_governor *old_gov) { }
|
|
#endif
|
|
|
|
extern void arch_freq_prepare_all(void);
|
|
extern unsigned int arch_freq_get_on_cpu(int cpu);
|
|
|
|
extern void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
|
|
unsigned long max_freq);
|
|
extern void arch_set_max_freq_scale(struct cpumask *cpus,
|
|
unsigned long policy_max_freq);
|
|
|
|
/* the following are really really optional */
|
|
extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
|
|
extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;
|
|
extern struct freq_attr *cpufreq_generic_attr[];
|
|
int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy);
|
|
|
|
unsigned int cpufreq_generic_get(unsigned int cpu);
|
|
void cpufreq_generic_init(struct cpufreq_policy *policy,
|
|
struct cpufreq_frequency_table *table,
|
|
unsigned int transition_latency);
|
|
#endif /* _LINUX_CPUFREQ_H */
|