title: How to soft reboot from a non-monolithic kernel module in an IRQ scope?
body: <p>I need to reboot upon handling an IRQ in kernel land.</p>
  
  <p>I want to call the <code>/sbin/reboot</code> binary, but I have got limitations due to the IRQ scope.</p>
  
  <p>Code follows :</p>
  
  <pre><code>#define MY_IRQ_ID       42
  
  void __init             rebootmodule_init(void) {
      request_any_context_irq(MY_IRQ_ID, rebootmodule_irq_handler, IRQF_TRIGGER_FALLING, "irq-name", NULL);
  }
  
  irqreturn_t             rebootmodule_irq_handler(int irq, void *dev_id) {
      my_reboot();
      return IRQ_HANDLED;
  }
  
  void                    my_reboot(void) {
      int                 ret;
      char                *argv[2], *envp[4];
  
      argv[0] = "/sbin/reboot";
      argv[1] = NULL;
      envp[0] = "HOME=/";
      envp[1] = "PWD=/";
      envp[2] = "PATH=/sbin";
      envp[3] = NULL;
      ret = call_usermodehelper(argv[0], argv, envp, 0);
      printk(KERN_INFO "trying to reboot (ret = %d)", ret);
  }
  </code></pre>
  
  <p>I can see the <code>printk(...)</code> when the IRQ is triggered but I have some errors, even if I replace <code>/sbin/reboot</code> by <code>/bin/rm /tmp/its-not-working</code>.</p>
  
  <p>I tested other way to do reboot like <code>mvBoardReset()</code>, <code>machine_halt()</code>, <code>arm_pm_restart()</code>, <code>pm_power_off()</code>, <code>kill(1, SIGTSTP)</code>, <code>reboot()</code>, <code>handle_sysrq('b')</code>, I always have errors that I don't have outside the IRQ scope.</p>
  
  <p>I really want to call <code>/sbin/reboot</code>, since it does <em>clean</em> soft reset.</p>
  
  <p>Thank you for your time.</p>