Kernel module that shuts down the device

Greg KH greg at kroah.com
Sun Nov 7 03:31:11 EST 2021


On Sat, Nov 06, 2021 at 07:54:39PM -0500, Drew Abbott wrote:
> Hi all,
> 
> I am working on a kernel module that should shut down the device when USB
> is unplugged. I make a call to kernel_power_off(), but I see that it gets
> stuck trying to call blocking_notifier_call_chain(&reboot_notifier_list,
> (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL); in
> kernel_shutdown_prepare().

Where are you calling it from?  Don't call it from irq context, which is
the context that USB urbs are called from.

> There is currently another driver that has the same function, and shuts
> down the device by calling kernel_power_off() successfully. I have tried
> adding prints in blocking_notifier_call_chain, but then the kernel log is
> flooded with calls and I can't really see what is happening.
> Does anyone have any insight into why my call to kernel_power_off() is
> hanging?

Do you have a link to your driver code so it can be reviewed?

thanks,

greg k-h



More information about the Kernelnewbies mailing list