diff mbox series

[v2] i8042: enable keyboard wakeups by default when s2idle is used

Message ID 20180910112438.7291-1-drake@endlessm.com (mailing list archive)
State New, archived
Headers show
Series [v2] i8042: enable keyboard wakeups by default when s2idle is used | expand

Commit Message

Daniel Drake Sept. 10, 2018, 11:24 a.m. UTC
Previously, on typical consumer laptops, pressing a key on the keyboard
when the system is in suspend would cause it to wake up (default or
unconditional behaviour). This happens because the EC generates a SCI
interrupt in this scenario.

That is no longer true on modern laptops based on Intel WhiskyLake,
including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
design has been modified so that the EC no longer generates a SCI
in this case; the keyboard controller itself should be used for wakeup.

In order to retain the standard behaviour of being able to use the
keyboard to wake up the system, enable serio wakeups by default on
platforms that are using s2idle.

Link: https://lkml.kernel.org/r/CAB4CAwfQ0mPMqCLp95TVjw4J0r5zKPWkSvvkK4cpZUGE--w8bQ@mail.gmail.com
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
---
 drivers/input/serio/i8042.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

v2: tweak comment as suggested by Rafael

Comments

kernel test robot Sept. 11, 2018, 3:29 a.m. UTC | #1
Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on input/next]
[also build test ERROR on v4.19-rc3 next-20180910]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniel-Drake/i8042-enable-keyboard-wakeups-by-default-when-s2idle-is-used/20180911-091924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-u0-09110814 (attached as .config)
compiler: gcc-5 (Debian 5.5.0-3) 5.4.1 20171010
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:10:0,
                    from include/linux/delay.h:22,
                    from drivers/input/serio/i8042.c:16:
   drivers/input/serio/i8042.c: In function 'i8042_register_ports':
>> drivers/input/serio/i8042.c:1415:7: error: 'mem_sleep_current' undeclared (first use in this function)
      if (mem_sleep_current == PM_SUSPEND_TO_IDLE
          ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
>> drivers/input/serio/i8042.c:1415:3: note: in expansion of macro 'if'
      if (mem_sleep_current == PM_SUSPEND_TO_IDLE
      ^
   drivers/input/serio/i8042.c:1415:7: note: each undeclared identifier is reported only once for each function it appears in
      if (mem_sleep_current == PM_SUSPEND_TO_IDLE
          ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^
>> drivers/input/serio/i8042.c:1415:3: note: in expansion of macro 'if'
      if (mem_sleep_current == PM_SUSPEND_TO_IDLE
      ^

vim +/mem_sleep_current +1415 drivers/input/serio/i8042.c

  1390	
  1391	static void __init i8042_register_ports(void)
  1392	{
  1393		int i;
  1394	
  1395		for (i = 0; i < I8042_NUM_PORTS; i++) {
  1396			struct serio *serio = i8042_ports[i].serio;
  1397	
  1398			if (!serio)
  1399				continue;
  1400	
  1401			printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
  1402				serio->name,
  1403				(unsigned long) I8042_DATA_REG,
  1404				(unsigned long) I8042_COMMAND_REG,
  1405				i8042_ports[i].irq);
  1406			serio_register_port(serio);
  1407			device_set_wakeup_capable(&serio->dev, true);
  1408	
  1409			/*
  1410			 * On platforms using suspend-to-idle by default, make the keyboard
  1411			 * wake up the system from sleep by enabling keyboard wakeups by
  1412			 * default.  That is consistent with keyboard wakeup behavior on
  1413			 * many platforms using suspend-to-RAM (ACPI S3) by default.
  1414			 */
> 1415			if (mem_sleep_current == PM_SUSPEND_TO_IDLE
  1416			    && i == I8042_KBD_PORT_NO)
  1417				device_set_wakeup_enable(&serio->dev, true);
  1418		}
  1419	}
  1420	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Sept. 11, 2018, 3:32 a.m. UTC | #2
Hi Daniel,

I love your patch! Yet something to improve:

[auto build test ERROR on input/next]
[also build test ERROR on v4.19-rc3 next-20180910]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Daniel-Drake/i8042-enable-keyboard-wakeups-by-default-when-s2idle-is-used/20180911-091924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   drivers/input/serio/i8042.c: In function 'i8042_register_ports':
>> drivers/input/serio/i8042.c:1415:7: error: 'mem_sleep_current' undeclared (first use in this function); did you mean 'rcu_sleep_check'?
      if (mem_sleep_current == PM_SUSPEND_TO_IDLE
          ^~~~~~~~~~~~~~~~~
          rcu_sleep_check
   drivers/input/serio/i8042.c:1415:7: note: each undeclared identifier is reported only once for each function it appears in

vim +1415 drivers/input/serio/i8042.c

  1390	
  1391	static void __init i8042_register_ports(void)
  1392	{
  1393		int i;
  1394	
  1395		for (i = 0; i < I8042_NUM_PORTS; i++) {
  1396			struct serio *serio = i8042_ports[i].serio;
  1397	
  1398			if (!serio)
  1399				continue;
  1400	
  1401			printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
  1402				serio->name,
  1403				(unsigned long) I8042_DATA_REG,
  1404				(unsigned long) I8042_COMMAND_REG,
  1405				i8042_ports[i].irq);
  1406			serio_register_port(serio);
  1407			device_set_wakeup_capable(&serio->dev, true);
  1408	
  1409			/*
  1410			 * On platforms using suspend-to-idle by default, make the keyboard
  1411			 * wake up the system from sleep by enabling keyboard wakeups by
  1412			 * default.  That is consistent with keyboard wakeup behavior on
  1413			 * many platforms using suspend-to-RAM (ACPI S3) by default.
  1414			 */
> 1415			if (mem_sleep_current == PM_SUSPEND_TO_IDLE
  1416			    && i == I8042_KBD_PORT_NO)
  1417				device_set_wakeup_enable(&serio->dev, true);
  1418		}
  1419	}
  1420	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index b8bc71569349..e2186a5fa489 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1395,15 +1395,26 @@  static void __init i8042_register_ports(void)
 	for (i = 0; i < I8042_NUM_PORTS; i++) {
 		struct serio *serio = i8042_ports[i].serio;
 
-		if (serio) {
-			printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
-				serio->name,
-				(unsigned long) I8042_DATA_REG,
-				(unsigned long) I8042_COMMAND_REG,
-				i8042_ports[i].irq);
-			serio_register_port(serio);
-			device_set_wakeup_capable(&serio->dev, true);
-		}
+		if (!serio)
+			continue;
+
+		printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n",
+			serio->name,
+			(unsigned long) I8042_DATA_REG,
+			(unsigned long) I8042_COMMAND_REG,
+			i8042_ports[i].irq);
+		serio_register_port(serio);
+		device_set_wakeup_capable(&serio->dev, true);
+
+		/*
+		 * On platforms using suspend-to-idle by default, make the keyboard
+		 * wake up the system from sleep by enabling keyboard wakeups by
+		 * default.  That is consistent with keyboard wakeup behavior on
+		 * many platforms using suspend-to-RAM (ACPI S3) by default.
+		 */
+		if (mem_sleep_current == PM_SUSPEND_TO_IDLE
+		    && i == I8042_KBD_PORT_NO)
+			device_set_wakeup_enable(&serio->dev, true);
 	}
 }