linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: Adding graceful shutdown to sysrq key reset
@ 2013-04-05 13:38 mathieu.poirier
  2013-04-15 20:45 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: mathieu.poirier @ 2013-04-05 13:38 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: linux-input, arve, kernel-team, john.stultz, mathieu.poirier

From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>

Attempt to reboot the system gracefully when a key combo
is detected.  The system is force to go down if the first
attempt failed and the key combo is pressed a second time.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/tty/sysrq.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 766878a..bd852fc 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -43,6 +43,7 @@
 #include <linux/uaccess.h>
 #include <linux/moduleparam.h>
 #include <linux/jiffies.h>
+#include <linux/syscalls.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq_regs.h>
@@ -584,6 +585,7 @@ struct sysrq_state {
 
 	/* reset sequence handling */
 	bool reset_canceled;
+	bool reset_requested;
 	unsigned long reset_keybit[BITS_TO_LONGS(KEY_CNT)];
 	int reset_seq_len;
 	int reset_seq_cnt;
@@ -624,11 +626,17 @@ static void sysrq_parse_reset_sequence(struct sysrq_state *state)
 
 static void sysrq_do_reset(unsigned long dummy)
 {
-	__handle_sysrq(sysrq_xlate[KEY_B], false);
+	sys_sync();
+	kernel_restart(NULL);
 }
 
 static void sysrq_handle_reset_request(struct sysrq_state *state)
 {
+	if (state->reset_requested)
+		__handle_sysrq(sysrq_xlate[KEY_B], false);
+
+	state->reset_requested = true;
+
 	if (sysrq_reset_downtime_ms)
 		mod_timer(&state->keyreset_timer,
 			jiffies + msecs_to_jiffies(sysrq_reset_downtime_ms));
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: Adding graceful shutdown to sysrq key reset
  2013-04-05 13:38 [PATCH] Input: Adding graceful shutdown to sysrq key reset mathieu.poirier
@ 2013-04-15 20:45 ` Dmitry Torokhov
  2013-04-16 14:45   ` Mathieu Poirier
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2013-04-15 20:45 UTC (permalink / raw)
  To: mathieu.poirier; +Cc: linux-input, arve, kernel-team, john.stultz

Hi Mathieu,

On Fri, Apr 05, 2013 at 07:38:32AM -0600, mathieu.poirier@linaro.org wrote:
> From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>
> 
> Attempt to reboot the system gracefully when a key combo
> is detected.  The system is force to go down if the first
> attempt failed and the key combo is pressed a second time.
> 

If system can gracefully shutdown can;t we request it through normal
means?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: Adding graceful shutdown to sysrq key reset
  2013-04-15 20:45 ` Dmitry Torokhov
@ 2013-04-16 14:45   ` Mathieu Poirier
  2013-04-23 23:50     ` Mathieu Poirier
  0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Poirier @ 2013-04-16 14:45 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, arve, kernel-team, john.stultz

On 13-04-15 02:45 PM, Dmitry Torokhov wrote:
> Hi Mathieu,
> 
> On Fri, Apr 05, 2013 at 07:38:32AM -0600, mathieu.poirier@linaro.org wrote:
>> From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>
>>
>> Attempt to reboot the system gracefully when a key combo
>> is detected.  The system is force to go down if the first
>> attempt failed and the key combo is pressed a second time.
>>
> 
> If system can gracefully shutdown can;t we request it through normal
> means?
> 
> Thanks.
> 

Can you provide more details on how you'd like to see this done please ?
 Since 'kernel_restart' is found in 'linux/reboot.h' I was under the
impression that it is fairly mainstream.

Thanks,
Mathieu.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: Adding graceful shutdown to sysrq key reset
  2013-04-16 14:45   ` Mathieu Poirier
@ 2013-04-23 23:50     ` Mathieu Poirier
  2013-04-24  0:42       ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Mathieu Poirier @ 2013-04-23 23:50 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, arve, kernel-team, john.stultz

On 13-04-16 08:45 AM, Mathieu Poirier wrote:
> On 13-04-15 02:45 PM, Dmitry Torokhov wrote:
>> Hi Mathieu,
>>
>> On Fri, Apr 05, 2013 at 07:38:32AM -0600, mathieu.poirier@linaro.org wrote:
>>> From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>
>>>
>>> Attempt to reboot the system gracefully when a key combo
>>> is detected.  The system is force to go down if the first
>>> attempt failed and the key combo is pressed a second time.
>>>
>>
>> If system can gracefully shutdown can;t we request it through normal
>> means?
>>
>> Thanks.
>>
> 
> Can you provide more details on how you'd like to see this done please ?
>  Since 'kernel_restart' is found in 'linux/reboot.h' I was under the
> impression that it is fairly mainstream.
> 
> Thanks,
> Mathieu.
> 

I haven't hard back from my last question so I'll try to interpret your
original answer differently.

The proposed functionality is a last effort at rebooting the system when
the UI is hung.  In such case the rest of the system could still be
alive and as such should be given a chance to reboot more gracefully
than when using emergency_reset().

Hope this helps clarifying my position.  I would be more than happy to
re-work the commit message if need be.  Please consider getting back to me.

Mathieu.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: Adding graceful shutdown to sysrq key reset
  2013-04-23 23:50     ` Mathieu Poirier
@ 2013-04-24  0:42       ` Dmitry Torokhov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2013-04-24  0:42 UTC (permalink / raw)
  To: Mathieu Poirier; +Cc: linux-input, arve, kernel-team, john.stultz

On Tue, Apr 23, 2013 at 05:50:32PM -0600, Mathieu Poirier wrote:
> On 13-04-16 08:45 AM, Mathieu Poirier wrote:
> > On 13-04-15 02:45 PM, Dmitry Torokhov wrote:
> >> Hi Mathieu,
> >>
> >> On Fri, Apr 05, 2013 at 07:38:32AM -0600, mathieu.poirier@linaro.org wrote:
> >>> From: "Mathieu J. Poirier" <mathieu.poirier@linaro.org>
> >>>
> >>> Attempt to reboot the system gracefully when a key combo
> >>> is detected.  The system is force to go down if the first
> >>> attempt failed and the key combo is pressed a second time.
> >>>
> >>
> >> If system can gracefully shutdown can;t we request it through normal
> >> means?
> >>
> >> Thanks.
> >>
> > 
> > Can you provide more details on how you'd like to see this done please ?
> >  Since 'kernel_restart' is found in 'linux/reboot.h' I was under the
> > impression that it is fairly mainstream.
> > 
> > Thanks,
> > Mathieu.
> > 
> 
> I haven't hard back from my last question so I'll try to interpret your
> original answer differently.
> 
> The proposed functionality is a last effort at rebooting the system when
> the UI is hung.  In such case the rest of the system could still be
> alive and as such should be given a chance to reboot more gracefully
> than when using emergency_reset().

OK, fair enough.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-24  0:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-05 13:38 [PATCH] Input: Adding graceful shutdown to sysrq key reset mathieu.poirier
2013-04-15 20:45 ` Dmitry Torokhov
2013-04-16 14:45   ` Mathieu Poirier
2013-04-23 23:50     ` Mathieu Poirier
2013-04-24  0:42       ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).