Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: power: Add document on debugging shutdown hangs

If the kernel hangs while shutting down, ideally a UART log should
be captured to debug the problem. However if one isn't available,
users can use the pstore functionality to retrieve logs.

Add a document explaining how this works to make it more accessible
to users.

Tested-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Link: https://patch.msgid.link/20251025004341.2386868-1-superm1@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Mario Limonciello (AMD) and committed by
Rafael J. Wysocki
b1f02f00 1cf9c4f1

+54
+1
Documentation/power/index.rst
··· 19 19 power_supply_class 20 20 runtime_pm 21 21 s2ram 22 + shutdown-debugging 22 23 suspend-and-cpuhotplug 23 24 suspend-and-interrupts 24 25 swsusp-and-swap-files
+53
Documentation/power/shutdown-debugging.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Debugging Kernel Shutdown Hangs with pstore 4 + +++++++++++++++++++++++++++++++++++++++++++ 5 + 6 + Overview 7 + ======== 8 + If the system hangs while shutting down, the kernel logs may need to be 9 + retrieved to debug the issue. 10 + 11 + On systems that have a UART available, it is best to configure the kernel to use 12 + this UART for kernel console output. 13 + 14 + If a UART isn't available, the ``pstore`` subsystem provides a mechanism to 15 + persist this data across a system reset, allowing it to be retrieved on the next 16 + boot. 17 + 18 + Kernel Configuration 19 + ==================== 20 + To enable ``pstore`` and enable saving kernel ring buffer logs, set the 21 + following kernel configuration options: 22 + 23 + * ``CONFIG_PSTORE=y`` 24 + * ``CONFIG_PSTORE_CONSOLE=y`` 25 + 26 + Additionally, enable a backend to store the data. Depending upon your platform 27 + some options include: 28 + 29 + * ``CONFIG_EFI_VARS_PSTORE=y`` 30 + * ``CONFIG_PSTORE_RAM=y`` 31 + * ``CONFIG_PSTORE_FIRMWARE=y`` 32 + * ``CONFIG_PSTORE_BLK=y`` 33 + 34 + Kernel Command-line Parameters 35 + ============================== 36 + Add these parameters to your kernel command line: 37 + 38 + * ``printk.always_kmsg_dump=Y`` 39 + * Forces the kernel to dump the entire message buffer to pstore during 40 + shutdown 41 + * ``efi_pstore.pstore_disable=N`` 42 + * For EFI-based systems, ensures the EFI backend is active 43 + 44 + Userspace Interaction and Log Retrieval 45 + ======================================= 46 + On the next boot after a hang, pstore logs will be available in the pstore 47 + filesystem (``/sys/fs/pstore``) and can be retrieved by userspace. 48 + 49 + On systemd systems, the ``systemd-pstore`` service will help do the following: 50 + 51 + #. Locate pstore data in ``/sys/fs/pstore`` 52 + #. Read and save it to ``/var/lib/systemd/pstore`` 53 + #. Clear pstore data for the next event