Page MenuHomeFreeBSD

linuxkpi: Add orderly_poweroff
ClosedPublic

Authored by manu on Feb 15 2022, 11:11 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Sep 5, 5:30 AM
Unknown Object (File)
Wed, Sep 4, 6:00 AM
Unknown Object (File)
Mon, Sep 2, 11:06 AM
Unknown Object (File)
Sat, Aug 31, 7:49 AM
Unknown Object (File)
Thu, Aug 29, 5:18 PM
Unknown Object (File)
Mon, Aug 26, 5:30 PM
Unknown Object (File)
Mon, Aug 26, 11:08 AM
Unknown Object (File)
Mon, Aug 26, 8:11 AM
Subscribers

Details

Summary

This simply poweroff the system.
Needed by drm-kmod v5.8

MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

manu requested review of this revision.Feb 15 2022, 11:11 AM
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/reboot.h
28

I thought things got harmonized onto one "_".

41

Do you actually need anything but RB_POWEROFF for these two as shutdown_nice_task_fn will not look at the others if that is set. And if you run into kern_reboot RB_NOSYNC gets set (but unlikely you'd run into that from here given that requires no init running).

Remove RB_HALT (not needed).
Remove one _ in header guard.

manu marked 2 inline comments as done.Feb 16 2022, 8:51 AM
manu added inline comments.
sys/compat/linuxkpi/common/include/linux/reboot.h
41

RB_NOSYNC is needed in that case so we don't call bufshutdown

sys/compat/linuxkpi/common/include/linux/reboot.h
41

RB_NOSYNC is needed in that case so we don't call bufshutdown

{{{

340 /*
341  * Called by events that want to shut down.. e.g  <CTL><ALT><DEL> on a PC
342  */
343 void
344 shutdown_nice(int howto)
345 {
346
347         if (initproc != NULL && !SCHEDULER_STOPPED()) {
348                 shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
349                 taskqueue_enqueue(taskqueue_fast, &shutdown_nice_task);
350         } else {
351                 /*
352                  * No init(8) running, or scheduler would not allow it
353                  * to run, so simply reboot.
354                  */
355                 kern_reboot(howto | RB_NOSYNC);
356         }
357 }

}}}

The first runs shutdown_nice_task_fn which then calls kern_psignal() depending on howto but doesn't pass it on.
The latter does add RB_NOSYNC itself.

manu marked an inline comment as done.Feb 16 2022, 9:53 AM
manu added inline comments.
sys/compat/linuxkpi/common/include/linux/reboot.h
41

Ah yes indeed, I've missed that howto isn't passed on.
Will update and make this a single call to shutdown_nice then.

Remove RB_NOSYNC as it's not passed on.

This revision is now accepted and ready to land.Feb 16 2022, 12:02 PM
This revision was automatically updated to reflect the committed changes.