On Fri, Nov 24, 2023 at 03:53:37PM +0100, Oleksij Rempel wrote: > This commit revises the device shutdown mechanism to implement a > prioritized shutdown sequence. The new function, > prioritized_device_shutdown, ensures devices are shut down in reverse > order, mirroring the system construction order. Within this process, > devices are shut down based on their assigned priority levels. > Additionally, this patch ensures that a device inherits its shutdown > priority from its parent, maintaining hierarchy integrity. This is > crucial to prevent child nodes of high-priority parents from being > orphaned in the shutdown sequence. > > This change is vital in scenarios like power drops with limited backup > energy, where shutdown time is constrained. By prioritizing critical > devices, particularly storage, the focus is on maintaining device > integrity by ensuring they are properly shut down. This approach reduces > the risk of hardware damage and enhances system resilience during > emergency shutdowns. So you are going to race the power drain and just hope and pray that the kernel gets to shut down the hardware before the capacitors discharge? That seems ripe for loads of problems, as you are trying to achive something that software just can not do, as the hardware isn't supporting it at all. You are making a promise here that the kernel can never achive, sorry. I understand your wish to try to fix broken hardware with software, but please go back and tell those hardware engineers that they need to fix this properly if they don't want broken devices as this is just not going to work at all. One naming nit: > -void device_shutdown(void) > +void prioritized_device_shutdown(void) It's the driver core, please prefix stuff correctly, so this would be device_shutdown_prioritized() if we were to take this. Anyway, good luck with the hardware engineers! greg k-h