Module: xenomai-3
Branch: stable-3.0.x
Commit: be6f3c41769cacbcfa9efc9add46543be0d09bde
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be6f3c41769cacbcfa9efc9add46543be0d09bde

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Sep  9 19:00:22 2016 +0200

cobalt/x86: upgrade I-pipe support

---

 ...-x86-6.patch => ipipe-core-3.18.20-x86-8.patch} |   79 +++--
 ...8-x86-3.patch => ipipe-core-4.1.18-x86-7.patch} |  313 +++++++++++++++-----
 2 files changed, 302 insertions(+), 90 deletions(-)

diff --git a/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch 
b/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
similarity index 99%
rename from kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch
rename to kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
index 128c382..51ebf67 100644
--- a/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-6.patch
+++ b/kernel/cobalt/arch/x86/patches/ipipe-core-3.18.20-x86-8.patch
@@ -449,7 +449,7 @@ index 615fa90..e0a62ab 100644
  extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
 diff --git a/arch/x86/include/asm/ipipe.h b/arch/x86/include/asm/ipipe.h
 new file mode 100644
-index 0000000..ccc8945
+index 0000000..12305ff
 --- /dev/null
 +++ b/arch/x86/include/asm/ipipe.h
 @@ -0,0 +1,118 @@
@@ -479,7 +479,7 @@ index 0000000..ccc8945
 +
 +#ifdef CONFIG_IPIPE
 +
-+#define IPIPE_CORE_RELEASE    6
++#define IPIPE_CORE_RELEASE    8
 +
 +struct ipipe_domain;
 +struct pt_regs;
@@ -3426,10 +3426,10 @@ index e7cc537..bc5e8f8 100644
  handle_real_irq:
 diff --git a/arch/x86/kernel/ipipe.c b/arch/x86/kernel/ipipe.c
 new file mode 100644
-index 0000000..a06e6bb
+index 0000000..d756d17
 --- /dev/null
 +++ b/arch/x86/kernel/ipipe.c
-@@ -0,0 +1,499 @@
+@@ -0,0 +1,504 @@
 +/*   -*- linux-c -*-
 + *   linux/arch/x86/kernel/ipipe.c
 + *
@@ -3465,6 +3465,7 @@ index 0000000..a06e6bb
 +#include <linux/mm.h>
 +#include <linux/kgdb.h>
 +#include <linux/ipipe_tickdev.h>
++#include <trace/events/tlb.h>
 +#include <asm/asm-offsets.h>
 +#include <asm/unistd.h>
 +#include <asm/processor.h>
@@ -3929,6 +3930,10 @@ index 0000000..a06e6bb
 +#if defined(CONFIG_CC_STACKPROTECTOR) && defined(CONFIG_X86_64)
 +EXPORT_PER_CPU_SYMBOL_GPL(irq_stack_union);
 +#endif
++
++#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_IPIPE_LEGACY)
++EXPORT_TRACEPOINT_SYMBOL_GPL(tlb_flush);
++#endif
 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
 index 3790775..218eb83 100644
 --- a/arch/x86/kernel/irq.c
@@ -5831,6 +5836,18 @@ index abcafaa..a8440e4 100644
  } ____cacheline_aligned;
  
  /*
+diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
+index 662697b..6a9b6ad 100644
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -108,6 +108,7 @@ enum {
+       FTRACE_OPS_FL_ADDING                    = 1 << 9,
+       FTRACE_OPS_FL_REMOVING                  = 1 << 10,
+       FTRACE_OPS_FL_MODIFYING                 = 1 << 11,
++      FTRACE_OPS_FL_IPIPE_EXCLUSIVE           = 1 << 12,
+ };
+ 
+ #ifdef CONFIG_DYNAMIC_FTRACE
 diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
 index cba442e..b513a46 100644
 --- a/include/linux/hardirq.h
@@ -11776,7 +11793,7 @@ index 0000000..143f9e6
 +#endif /* CONFIG_IPIPE_HAVE_HOSTRT */
 diff --git a/kernel/ipipe/tracer.c b/kernel/ipipe/tracer.c
 new file mode 100644
-index 0000000..da272c50
+index 0000000..8388671
 --- /dev/null
 +++ b/kernel/ipipe/tracer.c
 @@ -0,0 +1,1468 @@
@@ -13114,7 +13131,7 @@ index 0000000..da272c50
 +
 +static struct ftrace_ops ipipe_trace_ops = {
 +      .func = ipipe_trace_function,
-+      .flags = FTRACE_OPS_FL_RECURSION_SAFE,
++      .flags = FTRACE_OPS_FL_IPIPE_EXCLUSIVE,
 +};
 +
 +static ssize_t __ipipe_wr_enable(struct file *file, const char __user *buffer,
@@ -14675,7 +14692,7 @@ index a5da09c..6650799 100644
        help
          This option will modify all the calls to function tracing
 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
-index d1eff3d..2a324bc 100644
+index d1eff3d..f8b9472 100644
 --- a/kernel/trace/ftrace.c
 +++ b/kernel/trace/ftrace.c
 @@ -32,6 +32,7 @@
@@ -14686,7 +14703,33 @@ index d1eff3d..2a324bc 100644
  
  #include <trace/events/sched.h>
  
-@@ -2298,6 +2299,9 @@ void __weak arch_ftrace_update_code(int command)
+@@ -251,8 +252,17 @@ static inline void update_function_graph_func(void) { }
+ 
+ static void update_ftrace_function(void)
+ {
++      struct ftrace_ops *ops;
+       ftrace_func_t func;
+ 
++      for (ops = ftrace_ops_list;
++           ops != &ftrace_list_end; ops = ops->next)
++              if (ops->flags & FTRACE_OPS_FL_IPIPE_EXCLUSIVE) {
++                      set_function_trace_op = ops;
++                      func = ops->func;
++                      goto set_pointers;
++              }
++
+       /*
+        * Prepare the ftrace_ops that the arch callback will use.
+        * If there's only one ftrace_ops registered, the ftrace_ops_list
+@@ -280,6 +290,7 @@ static void update_ftrace_function(void)
+ 
+       update_function_graph_func();
+ 
++  set_pointers:
+       /* If there's no change, then do nothing more here */
+       if (ftrace_trace_function == func)
+               return;
+@@ -2298,6 +2309,9 @@ void __weak arch_ftrace_update_code(int command)
  
  static void ftrace_run_update_code(int command)
  {
@@ -14696,7 +14739,7 @@ index d1eff3d..2a324bc 100644
        int ret;
  
        ret = ftrace_arch_code_modify_prepare();
-@@ -2311,7 +2315,13 @@ static void ftrace_run_update_code(int command)
+@@ -2311,7 +2325,13 @@ static void ftrace_run_update_code(int command)
         * is safe. The stop_machine() is the safest, but also
         * produces the most overhead.
         */
@@ -14710,7 +14753,7 @@ index d1eff3d..2a324bc 100644
  
        ret = ftrace_arch_code_modify_post_process();
        FTRACE_WARN_ON(ret);
-@@ -4621,10 +4631,10 @@ static int ftrace_process_locs(struct module *mod,
+@@ -4621,10 +4641,10 @@ static int ftrace_process_locs(struct module *mod,
         * reason to cause large interrupt latencies while we do it.
         */
        if (!mod)
@@ -14723,7 +14766,7 @@ index d1eff3d..2a324bc 100644
        ret = 0;
   out:
        mutex_unlock(&ftrace_lock);
-@@ -4723,9 +4733,11 @@ void __init ftrace_init(void)
+@@ -4723,9 +4743,11 @@ void __init ftrace_init(void)
        unsigned long count, flags;
        int ret;
  
@@ -14737,7 +14780,7 @@ index d1eff3d..2a324bc 100644
        if (ret)
                goto failed;
  
-@@ -4891,7 +4903,16 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long 
parent_ip,
+@@ -4891,7 +4913,16 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long 
parent_ip,
                }
        } while_for_each_ftrace_op(op);
  out:
@@ -15103,24 +15146,22 @@ index 0c9216c..00a9a30 100644
        return err;
  }
 diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
-index 1afec32..5803111 100644
+index 1afec32..f7c1a2a 100644
 --- a/lib/smp_processor_id.c
 +++ b/lib/smp_processor_id.c
-@@ -12,10 +12,13 @@ notrace static unsigned int 
check_preemption_disabled(const char *what1,
+@@ -12,6 +12,12 @@ notrace static unsigned int check_preemption_disabled(const 
char *what1,
  {
        int this_cpu = raw_smp_processor_id();
  
++      if (hard_irqs_disabled())
++              goto out;
++
 +      if (!ipipe_root_p)
 +              goto out;
 +
        if (likely(preempt_count()))
                goto out;
  
--      if (irqs_disabled())
-+      if (irqs_disabled() || hard_irqs_disabled())
-               goto out;
- 
-       /*
 diff --git a/mm/memory.c b/mm/memory.c
 index 90fb265..8a1fd79 100644
 --- a/mm/memory.c
diff --git a/kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-3.patch 
b/kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-7.patch
similarity index 98%
rename from kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-3.patch
rename to kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-7.patch
index 5a8cf1e..48a87d8 100644
--- a/kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-3.patch
+++ b/kernel/cobalt/arch/x86/patches/ipipe-core-4.1.18-x86-7.patch
@@ -434,7 +434,7 @@ index 615fa90..e0a62ab 100644
  extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
 diff --git a/arch/x86/include/asm/ipipe.h b/arch/x86/include/asm/ipipe.h
 new file mode 100644
-index 0000000..b5966a6
+index 0000000..ed68a7e
 --- /dev/null
 +++ b/arch/x86/include/asm/ipipe.h
 @@ -0,0 +1,112 @@
@@ -464,7 +464,7 @@ index 0000000..b5966a6
 +
 +#ifdef CONFIG_IPIPE
 +
-+#define IPIPE_CORE_RELEASE    3
++#define IPIPE_CORE_RELEASE    7
 +
 +struct ipipe_domain;
 +struct pt_regs;
@@ -3423,10 +3423,10 @@ index e7cc537..bc5e8f8 100644
  handle_real_irq:
 diff --git a/arch/x86/kernel/ipipe.c b/arch/x86/kernel/ipipe.c
 new file mode 100644
-index 0000000..d63126c
+index 0000000..fb9d80f
 --- /dev/null
 +++ b/arch/x86/kernel/ipipe.c
-@@ -0,0 +1,499 @@
+@@ -0,0 +1,510 @@
 +/*   -*- linux-c -*-
 + *   linux/arch/x86/kernel/ipipe.c
 + *
@@ -3485,6 +3485,7 @@ index 0000000..d63126c
 +#include <asm/i387.h>
 +#include <asm/fpu-internal.h>
 +#include <asm/mce.h>
++#include <asm/mmu_context.h>
 +
 +DEFINE_PER_CPU(unsigned long, __ipipe_cr2);
 +EXPORT_PER_CPU_SYMBOL_GPL(__ipipe_cr2);
@@ -3926,6 +3927,16 @@ index 0000000..d63126c
 +#if defined(CONFIG_CC_STACKPROTECTOR) && defined(CONFIG_X86_64)
 +EXPORT_PER_CPU_SYMBOL_GPL(irq_stack_union);
 +#endif
++
++#ifdef CONFIG_IPIPE_LEGACY
++#ifdef CONFIG_TRACEPOINTS
++EXPORT_TRACEPOINT_SYMBOL_GPL(tlb_flush);
++#endif
++#ifdef CONFIG_PERF_EVENTS
++EXPORT_SYMBOL_GPL(rdpmc_always_available);
++#endif
++#endif
++
 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
 index e5952c2..9376ee0 100644
 --- a/arch/x86/kernel/irq.c
@@ -5746,6 +5757,19 @@ index 0000000..1f6e9c3
 +static inline void __ipipe_init_threadinfo(struct ipipe_threadinfo *p) { }
 +
 +#endif /* !_IPIPE_THREAD_INFO_H */
+diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h
+index 0e97856..b5d7e60 100644
+--- a/include/linux/basic_mmio_gpio.h
++++ b/include/linux/basic_mmio_gpio.h
+@@ -50,7 +50,7 @@ struct bgpio_chip {
+        * Used to lock bgpio_chip->data. Also, this is needed to keep
+        * shadowed and real data registers writes together.
+        */
+-      spinlock_t lock;
++      ipipe_spinlock_t lock;
+ 
+       /* Shadowed data register to clear/set bits safely. */
+       unsigned long data;
 diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
 index 96c280b..0baa8f1 100644
 --- a/include/linux/clockchips.h
@@ -5798,6 +5822,18 @@ index 901555a..1ba117c 100644
        int     (*read)(struct console *, char *, unsigned);
        struct tty_driver *(*device)(struct console *, int *);
        void    (*unblank)(void);
+diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
+index 6cd8c0e..0951ab4 100644
+--- a/include/linux/ftrace.h
++++ b/include/linux/ftrace.h
+@@ -134,6 +134,7 @@ enum {
+       FTRACE_OPS_FL_ALLOC_TRAMP               = 1 << 12,
+       FTRACE_OPS_FL_IPMODIFY                  = 1 << 13,
+       FTRACE_OPS_FL_PID                       = 1 << 14,
++      FTRACE_OPS_FL_IPIPE_EXCLUSIVE           = 1 << 15,
+ };
+ 
+ #ifdef CONFIG_DYNAMIC_FTRACE
 diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
 index f4af034..fa16b8c 100644
 --- a/include/linux/hardirq.h
@@ -6308,10 +6344,10 @@ index 0000000..0a9b5b6
 +#endif        /* !__LINUX_IPIPE_H */
 diff --git a/include/linux/ipipe_base.h b/include/linux/ipipe_base.h
 new file mode 100644
-index 0000000..8c06eed
+index 0000000..42b368a
 --- /dev/null
 +++ b/include/linux/ipipe_base.h
-@@ -0,0 +1,360 @@
+@@ -0,0 +1,365 @@
 +/* -*- linux-c -*-
 + * include/linux/ipipe_base.h
 + *
@@ -6422,6 +6458,7 @@ index 0000000..8c06eed
 +#define IPIPE_KEVT_EXIT               4
 +#define IPIPE_KEVT_CLEANUP    5
 +#define IPIPE_KEVT_HOSTRT     6
++#define IPIPE_KEVT_CLOCKFREQ  7
 +
 +struct ipipe_vm_notifier {
 +      void (*handler)(struct ipipe_vm_notifier *nfy);
@@ -6550,6 +6587,9 @@ index 0000000..8c06eed
 +#define __ipipe_report_cleanup(mm)                                    \
 +      __ipipe_notify_kevent(IPIPE_KEVT_CLEANUP, mm)
 +
++#define __ipipe_report_clockfreq_update(freq)                         \
++      __ipipe_notify_kevent(IPIPE_KEVT_CLOCKFREQ, &(freq))
++
 +void __ipipe_notify_vm_preemption(void);
 +
 +void __ipipe_call_mayday(struct pt_regs *regs);
@@ -6569,7 +6609,8 @@ index 0000000..8c06eed
 +#define IPIPE_EVENT_EXIT      (IPIPE_FIRST_EVENT + 4)
 +#define IPIPE_EVENT_CLEANUP   (IPIPE_FIRST_EVENT + 5)
 +#define IPIPE_EVENT_HOSTRT    (IPIPE_FIRST_EVENT + 6)
-+#define IPIPE_EVENT_SYSCALL   (IPIPE_FIRST_EVENT + 7)
++#define IPIPE_EVENT_CLOCKFREQ (IPIPE_FIRST_EVENT + 7)
++#define IPIPE_EVENT_SYSCALL   (IPIPE_FIRST_EVENT + 8)
 +#define IPIPE_LAST_EVENT      IPIPE_EVENT_SYSCALL
 +#define IPIPE_NR_EVENTS               (IPIPE_LAST_EVENT + 1)
 +
@@ -7420,10 +7461,10 @@ index 0000000..d00c56b
 +#endif        /* !__LINUX_IPIPE_DOMAIN_H */
 diff --git a/include/linux/ipipe_lock.h b/include/linux/ipipe_lock.h
 new file mode 100644
-index 0000000..f71d2f1
+index 0000000..a108278
 --- /dev/null
 +++ b/include/linux/ipipe_lock.h
-@@ -0,0 +1,260 @@
+@@ -0,0 +1,327 @@
 +/*   -*- linux-c -*-
 + *   include/linux/ipipe_lock.h
 + *
@@ -7452,22 +7493,87 @@ index 0000000..f71d2f1
 +      arch_spinlock_t arch_lock;
 +} __ipipe_spinlock_t;
 +
++#define ipipe_spinlock(lock)  ((__ipipe_spinlock_t *)(lock))
 +#define ipipe_spinlock_p(lock)                                                
        \
 +      __builtin_types_compatible_p(typeof(lock), __ipipe_spinlock_t *) ||     
\
 +      __builtin_types_compatible_p(typeof(lock), __ipipe_spinlock_t [])
 +
++#define std_spinlock_raw(lock)        ((raw_spinlock_t *)(lock))
 +#define std_spinlock_raw_p(lock)                                      \
 +      __builtin_types_compatible_p(typeof(lock), raw_spinlock_t *) || \
 +      __builtin_types_compatible_p(typeof(lock), raw_spinlock_t [])
 +
++#ifdef CONFIG_PREEMPT_RT_FULL
++
++#define PICK_SPINLOCK_IRQSAVE(lock, flags)                            \
++      do {                                                            \
++              if (ipipe_spinlock_p(lock))                             \
++                      (flags) = 
__ipipe_spin_lock_irqsave(ipipe_spinlock(lock)); \
++              else if (std_spinlock_raw_p(lock))                              
\
++                      __real_raw_spin_lock_irqsave(std_spinlock_raw(lock), 
flags); \
++              else __bad_lock_type();                                 \
++      } while (0)
++
++#define PICK_SPINTRYLOCK_IRQSAVE(lock, flags)                         \
++      ({                                                              \
++              int __ret__;                                            \
++              if (ipipe_spinlock_p(lock))                             \
++                      __ret__ = 
__ipipe_spin_trylock_irqsave(ipipe_spinlock(lock), &(flags)); \
++              else if (std_spinlock_raw_p(lock))                              
\
++                      __ret__ = 
__real_raw_spin_trylock_irqsave(std_spinlock_raw(lock), flags); \
++              else __bad_lock_type();                                 \
++              __ret__;                                                \
++       })
++
++#define PICK_SPINTRYLOCK_IRQ(lock)                                    \
++      ({                                                              \
++              int __ret__;                                            \
++              if (ipipe_spinlock_p(lock))                             \
++                      __ret__ = 
__ipipe_spin_trylock_irq(ipipe_spinlock(lock)); \
++              else if (std_spinlock_raw_p(lock))                              
\
++                      __ret__ = 
__real_raw_spin_trylock_irq(std_spinlock_raw(lock)); \
++              else __bad_lock_type();                                 \
++              __ret__;                                                \
++       })
++
++#define PICK_SPINUNLOCK_IRQRESTORE(lock, flags)                               
\
++      do {                                                            \
++              if (ipipe_spinlock_p(lock))                             \
++                      __ipipe_spin_unlock_irqrestore(ipipe_spinlock(lock), 
flags); \
++              else if (std_spinlock_raw_p(lock)) {                    \
++                      __ipipe_spin_unlock_debug(flags);               \
++                      
__real_raw_spin_unlock_irqrestore(std_spinlock_raw(lock), flags); \
++              } else __bad_lock_type();                               \
++      } while (0)
++
++#define PICK_SPINOP(op, lock)                                         \
++      ({                                                              \
++              if (ipipe_spinlock_p(lock))                             \
++                      arch_spin##op(&ipipe_spinlock(lock)->arch_lock); \
++              else if (std_spinlock_raw_p(lock))                      \
++                      __real_raw_spin##op(std_spinlock_raw(lock));    \
++              else __bad_lock_type();                                 \
++              (void)0;                                                \
++      })
++
++#define PICK_SPINOP_RET(op, lock, type)                                       
\
++      ({                                                              \
++              type __ret__;                                           \
++              if (ipipe_spinlock_p(lock))                             \
++                      __ret__ = 
arch_spin##op(&ipipe_spinlock(lock)->arch_lock); \
++              else if (std_spinlock_raw_p(lock))                      \
++                      __ret__ = __real_raw_spin##op(std_spinlock_raw(lock)); \
++              else { __ret__ = -1; __bad_lock_type(); }               \
++              __ret__;                                                \
++      })
++
++#else /* !CONFIG_PREEMPT_RT_FULL */
++
++#define std_spinlock(lock)    ((spinlock_t *)(lock))
 +#define std_spinlock_p(lock)                                          \
 +      __builtin_types_compatible_p(typeof(lock), spinlock_t *) ||     \
 +      __builtin_types_compatible_p(typeof(lock), spinlock_t [])
 +
-+#define ipipe_spinlock(lock)  ((__ipipe_spinlock_t *)(lock))
-+#define std_spinlock_raw(lock)        ((raw_spinlock_t *)(lock))
-+#define std_spinlock(lock)    ((spinlock_t *)(lock))
-+
 +#define PICK_SPINLOCK_IRQSAVE(lock, flags)                            \
 +      do {                                                            \
 +              if (ipipe_spinlock_p(lock))                             \
@@ -7543,6 +7649,8 @@ index 0000000..f71d2f1
 +              __ret__;                                                \
 +      })
 +
++#endif /* !CONFIG_PREEMPT_RT_FULL */
++
 +#define arch_spin_lock_init(lock)                                     \
 +      do {                                                            \
 +              IPIPE_DEFINE_SPINLOCK(__lock__);                        \
@@ -7672,7 +7780,7 @@ index 0000000..f71d2f1
 +#define __ipipe_spin_trylock_irq(lock)                1
 +#define __ipipe_spin_trylock_irqsave(lock, x) ({ (void)(x); 1; })
 +#define __ipipe_spin_unlock_irqrestore(lock, x)       do { (void)(x); } while 
(0)
-+#define __ipipe_spin_unlock_irqbegin(lock)    do { } while (0)
++#define __ipipe_spin_unlock_irqbegin(lock)    spin_unlock(lock)
 +#define __ipipe_spin_unlock_irqcomplete(x)    do { (void)(x); } while (0)
 +#define __ipipe_spin_unlock_debug(flags)      do { } while (0)
 +
@@ -7686,10 +7794,10 @@ index 0000000..f71d2f1
 +#endif /* !__LINUX_IPIPE_LOCK_H */
 diff --git a/include/linux/ipipe_tickdev.h b/include/linux/ipipe_tickdev.h
 new file mode 100644
-index 0000000..58a4142
+index 0000000..2f065ad
 --- /dev/null
 +++ b/include/linux/ipipe_tickdev.h
-@@ -0,0 +1,145 @@
+@@ -0,0 +1,148 @@
 +/* -*- linux-c -*-
 + * include/linux/ipipe_tickdev.h
 + *
@@ -7769,6 +7877,7 @@ index 0000000..58a4142
 +                            struct clock_event_device *cdev);
 +      int (*real_set_next_event)(unsigned long evt,
 +                                 struct clock_event_device *cdev);
++      unsigned int (*refresh_freq)(void);
 +};
 +
 +#define __ipipe_hrtimer_irq __ipipe_raw_cpu_read(ipipe_percpu.hrtimer_irq)
@@ -7821,6 +7930,8 @@ index 0000000..58a4142
 +
 +unsigned ipipe_timer_ns2ticks(struct ipipe_timer *timer, unsigned ns);
 +
++void __ipipe_timer_refresh_freq(unsigned int hrclock_freq);
++
 +#else /* !CONFIG_IPIPE */
 +
 +#define ipipe_host_timer_register(clkevt) do { } while (0)
@@ -9375,7 +9486,7 @@ index 0000000..797a849
 +}
 diff --git a/kernel/ipipe/core.c b/kernel/ipipe/core.c
 new file mode 100644
-index 0000000..3b07d65
+index 0000000..339fb95
 --- /dev/null
 +++ b/kernel/ipipe/core.c
 @@ -0,0 +1,1916 @@
@@ -10203,7 +10314,7 @@ index 0000000..3b07d65
 +      unsigned long flags, irq = 0;
 +      int ipos;
 +
-+      spin_lock_irqsave(&__ipipe_lock, flags);
++      raw_spin_lock_irqsave(&__ipipe_lock, flags);
 +
 +      if (__ipipe_virtual_irq_map != ~0) {
 +              ipos = ffz(__ipipe_virtual_irq_map);
@@ -10211,7 +10322,7 @@ index 0000000..3b07d65
 +              irq = ipos + IPIPE_VIRQ_BASE;
 +      }
 +
-+      spin_unlock_irqrestore(&__ipipe_lock, flags);
++      raw_spin_unlock_irqrestore(&__ipipe_lock, flags);
 +
 +      return irq;
 +}
@@ -10241,7 +10352,7 @@ index 0000000..3b07d65
 +          (irq >= IPIPE_NR_XIRQS && !ipipe_virtual_irq_p(irq)))
 +              return -EINVAL;
 +
-+      spin_lock_irqsave(&__ipipe_lock, flags);
++      raw_spin_lock_irqsave(&__ipipe_lock, flags);
 +
 +      if (ipd->irqs[irq].handler) {
 +              ret = -EBUSY;
@@ -10259,7 +10370,7 @@ index 0000000..3b07d65
 +      if (irq < IPIPE_NR_ROOT_IRQS)
 +              __ipipe_enable_irqdesc(ipd, irq);
 +out:
-+      spin_unlock_irqrestore(&__ipipe_lock, flags);
++      raw_spin_unlock_irqrestore(&__ipipe_lock, flags);
 +
 +      return ret;
 +}
@@ -10274,7 +10385,7 @@ index 0000000..3b07d65
 +      ipipe_root_only();
 +#endif /* CONFIG_IPIPE_LEGACY */
 +
-+      spin_lock_irqsave(&__ipipe_lock, flags);
++      raw_spin_lock_irqsave(&__ipipe_lock, flags);
 +
 +      if (ipd->irqs[irq].handler == NULL)
 +              goto out;
@@ -10287,7 +10398,7 @@ index 0000000..3b07d65
 +      if (irq < IPIPE_NR_ROOT_IRQS)
 +              __ipipe_disable_irqdesc(ipd, irq);
 +out:
-+      spin_unlock_irqrestore(&__ipipe_lock, flags);
++      raw_spin_unlock_irqrestore(&__ipipe_lock, flags);
 +}
 +EXPORT_SYMBOL_GPL(ipipe_free_irq);
 +
@@ -10930,7 +11041,7 @@ index 0000000..3b07d65
 +       * another CPU. Enter a spinning wait until he releases the
 +       * global lock.
 +       */
-+      spin_lock(&__ipipe_cpu_barrier);
++      raw_spin_lock(&__ipipe_cpu_barrier);
 +
 +      /* Got it. Now get out. */
 +
@@ -10940,7 +11051,7 @@ index 0000000..3b07d65
 +
 +      cpumask_set_cpu(cpu, &__ipipe_cpu_pass_map);
 +
-+      spin_unlock(&__ipipe_cpu_barrier);
++      raw_spin_unlock(&__ipipe_cpu_barrier);
 +
 +      cpumask_clear_cpu(cpu, &__ipipe_cpu_sync_map);
 +}
@@ -10973,7 +11084,7 @@ index 0000000..3b07d65
 +              }
 +restart:
 +              online = *cpu_online_mask;
-+              spin_lock(&__ipipe_cpu_barrier);
++              raw_spin_lock(&__ipipe_cpu_barrier);
 +
 +              __ipipe_cpu_sync = syncfn;
 +
@@ -10999,7 +11110,7 @@ index 0000000..3b07d65
 +                       */
 +                      __ipipe_cpu_sync = NULL;
 +
-+                      spin_unlock(&__ipipe_cpu_barrier);
++                      raw_spin_unlock(&__ipipe_cpu_barrier);
 +                      /*
 +                       * Ensure all CPUs consumed the IPI to avoid
 +                       * running __ipipe_cpu_sync prematurely. This
@@ -11029,7 +11140,7 @@ index 0000000..3b07d65
 +
 +#ifdef CONFIG_SMP
 +      if (atomic_dec_and_test(&__ipipe_critical_count)) {
-+              spin_unlock(&__ipipe_cpu_barrier);
++              raw_spin_unlock(&__ipipe_cpu_barrier);
 +              while (!cpumask_empty(&__ipipe_cpu_sync_map))
 +                      cpu_relax();
 +              cpumask_clear_cpu(ipipe_processor_id(), &__ipipe_cpu_lock_map);
@@ -11297,10 +11408,10 @@ index 0000000..3b07d65
 +#endif
 diff --git a/kernel/ipipe/timer.c b/kernel/ipipe/timer.c
 new file mode 100644
-index 0000000..73f748e
+index 0000000..a9917f4
 --- /dev/null
 +++ b/kernel/ipipe/timer.c
-@@ -0,0 +1,497 @@
+@@ -0,0 +1,520 @@
 +/* -*- linux-c -*-
 + * linux/kernel/ipipe/timer.c
 + *
@@ -11427,7 +11538,7 @@ index 0000000..73f748e
 +      if (timer->cpumask == NULL)
 +              timer->cpumask = cpumask_of(smp_processor_id());
 +
-+      spin_lock_irqsave(&lock, flags);
++      raw_spin_lock_irqsave(&lock, flags);
 +
 +      list_for_each_entry(t, &timers, link) {
 +              if (t->rating <= timer->rating) {
@@ -11437,7 +11548,7 @@ index 0000000..73f748e
 +      }
 +      list_add_tail(&timer->link, &timers);
 +  done:
-+      spin_unlock_irqrestore(&lock, flags);
++      raw_spin_unlock_irqrestore(&lock, flags);
 +}
 +
 +static void ipipe_timer_request_sync(void)
@@ -11460,18 +11571,14 @@ index 0000000..73f748e
 +      timer->request(timer, steal);
 +}
 +
-+/* Set up a timer as per-cpu timer for ipipe */
-+static void install_pcpu_timer(unsigned cpu, unsigned hrclock_freq,
-+                            struct ipipe_timer *t) {
-+      unsigned hrtimer_freq;
++static void config_pcpu_timer(struct ipipe_timer *t, unsigned hrclock_freq)
++{
 +      unsigned long long tmp;
++      unsigned hrtimer_freq;
 +
-+      if (__ipipe_hrtimer_freq == 0)
++      if (__ipipe_hrtimer_freq != t->freq)
 +              __ipipe_hrtimer_freq = t->freq;
 +
-+      per_cpu(ipipe_percpu.hrtimer_irq, cpu) = t->irq;
-+      per_cpu(percpu_timer, cpu) = t;
-+
 +      hrtimer_freq = t->freq;
 +      if (__ipipe_hrclock_freq > UINT_MAX)
 +              hrtimer_freq /= 1000;
@@ -11484,6 +11591,15 @@ index 0000000..73f748e
 +      t->c2t_frac = tmp;
 +}
 +
++/* Set up a timer as per-cpu timer for ipipe */
++static void install_pcpu_timer(unsigned cpu, unsigned hrclock_freq,
++                            struct ipipe_timer *t)
++{
++      per_cpu(ipipe_percpu.hrtimer_irq, cpu) = t->irq;
++      per_cpu(percpu_timer, cpu) = t;
++      config_pcpu_timer(t, hrclock_freq);
++}
++
 +static void select_root_only_timer(unsigned cpu, unsigned hrclock_khz,
 +                                 const struct cpumask *mask,
 +                                 struct ipipe_timer *t) {
@@ -11537,7 +11653,7 @@ index 0000000..73f748e
 +      } else
 +              hrclock_freq = __ipipe_hrclock_freq;
 +
-+      spin_lock_irqsave(&lock, flags);
++      raw_spin_lock_irqsave(&lock, flags);
 +
 +      /* First, choose timers for the CPUs handled by ipipe */
 +      for_each_cpu(cpu, mask) {
@@ -11577,7 +11693,7 @@ index 0000000..73f748e
 +              }
 +      }
 +
-+      spin_unlock_irqrestore(&lock, flags);
++      raw_spin_unlock_irqrestore(&lock, flags);
 +
 +      flags = ipipe_critical_enter(ipipe_timer_request_sync);
 +      ipipe_timer_request_sync();
@@ -11586,7 +11702,7 @@ index 0000000..73f748e
 +      return 0;
 +
 +err_remove_all:
-+      spin_unlock_irqrestore(&lock, flags);
++      raw_spin_unlock_irqrestore(&lock, flags);
 +
 +      for_each_cpu(cpu, mask) {
 +              per_cpu(ipipe_percpu.hrtimer_irq, cpu) = -1;
@@ -11798,9 +11914,27 @@ index 0000000..73f748e
 +}
 +
 +#endif /* CONFIG_IPIPE_HAVE_HOSTRT */
++
++int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
++                            bool force);
++
++void __ipipe_timer_refresh_freq(unsigned int hrclock_freq)
++{
++      struct ipipe_timer *t = __ipipe_raw_cpu_read(percpu_timer);
++      unsigned long flags;
++
++      if (t && t->refresh_freq) {
++              t->freq = t->refresh_freq();
++              flags = hard_local_irq_save();
++              config_pcpu_timer(t, hrclock_freq);
++              hard_local_irq_restore(flags);
++              clockevents_program_event(t->host_timer,
++                                        t->host_timer->next_event, false);
++      }
++}
 diff --git a/kernel/ipipe/tracer.c b/kernel/ipipe/tracer.c
 new file mode 100644
-index 0000000..da272c50
+index 0000000..1ae7bc2
 --- /dev/null
 +++ b/kernel/ipipe/tracer.c
 @@ -0,0 +1,1468 @@
@@ -11865,7 +11999,7 @@ index 0000000..da272c50
 +#define IPIPE_TFLG_CURRDOM_SHIFT    10         /* bits 10..11: current domain 
*/
 +#define IPIPE_TFLG_CURRDOM_MASK           0x0C00
 +#define IPIPE_TFLG_DOMSTATE_SHIFT   12         /* bits 12..15: domain 
stalled? */
-+#define IPIPE_TFLG_DOMSTATE_BITS    3
++#define IPIPE_TFLG_DOMSTATE_BITS    1
 +
 +#define IPIPE_TFLG_DOMAIN_STALLED(point, n) \
 +      (point->flags & (1 << (n + IPIPE_TFLG_DOMSTATE_SHIFT)))
@@ -12008,7 +12142,7 @@ index 0000000..da272c50
 +      if (length > per_cpu(trace_path, cpu)[per_cpu(max_path, cpu)].length) {
 +              /* we need protection here against other cpus trying
 +                 to start a proc dump */
-+              spin_lock(&global_path_lock);
++              raw_spin_lock(&global_path_lock);
 +
 +              /* active path holds new worst case */
 +              tp->length = length;
@@ -12017,7 +12151,7 @@ index 0000000..da272c50
 +              /* find next unused trace path */
 +              active = __ipipe_get_free_trace_path(active, cpu);
 +
-+              spin_unlock(&global_path_lock);
++              raw_spin_unlock(&global_path_lock);
 +
 +              tp = &per_cpu(trace_path, cpu)[active];
 +
@@ -12040,7 +12174,7 @@ index 0000000..da272c50
 +
 +      /* we need protection here against other cpus trying
 +       * to set their frozen path or to start a proc dump */
-+      spin_lock(&global_path_lock);
++      raw_spin_lock(&global_path_lock);
 +
 +      per_cpu(frozen_path, cpu) = active;
 +
@@ -12054,7 +12188,7 @@ index 0000000..da272c50
 +                      tp->end = -1;
 +      }
 +
-+      spin_unlock(&global_path_lock);
++      raw_spin_unlock(&global_path_lock);
 +
 +      tp = &per_cpu(trace_path, cpu)[active];
 +
@@ -12209,7 +12343,7 @@ index 0000000..da272c50
 +      int cpu;
 +      struct ipipe_trace_path *tp;
 +
-+      spin_lock_irqsave(&global_path_lock, flags);
++      raw_spin_lock_irqsave(&global_path_lock, flags);
 +
 +      cpu = ipipe_processor_id();
 + restart:
@@ -13138,7 +13272,7 @@ index 0000000..da272c50
 +
 +static struct ftrace_ops ipipe_trace_ops = {
 +      .func = ipipe_trace_function,
-+      .flags = FTRACE_OPS_FL_RECURSION_SAFE,
++      .flags = FTRACE_OPS_FL_IPIPE_EXCLUSIVE,
 +};
 +
 +static ssize_t __ipipe_wr_enable(struct file *file, const char __user *buffer,
@@ -14025,7 +14159,7 @@ index 2329daa..79cfe9b 100644
        if (pm_wakeup_pending()) {
                error = -EAGAIN;
 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
-index 3c1aca0..90b1189 100644
+index 3c1aca0..ae6b3d5 100644
 --- a/kernel/printk/printk.c
 +++ b/kernel/printk/printk.c
 @@ -62,6 +62,9 @@ int console_printk[4] = {
@@ -14141,7 +14275,7 @@ index 3c1aca0..90b1189 100644
 +      goto start;
 +
 +      do {
-+              spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
++              raw_spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
 + start:
 +              lmax = __ipipe_printk_fill;
 +              while (out < lmax) {
@@ -14150,13 +14284,13 @@ index 3c1aca0..90b1189 100644
 +                      p += len;
 +                      out += len;
 +              }
-+              spin_lock_irqsave(&__ipipe_printk_lock, flags);
++              raw_spin_lock_irqsave(&__ipipe_printk_lock, flags);
 +      }
 +      while (__ipipe_printk_fill != lmax);
 +
 +      __ipipe_printk_fill = 0;
 +
-+      spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
++      raw_spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
 +}
 +
  /**
@@ -14194,7 +14328,7 @@ index 3c1aca0..90b1189 100644
 +              goto out;
 +      }
 +
-+      spin_lock_irqsave(&__ipipe_printk_lock, flags);
++      raw_spin_lock_irqsave(&__ipipe_printk_lock, flags);
 +
 +      oldcount = __ipipe_printk_fill;
 +      fbytes = __LOG_BUF_LEN - oldcount;
@@ -14205,7 +14339,7 @@ index 3c1aca0..90b1189 100644
 +      } else
 +              r = 0;
 +
-+      spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
++      raw_spin_unlock_irqrestore(&__ipipe_printk_lock, flags);
 +
 +      if (oldcount == 0)
 +              ipipe_raise_irq(__ipipe_printk_virq);
@@ -14854,7 +14988,7 @@ index 3b9a48a..edd9470 100644
        help
          This option will modify all the calls to function tracing
 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
-index eb11011..5fa6c0a 100644
+index eb11011..d0957bd 100644
 --- a/kernel/trace/ftrace.c
 +++ b/kernel/trace/ftrace.c
 @@ -32,6 +32,7 @@
@@ -14865,7 +14999,33 @@ index eb11011..5fa6c0a 100644
  
  #include <trace/events/sched.h>
  
-@@ -2518,6 +2519,9 @@ void __weak arch_ftrace_update_code(int command)
+@@ -262,8 +263,17 @@ static ftrace_func_t ftrace_ops_get_list_func(struct 
ftrace_ops *ops)
+ 
+ static void update_ftrace_function(void)
+ {
++      struct ftrace_ops *ops;
+       ftrace_func_t func;
+ 
++      for (ops = ftrace_ops_list;
++           ops != &ftrace_list_end; ops = ops->next)
++              if (ops->flags & FTRACE_OPS_FL_IPIPE_EXCLUSIVE) {
++                      set_function_trace_op = ops;
++                      func = ops->func;
++                      goto set_pointers;
++              }
++
+       /*
+        * Prepare the ftrace_ops that the arch callback will use.
+        * If there's only one ftrace_ops registered, the ftrace_ops_list
+@@ -291,6 +301,7 @@ static void update_ftrace_function(void)
+ 
+       update_function_graph_func();
+ 
++  set_pointers:
+       /* If there's no change, then do nothing more here */
+       if (ftrace_trace_function == func)
+               return;
+@@ -2518,6 +2529,9 @@ void __weak arch_ftrace_update_code(int command)
  
  static void ftrace_run_update_code(int command)
  {
@@ -14875,7 +15035,7 @@ index eb11011..5fa6c0a 100644
        int ret;
  
        ret = ftrace_arch_code_modify_prepare();
-@@ -2531,7 +2535,13 @@ static void ftrace_run_update_code(int command)
+@@ -2531,7 +2545,13 @@ static void ftrace_run_update_code(int command)
         * is safe. The stop_machine() is the safest, but also
         * produces the most overhead.
         */
@@ -14889,7 +15049,7 @@ index eb11011..5fa6c0a 100644
  
        ret = ftrace_arch_code_modify_post_process();
        FTRACE_WARN_ON(ret);
-@@ -4877,10 +4887,10 @@ static int ftrace_process_locs(struct module *mod,
+@@ -4877,10 +4897,10 @@ static int ftrace_process_locs(struct module *mod,
         * reason to cause large interrupt latencies while we do it.
         */
        if (!mod)
@@ -14902,7 +15062,7 @@ index eb11011..5fa6c0a 100644
        ret = 0;
   out:
        mutex_unlock(&ftrace_lock);
-@@ -4979,9 +4989,11 @@ void __init ftrace_init(void)
+@@ -4979,9 +4999,11 @@ void __init ftrace_init(void)
        unsigned long count, flags;
        int ret;
  
@@ -14916,7 +15076,7 @@ index eb11011..5fa6c0a 100644
        if (ret)
                goto failed;
  
-@@ -5174,7 +5186,16 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long 
parent_ip,
+@@ -5174,7 +5196,16 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long 
parent_ip,
                }
        } while_for_each_ftrace_op(op);
  out:
@@ -15276,24 +15436,22 @@ index 86c8911..373a30b 100644
        return err;
  }
 diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
-index 1afec32..5803111 100644
+index 1afec32..f7c1a2a 100644
 --- a/lib/smp_processor_id.c
 +++ b/lib/smp_processor_id.c
-@@ -12,10 +12,13 @@ notrace static unsigned int 
check_preemption_disabled(const char *what1,
+@@ -12,6 +12,12 @@ notrace static unsigned int check_preemption_disabled(const 
char *what1,
  {
        int this_cpu = raw_smp_processor_id();
  
++      if (hard_irqs_disabled())
++              goto out;
++
 +      if (!ipipe_root_p)
 +              goto out;
 +
        if (likely(preempt_count()))
                goto out;
  
--      if (irqs_disabled())
-+      if (irqs_disabled() || hard_irqs_disabled())
-               goto out;
- 
-       /*
 diff --git a/mm/memory.c b/mm/memory.c
 index 2a9e098..46ec4cd 100644
 --- a/mm/memory.c
@@ -15501,7 +15659,7 @@ index 2a9e098..46ec4cd 100644
  
  static struct kmem_cache *page_ptl_cachep;
 diff --git a/mm/mlock.c b/mm/mlock.c
-index 3d3ee6c..ed47c08 100644
+index 3d3ee6ca..ed47c08 100644
 --- a/mm/mlock.c
 +++ b/mm/mlock.c
 @@ -756,3 +756,28 @@ void user_shm_unlock(size_t size, struct user_struct 
*user)
@@ -15636,3 +15794,16 @@ index 2faaa29..ef00f26 100644
        return nr;
  }
  
+diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
+index 96c2e42..2e6e3cf 100644
+--- a/sound/soc/intel/atom/sst/sst.c
++++ b/sound/soc/intel/atom/sst/sst.c
+@@ -369,7 +369,7 @@ static inline void sst_restore_shim64(struct intel_sst_drv 
*ctx,
+        */
+       spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
+       sst_shim_write64(shim, SST_IMRX, shim_regs->imrx),
+-      sst_shim_write64(shim, SST_CSR, shim_regs->csr),
++      sst_shim_write64(shim, SST_CSR, shim_regs->csr);
+       spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
+ }
+ 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to