* [RFC] tty/sysrq: Add alternative SysRq key
@ 2021-11-03 15:54 Andrzej Pietrasiewicz
2021-11-03 16:19 ` Randy Dunlap
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-03 15:54 UTC (permalink / raw)
To: linux-kernel, linux-input
Cc: Greg Kroah-Hartman, Dmitry Torokhov, Jiri Slaby,
Andrzej Pietrasiewicz, kernel
There exist machines which don't have SysRq key at all, e.g. chromebooks.
This patch allows configuring an alternative key to act as SysRq. Devices
which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
but other devices use the alternative SysRq key instead, by default F10.
Which key is actually used can be modified with sysrq's module parameter.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
I'd like to resurrect an old thread regarding supporting alternative SysRq
key for machines which don't have a physical SysRq key at all.
The old thread:
https://www.spinics.net/lists/linux-input/msg67982.html
I'm resending this patch, rebased onto v5.15.
Any (new) thoughts about it?
drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index c911196ac893..6dd288e53ce9 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -634,6 +634,7 @@ EXPORT_SYMBOL(handle_sysrq);
#ifdef CONFIG_INPUT
static int sysrq_reset_downtime_ms;
+static unsigned short alternative_sysrq_key = KEY_F10;
/* Simple translation table for the SysRq keys */
static const unsigned char sysrq_xlate[KEY_CNT] =
@@ -653,6 +654,7 @@ struct sysrq_state {
unsigned int alt_use;
unsigned int shift;
unsigned int shift_use;
+ unsigned short sys
bool active;
bool need_reinject;
bool reinjecting;
@@ -802,10 +804,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
/* Simulate press and release of Alt + SysRq */
input_inject_event(handle, EV_KEY, alt_code, 1);
- input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
+ input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
- input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
+ input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
input_inject_event(handle, EV_KEY, alt_code, 0);
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
@@ -845,6 +847,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
sysrq->shift = code;
break;
+key_sysrq:
case KEY_SYSRQ:
if (value == 1 && sysrq->alt != KEY_RESERVED) {
sysrq->active = true;
@@ -867,11 +870,15 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
* triggering print screen function.
*/
if (sysrq->active)
- clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
+ clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
break;
default:
+ /* handle non-default sysrq key */
+ if (code == sysrq->sysrq_key)
+ goto key_sysrq;
+
if (sysrq->active && value && value != 2) {
unsigned char c = sysrq_xlate[code];
@@ -970,6 +977,14 @@ static int sysrq_connect(struct input_handler *handler,
sysrq->handle.private = sysrq;
timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
+ if (test_bit(KEY_SYSRQ, dev->keybit)) {
+ sysrq->sysrq_key = KEY_SYSRQ;
+ pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
+ } else {
+ sysrq->sysrq_key = alternative_sysrq_key;
+ pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
+ }
+
error = input_register_handle(&sysrq->handle);
if (error) {
pr_err("Failed to register input sysrq handler, error %d\n",
@@ -1078,6 +1093,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq,
module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
+module_param(alternative_sysrq_key, ushort, 0644);
+MODULE_PARM_DESC(alternative_sysrq_key,
+ "Alternative SysRq key for input devices that don't have SysRq key. F10 by default.\n"
+ "Example\n"
+ "Using F9 as SysRq:\n"
+ "sysrq.alternative_sysrq_key=0x43\n");
+
#else
static inline void sysrq_register_handler(void)
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-03 15:54 [RFC] tty/sysrq: Add alternative SysRq key Andrzej Pietrasiewicz
@ 2021-11-03 16:19 ` Randy Dunlap
2021-11-04 8:44 ` Andrzej Pietrasiewicz
2021-11-04 9:34 ` Andrzej Pietrasiewicz
2021-11-03 18:44 ` kernel test robot
2021-11-04 12:01 ` Pavel Machek
2 siblings, 2 replies; 16+ messages in thread
From: Randy Dunlap @ 2021-11-03 16:19 UTC (permalink / raw)
To: Andrzej Pietrasiewicz, linux-kernel, linux-input
Cc: Greg Kroah-Hartman, Dmitry Torokhov, Jiri Slaby, kernel
On 11/3/21 8:54 AM, Andrzej Pietrasiewicz wrote:
> There exist machines which don't have SysRq key at all, e.g. chromebooks.
>
> This patch allows configuring an alternative key to act as SysRq. Devices
> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
> but other devices use the alternative SysRq key instead, by default F10.
> Which key is actually used can be modified with sysrq's module parameter.
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> ---
> I'd like to resurrect an old thread regarding supporting alternative SysRq
> key for machines which don't have a physical SysRq key at all.
>
> The old thread:
>
> https://www.spinics.net/lists/linux-input/msg67982.html
>
> I'm resending this patch, rebased onto v5.15.
>
> Any (new) thoughts about it?
>
Hi,
Did you test it with this patch?
>
> drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index c911196ac893..6dd288e53ce9 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -634,6 +634,7 @@ EXPORT_SYMBOL(handle_sysrq);
>
> #ifdef CONFIG_INPUT
> static int sysrq_reset_downtime_ms;
> +static unsigned short alternative_sysrq_key = KEY_F10;
>
> /* Simple translation table for the SysRq keys */
> static const unsigned char sysrq_xlate[KEY_CNT] =
> @@ -653,6 +654,7 @@ struct sysrq_state {
> unsigned int alt_use;
> unsigned int shift;
> unsigned int shift_use;
> + unsigned short sys
That line appears to need an ending ';'.
Or maybe that line was truncated since 'sys' isn't used anywhere in this patch.
> bool active;
> bool need_reinject;
> bool reinjecting;
> @@ -802,10 +804,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
>
> /* Simulate press and release of Alt + SysRq */
> input_inject_event(handle, EV_KEY, alt_code, 1);
> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>
> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
> input_inject_event(handle, EV_KEY, alt_code, 0);
> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>
> @@ -845,6 +847,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
> sysrq->shift = code;
> break;
>
> +key_sysrq:
> case KEY_SYSRQ:
> if (value == 1 && sysrq->alt != KEY_RESERVED) {
> sysrq->active = true;
> @@ -867,11 +870,15 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
> * triggering print screen function.
> */
> if (sysrq->active)
> - clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
> + clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
>
> break;
>
> default:
> + /* handle non-default sysrq key */
> + if (code == sysrq->sysrq_key)
> + goto key_sysrq;
> +
> if (sysrq->active && value && value != 2) {
> unsigned char c = sysrq_xlate[code];
>
> @@ -970,6 +977,14 @@ static int sysrq_connect(struct input_handler *handler,
> sysrq->handle.private = sysrq;
> timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
>
> + if (test_bit(KEY_SYSRQ, dev->keybit)) {
> + sysrq->sysrq_key = KEY_SYSRQ;
> + pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
> + } else {
> + sysrq->sysrq_key = alternative_sysrq_key;
> + pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
> + }
> +
> error = input_register_handle(&sysrq->handle);
> if (error) {
> pr_err("Failed to register input sysrq handler, error %d\n",
> @@ -1078,6 +1093,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq,
>
> module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
>
> +module_param(alternative_sysrq_key, ushort, 0644);
> +MODULE_PARM_DESC(alternative_sysrq_key,
> + "Alternative SysRq key for input devices that don't have SysRq key. F10 by default.\n"
> + "Example\n"
> + "Using F9 as SysRq:\n"
> + "sysrq.alternative_sysrq_key=0x43\n");
> +
> #else
>
> static inline void sysrq_register_handler(void)
>
--
~Randy
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-03 15:54 [RFC] tty/sysrq: Add alternative SysRq key Andrzej Pietrasiewicz
2021-11-03 16:19 ` Randy Dunlap
@ 2021-11-03 18:44 ` kernel test robot
2021-11-04 12:01 ` Pavel Machek
2 siblings, 0 replies; 16+ messages in thread
From: kernel test robot @ 2021-11-03 18:44 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 44923 bytes --]
Hi Andrzej,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linux/master]
[also build test ERROR on hid/for-next linus/master v5.15 next-20211103]
[cannot apply to tty/tty-testing]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Andrzej-Pietrasiewicz/tty-sysrq-Add-alternative-SysRq-key/20211103-235630
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2f111a6fd5b5297b4e92f53798ca086f7c7d33a4
config: um-x86_64_defconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/ed36496ef4a480d6bc468152578cfb49a500e2dd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrzej-Pietrasiewicz/tty-sysrq-Add-alternative-SysRq-key/20211103-235630
git checkout ed36496ef4a480d6bc468152578cfb49a500e2dd
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=um SUBARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/tty/sysrq.c:658:2: error: expected ':', ',', ';', '}' or '__attribute__' before 'bool'
658 | bool active;
| ^~~~
drivers/tty/sysrq.c: In function 'sysrq_parse_reset_sequence':
>> drivers/tty/sysrq.c:682:7: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
682 | state->reset_seq_cnt = 0;
| ^~
>> drivers/tty/sysrq.c:690:23: error: 'struct sysrq_state' has no member named 'reset_keybit'
690 | __set_bit(key, state->reset_keybit);
| ^~
>> drivers/tty/sysrq.c:691:8: error: 'struct sysrq_state' has no member named 'reset_seq_len'
691 | state->reset_seq_len++;
| ^~
drivers/tty/sysrq.c:694:9: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
694 | state->reset_seq_cnt++;
| ^~
>> drivers/tty/sysrq.c:698:7: error: 'struct sysrq_state' has no member named 'reset_canceled'
698 | state->reset_canceled = state->reset_seq_cnt != 0;
| ^~
drivers/tty/sysrq.c:698:31: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
698 | state->reset_canceled = state->reset_seq_cnt != 0;
| ^~
>> drivers/tty/sysrq.c:700:7: error: 'struct sysrq_state' has no member named 'reset_seq_version'
700 | state->reset_seq_version = sysrq_reset_seq_version;
| ^~
In file included from <command-line>:
drivers/tty/sysrq.c: In function 'sysrq_do_reset':
>> include/linux/kernel.h:495:51: error: 'struct sysrq_state' has no member named 'keyreset_timer'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~
include/linux/compiler_types.h:302:9: note: in definition of macro '__compiletime_assert'
302 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:322:2: note: in expansion of macro '_compiletime_assert'
322 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:495:20: note: in expansion of macro '__same_type'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~
include/linux/timer.h:154:2: note: in expansion of macro 'container_of'
154 | container_of(callback_timer, typeof(*var), timer_fieldname)
| ^~~~~~~~~~~~
drivers/tty/sysrq.c:705:30: note: in expansion of macro 'from_timer'
705 | struct sysrq_state *state = from_timer(state, t, keyreset_timer);
| ^~~~~~~~~~
>> include/linux/compiler_types.h:140:35: error: 'struct sysrq_state' has no member named 'keyreset_timer'
140 | #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
| ^~~~~~~~~~~~~~~~~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:498:21: note: in expansion of macro 'offsetof'
498 | ((type *)(__mptr - offsetof(type, member))); })
| ^~~~~~~~
include/linux/timer.h:154:2: note: in expansion of macro 'container_of'
154 | container_of(callback_timer, typeof(*var), timer_fieldname)
| ^~~~~~~~~~~~
drivers/tty/sysrq.c:705:30: note: in expansion of macro 'from_timer'
705 | struct sysrq_state *state = from_timer(state, t, keyreset_timer);
| ^~~~~~~~~~
>> drivers/tty/sysrq.c:707:7: error: 'struct sysrq_state' has no member named 'reset_requested'
707 | state->reset_requested = true;
| ^~
drivers/tty/sysrq.c: In function 'sysrq_handle_reset_request':
drivers/tty/sysrq.c:714:11: error: 'struct sysrq_state' has no member named 'reset_requested'
714 | if (state->reset_requested)
| ^~
>> drivers/tty/sysrq.c:718:19: error: 'struct sysrq_state' has no member named 'keyreset_timer'
718 | mod_timer(&state->keyreset_timer,
| ^~
drivers/tty/sysrq.c:721:24: error: 'struct sysrq_state' has no member named 'keyreset_timer'
721 | sysrq_do_reset(&state->keyreset_timer);
| ^~
drivers/tty/sysrq.c: In function 'sysrq_detect_reset_sequence':
drivers/tty/sysrq.c:727:27: error: 'struct sysrq_state' has no member named 'reset_keybit'
727 | if (!test_bit(code, state->reset_keybit)) {
| ^~
drivers/tty/sysrq.c:734:21: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
734 | if (value && state->reset_seq_cnt) {
| ^~
drivers/tty/sysrq.c:735:9: error: 'struct sysrq_state' has no member named 'reset_canceled'
735 | state->reset_canceled = true;
| ^~
drivers/tty/sysrq.c:736:20: error: 'struct sysrq_state' has no member named 'keyreset_timer'
736 | del_timer(&state->keyreset_timer);
| ^~
drivers/tty/sysrq.c:744:19: error: 'struct sysrq_state' has no member named 'keyreset_timer'
744 | del_timer(&state->keyreset_timer);
| ^~
drivers/tty/sysrq.c:746:14: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
746 | if (--state->reset_seq_cnt == 0)
| ^~
drivers/tty/sysrq.c:747:9: error: 'struct sysrq_state' has no member named 'reset_canceled'
747 | state->reset_canceled = false;
| ^~
drivers/tty/sysrq.c:750:14: error: 'struct sysrq_state' has no member named 'reset_seq_cnt'
750 | if (++state->reset_seq_cnt == state->reset_seq_len &&
| ^~
drivers/tty/sysrq.c:750:38: error: 'struct sysrq_state' has no member named 'reset_seq_len'
750 | if (++state->reset_seq_cnt == state->reset_seq_len &&
| ^~
drivers/tty/sysrq.c:751:13: error: 'struct sysrq_state' has no member named 'reset_canceled'
751 | !state->reset_canceled) {
| ^~
drivers/tty/sysrq.c: In function 'sysrq_reinject_alt_sysrq':
>> drivers/tty/sysrq.c:800:11: error: 'struct sysrq_state' has no member named 'need_reinject'
800 | if (sysrq->need_reinject) {
| ^~
>> drivers/tty/sysrq.c:802:10: error: 'struct sysrq_state' has no member named 'reinjecting'; did you mean 'reinject_work'?
802 | sysrq->reinjecting = true;
| ^~~~~~~~~~~
| reinject_work
>> drivers/tty/sysrq.c:807:43: error: 'struct sysrq_state' has no member named 'sysrq_key'
807 | input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
| ^~
drivers/tty/sysrq.c:810:43: error: 'struct sysrq_state' has no member named 'sysrq_key'
810 | input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
| ^~
drivers/tty/sysrq.c:815:10: error: 'struct sysrq_state' has no member named 'reinjecting'; did you mean 'reinject_work'?
815 | sysrq->reinjecting = false;
| ^~~~~~~~~~~
| reinject_work
drivers/tty/sysrq.c: In function 'sysrq_handle_keypress':
>> drivers/tty/sysrq.c:822:25: error: 'struct sysrq_state' has no member named 'active'
822 | bool was_active = sysrq->active;
| ^~
drivers/tty/sysrq.c:831:13: error: 'struct sysrq_state' has no member named 'active'
831 | if (sysrq->active && code == sysrq->alt_use)
| ^~
drivers/tty/sysrq.c:832:10: error: 'struct sysrq_state' has no member named 'active'
832 | sysrq->active = false;
| ^~
drivers/tty/sysrq.c:838:9: error: 'struct sysrq_state' has no member named 'need_reinject'
838 | sysrq->need_reinject = false;
| ^~
drivers/tty/sysrq.c:853:9: error: 'struct sysrq_state' has no member named 'active'
853 | sysrq->active = true;
| ^~
drivers/tty/sysrq.c:861:9: error: 'struct sysrq_state' has no member named 'need_reinject'
861 | sysrq->need_reinject = true;
| ^~
drivers/tty/sysrq.c:872:12: error: 'struct sysrq_state' has no member named 'active'
872 | if (sysrq->active)
| ^~
drivers/tty/sysrq.c:873:19: error: 'struct sysrq_state' has no member named 'sysrq_key'
873 | clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
| ^~
drivers/tty/sysrq.c:879:20: error: 'struct sysrq_state' has no member named 'sysrq_key'
879 | if (code == sysrq->sysrq_key)
| ^~
drivers/tty/sysrq.c:882:12: error: 'struct sysrq_state' has no member named 'active'
882 | if (sysrq->active && value && value != 2) {
| ^~
drivers/tty/sysrq.c:885:9: error: 'struct sysrq_state' has no member named 'need_reinject'
885 | sysrq->need_reinject = false;
| ^~
drivers/tty/sysrq.c:893:18: error: 'struct sysrq_state' has no member named 'active'
893 | suppress = sysrq->active;
| ^~
drivers/tty/sysrq.c:895:12: error: 'struct sysrq_state' has no member named 'active'
895 | if (!sysrq->active) {
| ^~
drivers/tty/sysrq.c:900:12: error: 'struct sysrq_state' has no member named 'reset_seq_version'
900 | if (sysrq->reset_seq_version != sysrq_reset_seq_version)
| ^~
drivers/tty/sysrq.c: In function 'sysrq_filter':
drivers/tty/sysrq.c:940:13: error: 'struct sysrq_state' has no member named 'reinjecting'; did you mean 'reinject_work'?
940 | if (sysrq->reinjecting)
| ^~~~~~~~~~~
| reinject_work
drivers/tty/sysrq.c:954:19: error: 'struct sysrq_state' has no member named 'active'
954 | suppress = sysrq->active;
| ^~
In file included from include/linux/workqueue.h:9,
from include/linux/rhashtable-types.h:15,
from include/linux/ipc.h:7,
from include/uapi/linux/sem.h:5,
from include/linux/sem.h:5,
from include/linux/sched.h:15,
from include/linux/sched/signal.h:7,
from drivers/tty/sysrq.c:18:
drivers/tty/sysrq.c: In function 'sysrq_connect':
drivers/tty/sysrq.c:978:20: error: 'struct sysrq_state' has no member named 'keyreset_timer'
978 | timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
| ^~
include/linux/timer.h:126:18: note: in definition of macro '__init_timer'
126 | init_timer_key((_timer), (_fn), (_flags), NULL, NULL)
| ^~~~~~
drivers/tty/sysrq.c:978:2: note: in expansion of macro 'timer_setup'
978 | timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
| ^~~~~~~~~~~
drivers/tty/sysrq.c:981:8: error: 'struct sysrq_state' has no member named 'sysrq_key'
981 | sysrq->sysrq_key = KEY_SYSRQ;
| ^~
drivers/tty/sysrq.c:984:8: error: 'struct sysrq_state' has no member named 'sysrq_key'
984 | sysrq->sysrq_key = alternative_sysrq_key;
| ^~
In file included from include/linux/kernel.h:19,
from include/linux/list.h:9,
from include/linux/rculist.h:10,
from include/linux/sched/signal.h:5,
from drivers/tty/sysrq.c:18:
drivers/tty/sysrq.c:985:70: error: 'struct sysrq_state' has no member named 'sysrq_key'
985 | pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
| ^~
include/linux/printk.h:418:19: note: in definition of macro 'printk_index_wrap'
418 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/printk.h:519:2: note: in expansion of macro 'printk'
519 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~
drivers/tty/sysrq.c:985:3: note: in expansion of macro 'pr_info'
985 | pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
| ^~~~~~~
In file included from include/linux/workqueue.h:9,
from include/linux/rhashtable-types.h:15,
from include/linux/ipc.h:7,
from include/uapi/linux/sem.h:5,
from include/linux/sem.h:5,
from include/linux/sched.h:15,
from include/linux/sched/signal.h:7,
from drivers/tty/sysrq.c:18:
drivers/tty/sysrq.c: In function 'sysrq_disconnect':
drivers/tty/sysrq.c:1016:23: error: 'struct sysrq_state' has no member named 'keyreset_timer'
vim +658 drivers/tty/sysrq.c
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 638
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 639 /* Simple translation table for the SysRq keys */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 640 static const unsigned char sysrq_xlate[KEY_CNT] =
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 641 "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 642 "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 643 "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 644 "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 645 "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 646 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 647 "\r\000/"; /* 0x60 - 0x6f */
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 648
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 649 struct sysrq_state {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 650 struct input_handle handle;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 651 struct work_struct reinject_work;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 652 unsigned long key_down[BITS_TO_LONGS(KEY_CNT)];
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 653 unsigned int alt;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 654 unsigned int alt_use;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 655 unsigned int shift;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 656 unsigned int shift_use;
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 657 unsigned short sys
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 @658 bool active;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 659 bool need_reinject;
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 660 bool reinjecting;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 661
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 662 /* reset sequence handling */
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 663 bool reset_canceled;
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 664 bool reset_requested;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 665 unsigned long reset_keybit[BITS_TO_LONGS(KEY_CNT)];
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 666 int reset_seq_len;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 667 int reset_seq_cnt;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 668 int reset_seq_version;
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 669 struct timer_list keyreset_timer;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 670 };
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 671
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 672 #define SYSRQ_KEY_RESET_MAX 20 /* Should be plenty */
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 673 static unsigned short sysrq_reset_seq[SYSRQ_KEY_RESET_MAX];
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 674 static unsigned int sysrq_reset_seq_len;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 675 static unsigned int sysrq_reset_seq_version = 1;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 676
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 677 static void sysrq_parse_reset_sequence(struct sysrq_state *state)
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 678 {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 679 int i;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 680 unsigned short key;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 681
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 @682 state->reset_seq_cnt = 0;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 683
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 684 for (i = 0; i < sysrq_reset_seq_len; i++) {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 685 key = sysrq_reset_seq[i];
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 686
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 687 if (key == KEY_RESERVED || key > KEY_MAX)
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 688 break;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 689
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 @690 __set_bit(key, state->reset_keybit);
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 @691 state->reset_seq_len++;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 692
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 693 if (test_bit(key, state->key_down))
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 694 state->reset_seq_cnt++;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 695 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 696
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 697 /* Disable reset until old keys are not released */
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 @698 state->reset_canceled = state->reset_seq_cnt != 0;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 699
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 @700 state->reset_seq_version = sysrq_reset_seq_version;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 701 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 702
8c318fa93dfcd1 drivers/tty/sysrq.c Kees Cook 2017-10-16 703 static void sysrq_do_reset(struct timer_list *t)
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 704 {
8c318fa93dfcd1 drivers/tty/sysrq.c Kees Cook 2017-10-16 705 struct sysrq_state *state = from_timer(state, t, keyreset_timer);
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 706
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 @707 state->reset_requested = true;
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 708
8fefbc6d4b2660 drivers/tty/sysrq.c Mark Tomlinson 2018-11-27 709 orderly_reboot();
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 710 }
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 711
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 712 static void sysrq_handle_reset_request(struct sysrq_state *state)
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 713 {
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 714 if (state->reset_requested)
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 715 __handle_sysrq(sysrq_xlate[KEY_B], false);
3d289517dfd48f drivers/tty/sysrq.c Mathieu J. Poirier 2013-06-05 716
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 717 if (sysrq_reset_downtime_ms)
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 @718 mod_timer(&state->keyreset_timer,
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 719 jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms));
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 720 else
8c318fa93dfcd1 drivers/tty/sysrq.c Kees Cook 2017-10-16 721 sysrq_do_reset(&state->keyreset_timer);
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 722 }
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 723
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 724 static void sysrq_detect_reset_sequence(struct sysrq_state *state,
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 725 unsigned int code, int value)
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 726 {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 727 if (!test_bit(code, state->reset_keybit)) {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 728 /*
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 729 * Pressing any key _not_ in reset sequence cancels
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 730 * the reset sequence. Also cancelling the timer in
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 731 * case additional keys were pressed after a reset
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 732 * has been requested.
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 733 */
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 734 if (value && state->reset_seq_cnt) {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 735 state->reset_canceled = true;
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 736 del_timer(&state->keyreset_timer);
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 737 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 738 } else if (value == 0) {
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 739 /*
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 740 * Key release - all keys in the reset sequence need
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 741 * to be pressed and held for the reset timeout
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 742 * to hold.
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 743 */
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 744 del_timer(&state->keyreset_timer);
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 745
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 746 if (--state->reset_seq_cnt == 0)
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 747 state->reset_canceled = false;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 748 } else if (value == 1) {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 749 /* key press, not autorepeat */
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 750 if (++state->reset_seq_cnt == state->reset_seq_len &&
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 751 !state->reset_canceled) {
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 752 sysrq_handle_reset_request(state);
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 753 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 754 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 755 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 756
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 757 #ifdef CONFIG_OF
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 758 static void sysrq_of_get_keyreset_config(void)
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 759 {
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 760 u32 key;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 761 struct device_node *np;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 762 struct property *prop;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 763 const __be32 *p;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 764
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 765 np = of_find_node_by_path("/chosen/linux,sysrq-reset-seq");
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 766 if (!np) {
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 767 pr_debug("No sysrq node found");
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 768 return;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 769 }
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 770
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 771 /* Reset in case a __weak definition was present */
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 772 sysrq_reset_seq_len = 0;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 773
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 774 of_property_for_each_u32(np, "keyset", prop, p, key) {
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 775 if (key == KEY_RESERVED || key > KEY_MAX ||
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 776 sysrq_reset_seq_len == SYSRQ_KEY_RESET_MAX)
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 777 break;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 778
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 779 sysrq_reset_seq[sysrq_reset_seq_len++] = (unsigned short)key;
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 780 }
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 781
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 782 /* Get reset timeout if any. */
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 783 of_property_read_u32(np, "timeout-ms", &sysrq_reset_downtime_ms);
279070b96a5a08 drivers/tty/sysrq.c Yangtao Li 2018-11-21 784
279070b96a5a08 drivers/tty/sysrq.c Yangtao Li 2018-11-21 785 of_node_put(np);
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 786 }
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 787 #else
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 788 static void sysrq_of_get_keyreset_config(void)
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 789 {
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 790 }
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 791 #endif
4c076eb0cfd9fa drivers/tty/sysrq.c Mathieu J. Poirier 2013-08-03 792
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 793 static void sysrq_reinject_alt_sysrq(struct work_struct *work)
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 794 {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 795 struct sysrq_state *sysrq =
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 796 container_of(work, struct sysrq_state, reinject_work);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 797 struct input_handle *handle = &sysrq->handle;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 798 unsigned int alt_code = sysrq->alt_use;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 799
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 @800 if (sysrq->need_reinject) {
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 801 /* we do not want the assignment to be reordered */
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 @802 sysrq->reinjecting = true;
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 803 mb();
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 804
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 805 /* Simulate press and release of Alt + SysRq */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 806 input_inject_event(handle, EV_KEY, alt_code, 1);
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 @807 input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 808 input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 809
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 810 input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 811 input_inject_event(handle, EV_KEY, alt_code, 0);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 812 input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 813
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 814 mb();
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 815 sysrq->reinjecting = false;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 816 }
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 817 }
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 818
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 819 static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 820 unsigned int code, int value)
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 821 {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 @822 bool was_active = sysrq->active;
1966cb225c6f90 drivers/char/sysrq.c Dmitry Torokhov 2010-09-29 823 bool suppress;
1966cb225c6f90 drivers/char/sysrq.c Dmitry Torokhov 2010-09-29 824
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 825 switch (code) {
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 826
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 827 case KEY_LEFTALT:
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 828 case KEY_RIGHTALT:
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 829 if (!value) {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 830 /* One of ALTs is being released */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 831 if (sysrq->active && code == sysrq->alt_use)
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 832 sysrq->active = false;
f5dec51172b81d drivers/char/sysrq.c Dmitry Torokhov 2010-06-09 833
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 834 sysrq->alt = KEY_RESERVED;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 835
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 836 } else if (value != 2) {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 837 sysrq->alt = code;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 838 sysrq->need_reinject = false;
f5dec51172b81d drivers/char/sysrq.c Dmitry Torokhov 2010-06-09 839 }
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 840 break;
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 841
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 842 case KEY_LEFTSHIFT:
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 843 case KEY_RIGHTSHIFT:
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 844 if (!value)
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 845 sysrq->shift = KEY_RESERVED;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 846 else if (value != 2)
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 847 sysrq->shift = code;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 848 break;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 849
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 850 key_sysrq:
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 851 case KEY_SYSRQ:
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 852 if (value == 1 && sysrq->alt != KEY_RESERVED) {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 853 sysrq->active = true;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 854 sysrq->alt_use = sysrq->alt;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 855 /* either RESERVED (for released) or actual code */
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 856 sysrq->shift_use = sysrq->shift;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 857 /*
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 858 * If nothing else will be pressed we'll need
7ab7b5adfb9239 drivers/char/sysrq.c Dmitry Torokhov 2011-02-02 859 * to re-inject Alt-SysRq keysroke.
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 860 */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 861 sysrq->need_reinject = true;
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 862 }
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 863
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 864 /*
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 865 * Pretend that sysrq was never pressed at all. This
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 866 * is needed to properly handle KGDB which will try
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 867 * to release all keys after exiting debugger. If we
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 868 * do not clear key bit it KGDB will end up sending
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 869 * release events for Alt and SysRq, potentially
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 870 * triggering print screen function.
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 871 */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 872 if (sysrq->active)
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 873 clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 874
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 875 break;
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 876
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 877 default:
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 878 /* handle non-default sysrq key */
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 879 if (code == sysrq->sysrq_key)
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 880 goto key_sysrq;
ed36496ef4a480 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2021-11-03 881
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 882 if (sysrq->active && value && value != 2) {
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 883 unsigned char c = sysrq_xlate[code];
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 884
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 885 sysrq->need_reinject = false;
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 886 if (sysrq->shift_use != KEY_RESERVED)
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 887 c = toupper(c);
a27eb0cb4b2104 drivers/tty/sysrq.c Andrzej Pietrasiewicz 2020-08-18 888 __handle_sysrq(c, true);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 889 }
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 890 break;
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 891 }
97f5f0cd8cd0a0 drivers/char/sysrq.c Dmitry Torokhov 2010-03-21 892
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 893 suppress = sysrq->active;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 894
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 895 if (!sysrq->active) {
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 896
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 897 /*
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 898 * See if reset sequence has changed since the last time.
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 899 */
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 900 if (sysrq->reset_seq_version != sysrq_reset_seq_version)
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 901 sysrq_parse_reset_sequence(sysrq);
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 902
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 903 /*
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 904 * If we are not suppressing key presses keep track of
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 905 * keyboard state so we can release keys that have been
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 906 * pressed before entering SysRq mode.
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 907 */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 908 if (value)
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 909 set_bit(code, sysrq->key_down);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 910 else
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 911 clear_bit(code, sysrq->key_down);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 912
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 913 if (was_active)
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 914 schedule_work(&sysrq->reinject_work);
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 915
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 916 /* Check for reset sequence */
3903078677a8dc drivers/tty/sysrq.c Mathieu J. Poirier 2013-04-01 917 sysrq_detect_reset_sequence(sysrq, code, value);
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 918
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 919 } else if (value == 0 && test_and_clear_bit(code, sysrq->key_down)) {
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 920 /*
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 921 * Pass on release events for keys that was pressed before
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 922 * entering SysRq mode.
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 923 */
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 924 suppress = false;
fcb7193096969c drivers/char/sysrq.c Dmitry Torokhov 2010-11-15 925 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 926
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 927 return suppress;
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 928 }
154b7a489a5b1d drivers/tty/sysrq.c Mathieu Poirier 2013-01-06 929
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 9705 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-03 16:19 ` Randy Dunlap
@ 2021-11-04 8:44 ` Andrzej Pietrasiewicz
2021-11-04 9:34 ` Andrzej Pietrasiewicz
1 sibling, 0 replies; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-04 8:44 UTC (permalink / raw)
To: Randy Dunlap, linux-kernel, linux-input
Cc: Greg Kroah-Hartman, Dmitry Torokhov, Jiri Slaby, kernel
Hi Randy,
W dniu 03.11.2021 o 17:19, Randy Dunlap pisze:
> On 11/3/21 8:54 AM, Andrzej Pietrasiewicz wrote:
>> There exist machines which don't have SysRq key at all, e.g. chromebooks.
>>
>> This patch allows configuring an alternative key to act as SysRq. Devices
>> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
>> but other devices use the alternative SysRq key instead, by default F10.
>> Which key is actually used can be modified with sysrq's module parameter.
>>
>> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>> ---
>> I'd like to resurrect an old thread regarding supporting alternative SysRq
>> key for machines which don't have a physical SysRq key at all.
>>
>> The old thread:
>>
>> https://www.spinics.net/lists/linux-input/msg67982.html
>>
>> I'm resending this patch, rebased onto v5.15.
>>
>> Any (new) thoughts about it?
>>
>
> Hi,
> Did you test it with this patch?
Thanks... I must have sent an incorrect version (with incomplete
conflict resolution).
Andrzej
>
>
>>
>> drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
>> 1 file changed, 25 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
>> index c911196ac893..6dd288e53ce9 100644
>> --- a/drivers/tty/sysrq.c
>> +++ b/drivers/tty/sysrq.c
>> @@ -634,6 +634,7 @@ EXPORT_SYMBOL(handle_sysrq);
>> #ifdef CONFIG_INPUT
>> static int sysrq_reset_downtime_ms;
>> +static unsigned short alternative_sysrq_key = KEY_F10;
>> /* Simple translation table for the SysRq keys */
>> static const unsigned char sysrq_xlate[KEY_CNT] =
>> @@ -653,6 +654,7 @@ struct sysrq_state {
>> unsigned int alt_use;
>> unsigned int shift;
>> unsigned int shift_use;
>> + unsigned short sys
>
> That line appears to need an ending ';'.
> Or maybe that line was truncated since 'sys' isn't used anywhere in this patch.
>
>> bool active;
>> bool need_reinject;
>> bool reinjecting;
>> @@ -802,10 +804,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct
>> *work)
>> /* Simulate press and release of Alt + SysRq */
>> input_inject_event(handle, EV_KEY, alt_code, 1);
>> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
>> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
>> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
>> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
>> input_inject_event(handle, EV_KEY, alt_code, 0);
>> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>> @@ -845,6 +847,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
>> sysrq->shift = code;
>> break;
>> +key_sysrq:
>> case KEY_SYSRQ:
>> if (value == 1 && sysrq->alt != KEY_RESERVED) {
>> sysrq->active = true;
>> @@ -867,11 +870,15 @@ static bool sysrq_handle_keypress(struct sysrq_state
>> *sysrq,
>> * triggering print screen function.
>> */
>> if (sysrq->active)
>> - clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
>> + clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
>> break;
>> default:
>> + /* handle non-default sysrq key */
>> + if (code == sysrq->sysrq_key)
>> + goto key_sysrq;
>> +
>> if (sysrq->active && value && value != 2) {
>> unsigned char c = sysrq_xlate[code];
>> @@ -970,6 +977,14 @@ static int sysrq_connect(struct input_handler *handler,
>> sysrq->handle.private = sysrq;
>> timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
>> + if (test_bit(KEY_SYSRQ, dev->keybit)) {
>> + sysrq->sysrq_key = KEY_SYSRQ;
>> + pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
>> + } else {
>> + sysrq->sysrq_key = alternative_sysrq_key;
>> + pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name,
>> sysrq->sysrq_key);
>> + }
>> +
>> error = input_register_handle(&sysrq->handle);
>> if (error) {
>> pr_err("Failed to register input sysrq handler, error %d\n",
>> @@ -1078,6 +1093,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq,
>> sysrq_reset_seq,
>> module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
>> +module_param(alternative_sysrq_key, ushort, 0644);
>> +MODULE_PARM_DESC(alternative_sysrq_key,
>> + "Alternative SysRq key for input devices that don't have SysRq key. F10
>> by default.\n"
>> + "Example\n"
>> + "Using F9 as SysRq:\n"
>> + "sysrq.alternative_sysrq_key=0x43\n");
>> +
>> #else
>> static inline void sysrq_register_handler(void)
>>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC] tty/sysrq: Add alternative SysRq key
2021-11-03 16:19 ` Randy Dunlap
2021-11-04 8:44 ` Andrzej Pietrasiewicz
@ 2021-11-04 9:34 ` Andrzej Pietrasiewicz
2021-11-04 9:52 ` Greg Kroah-Hartman
1 sibling, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-04 9:34 UTC (permalink / raw)
To: linux-kernel, linux-input
Cc: Greg Kroah-Hartman, Dmitry Torokhov, Jiri Slaby,
Andrzej Pietrasiewicz, kernel
There exist machines which don't have SysRq key at all, e.g. chromebooks.
This patch allows configuring an alternative key to act as SysRq. Devices
which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
but other devices use the alternative SysRq key instead, by default F10.
Which key is actually used can be modified with sysrq's module parameter.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
A corrected version with completed conflict resolution.
drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index c911196ac893..fb59745b23c9 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -634,6 +634,7 @@ EXPORT_SYMBOL(handle_sysrq);
#ifdef CONFIG_INPUT
static int sysrq_reset_downtime_ms;
+static unsigned short alternative_sysrq_key = KEY_F10;
/* Simple translation table for the SysRq keys */
static const unsigned char sysrq_xlate[KEY_CNT] =
@@ -653,6 +654,7 @@ struct sysrq_state {
unsigned int alt_use;
unsigned int shift;
unsigned int shift_use;
+ unsigned short sysrq_key;
bool active;
bool need_reinject;
bool reinjecting;
@@ -802,10 +804,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
/* Simulate press and release of Alt + SysRq */
input_inject_event(handle, EV_KEY, alt_code, 1);
- input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
+ input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
- input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
+ input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
input_inject_event(handle, EV_KEY, alt_code, 0);
input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
@@ -845,6 +847,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
sysrq->shift = code;
break;
+key_sysrq:
case KEY_SYSRQ:
if (value == 1 && sysrq->alt != KEY_RESERVED) {
sysrq->active = true;
@@ -867,11 +870,15 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
* triggering print screen function.
*/
if (sysrq->active)
- clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
+ clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
break;
default:
+ /* handle non-default sysrq key */
+ if (code == sysrq->sysrq_key)
+ goto key_sysrq;
+
if (sysrq->active && value && value != 2) {
unsigned char c = sysrq_xlate[code];
@@ -970,6 +977,14 @@ static int sysrq_connect(struct input_handler *handler,
sysrq->handle.private = sysrq;
timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
+ if (test_bit(KEY_SYSRQ, dev->keybit)) {
+ sysrq->sysrq_key = KEY_SYSRQ;
+ pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
+ } else {
+ sysrq->sysrq_key = alternative_sysrq_key;
+ pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
+ }
+
error = input_register_handle(&sysrq->handle);
if (error) {
pr_err("Failed to register input sysrq handler, error %d\n",
@@ -1078,6 +1093,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq,
module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
+module_param(alternative_sysrq_key, ushort, 0644);
+MODULE_PARM_DESC(alternative_sysrq_key,
+ "Alternative SysRq key for input devices that don't have SysRq key. F10 by default.\n"
+ "Example\n"
+ "Using F9 as SysRq:\n"
+ "sysrq.alternative_sysrq_key=0x43\n");
+
#else
static inline void sysrq_register_handler(void)
--
2.17.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 9:34 ` Andrzej Pietrasiewicz
@ 2021-11-04 9:52 ` Greg Kroah-Hartman
0 siblings, 0 replies; 16+ messages in thread
From: Greg Kroah-Hartman @ 2021-11-04 9:52 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: linux-kernel, linux-input, Dmitry Torokhov, Jiri Slaby, kernel
On Thu, Nov 04, 2021 at 10:34:29AM +0100, Andrzej Pietrasiewicz wrote:
> There exist machines which don't have SysRq key at all, e.g. chromebooks.
>
> This patch allows configuring an alternative key to act as SysRq. Devices
> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
> but other devices use the alternative SysRq key instead, by default F10.
> Which key is actually used can be modified with sysrq's module parameter.
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> ---
>
>
> A corrected version with completed conflict resolution.
>
>
>
> drivers/tty/sysrq.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index c911196ac893..fb59745b23c9 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -634,6 +634,7 @@ EXPORT_SYMBOL(handle_sysrq);
>
> #ifdef CONFIG_INPUT
> static int sysrq_reset_downtime_ms;
> +static unsigned short alternative_sysrq_key = KEY_F10;
>
> /* Simple translation table for the SysRq keys */
> static const unsigned char sysrq_xlate[KEY_CNT] =
> @@ -653,6 +654,7 @@ struct sysrq_state {
> unsigned int alt_use;
> unsigned int shift;
> unsigned int shift_use;
> + unsigned short sysrq_key;
> bool active;
> bool need_reinject;
> bool reinjecting;
> @@ -802,10 +804,10 @@ static void sysrq_reinject_alt_sysrq(struct work_struct *work)
>
> /* Simulate press and release of Alt + SysRq */
> input_inject_event(handle, EV_KEY, alt_code, 1);
> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 1);
> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 1);
> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>
> - input_inject_event(handle, EV_KEY, KEY_SYSRQ, 0);
> + input_inject_event(handle, EV_KEY, sysrq->sysrq_key, 0);
> input_inject_event(handle, EV_KEY, alt_code, 0);
> input_inject_event(handle, EV_SYN, SYN_REPORT, 1);
>
> @@ -845,6 +847,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
> sysrq->shift = code;
> break;
>
> +key_sysrq:
> case KEY_SYSRQ:
> if (value == 1 && sysrq->alt != KEY_RESERVED) {
> sysrq->active = true;
> @@ -867,11 +870,15 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
> * triggering print screen function.
> */
> if (sysrq->active)
> - clear_bit(KEY_SYSRQ, sysrq->handle.dev->key);
> + clear_bit(sysrq->sysrq_key, sysrq->handle.dev->key);
>
> break;
>
> default:
> + /* handle non-default sysrq key */
> + if (code == sysrq->sysrq_key)
> + goto key_sysrq;
> +
> if (sysrq->active && value && value != 2) {
> unsigned char c = sysrq_xlate[code];
>
> @@ -970,6 +977,14 @@ static int sysrq_connect(struct input_handler *handler,
> sysrq->handle.private = sysrq;
> timer_setup(&sysrq->keyreset_timer, sysrq_do_reset, 0);
>
> + if (test_bit(KEY_SYSRQ, dev->keybit)) {
> + sysrq->sysrq_key = KEY_SYSRQ;
> + pr_info("%s: using default sysrq key [%x]\n", dev->name, KEY_SYSRQ);
> + } else {
> + sysrq->sysrq_key = alternative_sysrq_key;
> + pr_info("%s: Using alternative sysrq key: [%x]\n", dev->name, sysrq->sysrq_key);
> + }
> +
> error = input_register_handle(&sysrq->handle);
> if (error) {
> pr_err("Failed to register input sysrq handler, error %d\n",
> @@ -1078,6 +1093,13 @@ module_param_array_named(reset_seq, sysrq_reset_seq, sysrq_reset_seq,
>
> module_param_named(sysrq_downtime_ms, sysrq_reset_downtime_ms, int, 0644);
>
> +module_param(alternative_sysrq_key, ushort, 0644);
> +MODULE_PARM_DESC(alternative_sysrq_key,
> + "Alternative SysRq key for input devices that don't have SysRq key. F10 by default.\n"
> + "Example\n"
> + "Using F9 as SysRq:\n"
> + "sysrq.alternative_sysrq_key=0x43\n");
> +
> #else
>
> static inline void sysrq_register_handler(void)
> --
> 2.17.1
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/SubmittingPatches for what needs to be done
here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-03 15:54 [RFC] tty/sysrq: Add alternative SysRq key Andrzej Pietrasiewicz
2021-11-03 16:19 ` Randy Dunlap
2021-11-03 18:44 ` kernel test robot
@ 2021-11-04 12:01 ` Pavel Machek
2021-11-04 12:21 ` Andrzej Pietrasiewicz
2 siblings, 1 reply; 16+ messages in thread
From: Pavel Machek @ 2021-11-04 12:01 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: linux-kernel, linux-input, Greg Kroah-Hartman, Dmitry Torokhov,
Jiri Slaby, kernel
[-- Attachment #1: Type: text/plain, Size: 602 bytes --]
Hi!
> There exist machines which don't have SysRq key at all, e.g. chromebooks.
>
> This patch allows configuring an alternative key to act as SysRq. Devices
> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
> but other devices use the alternative SysRq key instead, by default F10.
> Which key is actually used can be modified with sysrq's module
> parameter.
Is F10 sensible default? Would it make sense to use something like
alt-shift-esc so that this can be enabled by default?
Best regards,
Pavel
--
http://www.livejournal.com/~pavelmachek
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 12:01 ` Pavel Machek
@ 2021-11-04 12:21 ` Andrzej Pietrasiewicz
2021-11-04 13:07 ` Maciej W. Rozycki
0 siblings, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-04 12:21 UTC (permalink / raw)
To: Pavel Machek
Cc: linux-kernel, linux-input, Greg Kroah-Hartman, Dmitry Torokhov,
Jiri Slaby, kernel
Hi Pavel,
W dniu 04.11.2021 o 13:01, Pavel Machek pisze:
> Hi!
>
>> There exist machines which don't have SysRq key at all, e.g. chromebooks.
>>
>> This patch allows configuring an alternative key to act as SysRq. Devices
>> which declare KEY_SYSRQ in their 'keybit' bitmap continue using KEY_SYSRQ,
>> but other devices use the alternative SysRq key instead, by default F10.
>> Which key is actually used can be modified with sysrq's module
>> parameter.
>
> Is F10 sensible default? Would it make sense to use something like
> alt-shift-esc so that this can be enabled by default?
Why "alt-shift-esc" could be enabled by default? Do you mean to enable it for
all systems regardless of whether they declare or don't declare KEY_SYSRQ
in their 'keybit' bitmap?
Andrzej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 12:21 ` Andrzej Pietrasiewicz
@ 2021-11-04 13:07 ` Maciej W. Rozycki
2021-11-04 13:13 ` Maciej W. Rozycki
0 siblings, 1 reply; 16+ messages in thread
From: Maciej W. Rozycki @ 2021-11-04 13:07 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: Pavel Machek, linux-kernel, linux-input, Greg Kroah-Hartman,
Dmitry Torokhov, Jiri Slaby, kernel
On Thu, 4 Nov 2021, Andrzej Pietrasiewicz wrote:
> > Is F10 sensible default? Would it make sense to use something like
> > alt-shift-esc so that this can be enabled by default?
>
> Why "alt-shift-esc" could be enabled by default? Do you mean to enable it for
> all systems regardless of whether they declare or don't declare KEY_SYSRQ
> in their 'keybit' bitmap?
FWIW from my perspective it'll work better as a replacement rather than
additional key combination.
The reason for this is with their more recent laptops Lenovo in their
infinite wisdom have placed the <PrintScreen> key (which in a traditional
PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
as accurate as other fingers (and the overall misdesign of the keyboard
and touchpad interface) you can imagine how often I have inadvertently hit
<SysRq> combined with a letter key, wreaking havoc to my system (and of
course I want to keep the key enabled for times when I do need it).
Also Documentation/admin-guide/sysrq.rst mentions that you can set an
alternative keycode sequence for KEY_SYSRQ with `setkeycodes <sequence>
99' already, but I find this pretty limiting as this only works for single
keypresses rather than combinations of keys, because <sequence> actually
refers to a single scancode (possibly 0xe0-prefixed).
Maciej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 13:07 ` Maciej W. Rozycki
@ 2021-11-04 13:13 ` Maciej W. Rozycki
2021-11-04 14:17 ` Andrzej Pietrasiewicz
0 siblings, 1 reply; 16+ messages in thread
From: Maciej W. Rozycki @ 2021-11-04 13:13 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: Pavel Machek, linux-kernel, linux-input, Greg Kroah-Hartman,
Dmitry Torokhov, Jiri Slaby, kernel
On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
> The reason for this is with their more recent laptops Lenovo in their
> infinite wisdom have placed the <PrintScreen> key (which in a traditional
> PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
> keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
> as accurate as other fingers (and the overall misdesign of the keyboard
> and touchpad interface) you can imagine how often I have inadvertently hit
> <SysRq> combined with a letter key, wreaking havoc to my system (and of
> course I want to keep the key enabled for times when I do need it).
On second thoughts this can be disabled with `setkeycodes 54 0' once we
do have an alternative combination available.
Maciej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 13:13 ` Maciej W. Rozycki
@ 2021-11-04 14:17 ` Andrzej Pietrasiewicz
2021-11-05 13:01 ` Andrzej Pietrasiewicz
0 siblings, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-04 14:17 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Pavel Machek, linux-kernel, linux-input, Greg Kroah-Hartman,
Dmitry Torokhov, Jiri Slaby, kernel
Hi Maciej,
W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
> On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
>
>> The reason for this is with their more recent laptops Lenovo in their
>> infinite wisdom have placed the <PrintScreen> key (which in a traditional
>> PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
>> keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
>> as accurate as other fingers (and the overall misdesign of the keyboard
>> and touchpad interface) you can imagine how often I have inadvertently hit
>> <SysRq> combined with a letter key, wreaking havoc to my system (and of
>> course I want to keep the key enabled for times when I do need it).
>
> On second thoughts this can be disabled with `setkeycodes 54 0' once we
> do have an alternative combination available.
>
Doesn't `setkeycodes` affect only one keyboard? What if there are more
keyboards connected to a machine?
From drivers/tty/vt/keyboard.c:
/*
* Translation of scancodes to keycodes. We set them on only the first
* keyboard in the list that accepts the scancode and keycode.
* Explanation for not choosing the first attached keyboard anymore:
* USB keyboards for example have two event devices: one for all "normal"
* keys and one for extra function keys (like "volume up", "make coffee",
* etc.). So this means that scancodes for the extra function keys won't
* be valid for the first event device, but will be for the second.
*/
Regards,
Andrzej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-04 14:17 ` Andrzej Pietrasiewicz
@ 2021-11-05 13:01 ` Andrzej Pietrasiewicz
2021-11-05 13:27 ` Greg Kroah-Hartman
0 siblings, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-05 13:01 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Pavel Machek, linux-kernel, linux-input, Greg Kroah-Hartman,
Dmitry Torokhov, Jiri Slaby, kernel
Hi,
W dniu 04.11.2021 o 15:17, Andrzej Pietrasiewicz pisze:
> Hi Maciej,
>
> W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
>> On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
>>
>>> The reason for this is with their more recent laptops Lenovo in their
>>> infinite wisdom have placed the <PrintScreen> key (which in a traditional
>>> PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
>>> keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
>>> as accurate as other fingers (and the overall misdesign of the keyboard
>>> and touchpad interface) you can imagine how often I have inadvertently hit
>>> <SysRq> combined with a letter key, wreaking havoc to my system (and of
>>> course I want to keep the key enabled for times when I do need it).
>>
>> On second thoughts this can be disabled with `setkeycodes 54 0' once we
>> do have an alternative combination available.
>>
>
> Doesn't `setkeycodes` affect only one keyboard? What if there are more
> keyboards connected to a machine?
>
> From drivers/tty/vt/keyboard.c:
>
> /*
> * Translation of scancodes to keycodes. We set them on only the first
> * keyboard in the list that accepts the scancode and keycode.
> * Explanation for not choosing the first attached keyboard anymore:
> * USB keyboards for example have two event devices: one for all "normal"
> * keys and one for extra function keys (like "volume up", "make coffee",
> * etc.). So this means that scancodes for the extra function keys won't
> * be valid for the first event device, but will be for the second.
> */
>
My second thoughts: if we run `setkeycodes` to map, say, F10 as SysRq,
don't we lose F10?
Andrzej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-05 13:01 ` Andrzej Pietrasiewicz
@ 2021-11-05 13:27 ` Greg Kroah-Hartman
2021-11-05 14:06 ` Andrzej Pietrasiewicz
0 siblings, 1 reply; 16+ messages in thread
From: Greg Kroah-Hartman @ 2021-11-05 13:27 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: Maciej W. Rozycki, Pavel Machek, linux-kernel, linux-input,
Dmitry Torokhov, Jiri Slaby, kernel
On Fri, Nov 05, 2021 at 02:01:23PM +0100, Andrzej Pietrasiewicz wrote:
> Hi,
>
> W dniu 04.11.2021 o 15:17, Andrzej Pietrasiewicz pisze:
> > Hi Maciej,
> >
> > W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
> > > On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
> > >
> > > > The reason for this is with their more recent laptops Lenovo in their
> > > > infinite wisdom have placed the <PrintScreen> key (which in a traditional
> > > > PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
> > > > keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
> > > > as accurate as other fingers (and the overall misdesign of the keyboard
> > > > and touchpad interface) you can imagine how often I have inadvertently hit
> > > > <SysRq> combined with a letter key, wreaking havoc to my system (and of
> > > > course I want to keep the key enabled for times when I do need it).
> > >
> > > On second thoughts this can be disabled with `setkeycodes 54 0' once we
> > > do have an alternative combination available.
> > >
> >
> > Doesn't `setkeycodes` affect only one keyboard? What if there are more
> > keyboards connected to a machine?
> >
> > From drivers/tty/vt/keyboard.c:
> >
> > /*
> > * Translation of scancodes to keycodes. We set them on only the first
> > * keyboard in the list that accepts the scancode and keycode.
> > * Explanation for not choosing the first attached keyboard anymore:
> > * USB keyboards for example have two event devices: one for all "normal"
> > * keys and one for extra function keys (like "volume up", "make coffee",
> > * etc.). So this means that scancodes for the extra function keys won't
> > * be valid for the first event device, but will be for the second.
> > */
> >
>
> My second thoughts: if we run `setkeycodes` to map, say, F10 as SysRq,
> don't we lose F10?
The fact that this patch adds a "new" sysrq key no matter what is a
non-starter, please think through the consequences of such a change...
So no, as-is, this change is not acceptable at all, and I would be
amazed if anyone would ship such a thing.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-05 13:27 ` Greg Kroah-Hartman
@ 2021-11-05 14:06 ` Andrzej Pietrasiewicz
2021-11-15 14:48 ` Andrzej Pietrasiewicz
0 siblings, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-05 14:06 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Maciej W. Rozycki, Pavel Machek, linux-kernel, linux-input,
Dmitry Torokhov, Jiri Slaby, kernel
Hi Greg,
W dniu 05.11.2021 o 14:27, Greg Kroah-Hartman pisze:
> On Fri, Nov 05, 2021 at 02:01:23PM +0100, Andrzej Pietrasiewicz wrote:
>> Hi,
>>
>> W dniu 04.11.2021 o 15:17, Andrzej Pietrasiewicz pisze:
>>> Hi Maciej,
>>>
>>> W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
>>>> On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
>>>>
>>>>> The reason for this is with their more recent laptops Lenovo in their
>>>>> infinite wisdom have placed the <PrintScreen> key (which in a traditional
>>>>> PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
>>>>> keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
>>>>> as accurate as other fingers (and the overall misdesign of the keyboard
>>>>> and touchpad interface) you can imagine how often I have inadvertently hit
>>>>> <SysRq> combined with a letter key, wreaking havoc to my system (and of
>>>>> course I want to keep the key enabled for times when I do need it).
>>>>
>>>> On second thoughts this can be disabled with `setkeycodes 54 0' once we
>>>> do have an alternative combination available.
>>>>
>>>
>>> Doesn't `setkeycodes` affect only one keyboard? What if there are more
>>> keyboards connected to a machine?
>>>
>>> From drivers/tty/vt/keyboard.c:
>>>
>>> /*
>>> * Translation of scancodes to keycodes. We set them on only the first
>>> * keyboard in the list that accepts the scancode and keycode.
>>> * Explanation for not choosing the first attached keyboard anymore:
>>> * USB keyboards for example have two event devices: one for all "normal"
>>> * keys and one for extra function keys (like "volume up", "make coffee",
>>> * etc.). So this means that scancodes for the extra function keys won't
>>> * be valid for the first event device, but will be for the second.
>>> */
>>>
>>
>> My second thoughts: if we run `setkeycodes` to map, say, F10 as SysRq,
>> don't we lose F10?
>
> The fact that this patch adds a "new" sysrq key no matter what is a
> non-starter, please think through the consequences of such a change...
>
I wouldn't say this RFC adds a "new" sysrq no matter what. It does so only
when the input device (keyboard) does _not_ have SysRq key at all. So I would
say that this patch adds a replacement SysRq key if the SysRq key proper is
_physically_ absent. Which seems not such a bad thing to me. The problem I'm
trying to solve is exactly this: what to use as SysRq if there's no SysRq?
Andrzej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-05 14:06 ` Andrzej Pietrasiewicz
@ 2021-11-15 14:48 ` Andrzej Pietrasiewicz
2021-11-15 15:09 ` Greg Kroah-Hartman
0 siblings, 1 reply; 16+ messages in thread
From: Andrzej Pietrasiewicz @ 2021-11-15 14:48 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Maciej W. Rozycki, Pavel Machek, linux-kernel, linux-input,
Dmitry Torokhov, Jiri Slaby, kernel
Jiri, Greg,
W dniu 05.11.2021 o 15:06, Andrzej Pietrasiewicz pisze:
> Hi Greg,
>
> W dniu 05.11.2021 o 14:27, Greg Kroah-Hartman pisze:
>> On Fri, Nov 05, 2021 at 02:01:23PM +0100, Andrzej Pietrasiewicz wrote:
>>> Hi,
>>>
>>> W dniu 04.11.2021 o 15:17, Andrzej Pietrasiewicz pisze:
>>>> Hi Maciej,
>>>>
>>>> W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
>>>>> On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
>>>>>
>>>>>> The reason for this is with their more recent laptops Lenovo in their
>>>>>> infinite wisdom have placed the <PrintScreen> key (which in a traditional
>>>>>> PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
>>>>>> keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
>>>>>> as accurate as other fingers (and the overall misdesign of the keyboard
>>>>>> and touchpad interface) you can imagine how often I have inadvertently hit
>>>>>> <SysRq> combined with a letter key, wreaking havoc to my system (and of
>>>>>> course I want to keep the key enabled for times when I do need it).
>>>>>
>>>>> On second thoughts this can be disabled with `setkeycodes 54 0' once we
>>>>> do have an alternative combination available.
>>>>>
>>>>
>>>> Doesn't `setkeycodes` affect only one keyboard? What if there are more
>>>> keyboards connected to a machine?
>>>>
>>>> From drivers/tty/vt/keyboard.c:
>>>>
>>>> /*
>>>> * Translation of scancodes to keycodes. We set them on only the first
>>>> * keyboard in the list that accepts the scancode and keycode.
>>>> * Explanation for not choosing the first attached keyboard anymore:
>>>> * USB keyboards for example have two event devices: one for all "normal"
>>>> * keys and one for extra function keys (like "volume up", "make coffee",
>>>> * etc.). So this means that scancodes for the extra function keys won't
>>>> * be valid for the first event device, but will be for the second.
>>>> */
>>>>
>>>
>>> My second thoughts: if we run `setkeycodes` to map, say, F10 as SysRq,
>>> don't we lose F10?
>>
>> The fact that this patch adds a "new" sysrq key no matter what is a
>> non-starter, please think through the consequences of such a change...
>>
>
> I wouldn't say this RFC adds a "new" sysrq no matter what. It does so only
> when the input device (keyboard) does _not_ have SysRq key at all. So I would
> say that this patch adds a replacement SysRq key if the SysRq key proper is
> _physically_ absent. Which seems not such a bad thing to me. The problem I'm
> trying to solve is exactly this: what to use as SysRq if there's no SysRq?
>
What approach is acceptable then? Any criteria other than "go guess"?
Is "connect an external keyboard" the _only_ choice Linux wants to offer
to its users in case of devices such as e.g. Chromebooks?
Regards,
Andrzej
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC] tty/sysrq: Add alternative SysRq key
2021-11-15 14:48 ` Andrzej Pietrasiewicz
@ 2021-11-15 15:09 ` Greg Kroah-Hartman
0 siblings, 0 replies; 16+ messages in thread
From: Greg Kroah-Hartman @ 2021-11-15 15:09 UTC (permalink / raw)
To: Andrzej Pietrasiewicz
Cc: Maciej W. Rozycki, Pavel Machek, linux-kernel, linux-input,
Dmitry Torokhov, Jiri Slaby, kernel
On Mon, Nov 15, 2021 at 03:48:59PM +0100, Andrzej Pietrasiewicz wrote:
> Jiri, Greg,
>
>
> W dniu 05.11.2021 o 15:06, Andrzej Pietrasiewicz pisze:
> > Hi Greg,
> >
> > W dniu 05.11.2021 o 14:27, Greg Kroah-Hartman pisze:
> > > On Fri, Nov 05, 2021 at 02:01:23PM +0100, Andrzej Pietrasiewicz wrote:
> > > > Hi,
> > > >
> > > > W dniu 04.11.2021 o 15:17, Andrzej Pietrasiewicz pisze:
> > > > > Hi Maciej,
> > > > >
> > > > > W dniu 04.11.2021 o 14:13, Maciej W. Rozycki pisze:
> > > > > > On Thu, 4 Nov 2021, Maciej W. Rozycki wrote:
> > > > > >
> > > > > > > The reason for this is with their more recent laptops Lenovo in their
> > > > > > > infinite wisdom have placed the <PrintScreen> key (which in a traditional
> > > > > > > PS/2-keyboard manner produces <SysRq> when combined with <Alt>) in their
> > > > > > > keyboards between the right <Alt> and <Ctrl> keys. With thumbs not being
> > > > > > > as accurate as other fingers (and the overall misdesign of the keyboard
> > > > > > > and touchpad interface) you can imagine how often I have inadvertently hit
> > > > > > > <SysRq> combined with a letter key, wreaking havoc to my system (and of
> > > > > > > course I want to keep the key enabled for times when I do need it).
> > > > > >
> > > > > > On second thoughts this can be disabled with `setkeycodes 54 0' once we
> > > > > > do have an alternative combination available.
> > > > > >
> > > > >
> > > > > Doesn't `setkeycodes` affect only one keyboard? What if there are more
> > > > > keyboards connected to a machine?
> > > > >
> > > > > From drivers/tty/vt/keyboard.c:
> > > > >
> > > > > /*
> > > > > * Translation of scancodes to keycodes. We set them on only the first
> > > > > * keyboard in the list that accepts the scancode and keycode.
> > > > > * Explanation for not choosing the first attached keyboard anymore:
> > > > > * USB keyboards for example have two event devices: one for all "normal"
> > > > > * keys and one for extra function keys (like "volume up", "make coffee",
> > > > > * etc.). So this means that scancodes for the extra function keys won't
> > > > > * be valid for the first event device, but will be for the second.
> > > > > */
> > > > >
> > > >
> > > > My second thoughts: if we run `setkeycodes` to map, say, F10 as SysRq,
> > > > don't we lose F10?
> > >
> > > The fact that this patch adds a "new" sysrq key no matter what is a
> > > non-starter, please think through the consequences of such a change...
> > >
> >
> > I wouldn't say this RFC adds a "new" sysrq no matter what. It does so only
> > when the input device (keyboard) does _not_ have SysRq key at all. So I would
> > say that this patch adds a replacement SysRq key if the SysRq key proper is
> > _physically_ absent. Which seems not such a bad thing to me. The problem I'm
> > trying to solve is exactly this: what to use as SysRq if there's no SysRq?
> >
>
> What approach is acceptable then? Any criteria other than "go guess"?
> Is "connect an external keyboard" the _only_ choice Linux wants to offer
> to its users in case of devices such as e.g. Chromebooks?
I don't see how this patch only kicks in if a keyboard does not have a
sysrq key present given that you are allowing a different key to be used
as it also.
Anyway, it's an RFC, which can't be applied to the tree so I'll wait to
review it "for real" when you feel comfortable enough to submit it for
inclusion.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-11-15 15:10 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03 15:54 [RFC] tty/sysrq: Add alternative SysRq key Andrzej Pietrasiewicz
2021-11-03 16:19 ` Randy Dunlap
2021-11-04 8:44 ` Andrzej Pietrasiewicz
2021-11-04 9:34 ` Andrzej Pietrasiewicz
2021-11-04 9:52 ` Greg Kroah-Hartman
2021-11-03 18:44 ` kernel test robot
2021-11-04 12:01 ` Pavel Machek
2021-11-04 12:21 ` Andrzej Pietrasiewicz
2021-11-04 13:07 ` Maciej W. Rozycki
2021-11-04 13:13 ` Maciej W. Rozycki
2021-11-04 14:17 ` Andrzej Pietrasiewicz
2021-11-05 13:01 ` Andrzej Pietrasiewicz
2021-11-05 13:27 ` Greg Kroah-Hartman
2021-11-05 14:06 ` Andrzej Pietrasiewicz
2021-11-15 14:48 ` Andrzej Pietrasiewicz
2021-11-15 15:09 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.