Skip to content

Commit

Permalink
Merge tag 'timers-core-2024-09-16' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/kernel/git/tip/tip

Pull timer updates from Thomas Gleixner:
 "Core:

   - Overhaul of posix-timers in preparation of removing the workaround
     for periodic timers which have signal delivery ignored.

   - Remove the historical extra jiffie in msleep()

     msleep() adds an extra jiffie to the timeout value to ensure
     minimal sleep time. The timer wheel ensures minimal sleep time
     since the large rewrite to a non-cascading wheel, but the extra
     jiffie in msleep() remained unnoticed. Remove it.

   - Make the timer slack handling correct for realtime tasks.

     The procfs interface is inconsistent and does neither reflect
     reality nor conforms to the man page. Show the correct 0 slack for
     real time tasks and enforce it at the core level instead of having
     inconsistent individual checks in various timer setup functions.

   - The usual set of updates and enhancements all over the place.

  Drivers:

   - Allow the ACPI PM timer to be turned off during suspend

   - No new drivers

   - The usual updates and enhancements in various drivers"

* tag 'timers-core-2024-09-16' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (43 commits)
  ntp: Make sure RTC is synchronized when time goes backwards
  treewide: Fix wrong singular form of jiffies in comments
  cpu: Use already existing usleep_range()
  timers: Rename next_expiry_recalc() to be unique
  platform/x86:intel/pmc: Fix comment for the pmc_core_acpi_pm_timer_suspend_resume function
  clocksource/drivers/jcore: Use request_percpu_irq()
  clocksource/drivers/cadence-ttc: Add missing clk_disable_unprepare in ttc_setup_clockevent
  clocksource/drivers/asm9260: Add missing clk_disable_unprepare in asm9260_timer_init
  clocksource/drivers/qcom: Add missing iounmap() on errors in msm_dt_timer_init()
  clocksource/drivers/ingenic: Use devm_clk_get_enabled() helpers
  platform/x86:intel/pmc: Enable the ACPI PM Timer to be turned off when suspended
  clocksource: acpi_pm: Add external callback for suspend/resume
  clocksource/drivers/arm_arch_timer: Using for_each_available_child_of_node_scoped()
  dt-bindings: timer: rockchip: Add rk3576 compatible
  timers: Annotate possible non critical data race of next_expiry
  timers: Remove historical extra jiffie for timeout in msleep()
  hrtimer: Use and report correct timerslack values for realtime tasks
  hrtimer: Annotate hrtimer_cpu_base_.*_expiry() for sparse.
  timers: Add sparse annotation for timer_sync_wait_running().
  signal: Replace BUG_ON()s
  ...
  • Loading branch information
torvalds committed Sep 17, 2024
2 parents cb69d86 + 35b603f commit 9ea925c
Show file tree
Hide file tree
Showing 58 changed files with 848 additions and 377 deletions.
2 changes: 1 addition & 1 deletion Documentation/admin-guide/media/vivid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ and an HDMI input, one input for each input type. Those are described in more
detail below.

Special attention has been given to the rate at which new frames become
available. The jitter will be around 1 jiffie (that depends on the HZ
available. The jitter will be around 1 jiffy (that depends on the HZ
configuration of your kernel, so usually 1/100, 1/250 or 1/1000 of a second),
but the long-term behavior is exactly following the framerate. So a
framerate of 59.94 Hz is really different from 60 Hz. If the framerate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ properties:
- rockchip,rk3228-timer
- rockchip,rk3229-timer
- rockchip,rk3368-timer
- rockchip,rk3576-timer
- rockchip,rk3588-timer
- rockchip,px30-timer
- const: rockchip,rk3288-timer
Expand Down
2 changes: 1 addition & 1 deletion Documentation/timers/timers-howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ it really need to delay in atomic context?" If so...

ATOMIC CONTEXT:
You must use the `*delay` family of functions. These
functions use the jiffie estimation of clock speed
functions use the jiffy estimation of clock speed
and will busy wait for enough loop cycles to achieve
the desired delay:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ para que se ejecute, y la tarea en ejecución es interrumpida.
==================================

CFS usa una granularidad de nanosegundos y no depende de ningún
jiffie o detalles como HZ. De este modo, el gestor de tareas CFS no tiene
jiffy o detalles como HZ. De este modo, el gestor de tareas CFS no tiene
noción de "ventanas de tiempo" de la forma en que tenía el gestor de
tareas previo, y tampoco tiene heurísticos. Únicamente hay un parámetro
central ajustable (se ha de cambiar en CONFIG_SCHED_DEBUG):
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-versatile/spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

/*
* Even though the SPC takes max 3-5 ms to complete any OPP/COMMS
* operation, the operation could start just before jiffie is about
* operation, the operation could start just before jiffy is about
* to be incremented. So setting timeout value of 20ms = 2jiffies@100Hz
*/
#define TIMEOUT_US 20000
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/q40/q40ints.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void __init q40_init_IRQ(void)
* this stuff doesn't really belong here..
*/

int ql_ticks; /* 200Hz ticks since last jiffie */
int ql_ticks; /* 200Hz ticks since last jiffy */
static int sound_ticks;

#define SVOL 45
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/cpu/mce/dev-mcelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,

/*
* Need to give user space some time to set everything up,
* so do it a jiffie or two later everywhere.
* so do it a jiffy or two later everywhere.
*/
schedule_timeout(2);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_ssif.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
ipmi_ssif_unlock_cond(ssif_info, flags);
start_get(ssif_info);
} else {
/* Wait a jiffie then request the next message */
/* Wait a jiffy then request the next message */
ssif_info->waiting_alert = true;
ssif_info->retries_left = SSIF_RECV_RETRIES;
if (!ssif_info->stopping)
Expand Down
32 changes: 32 additions & 0 deletions drivers/clocksource/acpi_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <asm/io.h>
#include <asm/time.h>

static void *suspend_resume_cb_data;

static void (*suspend_resume_callback)(void *data, bool suspend);

/*
* The I/O port the PMTMR resides at.
* The location is detected during setup_arch(),
Expand Down Expand Up @@ -58,6 +62,32 @@ u32 acpi_pm_read_verified(void)
return v2;
}

void acpi_pmtmr_register_suspend_resume_callback(void (*cb)(void *data, bool suspend), void *data)
{
suspend_resume_callback = cb;
suspend_resume_cb_data = data;
}
EXPORT_SYMBOL_GPL(acpi_pmtmr_register_suspend_resume_callback);

void acpi_pmtmr_unregister_suspend_resume_callback(void)
{
suspend_resume_callback = NULL;
suspend_resume_cb_data = NULL;
}
EXPORT_SYMBOL_GPL(acpi_pmtmr_unregister_suspend_resume_callback);

static void acpi_pm_suspend(struct clocksource *cs)
{
if (suspend_resume_callback)
suspend_resume_callback(suspend_resume_cb_data, true);
}

static void acpi_pm_resume(struct clocksource *cs)
{
if (suspend_resume_callback)
suspend_resume_callback(suspend_resume_cb_data, false);
}

static u64 acpi_pm_read(struct clocksource *cs)
{
return (u64)read_pmtmr();
Expand All @@ -69,6 +99,8 @@ static struct clocksource clocksource_acpi_pm = {
.read = acpi_pm_read,
.mask = (u64)ACPI_PM_MASK,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
.suspend = acpi_pm_suspend,
.resume = acpi_pm_resume,
};


Expand Down
11 changes: 3 additions & 8 deletions drivers/clocksource/arm_arch_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,6 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
{
struct arch_timer_mem *timer_mem;
struct arch_timer_mem_frame *frame;
struct device_node *frame_node;
struct resource res;
int ret = -EINVAL;
u32 rate;
Expand All @@ -1608,33 +1607,29 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
timer_mem->cntctlbase = res.start;
timer_mem->size = resource_size(&res);

for_each_available_child_of_node(np, frame_node) {
for_each_available_child_of_node_scoped(np, frame_node) {
u32 n;
struct arch_timer_mem_frame *frame;

if (of_property_read_u32(frame_node, "frame-number", &n)) {
pr_err(FW_BUG "Missing frame-number.\n");
of_node_put(frame_node);
goto out;
}
if (n >= ARCH_TIMER_MEM_MAX_FRAMES) {
pr_err(FW_BUG "Wrong frame-number, only 0-%u are permitted.\n",
ARCH_TIMER_MEM_MAX_FRAMES - 1);
of_node_put(frame_node);
goto out;
}
frame = &timer_mem->frame[n];

if (frame->valid) {
pr_err(FW_BUG "Duplicated frame-number.\n");
of_node_put(frame_node);
goto out;
}

if (of_address_to_resource(frame_node, 0, &res)) {
of_node_put(frame_node);
if (of_address_to_resource(frame_node, 0, &res))
goto out;
}

frame->cntbase = res.start;
frame->size = resource_size(&res);

Expand Down
1 change: 1 addition & 0 deletions drivers/clocksource/asm9260_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ static int __init asm9260_timer_init(struct device_node *np)
DRIVER_NAME, &event_dev);
if (ret) {
pr_err("Failed to setup irq!\n");
clk_disable_unprepare(clk);
return ret;
}

Expand Down
7 changes: 1 addition & 6 deletions drivers/clocksource/ingenic-ost.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ static int __init ingenic_ost_probe(struct platform_device *pdev)
return PTR_ERR(map);
}

ost->clk = devm_clk_get(dev, "ost");
ost->clk = devm_clk_get_enabled(dev, "ost");
if (IS_ERR(ost->clk))
return PTR_ERR(ost->clk);

err = clk_prepare_enable(ost->clk);
if (err)
return err;

/* Clear counter high/low registers */
if (soc_info->is64bit)
regmap_write(map, TCU_REG_OST_CNTL, 0);
Expand Down Expand Up @@ -129,7 +125,6 @@ static int __init ingenic_ost_probe(struct platform_device *pdev)
err = clocksource_register_hz(cs, rate);
if (err) {
dev_err(dev, "clocksource registration failed");
clk_disable_unprepare(ost->clk);
return err;
}

Expand Down
7 changes: 3 additions & 4 deletions drivers/clocksource/jcore-pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static int jcore_pit_local_init(unsigned cpu)

static irqreturn_t jcore_timer_interrupt(int irq, void *dev_id)
{
struct jcore_pit *pit = this_cpu_ptr(dev_id);
struct jcore_pit *pit = dev_id;

if (clockevent_state_oneshot(&pit->ced))
jcore_pit_disable(pit);
Expand Down Expand Up @@ -168,9 +168,8 @@ static int __init jcore_pit_init(struct device_node *node)
return -ENOMEM;
}

err = request_irq(pit_irq, jcore_timer_interrupt,
IRQF_TIMER | IRQF_PERCPU,
"jcore_pit", jcore_pit_percpu);
err = request_percpu_irq(pit_irq, jcore_timer_interrupt,
"jcore_pit", jcore_pit_percpu);
if (err) {
pr_err("pit irq request failed: %d\n", err);
free_percpu(jcore_pit_percpu);
Expand Down
6 changes: 4 additions & 2 deletions drivers/clocksource/timer-cadence-ttc.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
&ttcce->ttc.clk_rate_change_nb);
if (err) {
pr_warn("Unable to register clock notifier.\n");
goto out_kfree;
goto out_clk_unprepare;
}

ttcce->ttc.freq = clk_get_rate(ttcce->ttc.clk);
Expand Down Expand Up @@ -465,13 +465,15 @@ static int __init ttc_setup_clockevent(struct clk *clk,
err = request_irq(irq, ttc_clock_event_interrupt,
IRQF_TIMER, ttcce->ce.name, ttcce);
if (err)
goto out_kfree;
goto out_clk_unprepare;

clockevents_config_and_register(&ttcce->ce,
ttcce->ttc.freq / PRESCALE, 1, 0xfffe);

return 0;

out_clk_unprepare:
clk_disable_unprepare(ttcce->ttc.clk);
out_kfree:
kfree(ttcce);
return err;
Expand Down
7 changes: 6 additions & 1 deletion drivers/clocksource/timer-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ static int __init msm_dt_timer_init(struct device_node *np)
}

if (of_property_read_u32(np, "clock-frequency", &freq)) {
iounmap(cpu0_base);
pr_err("Unknown frequency\n");
return -EINVAL;
}
Expand All @@ -243,7 +244,11 @@ static int __init msm_dt_timer_init(struct device_node *np)
freq /= 4;
writel_relaxed(DGT_CLK_CTL_DIV_4, source_base + DGT_CLK_CTL);

return msm_timer_init(freq, 32, irq, !!percpu_offset);
ret = msm_timer_init(freq, 32, irq, !!percpu_offset);
if (ret)
iounmap(cpu0_base);

return ret;
}
TIMER_OF_DECLARE(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init);
TIMER_OF_DECLARE(scss_timer, "qcom,scss-timer", msm_dt_timer_init);
2 changes: 1 addition & 1 deletion drivers/dma-buf/st-dma-fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ static int test_wait_timeout(void *arg)

if (dma_fence_wait_timeout(wt.f, false, 2) == -ETIME) {
if (timer_pending(&wt.timer)) {
pr_notice("Timer did not fire within the jiffie!\n");
pr_notice("Timer did not fire within the jiffy!\n");
err = 0; /* not our fault! */
} else {
pr_err("Wait reported incomplete after timeout\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
if (ret == -ETIME && !nsecs_to_jiffies(args->timeout_ns))
args->timeout_ns = 0;

/* Asked to wait beyond the jiffie/scheduler precision? */
/* Asked to wait beyond the jiffy/scheduler precision? */
if (ret == -ETIME && args->timeout_ns)
ret = -EAGAIN;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/gt/selftest_execlists.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int wait_for_reset(struct intel_engine_cs *engine,
return -EINVAL;
}

/* Give the request a jiffie to complete after flushing the worker */
/* Give the request a jiffy to complete after flushing the worker */
if (i915_request_wait(rq, 0,
max(0l, (long)(timeout - jiffies)) + 1) < 0) {
pr_err("%s: hanging request %llx:%lld did not complete\n",
Expand Down Expand Up @@ -3426,7 +3426,7 @@ static int live_preempt_timeout(void *arg)
cpu_relax();

saved_timeout = engine->props.preempt_timeout_ms;
engine->props.preempt_timeout_ms = 1; /* in ms, -> 1 jiffie */
engine->props.preempt_timeout_ms = 1; /* in ms, -> 1 jiffy */

i915_request_get(rq);
i915_request_add(rq);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void set_timer_ms(struct timer_list *t, unsigned long timeout)
* Paranoia to make sure the compiler computes the timeout before
* loading 'jiffies' as jiffies is volatile and may be updated in
* the background by a timer tick. All to reduce the complexity
* of the addition and reduce the risk of losing a jiffie.
* of the addition and reduce the risk of losing a jiffy.
*/
barrier();

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/v3d/v3d_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ v3d_wait_bo_ioctl(struct drm_device *dev, void *data,
else
args->timeout_ns = 0;

/* Asked to wait beyond the jiffie/scheduler precision? */
/* Asked to wait beyond the jiffy/scheduler precision? */
if (ret == -ETIME && args->timeout_ns)
ret = -EAGAIN;

Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/mISDN/dsp_cmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
* - has multiple clocks.
* - has no usable clock due to jitter or packet loss (VoIP).
* In this case the system's clock is used. The clock resolution depends on
* the jiffie resolution.
* the jiffy resolution.
*
* If a member joins a conference:
*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/marvell/mvmdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int orion_mdio_wait_ready(const struct orion_mdio_ops *ops,
return 0;
} else {
/* wait_event_timeout does not guarantee a delay of at
* least one whole jiffie, so timeout must be no less
* least one whole jiffy, so timeout must be no less
* than two.
*/
timeout = max(usecs_to_jiffies(MVMDIO_SMI_TIMEOUT), 2);
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/x86/intel/pmc/adl.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ const struct pmc_reg_map adl_reg_map = {
.ppfear_buckets = CNP_PPFEAR_NUM_ENTRIES,
.pm_cfg_offset = CNP_PMC_PM_CFG_OFFSET,
.pm_read_disable_bit = CNP_PMC_READ_DISABLE_BIT,
.acpi_pm_tmr_ctl_offset = SPT_PMC_ACPI_PM_TMR_CTL_OFFSET,
.acpi_pm_tmr_disable_bit = SPT_PMC_BIT_ACPI_PM_TMR_DISABLE,
.ltr_ignore_max = ADL_NUM_IP_IGN_ALLOWED,
.lpm_num_modes = ADL_LPM_NUM_MODES,
.lpm_num_maps = ADL_LPM_NUM_MAPS,
Expand Down
2 changes: 2 additions & 0 deletions drivers/platform/x86/intel/pmc/cnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ const struct pmc_reg_map cnp_reg_map = {
.ppfear_buckets = CNP_PPFEAR_NUM_ENTRIES,
.pm_cfg_offset = CNP_PMC_PM_CFG_OFFSET,
.pm_read_disable_bit = CNP_PMC_READ_DISABLE_BIT,
.acpi_pm_tmr_ctl_offset = SPT_PMC_ACPI_PM_TMR_CTL_OFFSET,
.acpi_pm_tmr_disable_bit = SPT_PMC_BIT_ACPI_PM_TMR_DISABLE,
.ltr_ignore_max = CNP_NUM_IP_IGN_ALLOWED,
.etr3_offset = ETR3_OFFSET,
};
Expand Down
Loading

0 comments on commit 9ea925c

Please sign in to comment.