Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Oct 2018 10:35:02 +0000 (12:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 12 Oct 2018 10:35:02 +0000 (12:35 +0200)
Dmitry writes:
  "Input updates for v4.19-rc7

   - we added a few scheduling points into various input interfaces to
     ensure that large writes will not cause RCU stalls
   - fixed configuring PS/2 keyboards as wakeup devices on newer
     platforms
   - added a new Xbox gamepad ID."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: uinput - add a schedule point in uinput_inject_events()
  Input: evdev - add a schedule point in evdev_write()
  Input: mousedev - add a schedule point in mousedev_write()
  Input: i8042 - enable keyboard wakeups by default when s2idle is used
  Input: xpad - add support for Xbox1 PDP Camo series gamepad

1  2 
include/linux/suspend.h
kernel/power/suspend.c

diff --combined include/linux/suspend.h
index 5a28ac9284f0e1d10f639564ee046c6171d676c0,206b735f383f4d4e6a9f3fb08449da9d492713dd..3f529ad9a9d2ec33bf8fcdfa72bb9ddce46a292a
@@@ -251,6 -251,7 +251,7 @@@ static inline bool idle_should_enter_s2
        return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
  }
  
+ extern bool pm_suspend_via_s2idle(void);
  extern void __init pm_states_init(void);
  extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
  extern void s2idle_wake(void);
@@@ -282,6 -283,7 +283,7 @@@ static inline void pm_set_suspend_via_f
  static inline void pm_set_resume_via_firmware(void) {}
  static inline bool pm_suspend_via_firmware(void) { return false; }
  static inline bool pm_resume_via_firmware(void) { return false; }
+ static inline bool pm_suspend_via_s2idle(void) { return false; }
  
  static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
  static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
@@@ -414,7 -416,7 +416,7 @@@ static inline bool hibernation_availabl
  #define PM_RESTORE_PREPARE    0x0005 /* Going to restore a saved image */
  #define PM_POST_RESTORE               0x0006 /* Restore failed */
  
 -extern struct mutex pm_mutex;
 +extern struct mutex system_transition_mutex;
  
  #ifdef CONFIG_PM_SLEEP
  void save_processor_state(void);
diff --combined kernel/power/suspend.c
index 5342f6fc022e5740fa46b9d2378e181c18d65b5e,be3d0d4776618e0677b2c3548c6f01681404925a..0bd595a0b6103c56439871b765ef0d4fb5ac672b
@@@ -27,7 -27,6 +27,7 @@@
  #include <linux/export.h>
  #include <linux/suspend.h>
  #include <linux/syscore_ops.h>
 +#include <linux/swait.h>
  #include <linux/ftrace.h>
  #include <trace/events/power.h>
  #include <linux/compiler.h>
@@@ -58,11 -57,17 +58,17 @@@ EXPORT_SYMBOL_GPL(pm_suspend_global_fla
  
  static const struct platform_suspend_ops *suspend_ops;
  static const struct platform_s2idle_ops *s2idle_ops;
 -static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head);
 +static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
  
  enum s2idle_states __read_mostly s2idle_state;
 -static DEFINE_SPINLOCK(s2idle_lock);
 +static DEFINE_RAW_SPINLOCK(s2idle_lock);
  
+ bool pm_suspend_via_s2idle(void)
+ {
+       return mem_sleep_current == PM_SUSPEND_TO_IDLE;
+ }
+ EXPORT_SYMBOL_GPL(pm_suspend_via_s2idle);
  void s2idle_set_ops(const struct platform_s2idle_ops *ops)
  {
        lock_system_sleep();
@@@ -79,12 -84,12 +85,12 @@@ static void s2idle_enter(void
  {
        trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true);
  
 -      spin_lock_irq(&s2idle_lock);
 +      raw_spin_lock_irq(&s2idle_lock);
        if (pm_wakeup_pending())
                goto out;
  
        s2idle_state = S2IDLE_STATE_ENTER;
 -      spin_unlock_irq(&s2idle_lock);
 +      raw_spin_unlock_irq(&s2idle_lock);
  
        get_online_cpus();
        cpuidle_resume();
        /* Push all the CPUs into the idle loop. */
        wake_up_all_idle_cpus();
        /* Make the current CPU wait so it can enter the idle loop too. */
 -      wait_event(s2idle_wait_head,
 -                 s2idle_state == S2IDLE_STATE_WAKE);
 +      swait_event_exclusive(s2idle_wait_head,
 +                  s2idle_state == S2IDLE_STATE_WAKE);
  
        cpuidle_pause();
        put_online_cpus();
  
 -      spin_lock_irq(&s2idle_lock);
 +      raw_spin_lock_irq(&s2idle_lock);
  
   out:
        s2idle_state = S2IDLE_STATE_NONE;
 -      spin_unlock_irq(&s2idle_lock);
 +      raw_spin_unlock_irq(&s2idle_lock);
  
        trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, false);
  }
@@@ -157,12 -162,12 +163,12 @@@ void s2idle_wake(void
  {
        unsigned long flags;
  
 -      spin_lock_irqsave(&s2idle_lock, flags);
 +      raw_spin_lock_irqsave(&s2idle_lock, flags);
        if (s2idle_state > S2IDLE_STATE_NONE) {
                s2idle_state = S2IDLE_STATE_WAKE;
 -              wake_up(&s2idle_wait_head);
 +              swake_up_one(&s2idle_wait_head);
        }
 -      spin_unlock_irqrestore(&s2idle_lock, flags);
 +      raw_spin_unlock_irqrestore(&s2idle_lock, flags);
  }
  EXPORT_SYMBOL_GPL(s2idle_wake);
  
@@@ -429,8 -434,6 +435,8 @@@ static int suspend_enter(suspend_state_
        arch_suspend_disable_irqs();
        BUG_ON(!irqs_disabled());
  
 +      system_state = SYSTEM_SUSPEND;
 +
        error = syscore_suspend();
        if (!error) {
                *wakeup = pm_wakeup_pending();
                syscore_resume();
        }
  
 +      system_state = SYSTEM_RUNNING;
 +
        arch_suspend_enable_irqs();
        BUG_ON(irqs_disabled());
  
@@@ -556,7 -557,7 +562,7 @@@ static int enter_state(suspend_state_t 
        } else if (!valid_state(state)) {
                return -EINVAL;
        }
 -      if (!mutex_trylock(&pm_mutex))
 +      if (!mutex_trylock(&system_transition_mutex))
                return -EBUSY;
  
        if (state == PM_SUSPEND_TO_IDLE)
        pm_pr_dbg("Finishing wakeup.\n");
        suspend_finish();
   Unlock:
 -      mutex_unlock(&pm_mutex);
 +      mutex_unlock(&system_transition_mutex);
        return error;
  }