Skip to content
Snippets Groups Projects
Select Git revision
  • 26ff46c6f23bb1497aaa1364a5c73a109493b653
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

pci.c

Blame
  • sched_clock.c 4.59 KiB
    /*
     * sched_clock.c: support for extending counters to full 64-bit ns counter
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    #include <linux/clocksource.h>
    #include <linux/init.h>
    #include <linux/jiffies.h>
    #include <linux/ktime.h>
    #include <linux/kernel.h>
    #include <linux/moduleparam.h>
    #include <linux/sched.h>
    #include <linux/syscore_ops.h>
    #include <linux/hrtimer.h>
    #include <linux/sched_clock.h>
    #include <linux/seqlock.h>
    
    struct clock_data {
    	ktime_t wrap_kt;
    	u64 epoch_ns;
    	u32 epoch_cyc;
    	seqcount_t seq;
    	unsigned long rate;
    	u32 mult;
    	u32 shift;
    	bool suspended;
    };
    
    static struct hrtimer sched_clock_timer;
    static int irqtime = -1;
    
    core_param(irqtime, irqtime, int, 0400);
    
    static struct clock_data cd = {
    	.mult	= NSEC_PER_SEC / HZ,
    };
    
    static u32 __read_mostly sched_clock_mask = 0xffffffff;
    
    static u32 notrace jiffy_sched_clock_read(void)
    {
    	return (u32)(jiffies - INITIAL_JIFFIES);
    }
    
    static u32 __read_mostly (*read_sched_clock)(void) = jiffy_sched_clock_read;
    
    static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
    {
    	return (cyc * mult) >> shift;
    }
    
    static unsigned long long notrace sched_clock_32(void)
    {
    	u64 epoch_ns;
    	u32 epoch_cyc;
    	u32 cyc;
    	unsigned long seq;
    
    	if (cd.suspended)
    		return cd.epoch_ns;
    
    	do {
    		seq = read_seqcount_begin(&cd.seq);
    		epoch_cyc = cd.epoch_cyc;
    		epoch_ns = cd.epoch_ns;
    	} while (read_seqcount_retry(&cd.seq, seq));
    
    	cyc = read_sched_clock();