162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci==================================
462306a36Sopenharmony_ciNVDIMM Runtime Firmware Activation
562306a36Sopenharmony_ci==================================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciSome persistent memory devices run a firmware locally on the device /
862306a36Sopenharmony_ci"DIMM" to perform tasks like media management, capacity provisioning,
962306a36Sopenharmony_ciand health monitoring. The process of updating that firmware typically
1062306a36Sopenharmony_ciinvolves a reboot because it has implications for in-flight memory
1162306a36Sopenharmony_citransactions. However, reboots are disruptive and at least the Intel
1262306a36Sopenharmony_cipersistent memory platform implementation, described by the Intel ACPI
1362306a36Sopenharmony_ciDSM specification [1], has added support for activating firmware at
1462306a36Sopenharmony_ciruntime.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciA native sysfs interface is implemented in libnvdimm to allow platform
1762306a36Sopenharmony_cito advertise and control their local runtime firmware activation
1862306a36Sopenharmony_cicapability.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciThe libnvdimm bus object, ndbusX, implements an ndbusX/firmware/activate
2162306a36Sopenharmony_ciattribute that shows the state of the firmware activation as one of 'idle',
2262306a36Sopenharmony_ci'armed', 'overflow', and 'busy'.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci- idle:
2562306a36Sopenharmony_ci  No devices are set / armed to activate firmware
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci- armed:
2862306a36Sopenharmony_ci  At least one device is armed
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci- busy:
3162306a36Sopenharmony_ci  In the busy state armed devices are in the process of transitioning
3262306a36Sopenharmony_ci  back to idle and completing an activation cycle.
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci- overflow:
3562306a36Sopenharmony_ci  If the platform has a concept of incremental work needed to perform
3662306a36Sopenharmony_ci  the activation it could be the case that too many DIMMs are armed for
3762306a36Sopenharmony_ci  activation. In that scenario the potential for firmware activation to
3862306a36Sopenharmony_ci  timeout is indicated by the 'overflow' state.
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciThe 'ndbusX/firmware/activate' property can be written with a value of
4162306a36Sopenharmony_cieither 'live', or 'quiesce'. A value of 'quiesce' triggers the kernel to
4262306a36Sopenharmony_cirun firmware activation from within the equivalent of the hibernation
4362306a36Sopenharmony_ci'freeze' state where drivers and applications are notified to stop their
4462306a36Sopenharmony_cimodifications of system memory. A value of 'live' attempts
4562306a36Sopenharmony_cifirmware activation without this hibernation cycle. The
4662306a36Sopenharmony_ci'ndbusX/firmware/activate' property will be elided completely if no
4762306a36Sopenharmony_cifirmware activation capability is detected.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciAnother property 'ndbusX/firmware/capability' indicates a value of
5062306a36Sopenharmony_ci'live' or 'quiesce', where 'live' indicates that the firmware
5162306a36Sopenharmony_cidoes not require or inflict any quiesce period on the system to update
5262306a36Sopenharmony_cifirmware. A capability value of 'quiesce' indicates that firmware does
5362306a36Sopenharmony_ciexpect and injects a quiet period for the memory controller, but 'live'
5462306a36Sopenharmony_cimay still be written to 'ndbusX/firmware/activate' as an override to
5562306a36Sopenharmony_ciassume the risk of racing firmware update with in-flight device and
5662306a36Sopenharmony_ciapplication activity. The 'ndbusX/firmware/capability' property will be
5762306a36Sopenharmony_cielided completely if no firmware activation capability is detected.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciThe libnvdimm memory-device / DIMM object, nmemX, implements
6062306a36Sopenharmony_ci'nmemX/firmware/activate' and 'nmemX/firmware/result' attributes to
6162306a36Sopenharmony_cicommunicate the per-device firmware activation state. Similar to the
6262306a36Sopenharmony_ci'ndbusX/firmware/activate' attribute, the 'nmemX/firmware/activate'
6362306a36Sopenharmony_ciattribute indicates 'idle', 'armed', or 'busy'. The state transitions
6462306a36Sopenharmony_cifrom 'armed' to 'idle' when the system is prepared to activate firmware,
6562306a36Sopenharmony_cifirmware staged + state set to armed, and 'ndbusX/firmware/activate' is
6662306a36Sopenharmony_citriggered. After that activation event the nmemX/firmware/result
6762306a36Sopenharmony_ciattribute reflects the state of the last activation as one of:
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci- none:
7062306a36Sopenharmony_ci  No runtime activation triggered since the last time the device was reset
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci- success:
7362306a36Sopenharmony_ci  The last runtime activation completed successfully.
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci- fail:
7662306a36Sopenharmony_ci  The last runtime activation failed for device-specific reasons.
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci- not_staged:
7962306a36Sopenharmony_ci  The last runtime activation failed due to a sequencing error of the
8062306a36Sopenharmony_ci  firmware image not being staged.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci- need_reset:
8362306a36Sopenharmony_ci  Runtime firmware activation failed, but the firmware can still be
8462306a36Sopenharmony_ci  activated via the legacy method of power-cycling the system.
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci[1]: https://docs.pmem.io/persistent-memory/
87