local_irq_enable in restart handler

Tomek The Messenger tomekthemessenger at gmail.com
Wed Apr 22 10:35:03 EDT 2020


Hi
The background:
Interrupts are disabled just before stopping other cores during handling
restart:
See example from:
/arch/arm/kernel/reboot.c:
/*
 * Restart requires that the secondary CPUs stop performing any activity
 * while the primary CPU resets the system.
 */
void machine_restart(char *cmd)
{
local_irq_disable();
smp_send_stop();

do_kernel_restart(cmd);

/* Give a grace period for failure to restart of 1s */
mdelay(1000);

/* Whoops - the platform was unable to reboot. Tell the user! */
printk("Reboot failed -- System halted\n");
while (1);
}

where function do_kernel_restart() invoke restart handlers:
void do_kernel_restart(char *cmd)
{
     atomic_notifier_call_chain(&restart_handler_list, reboot_mode, cmd);
}

One and the only one! restart handler is mine where I do i2c transaction in
order to reset the board. i2c transaction requires interrupts to be enabled.
Can I safely do: local_irq_enable on my handler entry and local_irq_disable
just before exit? In the meantime I will do i2c_smbus transaction and add
some 500ms delay before disable back irq just to make sure transaction is
succeed.
I know that it is strange question, but in company in which I work I
received subtask to get to know. The other alternative is to get response
by execute test with for example loop of 10 thousands of restarts.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20200422/23e1bfd5/attachment.html>


More information about the Kernelnewbies mailing list