Message ID | 20200511135918.8203-4-andrzej.p@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Magic SysRq extensions | expand |
On Mon, May 11, 2020 at 03:59:15PM +0200, Andrzej Pietrasiewicz wrote: > There are existing machines which don't have SysRq key, e.g. chromebooks. > This patch allows configuring which key acts as SysRq. The value is passed > with sysrq's module parameter. > > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > --- > drivers/tty/sysrq.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c > index 93202fc24308..ebad9799fdc0 100644 > --- a/drivers/tty/sysrq.c > +++ b/drivers/tty/sysrq.c > @@ -604,6 +604,7 @@ EXPORT_SYMBOL(handle_sysrq); > > #ifdef CONFIG_INPUT > static int sysrq_reset_downtime_ms; > +static unsigned short sysrq_key = KEY_SYSRQ; > > /* Simple translation table for the SysRq keys */ > static const unsigned char sysrq_xlate[KEY_CNT] = > @@ -735,10 +736,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_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_key, 0); > input_inject_event(handle, EV_KEY, alt_code, 0); > input_inject_event(handle, EV_SYN, SYN_REPORT, 1); > > @@ -770,6 +771,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq, > } > break; > > +key_sysrq: > case KEY_SYSRQ: > if (value == 1 && sysrq->alt != KEY_RESERVED) { > sysrq->active = true; > @@ -790,11 +792,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_key, sysrq->handle.dev->key); > > break; > > default: > + /* handle non-default sysrq key */ > + if (code == sysrq_key) > + goto key_sysrq; > + > if (sysrq->active && value && value != 2) { > sysrq->need_reinject = false; > __handle_sysrq(sysrq_xlate[code], true); > @@ -995,6 +1001,8 @@ 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(sysrq_key, ushort, 0644); No documentation of this new module parameter? :(
Hi Andrzej, On Mon, May 11, 2020 at 03:59:15PM +0200, Andrzej Pietrasiewicz wrote: > There are existing machines which don't have SysRq key, e.g. chromebooks. > This patch allows configuring which key acts as SysRq. The value is passed > with sysrq's module parameter. > > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> > --- > drivers/tty/sysrq.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c > index 93202fc24308..ebad9799fdc0 100644 > --- a/drivers/tty/sysrq.c > +++ b/drivers/tty/sysrq.c > @@ -604,6 +604,7 @@ EXPORT_SYMBOL(handle_sysrq); > > #ifdef CONFIG_INPUT > static int sysrq_reset_downtime_ms; > +static unsigned short sysrq_key = KEY_SYSRQ; > > /* Simple translation table for the SysRq keys */ > static const unsigned char sysrq_xlate[KEY_CNT] = > @@ -735,10 +736,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_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_key, 0); > input_inject_event(handle, EV_KEY, alt_code, 0); > input_inject_event(handle, EV_SYN, SYN_REPORT, 1); Unfortunately this means that if I connect my external keyboard to chromebook SysRq there will stop working, which is not great. If we want to support this we need to figure out how to make this handling per-device. FWIW Chrome OS cheats and simply adds more keys to be handled as SysRq without removing "classic" SysRq. But that hack is obviously not suitable for the mainline. Thanks.
Hi Dmitry, W dniu 11.05.2020 o 20:01, Dmitry Torokhov pisze: > Hi Andrzej, > > On Mon, May 11, 2020 at 03:59:15PM +0200, Andrzej Pietrasiewicz wrote: >> There are existing machines which don't have SysRq key, e.g. chromebooks. >> This patch allows configuring which key acts as SysRq. The value is passed >> with sysrq's module parameter. >> >> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> >> --- >> drivers/tty/sysrq.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c >> index 93202fc24308..ebad9799fdc0 100644 >> --- a/drivers/tty/sysrq.c >> +++ b/drivers/tty/sysrq.c >> @@ -604,6 +604,7 @@ EXPORT_SYMBOL(handle_sysrq); >> >> #ifdef CONFIG_INPUT >> static int sysrq_reset_downtime_ms; >> +static unsigned short sysrq_key = KEY_SYSRQ; >> >> /* Simple translation table for the SysRq keys */ >> static const unsigned char sysrq_xlate[KEY_CNT] = >> @@ -735,10 +736,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_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_key, 0); >> input_inject_event(handle, EV_KEY, alt_code, 0); >> input_inject_event(handle, EV_SYN, SYN_REPORT, 1); > > Unfortunately this means that if I connect my external keyboard to > chromebook SysRq there will stop working, which is not great. If we want > to support this we need to figure out how to make this handling > per-device. I see your point. So what you envision is SysRq key being configured for each input device separately. I can see these problems: - How to attach such a configuration information to each specific device instance? It is easy if done framework-wise, but gets messy if done per-device. And we are talking per-device rather than per-driver. - If a user has multiple USB keyboards connected (possibly through a cascade of hubs), how would they know which key is valid for which keyboard? Wouldn't it be better if such a piece of configuration were valid for the whole system instead of per-device? Andrzej
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 93202fc24308..ebad9799fdc0 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -604,6 +604,7 @@ EXPORT_SYMBOL(handle_sysrq); #ifdef CONFIG_INPUT static int sysrq_reset_downtime_ms; +static unsigned short sysrq_key = KEY_SYSRQ; /* Simple translation table for the SysRq keys */ static const unsigned char sysrq_xlate[KEY_CNT] = @@ -735,10 +736,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_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_key, 0); input_inject_event(handle, EV_KEY, alt_code, 0); input_inject_event(handle, EV_SYN, SYN_REPORT, 1); @@ -770,6 +771,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq, } break; +key_sysrq: case KEY_SYSRQ: if (value == 1 && sysrq->alt != KEY_RESERVED) { sysrq->active = true; @@ -790,11 +792,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_key, sysrq->handle.dev->key); break; default: + /* handle non-default sysrq key */ + if (code == sysrq_key) + goto key_sysrq; + if (sysrq->active && value && value != 2) { sysrq->need_reinject = false; __handle_sysrq(sysrq_xlate[code], true); @@ -995,6 +1001,8 @@ 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(sysrq_key, ushort, 0644); + #else static inline void sysrq_register_handler(void)
There are existing machines which don't have SysRq key, e.g. chromebooks. This patch allows configuring which key acts as SysRq. The value is passed with sysrq's module parameter. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> --- drivers/tty/sysrq.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)