Changes in 4.19.307
PCI: mediatek: Clear interrupt status before dispatching handler
include/linux/units.h: add helpers for kelvin to/from Celsius conversion
units: Add Watt units
units: change from 'L' to 'UL'
units: add the HZ macros
serial: sc16is7xx: set safe default SPI clock frequency
driver core: add device probe log helper
spi: introduce SPI_MODE_X_MASK macro
serial: sc16is7xx: add check for unsupported SPI modes during probe
ext4: allow for the last group to be marked as trimmed
crypto: api - Disallow identical driver names
PM: hibernate: Enforce ordering during image compression/decompression
hwrng: core - Fix page fault dead lock on mmap-ed hwrng
rpmsg: virtio: Free driver_override when rpmsg_remove()
parisc/firmware: Fix F-extend for PDC addresses
nouveau/vmm: don't set addr on the fail path to avoid warning
block: Remove special-casing of compound pages
powerpc: Use always instead of always-y in for crtsavres.o
x86/CPU/AMD: Fix disabling XSAVES on AMD family 0x17 due to erratum
driver core: Annotate dev_err_probe() with __must_check
Revert "driver core: Annotate dev_err_probe() with __must_check"
driver code: print symbolic error code
drivers: core: fix kernel-doc markup for dev_err_probe()
net/smc: fix illegal rmb_desc access in SMC-D connection dump
vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING
llc: make llc_ui_sendmsg() more robust against bonding changes
llc: Drop support for ETH_P_TR_802_2.
net/rds: Fix UBSAN: array-index-out-of-bounds in rds_cmsg_recv
tracing: Ensure visibility when inserting an element into tracing_map
tcp: Add memory barrier to tcp_push()
netlink: fix potential sleeping issue in mqueue_flush_file
net/mlx5: Use kfree(ft->g) in arfs_create_groups()
net/mlx5e: fix a double-free in arfs_create_groups
netfilter: nf_tables: restrict anonymous set and map names to 16 bytes
fjes: fix memleaks in fjes_hw_setup
net: fec: fix the unhandled context fault from smmu
btrfs: don't warn if discard range is not aligned to sector
btrfs: defrag: reject unknown flags of btrfs_ioctl_defrag_range_args
netfilter: nf_tables: reject QUEUE/DROP verdict parameters
gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-04
drm: Don't unref the same fb many times by mistake due to deadlock handling
drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking
drm/bridge: nxp-ptn3460: simplify some error checking
drm/exynos: gsc: minor fix for loop iteration in gsc_runtime_resume
gpio: eic-sprd: Clear interrupt after set the interrupt type
mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan
tick/sched: Preserve number of idle sleeps across CPU hotplug events
x86/entry/ia32: Ensure s32 is sign extended to s64
net/sched: cbs: Fix not adding cbs instance to list
powerpc/mm: Fix null-pointer dereference in pgtable_cache_add
powerpc: Fix build error due to is_valid_bugaddr()
powerpc/mm: Fix build failures due to arch_reserved_kernel_pages()
powerpc/lib: Validate size for vector operations
audit: Send netlink ACK before setting connection in auditd_set
ACPI: video: Add quirk for the Colorful X15 AT 23 Laptop
PNP: ACPI: fix fortify warning
ACPI: extlog: fix NULL pointer dereference check
FS:JFS:UBSAN:array-index-out-of-bounds in dbAdjTree
UBSAN: array-index-out-of-bounds in dtSplitRoot
jfs: fix slab-out-of-bounds Read in dtSearch
jfs: fix array-index-out-of-bounds in dbAdjTree
jfs: fix uaf in jfs_evict_inode
pstore/ram: Fix crash when setting number of cpus to an odd number
crypto: stm32/crc32 - fix parsing list of devices
afs: fix the usage of read_seqbegin_or_lock() in afs_find_server*()
rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock()
jfs: fix array-index-out-of-bounds in diNewExt
s390/ptrace: handle setting of fpc register correctly
KVM: s390: fix setting of fpc register
SUNRPC: Fix a suspicious RCU usage warning
ext4: fix inconsistent between segment fstrim and full fstrim
ext4: unify the type of flexbg_size to unsigned int
ext4: remove unnecessary check from alloc_flex_gd()
ext4: avoid online resizing failures due to oversized flex bg
scsi: lpfc: Fix possible file string name overflow when updating firmware
PCI: Add no PM reset quirk for NVIDIA Spectrum devices
bonding: return -ENOMEM instead of BUG in alb_upper_dev_walk
ARM: dts: imx7s: Fix lcdif compatible
ARM: dts: imx7s: Fix nand-controller #size-cells
wifi: ath9k: Fix potential array-index-out-of-bounds read in ath9k_htc_txstatus()
bpf: Add map and need_defer parameters to .map_fd_put_ptr()
scsi: libfc: Don't schedule abort twice
scsi: libfc: Fix up timeout error in fc_fcp_rec_error()
ARM: dts: rockchip: fix rk3036 hdmi ports node
ARM: dts: imx25/27-eukrea: Fix RTC node name
ARM: dts: imx: Use flash@0,0 pattern
ARM: dts: imx27: Fix sram node
ARM: dts: imx1: Fix sram node
ARM: dts: imx27-apf27dev: Fix LED name
ARM: dts: imx23-sansa: Use preferred i2c-gpios properties
ARM: dts: imx23/28: Fix the DMA controller node name
md: Whenassemble the array, consult the superblock of the freshest device
wifi: rtl8xxxu: Add additional USB IDs for RTL8192EU devices
wifi: rtlwifi: rtl8723{be,ae}: using calculate_bit_shift()
wifi: cfg80211: free beacon_ies when overridden from hidden BSS
f2fs: fix to check return value of f2fs_reserve_new_block()
ASoC: doc: Fix undefined SND_SOC_DAPM_NOPM argument
fast_dput(): handle underflows gracefully
RDMA/IPoIB: Fix error code return in ipoib_mcast_join
drm/drm_file: fix use of uninitialized variable
drm/framebuffer: Fix use of uninitialized variable
drm/mipi-dsi: Fix detach call without attach
media: stk1160: Fixed high volume of stk1160_dbg messages
media: rockchip: rga: fix swizzling for RGB formats
PCI: add INTEL_HDA_ARL to pci_ids.h
ALSA: hda: Intel: add HDA_ARL PCI ID support
drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time
IB/ipoib: Fix mcast list locking
media: ddbridge: fix an error code problem in ddb_probe
drm/msm/dpu: Ratelimit framedone timeout msgs
clk: hi3620: Fix memory leak in hi3620_mmc_clk_init()
clk: mmp: pxa168: Fix memory leak in pxa168_clk_init()
drm/amdgpu: Let KFD sync with VM fences
drm/amdgpu: Drop 'fence' check in 'to_amdgpu_amdkfd_fence()'
leds: trigger: panic: Don't register panic notifier if creating the trigger failed
um: Fix naming clash between UML and scheduler
um: Don't use vfprintf() for os_info()
um: net: Fix return type of uml_net_start_xmit()
mfd: ti_am335x_tscadc: Fix TI SoC dependencies
PCI: Only override AMD USB controller if required
usb: hub: Replace hardcoded quirk value with BIT() macro
libsubcmd: Fix memory leak in uniq()
virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings
blk-mq: fix IO hang from sbitmap wakeup race
ceph: fix deadlock or deadcode of misusing dget()
drm/amdgpu: Release 'adev->pm.fw' before return in 'amdgpu_device_need_post()'
wifi: cfg80211: fix RCU dereference in __cfg80211_bss_update
scsi: isci: Fix an error code problem in isci_io_request_build()
net: remove unneeded break
ixgbe: Remove non-inclusive language
ixgbe: Refactor returning internal error codes
ixgbe: Refactor overtemp event handling
ixgbe: Fix an error handling path in ixgbe_read_iosf_sb_reg_x550()
ipv6: Ensure natural alignment of const ipv6 loopback and router addresses
llc: call sock_orphan() at release time
netfilter: nf_log: replace BUG_ON by WARN_ON_ONCE when putting logger
net: ipv4: fix a memleak in ip_setup_cork
af_unix: fix lockdep positive in sk_diag_dump_icons()
net: sysfs: Fix /sys/class/net/<iface> path
HID: apple: Add support for the 2021 Magic Keyboard
HID: apple: Swap the Fn and Left Control keys on Apple keyboards
HID: apple: Add 2021 magic keyboard FN key mapping
bonding: remove print in bond_verify_device_path
dmaengine: fix is_slave_direction() return false when DMA_DEV_TO_DEV
phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP
atm: idt77252: fix a memleak in open_card_ubr0
hwmon: (aspeed-pwm-tacho) mutex for tach reading
hwmon: (coretemp) Fix out-of-bounds memory access
hwmon: (coretemp) Fix bogus core_id to attr name mapping
inet: read sk->sk_family once in inet_recv_error()
rxrpc: Fix response to PING RESPONSE ACKs to a dead call
tipc: Check the bearer type before calling tipc_udp_nl_bearer_add()
ppp_async: limit MRU to 64K
netfilter: nft_compat: reject unused compat flag
netfilter: nft_compat: restrict match/target protocol to u16
net/af_iucv: clean up a try_then_request_module()
USB: serial: qcserial: add new usb-id for Dell Wireless DW5826e
USB: serial: option: add Fibocom FM101-GL variant
USB: serial: cp210x: add ID for IMST iM871A-USB
Input: atkbd - skip ATKBD_CMD_SETLEDS when skipping ATKBD_CMD_GETID
vhost: use kzalloc() instead of kmalloc() followed by memset()
hrtimer: Report offline hrtimer enqueue
btrfs: forbid creating subvol qgroups
btrfs: send: return EOPNOTSUPP on unknown flags
spi: ppc4xx: Drop write-only variable
ASoC: rt5645: Fix deadlock in rt5645_jack_detect_work()
Documentation: net-sysfs: describe missing statistics
net: sysfs: Fix /sys/class/net/<iface> path for statistics
MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler
i40e: Fix waiting for queues of all VSIs to be disabled
tracing/trigger: Fix to return error if failed to alloc snapshot
mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again
HID: wacom: generic: Avoid reporting a serial of '0' to userspace
HID: wacom: Do not register input devices until after hid_hw_start
USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT
usb: f_mass_storage: forbid async queue when shutdown happen
scsi: Revert "scsi: fcoe: Fix potential deadlock on &fip->ctlr_lock"
firewire: core: correct documentation of fw_csr_string() kernel API
nfc: nci: free rx_data_reassembly skb on NCI device cleanup
xen-netback: properly sync TX responses
binder: signal epoll threads of self-work
ext4: fix double-free of blocks due to wrong extents moved_len
staging: iio: ad5933: fix type mismatch regression
ring-buffer: Clean ring_buffer_poll_wait() error return
serial: max310x: set default value when reading clock ready bit
serial: max310x: improve crystal stable clock detection
x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6
x86/mm/ident_map: Use gbpages only where full GB page should be mapped.
ALSA: hda/conexant: Add quirk for SWS JS201D
nilfs2: fix data corruption in dsync block recovery for small block sizes
nilfs2: fix hang in nilfs_lookup_dirty_data_buffers()
nfp: use correct macro for LengthSelect in BAR config
irqchip/irq-brcmstb-l2: Add write memory barrier before exit
pmdomain: core: Move the unused cleanup to a _sync initcall
Revert "md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d"
sched/membarrier: reduce the ability to hammer on sys_membarrier
nilfs2: fix potential bug in end_buffer_async_write
lsm: new security_file_ioctl_compat() hook
netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval()
Linux 4.19.307
Change-Id: Ib05aec445afe9920e2502bcfce1c52db76e27139
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
508 lines
15 KiB
C
508 lines
15 KiB
C
/*
|
|
* include/linux/hrtimer.h
|
|
*
|
|
* hrtimers - High-resolution kernel timers
|
|
*
|
|
* Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de>
|
|
* Copyright(C) 2005, Red Hat, Inc., Ingo Molnar
|
|
*
|
|
* data type definitions, declarations, prototypes
|
|
*
|
|
* Started by: Thomas Gleixner and Ingo Molnar
|
|
*
|
|
* For licencing details see kernel-base/COPYING
|
|
*/
|
|
#ifndef _LINUX_HRTIMER_H
|
|
#define _LINUX_HRTIMER_H
|
|
|
|
#include <linux/hrtimer_defs.h>
|
|
#include <linux/rbtree.h>
|
|
#include <linux/init.h>
|
|
#include <linux/list.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/timerqueue.h>
|
|
#include <linux/android_kabi.h>
|
|
|
|
struct hrtimer_clock_base;
|
|
struct hrtimer_cpu_base;
|
|
|
|
/*
|
|
* Mode arguments of xxx_hrtimer functions:
|
|
*
|
|
* HRTIMER_MODE_ABS - Time value is absolute
|
|
* HRTIMER_MODE_REL - Time value is relative to now
|
|
* HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered
|
|
* when starting the timer)
|
|
* HRTIMER_MODE_SOFT - Timer callback function will be executed in
|
|
* soft irq context
|
|
*/
|
|
enum hrtimer_mode {
|
|
HRTIMER_MODE_ABS = 0x00,
|
|
HRTIMER_MODE_REL = 0x01,
|
|
HRTIMER_MODE_PINNED = 0x02,
|
|
HRTIMER_MODE_SOFT = 0x04,
|
|
|
|
HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED,
|
|
HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED,
|
|
|
|
HRTIMER_MODE_ABS_SOFT = HRTIMER_MODE_ABS | HRTIMER_MODE_SOFT,
|
|
HRTIMER_MODE_REL_SOFT = HRTIMER_MODE_REL | HRTIMER_MODE_SOFT,
|
|
|
|
HRTIMER_MODE_ABS_PINNED_SOFT = HRTIMER_MODE_ABS_PINNED | HRTIMER_MODE_SOFT,
|
|
HRTIMER_MODE_REL_PINNED_SOFT = HRTIMER_MODE_REL_PINNED | HRTIMER_MODE_SOFT,
|
|
|
|
};
|
|
|
|
/*
|
|
* Return values for the callback function
|
|
*/
|
|
enum hrtimer_restart {
|
|
HRTIMER_NORESTART, /* Timer is not restarted */
|
|
HRTIMER_RESTART, /* Timer must be restarted */
|
|
};
|
|
|
|
/*
|
|
* Values to track state of the timer
|
|
*
|
|
* Possible states:
|
|
*
|
|
* 0x00 inactive
|
|
* 0x01 enqueued into rbtree
|
|
*
|
|
* The callback state is not part of the timer->state because clearing it would
|
|
* mean touching the timer after the callback, this makes it impossible to free
|
|
* the timer from the callback function.
|
|
*
|
|
* Therefore we track the callback state in:
|
|
*
|
|
* timer->base->cpu_base->running == timer
|
|
*
|
|
* On SMP it is possible to have a "callback function running and enqueued"
|
|
* status. It happens for example when a posix timer expired and the callback
|
|
* queued a signal. Between dropping the lock which protects the posix timer
|
|
* and reacquiring the base lock of the hrtimer, another CPU can deliver the
|
|
* signal and rearm the timer.
|
|
*
|
|
* All state transitions are protected by cpu_base->lock.
|
|
*/
|
|
#define HRTIMER_STATE_INACTIVE 0x00
|
|
#define HRTIMER_STATE_ENQUEUED 0x01
|
|
|
|
/**
|
|
* struct hrtimer - the basic hrtimer structure
|
|
* @node: timerqueue node, which also manages node.expires,
|
|
* the absolute expiry time in the hrtimers internal
|
|
* representation. The time is related to the clock on
|
|
* which the timer is based. Is setup by adding
|
|
* slack to the _softexpires value. For non range timers
|
|
* identical to _softexpires.
|
|
* @_softexpires: the absolute earliest expiry time of the hrtimer.
|
|
* The time which was given as expiry time when the timer
|
|
* was armed.
|
|
* @function: timer expiry callback function
|
|
* @base: pointer to the timer base (per cpu and per clock)
|
|
* @state: state information (See bit values above)
|
|
* @is_rel: Set if the timer was armed relative
|
|
* @is_soft: Set if hrtimer will be expired in soft interrupt context.
|
|
*
|
|
* The hrtimer structure must be initialized by hrtimer_init()
|
|
*/
|
|
struct hrtimer {
|
|
struct timerqueue_node node;
|
|
ktime_t _softexpires;
|
|
enum hrtimer_restart (*function)(struct hrtimer *);
|
|
struct hrtimer_clock_base *base;
|
|
u8 state;
|
|
u8 is_rel;
|
|
u8 is_soft;
|
|
|
|
ANDROID_KABI_RESERVE(1);
|
|
};
|
|
|
|
/**
|
|
* struct hrtimer_sleeper - simple sleeper structure
|
|
* @timer: embedded timer structure
|
|
* @task: task to wake up
|
|
*
|
|
* task is set to NULL, when the timer expires.
|
|
*/
|
|
struct hrtimer_sleeper {
|
|
struct hrtimer timer;
|
|
struct task_struct *task;
|
|
};
|
|
|
|
#ifdef CONFIG_64BIT
|
|
# define __hrtimer_clock_base_align ____cacheline_aligned
|
|
#else
|
|
# define __hrtimer_clock_base_align
|
|
#endif
|
|
|
|
/**
|
|
* struct hrtimer_clock_base - the timer base for a specific clock
|
|
* @cpu_base: per cpu clock base
|
|
* @index: clock type index for per_cpu support when moving a
|
|
* timer to a base on another cpu.
|
|
* @clockid: clock id for per_cpu support
|
|
* @seq: seqcount around __run_hrtimer
|
|
* @running: pointer to the currently running hrtimer
|
|
* @active: red black tree root node for the active timers
|
|
* @get_time: function to retrieve the current time of the clock
|
|
* @offset: offset of this clock to the monotonic base
|
|
*/
|
|
struct hrtimer_clock_base {
|
|
struct hrtimer_cpu_base *cpu_base;
|
|
unsigned int index;
|
|
clockid_t clockid;
|
|
seqcount_t seq;
|
|
struct hrtimer *running;
|
|
struct timerqueue_head active;
|
|
ktime_t (*get_time)(void);
|
|
ktime_t offset;
|
|
} __hrtimer_clock_base_align;
|
|
|
|
enum hrtimer_base_type {
|
|
HRTIMER_BASE_MONOTONIC,
|
|
HRTIMER_BASE_REALTIME,
|
|
HRTIMER_BASE_BOOTTIME,
|
|
HRTIMER_BASE_TAI,
|
|
HRTIMER_BASE_MONOTONIC_SOFT,
|
|
HRTIMER_BASE_REALTIME_SOFT,
|
|
HRTIMER_BASE_BOOTTIME_SOFT,
|
|
HRTIMER_BASE_TAI_SOFT,
|
|
HRTIMER_MAX_CLOCK_BASES,
|
|
};
|
|
|
|
/**
|
|
* struct hrtimer_cpu_base - the per cpu clock bases
|
|
* @lock: lock protecting the base and associated clock bases
|
|
* and timers
|
|
* @cpu: cpu number
|
|
* @active_bases: Bitfield to mark bases with active timers
|
|
* @clock_was_set_seq: Sequence counter of clock was set events
|
|
* @hres_active: State of high resolution mode
|
|
* @in_hrtirq: hrtimer_interrupt() is currently executing
|
|
* @hang_detected: The last hrtimer interrupt detected a hang
|
|
* @softirq_activated: displays, if the softirq is raised - update of softirq
|
|
* related settings is not required then.
|
|
* @online: CPU is online from an hrtimers point of view
|
|
* @nr_events: Total number of hrtimer interrupt events
|
|
* @nr_retries: Total number of hrtimer interrupt retries
|
|
* @nr_hangs: Total number of hrtimer interrupt hangs
|
|
* @max_hang_time: Maximum time spent in hrtimer_interrupt
|
|
* @expires_next: absolute time of the next event, is required for remote
|
|
* hrtimer enqueue; it is the total first expiry time (hard
|
|
* and soft hrtimer are taken into account)
|
|
* @next_timer: Pointer to the first expiring timer
|
|
* @softirq_expires_next: Time to check, if soft queues needs also to be expired
|
|
* @softirq_next_timer: Pointer to the first expiring softirq based timer
|
|
* @clock_base: array of clock bases for this cpu
|
|
*
|
|
* Note: next_timer is just an optimization for __remove_hrtimer().
|
|
* Do not dereference the pointer because it is not reliable on
|
|
* cross cpu removals.
|
|
*/
|
|
struct hrtimer_cpu_base {
|
|
raw_spinlock_t lock;
|
|
unsigned int cpu;
|
|
unsigned int active_bases;
|
|
unsigned int clock_was_set_seq;
|
|
unsigned int hres_active : 1,
|
|
in_hrtirq : 1,
|
|
hang_detected : 1,
|
|
softirq_activated : 1,
|
|
online : 1;
|
|
#ifdef CONFIG_HIGH_RES_TIMERS
|
|
unsigned int nr_events;
|
|
unsigned short nr_retries;
|
|
unsigned short nr_hangs;
|
|
unsigned int max_hang_time;
|
|
#endif
|
|
ktime_t expires_next;
|
|
struct hrtimer *next_timer;
|
|
ktime_t softirq_expires_next;
|
|
struct hrtimer *softirq_next_timer;
|
|
struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
|
|
} ____cacheline_aligned;
|
|
|
|
static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
|
|
{
|
|
timer->node.expires = time;
|
|
timer->_softexpires = time;
|
|
}
|
|
|
|
static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
|
|
{
|
|
timer->_softexpires = time;
|
|
timer->node.expires = ktime_add_safe(time, delta);
|
|
}
|
|
|
|
static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, u64 delta)
|
|
{
|
|
timer->_softexpires = time;
|
|
timer->node.expires = ktime_add_safe(time, ns_to_ktime(delta));
|
|
}
|
|
|
|
static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
|
|
{
|
|
timer->node.expires = tv64;
|
|
timer->_softexpires = tv64;
|
|
}
|
|
|
|
static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
|
|
{
|
|
timer->node.expires = ktime_add_safe(timer->node.expires, time);
|
|
timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
|
|
}
|
|
|
|
static inline void hrtimer_add_expires_ns(struct hrtimer *timer, u64 ns)
|
|
{
|
|
timer->node.expires = ktime_add_ns(timer->node.expires, ns);
|
|
timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
|
|
}
|
|
|
|
static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
|
|
{
|
|
return timer->node.expires;
|
|
}
|
|
|
|
static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
|
|
{
|
|
return timer->_softexpires;
|
|
}
|
|
|
|
static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
|
|
{
|
|
return timer->node.expires;
|
|
}
|
|
static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
|
|
{
|
|
return timer->_softexpires;
|
|
}
|
|
|
|
static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
|
|
{
|
|
return ktime_to_ns(timer->node.expires);
|
|
}
|
|
|
|
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
|
|
{
|
|
return ktime_sub(timer->node.expires, timer->base->get_time());
|
|
}
|
|
|
|
static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
|
|
{
|
|
return timer->base->get_time();
|
|
}
|
|
|
|
static inline int hrtimer_is_hres_active(struct hrtimer *timer)
|
|
{
|
|
return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ?
|
|
timer->base->cpu_base->hres_active : 0;
|
|
}
|
|
|
|
#ifdef CONFIG_HIGH_RES_TIMERS
|
|
struct clock_event_device;
|
|
|
|
extern void hrtimer_interrupt(struct clock_event_device *dev);
|
|
|
|
extern void clock_was_set_delayed(void);
|
|
|
|
extern unsigned int hrtimer_resolution;
|
|
|
|
#else
|
|
|
|
#define hrtimer_resolution (unsigned int)LOW_RES_NSEC
|
|
|
|
static inline void clock_was_set_delayed(void) { }
|
|
|
|
#endif
|
|
|
|
static inline ktime_t
|
|
__hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
|
|
{
|
|
ktime_t rem = ktime_sub(timer->node.expires, now);
|
|
|
|
/*
|
|
* Adjust relative timers for the extra we added in
|
|
* hrtimer_start_range_ns() to prevent short timeouts.
|
|
*/
|
|
if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel)
|
|
rem -= hrtimer_resolution;
|
|
return rem;
|
|
}
|
|
|
|
static inline ktime_t
|
|
hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
|
|
{
|
|
return __hrtimer_expires_remaining_adjusted(timer,
|
|
timer->base->get_time());
|
|
}
|
|
|
|
extern void clock_was_set(void);
|
|
#ifdef CONFIG_TIMERFD
|
|
extern void timerfd_clock_was_set(void);
|
|
#else
|
|
static inline void timerfd_clock_was_set(void) { }
|
|
#endif
|
|
extern void hrtimers_resume(void);
|
|
|
|
DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
|
|
|
|
|
|
/* Exported timer functions: */
|
|
|
|
/* Initialize timers: */
|
|
extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
|
|
enum hrtimer_mode mode);
|
|
|
|
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
|
|
extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
|
|
enum hrtimer_mode mode);
|
|
|
|
extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
|
|
#else
|
|
static inline void hrtimer_init_on_stack(struct hrtimer *timer,
|
|
clockid_t which_clock,
|
|
enum hrtimer_mode mode)
|
|
{
|
|
hrtimer_init(timer, which_clock, mode);
|
|
}
|
|
static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
|
|
#endif
|
|
|
|
/* Basic timer operations: */
|
|
extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
|
|
u64 range_ns, const enum hrtimer_mode mode);
|
|
|
|
/**
|
|
* hrtimer_start - (re)start an hrtimer
|
|
* @timer: the timer to be added
|
|
* @tim: expiry time
|
|
* @mode: timer mode: absolute (HRTIMER_MODE_ABS) or
|
|
* relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED);
|
|
* softirq based mode is considered for debug purpose only!
|
|
*/
|
|
static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
|
|
const enum hrtimer_mode mode)
|
|
{
|
|
hrtimer_start_range_ns(timer, tim, 0, mode);
|
|
}
|
|
|
|
extern int hrtimer_cancel(struct hrtimer *timer);
|
|
extern int hrtimer_try_to_cancel(struct hrtimer *timer);
|
|
|
|
static inline void hrtimer_start_expires(struct hrtimer *timer,
|
|
enum hrtimer_mode mode)
|
|
{
|
|
u64 delta;
|
|
ktime_t soft, hard;
|
|
soft = hrtimer_get_softexpires(timer);
|
|
hard = hrtimer_get_expires(timer);
|
|
delta = ktime_to_ns(ktime_sub(hard, soft));
|
|
hrtimer_start_range_ns(timer, soft, delta, mode);
|
|
}
|
|
|
|
static inline void hrtimer_restart(struct hrtimer *timer)
|
|
{
|
|
hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
|
|
}
|
|
|
|
/* Query timers: */
|
|
extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust);
|
|
|
|
static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
|
|
{
|
|
return __hrtimer_get_remaining(timer, false);
|
|
}
|
|
|
|
extern u64 hrtimer_get_next_event(void);
|
|
extern u64 hrtimer_next_event_without(const struct hrtimer *exclude);
|
|
|
|
extern bool hrtimer_active(const struct hrtimer *timer);
|
|
|
|
/**
|
|
* hrtimer_is_queued = check, whether the timer is on one of the queues
|
|
* @timer: Timer to check
|
|
*
|
|
* Returns: True if the timer is queued, false otherwise
|
|
*
|
|
* The function can be used lockless, but it gives only a current snapshot.
|
|
*/
|
|
static inline bool hrtimer_is_queued(struct hrtimer *timer)
|
|
{
|
|
/* The READ_ONCE pairs with the update functions of timer->state */
|
|
return !!(READ_ONCE(timer->state) & HRTIMER_STATE_ENQUEUED);
|
|
}
|
|
|
|
/*
|
|
* Helper function to check, whether the timer is running the callback
|
|
* function
|
|
*/
|
|
static inline int hrtimer_callback_running(struct hrtimer *timer)
|
|
{
|
|
return timer->base->running == timer;
|
|
}
|
|
|
|
/* Forward a hrtimer so it expires after now: */
|
|
extern u64
|
|
hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
|
|
|
|
/**
|
|
* hrtimer_forward_now - forward the timer expiry so it expires after now
|
|
* @timer: hrtimer to forward
|
|
* @interval: the interval to forward
|
|
*
|
|
* Forward the timer expiry so it will expire after the current time
|
|
* of the hrtimer clock base. Returns the number of overruns.
|
|
*
|
|
* Can be safely called from the callback function of @timer. If
|
|
* called from other contexts @timer must neither be enqueued nor
|
|
* running the callback and the caller needs to take care of
|
|
* serialization.
|
|
*
|
|
* Note: This only updates the timer expiry value and does not requeue
|
|
* the timer.
|
|
*/
|
|
static inline u64 hrtimer_forward_now(struct hrtimer *timer,
|
|
ktime_t interval)
|
|
{
|
|
return hrtimer_forward(timer, timer->base->get_time(), interval);
|
|
}
|
|
|
|
/* Precise sleep: */
|
|
|
|
extern int nanosleep_copyout(struct restart_block *, struct timespec64 *);
|
|
extern long hrtimer_nanosleep(const struct timespec64 *rqtp,
|
|
const enum hrtimer_mode mode,
|
|
const clockid_t clockid);
|
|
|
|
extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
|
|
struct task_struct *tsk);
|
|
|
|
extern int schedule_hrtimeout_range(ktime_t *expires, u64 delta,
|
|
const enum hrtimer_mode mode);
|
|
extern int schedule_hrtimeout_range_clock(ktime_t *expires,
|
|
u64 delta,
|
|
const enum hrtimer_mode mode,
|
|
clockid_t clock_id);
|
|
extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);
|
|
|
|
/* Soft interrupt function to run the hrtimer queues: */
|
|
extern void hrtimer_run_queues(void);
|
|
|
|
/* Bootup initialization: */
|
|
extern void __init hrtimers_init(void);
|
|
|
|
/* Show pending timers: */
|
|
extern void sysrq_timer_list_show(void);
|
|
|
|
int hrtimers_prepare_cpu(unsigned int cpu);
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
int hrtimers_dead_cpu(unsigned int cpu);
|
|
#else
|
|
#define hrtimers_dead_cpu NULL
|
|
#endif
|
|
|
|
#endif
|