···19192020#ifndef __ASSEMBLY__21212222+#include <asm/barrier.h>2223#include <arch/spr_def.h>23242425/* First, the 32-bit atomic ops that are "real" on our 64-bit platform. */
+148
arch/tile/include/asm/barrier.h
···11+/*22+ * Copyright 2010 Tilera Corporation. All Rights Reserved.33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License66+ * as published by the Free Software Foundation, version 2.77+ *88+ * This program is distributed in the hope that it will be useful, but99+ * WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or1111+ * NON INFRINGEMENT. See the GNU General Public License for1212+ * more details.1313+ */1414+1515+#ifndef _ASM_TILE_BARRIER_H1616+#define _ASM_TILE_BARRIER_H1717+1818+#ifndef __ASSEMBLY__1919+2020+#include <linux/types.h>2121+#include <arch/chip.h>2222+#include <arch/spr_def.h>2323+#include <asm/timex.h>2424+2525+/*2626+ * read_barrier_depends - Flush all pending reads that subsequents reads2727+ * depend on.2828+ *2929+ * No data-dependent reads from memory-like regions are ever reordered3030+ * over this barrier. All reads preceding this primitive are guaranteed3131+ * to access memory (but not necessarily other CPUs' caches) before any3232+ * reads following this primitive that depend on the data return by3333+ * any of the preceding reads. This primitive is much lighter weight than3434+ * rmb() on most CPUs, and is never heavier weight than is3535+ * rmb().3636+ *3737+ * These ordering constraints are respected by both the local CPU3838+ * and the compiler.3939+ *4040+ * Ordering is not guaranteed by anything other than these primitives,4141+ * not even by data dependencies. See the documentation for4242+ * memory_barrier() for examples and URLs to more information.4343+ *4444+ * For example, the following code would force ordering (the initial4545+ * value of "a" is zero, "b" is one, and "p" is "&a"):4646+ *4747+ * <programlisting>4848+ * CPU 0 CPU 14949+ *5050+ * b = 2;5151+ * memory_barrier();5252+ * p = &b; q = p;5353+ * read_barrier_depends();5454+ * d = *q;5555+ * </programlisting>5656+ *5757+ * because the read of "*q" depends on the read of "p" and these5858+ * two reads are separated by a read_barrier_depends(). However,5959+ * the following code, with the same initial values for "a" and "b":6060+ *6161+ * <programlisting>6262+ * CPU 0 CPU 16363+ *6464+ * a = 2;6565+ * memory_barrier();6666+ * b = 3; y = b;6767+ * read_barrier_depends();6868+ * x = a;6969+ * </programlisting>7070+ *7171+ * does not enforce ordering, since there is no data dependency between7272+ * the read of "a" and the read of "b". Therefore, on some CPUs, such7373+ * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()7474+ * in cases like this where there are no data dependencies.7575+ */7676+#define read_barrier_depends() do { } while (0)7777+7878+#define __sync() __insn_mf()7979+8080+#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()8181+#include <hv/syscall_public.h>8282+/*8383+ * Issue an uncacheable load to each memory controller, then8484+ * wait until those loads have completed.8585+ */8686+static inline void __mb_incoherent(void)8787+{8888+ long clobber_r10;8989+ asm volatile("swint2"9090+ : "=R10" (clobber_r10)9191+ : "R10" (HV_SYS_fence_incoherent)9292+ : "r0", "r1", "r2", "r3", "r4",9393+ "r5", "r6", "r7", "r8", "r9",9494+ "r11", "r12", "r13", "r14",9595+ "r15", "r16", "r17", "r18", "r19",9696+ "r20", "r21", "r22", "r23", "r24",9797+ "r25", "r26", "r27", "r28", "r29");9898+}9999+#endif100100+101101+/* Fence to guarantee visibility of stores to incoherent memory. */102102+static inline void103103+mb_incoherent(void)104104+{105105+ __insn_mf();106106+107107+#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()108108+ {109109+#if CHIP_HAS_TILE_WRITE_PENDING()110110+ const unsigned long WRITE_TIMEOUT_CYCLES = 400;111111+ unsigned long start = get_cycles_low();112112+ do {113113+ if (__insn_mfspr(SPR_TILE_WRITE_PENDING) == 0)114114+ return;115115+ } while ((get_cycles_low() - start) < WRITE_TIMEOUT_CYCLES);116116+#endif /* CHIP_HAS_TILE_WRITE_PENDING() */117117+ (void) __mb_incoherent();118118+ }119119+#endif /* CHIP_HAS_MF_WAITS_FOR_VICTIMS() */120120+}121121+122122+#define fast_wmb() __sync()123123+#define fast_rmb() __sync()124124+#define fast_mb() __sync()125125+#define fast_iob() mb_incoherent()126126+127127+#define wmb() fast_wmb()128128+#define rmb() fast_rmb()129129+#define mb() fast_mb()130130+#define iob() fast_iob()131131+132132+#ifdef CONFIG_SMP133133+#define smp_mb() mb()134134+#define smp_rmb() rmb()135135+#define smp_wmb() wmb()136136+#define smp_read_barrier_depends() read_barrier_depends()137137+#else138138+#define smp_mb() barrier()139139+#define smp_rmb() barrier()140140+#define smp_wmb() barrier()141141+#define smp_read_barrier_depends() do { } while (0)142142+#endif143143+144144+#define set_mb(var, value) \145145+ do { var = value; mb(); } while (0)146146+147147+#endif /* !__ASSEMBLY__ */148148+#endif /* _ASM_TILE_BARRIER_H */
-1
arch/tile/include/asm/bitops_32.h
···17171818#include <linux/compiler.h>1919#include <linux/atomic.h>2020-#include <asm/system.h>21202221/* Tile-specific routines to support <asm/bitops.h>. */2322unsigned long _atomic_or(volatile unsigned long *p, unsigned long mask);
-1
arch/tile/include/asm/bitops_64.h
···17171818#include <linux/compiler.h>1919#include <linux/atomic.h>2020-#include <asm/system.h>21202221/* See <asm/bitops.h> for API comments. */2322
+10-1
arch/tile/include/asm/cacheflush.h
···2020/* Keep includes the same across arches. */2121#include <linux/mm.h>2222#include <linux/cache.h>2323-#include <asm/system.h>2423#include <arch/icache.h>25242625/* Caches are physically-indexed and so don't need special treatment */···150151 * that is homed with "hash for home".151152 */152153void finv_buffer_remote(void *buffer, size_t size, int hfh);154154+155155+/*156156+ * On SMP systems, when the scheduler does migration-cost autodetection,157157+ * it needs a way to flush as much of the CPU's caches as possible:158158+ *159159+ * TODO: fill this in!160160+ */161161+static inline void sched_cacheflush(void)162162+{163163+}153164154165#endif /* _ASM_TILE_CACHEFLUSH_H */
+20
arch/tile/include/asm/exec.h
···11+/*22+ * Copyright 2010 Tilera Corporation. All Rights Reserved.33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License66+ * as published by the Free Software Foundation, version 2.77+ *88+ * This program is distributed in the hope that it will be useful, but99+ * WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or1111+ * NON INFRINGEMENT. See the GNU General Public License for1212+ * more details.1313+ */1414+1515+#ifndef _ASM_TILE_EXEC_H1616+#define _ASM_TILE_EXEC_H1717+1818+#define arch_align_stack(x) (x)1919+2020+#endif /* _ASM_TILE_EXEC_H */
···11+/*22+ * Copyright 2010 Tilera Corporation. All Rights Reserved.33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License66+ * as published by the Free Software Foundation, version 2.77+ *88+ * This program is distributed in the hope that it will be useful, but99+ * WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or1111+ * NON INFRINGEMENT. See the GNU General Public License for1212+ * more details.1313+ */1414+1515+#ifndef _ASM_TILE_SWITCH_TO_H1616+#define _ASM_TILE_SWITCH_TO_H1717+1818+#include <arch/sim_def.h>1919+2020+/*2121+ * switch_to(n) should switch tasks to task nr n, first2222+ * checking that n isn't the current task, in which case it does nothing.2323+ * The number of callee-saved registers saved on the kernel stack2424+ * is defined here for use in copy_thread() and must agree with __switch_to().2525+ */2626+#define CALLEE_SAVED_FIRST_REG 302727+#define CALLEE_SAVED_REGS_COUNT 24 /* r30 to r52, plus an empty to align */2828+2929+#ifndef __ASSEMBLY__3030+3131+struct task_struct;3232+3333+/*3434+ * Pause the DMA engine and static network before task switching.3535+ */3636+#define prepare_arch_switch(next) _prepare_arch_switch(next)3737+void _prepare_arch_switch(struct task_struct *next);3838+3939+struct task_struct;4040+#define switch_to(prev, next, last) ((last) = _switch_to((prev), (next)))4141+extern struct task_struct *_switch_to(struct task_struct *prev,4242+ struct task_struct *next);4343+4444+/* Helper function for _switch_to(). */4545+extern struct task_struct *__switch_to(struct task_struct *prev,4646+ struct task_struct *next,4747+ unsigned long new_system_save_k_0);4848+4949+/* Address that switched-away from tasks are at. */5050+extern unsigned long get_switch_to_pc(void);5151+5252+/*5353+ * Kernel threads can check to see if they need to migrate their5454+ * stack whenever they return from a context switch; for user5555+ * threads, we defer until they are returning to user-space.5656+ */5757+#define finish_arch_switch(prev) do { \5858+ if (unlikely((prev)->state == TASK_DEAD)) \5959+ __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_EXIT | \6060+ ((prev)->pid << _SIM_CONTROL_OPERATOR_BITS)); \6161+ __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_SWITCH | \6262+ (current->pid << _SIM_CONTROL_OPERATOR_BITS)); \6363+ if (current->mm == NULL && !kstack_hash && \6464+ current_thread_info()->homecache_cpu != smp_processor_id()) \6565+ homecache_migrate_kthread(); \6666+} while (0)6767+6868+/* Support function for forking a new task. */6969+void ret_from_fork(void);7070+7171+/* Called from ret_from_fork() when a new process starts up. */7272+struct task_struct *sim_notify_fork(struct task_struct *prev);7373+7474+#endif /* !__ASSEMBLY__ */7575+7676+#endif /* _ASM_TILE_SWITCH_TO_H */
+4-261
arch/tile/include/asm/system.h
···11-/*22- * Copyright 2010 Tilera Corporation. All Rights Reserved.33- *44- * This program is free software; you can redistribute it and/or55- * modify it under the terms of the GNU General Public License66- * as published by the Free Software Foundation, version 2.77- *88- * This program is distributed in the hope that it will be useful, but99- * WITHOUT ANY WARRANTY; without even the implied warranty of1010- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or1111- * NON INFRINGEMENT. See the GNU General Public License for1212- * more details.1313- */1414-1515-#ifndef _ASM_TILE_SYSTEM_H1616-#define _ASM_TILE_SYSTEM_H1717-1818-#ifndef __ASSEMBLY__1919-2020-#include <linux/types.h>2121-#include <linux/irqflags.h>2222-2323-/* NOTE: we can't include <linux/ptrace.h> due to #include dependencies. */2424-#include <asm/ptrace.h>2525-2626-#include <arch/chip.h>2727-#include <arch/sim_def.h>2828-#include <arch/spr_def.h>2929-3030-/*3131- * read_barrier_depends - Flush all pending reads that subsequents reads3232- * depend on.3333- *3434- * No data-dependent reads from memory-like regions are ever reordered3535- * over this barrier. All reads preceding this primitive are guaranteed3636- * to access memory (but not necessarily other CPUs' caches) before any3737- * reads following this primitive that depend on the data return by3838- * any of the preceding reads. This primitive is much lighter weight than3939- * rmb() on most CPUs, and is never heavier weight than is4040- * rmb().4141- *4242- * These ordering constraints are respected by both the local CPU4343- * and the compiler.4444- *4545- * Ordering is not guaranteed by anything other than these primitives,4646- * not even by data dependencies. See the documentation for4747- * memory_barrier() for examples and URLs to more information.4848- *4949- * For example, the following code would force ordering (the initial5050- * value of "a" is zero, "b" is one, and "p" is "&a"):5151- *5252- * <programlisting>5353- * CPU 0 CPU 15454- *5555- * b = 2;5656- * memory_barrier();5757- * p = &b; q = p;5858- * read_barrier_depends();5959- * d = *q;6060- * </programlisting>6161- *6262- * because the read of "*q" depends on the read of "p" and these6363- * two reads are separated by a read_barrier_depends(). However,6464- * the following code, with the same initial values for "a" and "b":6565- *6666- * <programlisting>6767- * CPU 0 CPU 16868- *6969- * a = 2;7070- * memory_barrier();7171- * b = 3; y = b;7272- * read_barrier_depends();7373- * x = a;7474- * </programlisting>7575- *7676- * does not enforce ordering, since there is no data dependency between7777- * the read of "a" and the read of "b". Therefore, on some CPUs, such7878- * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()7979- * in cases like this where there are no data dependencies.8080- */8181-8282-#define read_barrier_depends() do { } while (0)8383-8484-#define __sync() __insn_mf()8585-8686-#if CHIP_HAS_SPLIT_CYCLE()8787-#define get_cycles_low() __insn_mfspr(SPR_CYCLE_LOW)8888-#else8989-#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */9090-#endif9191-9292-#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()9393-#include <hv/syscall_public.h>9494-/*9595- * Issue an uncacheable load to each memory controller, then9696- * wait until those loads have completed.9797- */9898-static inline void __mb_incoherent(void)9999-{100100- long clobber_r10;101101- asm volatile("swint2"102102- : "=R10" (clobber_r10)103103- : "R10" (HV_SYS_fence_incoherent)104104- : "r0", "r1", "r2", "r3", "r4",105105- "r5", "r6", "r7", "r8", "r9",106106- "r11", "r12", "r13", "r14",107107- "r15", "r16", "r17", "r18", "r19",108108- "r20", "r21", "r22", "r23", "r24",109109- "r25", "r26", "r27", "r28", "r29");110110-}111111-#endif112112-113113-/* Fence to guarantee visibility of stores to incoherent memory. */114114-static inline void115115-mb_incoherent(void)116116-{117117- __insn_mf();118118-119119-#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()120120- {121121-#if CHIP_HAS_TILE_WRITE_PENDING()122122- const unsigned long WRITE_TIMEOUT_CYCLES = 400;123123- unsigned long start = get_cycles_low();124124- do {125125- if (__insn_mfspr(SPR_TILE_WRITE_PENDING) == 0)126126- return;127127- } while ((get_cycles_low() - start) < WRITE_TIMEOUT_CYCLES);128128-#endif /* CHIP_HAS_TILE_WRITE_PENDING() */129129- (void) __mb_incoherent();130130- }131131-#endif /* CHIP_HAS_MF_WAITS_FOR_VICTIMS() */132132-}133133-134134-#define fast_wmb() __sync()135135-#define fast_rmb() __sync()136136-#define fast_mb() __sync()137137-#define fast_iob() mb_incoherent()138138-139139-#define wmb() fast_wmb()140140-#define rmb() fast_rmb()141141-#define mb() fast_mb()142142-#define iob() fast_iob()143143-144144-#ifdef CONFIG_SMP145145-#define smp_mb() mb()146146-#define smp_rmb() rmb()147147-#define smp_wmb() wmb()148148-#define smp_read_barrier_depends() read_barrier_depends()149149-#else150150-#define smp_mb() barrier()151151-#define smp_rmb() barrier()152152-#define smp_wmb() barrier()153153-#define smp_read_barrier_depends() do { } while (0)154154-#endif155155-156156-#define set_mb(var, value) \157157- do { var = value; mb(); } while (0)158158-159159-/*160160- * Pause the DMA engine and static network before task switching.161161- */162162-#define prepare_arch_switch(next) _prepare_arch_switch(next)163163-void _prepare_arch_switch(struct task_struct *next);164164-165165-166166-/*167167- * switch_to(n) should switch tasks to task nr n, first168168- * checking that n isn't the current task, in which case it does nothing.169169- * The number of callee-saved registers saved on the kernel stack170170- * is defined here for use in copy_thread() and must agree with __switch_to().171171- */172172-#endif /* !__ASSEMBLY__ */173173-#define CALLEE_SAVED_FIRST_REG 30174174-#define CALLEE_SAVED_REGS_COUNT 24 /* r30 to r52, plus an empty to align */175175-#ifndef __ASSEMBLY__176176-struct task_struct;177177-#define switch_to(prev, next, last) ((last) = _switch_to((prev), (next)))178178-extern struct task_struct *_switch_to(struct task_struct *prev,179179- struct task_struct *next);180180-181181-/* Helper function for _switch_to(). */182182-extern struct task_struct *__switch_to(struct task_struct *prev,183183- struct task_struct *next,184184- unsigned long new_system_save_k_0);185185-186186-/* Address that switched-away from tasks are at. */187187-extern unsigned long get_switch_to_pc(void);188188-189189-/*190190- * On SMP systems, when the scheduler does migration-cost autodetection,191191- * it needs a way to flush as much of the CPU's caches as possible:192192- *193193- * TODO: fill this in!194194- */195195-static inline void sched_cacheflush(void)196196-{197197-}198198-199199-#define arch_align_stack(x) (x)200200-201201-/*202202- * Is the kernel doing fixups of unaligned accesses? If <0, no kernel203203- * intervention occurs and SIGBUS is delivered with no data address204204- * info. If 0, the kernel single-steps the instruction to discover205205- * the data address to provide with the SIGBUS. If 1, the kernel does206206- * a fixup.207207- */208208-extern int unaligned_fixup;209209-210210-/* Is the kernel printing on each unaligned fixup? */211211-extern int unaligned_printk;212212-213213-/* Number of unaligned fixups performed */214214-extern unsigned int unaligned_fixup_count;215215-216216-/* Init-time routine to do tile-specific per-cpu setup. */217217-void setup_cpu(int boot);218218-219219-/* User-level DMA management functions */220220-void grant_dma_mpls(void);221221-void restrict_dma_mpls(void);222222-223223-#ifdef CONFIG_HARDWALL224224-/* User-level network management functions */225225-void reset_network_state(void);226226-void grant_network_mpls(void);227227-void restrict_network_mpls(void);228228-int hardwall_deactivate(struct task_struct *task);229229-230230-/* Hook hardwall code into changes in affinity. */231231-#define arch_set_cpus_allowed(p, new_mask) do { \232232- if (p->thread.hardwall && !cpumask_equal(&p->cpus_allowed, new_mask)) \233233- hardwall_deactivate(p); \234234-} while (0)235235-#endif236236-237237-/*238238- * Kernel threads can check to see if they need to migrate their239239- * stack whenever they return from a context switch; for user240240- * threads, we defer until they are returning to user-space.241241- */242242-#define finish_arch_switch(prev) do { \243243- if (unlikely((prev)->state == TASK_DEAD)) \244244- __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_EXIT | \245245- ((prev)->pid << _SIM_CONTROL_OPERATOR_BITS)); \246246- __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_SWITCH | \247247- (current->pid << _SIM_CONTROL_OPERATOR_BITS)); \248248- if (current->mm == NULL && !kstack_hash && \249249- current_thread_info()->homecache_cpu != smp_processor_id()) \250250- homecache_migrate_kthread(); \251251-} while (0)252252-253253-/* Support function for forking a new task. */254254-void ret_from_fork(void);255255-256256-/* Called from ret_from_fork() when a new process starts up. */257257-struct task_struct *sim_notify_fork(struct task_struct *prev);258258-259259-#endif /* !__ASSEMBLY__ */260260-261261-#endif /* _ASM_TILE_SYSTEM_H */11+/* FILE TO BE DELETED. DO NOT ADD STUFF HERE! */22+#include <asm/barrier.h>33+#include <asm/exec.h>44+#include <asm/switch_to.h>
+2
arch/tile/include/asm/timex.h
···29293030#if CHIP_HAS_SPLIT_CYCLE()3131cycles_t get_cycles(void);3232+#define get_cycles_low() __insn_mfspr(SPR_CYCLE_LOW)3233#else3334static inline cycles_t get_cycles(void)3435{3536 return __insn_mfspr(SPR_CYCLE);3637}3838+#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */3739#endif38403941cycles_t get_clock_rate(void);
+15
arch/tile/include/asm/unaligned.h
···2121#define get_unaligned __get_unaligned_le2222#define put_unaligned __put_unaligned_le23232424+/*2525+ * Is the kernel doing fixups of unaligned accesses? If <0, no kernel2626+ * intervention occurs and SIGBUS is delivered with no data address2727+ * info. If 0, the kernel single-steps the instruction to discover2828+ * the data address to provide with the SIGBUS. If 1, the kernel does2929+ * a fixup.3030+ */3131+extern int unaligned_fixup;3232+3333+/* Is the kernel printing on each unaligned fixup? */3434+extern int unaligned_printk;3535+3636+/* Number of unaligned fixups performed */3737+extern unsigned int unaligned_fixup_count;3838+2439#endif /* _ASM_TILE_UNALIGNED_H */
···1313 */14141515#include <linux/linkage.h>1616-#include <asm/system.h>1716#include <asm/ptrace.h>1817#include <asm/asm-offsets.h>1918#include <arch/spr_def.h>2019#include <asm/processor.h>2020+#include <asm/switch_to.h>21212222/*2323 * See <asm/system.h>; called with prev and next task_struct pointers.
+1-1
arch/tile/kernel/regs_64.S
···1313 */14141515#include <linux/linkage.h>1616-#include <asm/system.h>1716#include <asm/ptrace.h>1817#include <asm/asm-offsets.h>1918#include <arch/spr_def.h>2019#include <asm/processor.h>2020+#include <asm/switch_to.h>21212222/*2323 * See <asm/system.h>; called with prev and next task_struct pointers.
···2121#include <asm/pgtable.h>2222#include <asm/pgalloc.h>2323#include <asm/sections.h>2424+#include <arch/sim_def.h>24252526/* Notify a running simulator, if any, that an exec just occurred. */2627static void sim_notify_exec(const char *binary_name)