summaryrefslogtreecommitdiff
path: root/arch/tile/kernel/time.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 20:20:12 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 20:20:12 -0700
commitf5a8eb632b562bd9c16c389f5db3a5260fba4157 (patch)
tree82687234d772ff8f72a31e598fe16553885c56c9 /arch/tile/kernel/time.c
parentc9297d284126b80c9cfd72c690e0da531c99fc48 (diff)
parentdd3b8c329aa270027fba61a02a12600972dc3983 (diff)
Merge tag 'arch-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
Pul removal of obsolete architecture ports from Arnd Bergmann: "This removes the entire architecture code for blackfin, cris, frv, m32r, metag, mn10300, score, and tile, including the associated device drivers. I have been working with the (former) maintainers for each one to ensure that my interpretation was right and the code is definitely unused in mainline kernels. Many had fond memories of working on the respective ports to start with and getting them included in upstream, but also saw no point in keeping the port alive without any users. In the end, it seems that while the eight architectures are extremely different, they all suffered the same fate: There was one company in charge of an SoC line, a CPU microarchitecture and a software ecosystem, which was more costly than licensing newer off-the-shelf CPU cores from a third party (typically ARM, MIPS, or RISC-V). It seems that all the SoC product lines are still around, but have not used the custom CPU architectures for several years at this point. In contrast, CPU instruction sets that remain popular and have actively maintained kernel ports tend to all be used across multiple licensees. [ See the new nds32 port merged in the previous commit for the next generation of "one company in charge of an SoC line, a CPU microarchitecture and a software ecosystem" - Linus ] The removal came out of a discussion that is now documented at https://lwn.net/Articles/748074/. Unlike the original plans, I'm not marking any ports as deprecated but remove them all at once after I made sure that they are all unused. Some architectures (notably tile, mn10300, and blackfin) are still being shipped in products with old kernels, but those products will never be updated to newer kernel releases. After this series, we still have a few architectures without mainline gcc support: - unicore32 and hexagon both have very outdated gcc releases, but the maintainers promised to work on providing something newer. At least in case of hexagon, this will only be llvm, not gcc. - openrisc, risc-v and nds32 are still in the process of finishing their support or getting it added to mainline gcc in the first place. They all have patched gcc-7.3 ports that work to some degree, but complete upstream support won't happen before gcc-8.1. Csky posted their first kernel patch set last week, their situation will be similar [ Palmer Dabbelt points out that RISC-V support is in mainline gcc since gcc-7, although gcc-7.3.0 is the recommended minimum - Linus ]" This really says it all: 2498 files changed, 95 insertions(+), 467668 deletions(-) * tag 'arch-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (74 commits) MAINTAINERS: UNICORE32: Change email account staging: iio: remove iio-trig-bfin-timer driver tty: hvc: remove tile driver tty: remove bfin_jtag_comm and hvc_bfin_jtag drivers serial: remove tile uart driver serial: remove m32r_sio driver serial: remove blackfin drivers serial: remove cris/etrax uart drivers usb: Remove Blackfin references in USB support usb: isp1362: remove blackfin arch glue usb: musb: remove blackfin port usb: host: remove tilegx platform glue pwm: remove pwm-bfin driver i2c: remove bfin-twi driver spi: remove blackfin related host drivers watchdog: remove bfin_wdt driver can: remove bfin_can driver mmc: remove bfin_sdh driver input: misc: remove blackfin rotary driver input: keyboard: remove bf54x driver ...
Diffstat (limited to 'arch/tile/kernel/time.c')
-rw-r--r--arch/tile/kernel/time.c306
1 files changed, 0 insertions, 306 deletions
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
deleted file mode 100644
index f95d65f3162bc..0000000000000
--- a/arch/tile/kernel/time.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright 2010 Tilera Corporation. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for
- * more details.
- *
- * Support the cycle counter clocksource and tile timer clock event device.
- */
-
-#include <linux/time.h>
-#include <linux/timex.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-#include <linux/hardirq.h>
-#include <linux/sched.h>
-#include <linux/sched/clock.h>
-#include <linux/smp.h>
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/timekeeper_internal.h>
-#include <asm/irq_regs.h>
-#include <asm/traps.h>
-#include <asm/vdso.h>
-#include <hv/hypervisor.h>
-#include <arch/interrupts.h>
-#include <arch/spr_def.h>
-
-
-/*
- * Define the cycle counter clock source.
- */
-
-/* How many cycles per second we are running at. */
-static cycles_t cycles_per_sec __ro_after_init;
-
-cycles_t get_clock_rate(void)
-{
- return cycles_per_sec;
-}
-
-#if CHIP_HAS_SPLIT_CYCLE()
-cycles_t get_cycles(void)
-{
- unsigned int high = __insn_mfspr(SPR_CYCLE_HIGH);
- unsigned int low = __insn_mfspr(SPR_CYCLE_LOW);
- unsigned int high2 = __insn_mfspr(SPR_CYCLE_HIGH);
-
- while (unlikely(high != high2)) {
- low = __insn_mfspr(SPR_CYCLE_LOW);
- high = high2;
- high2 = __insn_mfspr(SPR_CYCLE_HIGH);
- }
-
- return (((cycles_t)high) << 32) | low;
-}
-EXPORT_SYMBOL(get_cycles);
-#endif
-
-/*
- * We use a relatively small shift value so that sched_clock()
- * won't wrap around very often.
- */
-#define SCHED_CLOCK_SHIFT 10
-
-static unsigned long sched_clock_mult __ro_after_init;
-
-static cycles_t clocksource_get_cycles(struct clocksource *cs)
-{
- return get_cycles();
-}
-
-static struct clocksource cycle_counter_cs = {
- .name = "cycle counter",
- .rating = 300,
- .read = clocksource_get_cycles,
- .mask = CLOCKSOURCE_MASK(64),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-/*
- * Called very early from setup_arch() to set cycles_per_sec.
- * We initialize it early so we can use it to set up loops_per_jiffy.
- */
-void __init setup_clock(void)
-{
- cycles_per_sec = hv_sysconf(HV_SYSCONF_CPU_SPEED);
- sched_clock_mult =
- clocksource_hz2mult(cycles_per_sec, SCHED_CLOCK_SHIFT);
-}
-
-void __init calibrate_delay(void)
-{
- loops_per_jiffy = get_clock_rate() / HZ;
- pr_info("Clock rate yields %lu.%02lu BogoMIPS (lpj=%lu)\n",
- loops_per_jiffy / (500000 / HZ),
- (loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
-}
-
-/* Called fairly late in init/main.c, but before we go smp. */
-void __init time_init(void)
-{
- /* Initialize and register the clock source. */
- clocksource_register_hz(&cycle_counter_cs, cycles_per_sec);
-
- /* Start up the tile-timer interrupt source on the boot cpu. */
- setup_tile_timer();
-}
-
-/*
- * Define the tile timer clock event device. The timer is driven by
- * the TILE_TIMER_CONTROL register, which consists of a 31-bit down
- * counter, plus bit 31, which signifies that the counter has wrapped
- * from zero to (2**31) - 1. The INT_TILE_TIMER interrupt will be
- * raised as long as bit 31 is set.
- *
- * The TILE_MINSEC value represents the largest range of real-time
- * we can possibly cover with the timer, based on MAX_TICK combined
- * with the slowest reasonable clock rate we might run at.
- */
-
-#define MAX_TICK 0x7fffffff /* we have 31 bits of countdown timer */
-#define TILE_MINSEC 5 /* timer covers no more than 5 seconds */
-
-static int tile_timer_set_next_event(unsigned long ticks,
- struct clock_event_device *evt)
-{
- BUG_ON(ticks > MAX_TICK);
- __insn_mtspr(SPR_TILE_TIMER_CONTROL, ticks);
- arch_local_irq_unmask_now(INT_TILE_TIMER);
- return 0;
-}
-
-/*
- * Whenever anyone tries to change modes, we just mask interrupts
- * and wait for the next event to get set.
- */
-static int tile_timer_shutdown(struct clock_event_device *evt)
-{
- arch_local_irq_mask_now(INT_TILE_TIMER);
- return 0;
-}
-
-/*
- * Set min_delta_ns to 1 microsecond, since it takes about
- * that long to fire the interrupt.
- */
-static DEFINE_PER_CPU(struct clock_event_device, tile_timer) = {
- .name = "tile timer",
- .features = CLOCK_EVT_FEAT_ONESHOT,
- .min_delta_ns = 1000,
- .min_delta_ticks = 1,
- .max_delta_ticks = MAX_TICK,
- .rating = 100,
- .irq = -1,
- .set_next_event = tile_timer_set_next_event,
- .set_state_shutdown = tile_timer_shutdown,
- .set_state_oneshot = tile_timer_shutdown,
- .set_state_oneshot_stopped = tile_timer_shutdown,
- .tick_resume = tile_timer_shutdown,
-};
-
-void setup_tile_timer(void)
-{
- struct clock_event_device *evt = this_cpu_ptr(&tile_timer);
-
- /* Fill in fields that are speed-specific. */
- clockevents_calc_mult_shift(evt, cycles_per_sec, TILE_MINSEC);
- evt->max_delta_ns = clockevent_delta2ns(MAX_TICK, evt);
-
- /* Mark as being for this cpu only. */
- evt->cpumask = cpumask_of(smp_processor_id());
-
- /* Start out with timer not firing. */
- arch_local_irq_mask_now(INT_TILE_TIMER);
-
- /* Register tile timer. */
- clockevents_register_device(evt);
-}
-
-/* Called from the interrupt vector. */
-void do_timer_interrupt(struct pt_regs *regs, int fault_num)
-{
- struct pt_regs *old_regs = set_irq_regs(regs);
- struct clock_event_device *evt = this_cpu_ptr(&tile_timer);
-
- /*
- * Mask the timer interrupt here, since we are a oneshot timer
- * and there are now by definition no events pending.
- */
- arch_local_irq_mask(INT_TILE_TIMER);
-
- /* Track time spent here in an interrupt context */
- irq_enter();
-
- /* Track interrupt count. */
- __this_cpu_inc(irq_stat.irq_timer_count);
-
- /* Call the generic timer handler */
- evt->event_handler(evt);
-
- /*
- * Track time spent against the current process again and
- * process any softirqs if they are waiting.
- */
- irq_exit();
-
- set_irq_regs(old_regs);
-}
-
-/*
- * Scheduler clock - returns current time in nanosec units.
- * Note that with LOCKDEP, this is called during lockdep_init(), and
- * we will claim that sched_clock() is zero for a little while, until
- * we run setup_clock(), above.
- */
-unsigned long long sched_clock(void)
-{
- return mult_frac(get_cycles(),
- sched_clock_mult, 1ULL << SCHED_CLOCK_SHIFT);
-}
-
-int setup_profiling_timer(unsigned int multiplier)
-{
- return -EINVAL;
-}
-
-/*
- * Use the tile timer to convert nsecs to core clock cycles, relying
- * on it having the same frequency as SPR_CYCLE.
- */
-cycles_t ns2cycles(unsigned long nsecs)
-{
- /*
- * We do not have to disable preemption here as each core has the same
- * clock frequency.
- */
- struct clock_event_device *dev = raw_cpu_ptr(&tile_timer);
-
- /*
- * as in clocksource.h and x86's timer.h, we split the calculation
- * into 2 parts to avoid unecessary overflow of the intermediate
- * value. This will not lead to any loss of precision.
- */
- u64 quot = (u64)nsecs >> dev->shift;
- u64 rem = (u64)nsecs & ((1ULL << dev->shift) - 1);
- return quot * dev->mult + ((rem * dev->mult) >> dev->shift);
-}
-
-void update_vsyscall_tz(void)
-{
- write_seqcount_begin(&vdso_data->tz_seq);
- vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
- vdso_data->tz_dsttime = sys_tz.tz_dsttime;
- write_seqcount_end(&vdso_data->tz_seq);
-}
-
-void update_vsyscall(struct timekeeper *tk)
-{
- if (tk->tkr_mono.clock != &cycle_counter_cs)
- return;
-
- write_seqcount_begin(&vdso_data->tb_seq);
-
- vdso_data->cycle_last = tk->tkr_mono.cycle_last;
- vdso_data->mask = tk->tkr_mono.mask;
- vdso_data->mult = tk->tkr_mono.mult;
- vdso_data->shift = tk->tkr_mono.shift;
-
- vdso_data->wall_time_sec = tk->xtime_sec;
- vdso_data->wall_time_snsec = tk->tkr_mono.xtime_nsec;
-
- vdso_data->monotonic_time_sec = tk->xtime_sec
- + tk->wall_to_monotonic.tv_sec;
- vdso_data->monotonic_time_snsec = tk->tkr_mono.xtime_nsec
- + ((u64)tk->wall_to_monotonic.tv_nsec
- << tk->tkr_mono.shift);
- while (vdso_data->monotonic_time_snsec >=
- (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) {
- vdso_data->monotonic_time_snsec -=
- ((u64)NSEC_PER_SEC) << tk->tkr_mono.shift;
- vdso_data->monotonic_time_sec++;
- }
-
- vdso_data->wall_time_coarse_sec = tk->xtime_sec;
- vdso_data->wall_time_coarse_nsec = (long)(tk->tkr_mono.xtime_nsec >>
- tk->tkr_mono.shift);
-
- vdso_data->monotonic_time_coarse_sec =
- vdso_data->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec;
- vdso_data->monotonic_time_coarse_nsec =
- vdso_data->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec;
-
- while (vdso_data->monotonic_time_coarse_nsec >= NSEC_PER_SEC) {
- vdso_data->monotonic_time_coarse_nsec -= NSEC_PER_SEC;
- vdso_data->monotonic_time_coarse_sec++;
- }
-
- write_seqcount_end(&vdso_data->tb_seq);
-}