1. 03 Apr, 2019 24 commits
    • Jan Kiszka's avatar
      ipipe: Fix output layout of tracer · 432d2adc
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      A long time ago (probably in 2.6-times), someone converted spaces to
      tabs, shuffling the layout around this way, and by forgetting to account
      for the multi-domain removal.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      432d2adc
    • Jan Kiszka's avatar
      ipipe: Fix panic output of tracer · 4e5bb6a4
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      Since 4.9, we need to declare continued lines via KERN_CONT.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      4e5bb6a4
    • Jan Kiszka's avatar
      ipipe: Clean up per-CPU host timers on hotplug · cd0067e9
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      When a CPU is unplugged, make sure to drop all per-CPU ipipe timer
      devices when removing the CPU. Otherwise, we will corrupt the device
      list when re-registering the host timer on CPU onlining.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      cd0067e9
    • Jan Kiszka's avatar
      ipipe: Introduce and use ipipe_root_nr_syscalls · abeb1754
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      At least one arch, infamous x86, has a difference of NR_syscalls
      depending on compat vs. native ABI. Account for that by introducing a
      function that can deliver the currently valid syscall number if an arch
      implements such a service. In all other cases, this change is
      functionally no difference.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      abeb1754
    • Jan Kiszka's avatar
      ipipe: Introduce infrastructure for userspace return notifier · a3654dd9
      Jan Kiszka authored and Philippe Gerum's avatar Philippe Gerum committed
      
      
      A little bit inspired by the kernel's user return notifier, this
      introduces an I-pipe hook before the kernel jumps back to a userspace
      context from the root domain. The hook is design to allow a switch back
      to the head domain, thus will not run through signal/preemption checks
      when returning from the callback over head. It is guaranteed to fire on
      return from interrupts and exceptions but may also fire on certain
      syscall-return paths.
      
      The first use case for the hook is resumption of ptraced tasks over
      head if they were stopped in that domain.
      
      This provides just the generic infrastructure, the invocation of
      __ipipe_notify_user_intreturn as well as the definition of
      TIP_USERINTRET are architecture-specific.
      Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
      a3654dd9
    • Philippe Gerum's avatar
      ipipe: timer: prevent double-ack if host timer is not grabbed · d10ec2b9
      Philippe Gerum authored
      Only timers stolen away from the host kernel should be early acked by
      the pipeline core. Otherwise, the regular IRQ handler associated to
      the timer would duplicate the action. The IRQ line is left masked,
      waiting for the IRQ flow handler to unmask it eventually.
      d10ec2b9
    • Philippe Gerum's avatar
      ipipe: timer: notify co-kernel about entering ONESHOT_STOPPED mode · 70b9018f
      Philippe Gerum authored
      Although we don't want to disable the hardware not to wreck the
      outstanding timing requests managed by the co-kernel, we should
      nevertheless notify it about entering the ONESHOT_STOPPED mode, so
      that it may disable the host tick emulation.
      70b9018f
    • Philippe Gerum's avatar
      ipipe: timer: do not interpose on undefined handlers · 0929aeb5
      Philippe Gerum authored
      There is no point in interposing on clock chip handlers for which
      there was no support originally. In some cases (oneshot_stopped), we
      may even get a kernel fault, jumping to a NULL address.
      
      Interpose on non-NULL original handlers only.
      0929aeb5
    • Philippe Gerum's avatar
      ipipe: timer: resume hardware operations in oneshot handler · 3c888aa8
      Philippe Gerum authored
      Although we won't allow disabling the hardware when the clock event
      logic switches a device to stopped mode - so that we won't affect the
      timer logic running on the head stage unexpectedly -, we still have to
      enable the hardware when switched (back) to oneshot mode, since it may
      have been stopped prior to interposing on the device in
      ipipe_timer_start().
      
      Failing to do so would leave the hardware shut down for both regular
      and Xenomai operations, with no mean to bring it up again.
      3c888aa8
    • Philippe Gerum's avatar
      sched: idle: ipipe: drop spurious check · 67157bba
      Philippe Gerum authored
      67157bba
    • Philippe Gerum's avatar
    • Philippe Gerum's avatar
      ipipe: tick: revive the host tick after device grab · 44db4e30
      Philippe Gerum authored
      Once the device was grabbed by ipipe_timer_start(), any pending host
      tick programmed in the hardware is basically lost, unknown to the
      co-kernel implementing the proxy handlers.
      
      Schedule a host event with the latest target time programmed to have
      the co-kernel know about the pending tick.
      44db4e30
    • Philippe Gerum's avatar
      PM: ipipe: converge to Dovetail's CPUIDLE management · ced28fdc
      Philippe Gerum authored
      Handle requests for transitioning to deeper C-states the way Dovetail
      does, which prevents us from losing the timer when grabbed by a
      co-kernel, in presence of a CPUIDLE driver.
      ced28fdc
    • Philippe Gerum's avatar
      ipipe: tick: cap timer_set op to device supported max · 2d0950b8
      Philippe Gerum authored
      At this chance, switch the min_delay_tick value to unsigned long to
      match the corresponding clockevent definition.
      2d0950b8
    • Philippe Gerum's avatar
      ipipe: tick: out-of-band devices require GENERIC_CLOCKEVENTS · 7e7242e9
      Philippe Gerum authored
      Drop the legacy support for architectures not enabling the generic
      clock event framework, which would only provide periodic timing.
      
      We don't support any of those archs, and there is no point in running
      a Xenomai co-kernel on a hardware not capable of handling oneshot
      timing requests.
      7e7242e9
    • Philippe Gerum's avatar
      ipipe: add cpuidle control interface · 5b9c52b2
      Philippe Gerum authored
      Add a kernel interface for sharing CPU idling control between the host
      kernel and a co-kernel. The former invokes ipipe_cpuidle_control()
      which the latter should implement, for determining whether entering a
      sleep state is ok. This hook should return boolean true if so.
      
      The co-kernel may veto such entry if need be, in order to prevent
      latency spikes, as exiting sleep states might be costly depending on
      the CPU idling operation being used.
      5b9c52b2
    • Philippe Gerum's avatar
      KVM: ipipe: keep hypervisor state consistent across domain preemption · e5a589c9
      Philippe Gerum authored
      In order for the hypervisor to operate properly in presence of a
      co-kernel, we need:
      
      - the virtualization core to know when the hypervisor stalls due
        to a preemption by the co-kernel.
      
      - to know when the VM enters and leaves guest mode.
      e5a589c9
    • Philippe Gerum's avatar
      sched: ipipe: enable task migration between domains · 90b6728d
      Philippe Gerum authored
      This is the basic code enabling alternate control of tasks between the
      regular kernel and an embedded co-kernel. The changes cover the
      following aspects:
      
      - extend the per-thread information block with a private area usable
        by the co-kernel for storing additional state information
      
      - provide the API enabling a scheduler exchange mechanism, so that
        tasks can run under the control of either kernel alternatively. This
        includes a service to move the current task to the head domain under
        the control of the co-kernel, and the converse service to re-enter
        the root domain once the co-kernel has released such task.
      
      - ensure the generic context switching code can be used from any
        domain, serializing execution as required.
      
      These changes have to be paired with arch-specific code further
      enabling context switching from the head domain.
      90b6728d
    • Philippe Gerum's avatar
      ipipe: add kernel event notifiers · 6b70aed7
      Philippe Gerum authored
      Add the core API for enabling (regular) kernel event notifications to
      a co-kernel running over the head domain. For instance, such a
      co-kernel may need to know when a task is about to be resumed upon
      signal receipt, or when it gets an access fault trap.
      
      This commit adds the client-side API for enabling such notification
      for class of events, but does not provide the notification points per
      se, which comes later.
      6b70aed7
    • Philippe Gerum's avatar
      printk: ipipe: defer printk() from head domain · 7ff6fc47
      Philippe Gerum authored
      The printk() machinery cannot immediately invoke the console driver(s)
      when called from the head domain, since such driver code belongs to
      the root domain and cannot be shared between domains.
      
      Output issued from the head domain is formatted then logged into a
      staging buffer, and a dedicated virtual IRQ is posted to the root
      domain for notification. When the virtual IRQ handler runs, the
      contents of the staging buffer is flushed to the printk() interface
      anew, which may eventually pass the output on to the console drivers
      from such a context.
      7ff6fc47
    • Philippe Gerum's avatar
      ipipe: add latency tracer · 798079bc
      Philippe Gerum authored
      The latency tracer is a variant of ftrace's 'function' tracer
      providing detailed information about the current interrupt state at
      each function entry (i.e. virtual interrupt flag and CPU interrupt
      disable bit). This commit introduces the generic tracer code, which
      builds upon the regular ftrace API.
      
      The arch-specific code should provide for ipipe_read_tsc(), a helper
      routine returning a 64bit monotonic time value for timestamping
      purpose. HAVE_IPIPE_TRACER_SUPPORT should be selected by the
      arch-specific code for enabling the tracer, which in turn makes
      CONFIG_IPIPE_TRACE available from the Kconfig interface.
      798079bc
    • Philippe Gerum's avatar
      ipipe: add out-of-band tick device · 76b5183a
      Philippe Gerum authored
      The out-of-band tick device manages the timer hardware by interposing
      on selected clockevent handlers transparently, so that a client domain
      (e.g. a co-kernel) eventually controls such hardware for scheduling
      the high-precision timer events it needs to. Those events are
      delivered to out-of-hand activities running on the head stage,
      unimpeded by (only virtually) interrupt-free sections of the regular
      kernel code.
      
      This commit introduces the generic API for controlling the out-of-band
      tick device from a co-kernel. It also provides for the internal API
      clock event chip drivers should use for enabling high-precision
      timing for their hardware.
      76b5183a
    • Philippe Gerum's avatar
      locking: ipipe: add hard lock alternative to regular spinlocks · 16437c64
      Philippe Gerum authored
      Hard spinlocks manipulate the CPU interrupt mask, without affecting
      the kernel preemption state in locking/unlocking operations.
      
      This type of spinlock is useful for implementing a critical section to
      serialize concurrent accesses from both in-band and out-of-band
      contexts, i.e. from root and head stages.
      
      Hard spinlocks exclusively depend on the pre-existing arch-specific
      bits which implement regular spinlocks. They can be seen as basic
      spinlocks still affecting the CPU's interrupt state when all other
      spinlock types only deal with the virtual interrupt flag managed by
      the pipeline core - i.e. only disable interrupts for the regular
      in-band kernel activity.
      16437c64
    • Philippe Gerum's avatar
      genirq: add generic I-pipe core · e38940ba
      Philippe Gerum authored
      This commit provides the arch-independent bits for implementing the
      interrupt pipeline core, a lightweight layer introducing a separate,
      high-priority execution stage for handling all IRQs in pseudo-NMI
      mode, which cannot be delayed by the regular kernel code. See
      Documentation/ipipe.rst for details about interrupt pipelining.
      
      Architectures which support interrupt pipelining should select
      HAVE_IPIPE_SUPPORT, along with implementing the required arch-specific
      code. In such a case, CONFIG_IPIPE becomes available to the user via
      the Kconfig interface for enabling the feature.
      e38940ba