summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
authorJay Buddhabhatti <jay.buddhabhatti@amd.com>2026-07-29 05:25:20 -0700
committerMichal Simek <michal.simek@amd.com>2026-08-10 09:30:44 +0200
commit00bee072c8ae394b029ed4ce6fc8def3e5627e1c (patch)
tree420206aaf49486931e84a802b27af84b4f01e7a2 /drivers/firmware
parent5b8c4b238b02db7af65f349a9d677c2dd60359ac (diff)
firmware: xilinx: Add support to clear EL3 PM state
Currently, during a kexec restart, only the kernel is reloaded, while EL3-specific data remain unchanged. This leads to a mismatch between the kernel state and secure firmware state like SGI number and shutdown scope variable. For example, the kernel registers an SGI number with EL3 firmware so that secure firmware can notify the kernel of events via that SGI. EL3 stores this SGI number in its internal state. After a kexec, the newly loaded kernel re-registers and may request a different SGI number, but the stale value programmed in EL3 remains, so event notifications are delivered on the old SGI and are missed by the new kernel. The shutdown scope variable has a similar stale state problem. To resolve this, the TF_A_CLEAR_PM_STATE PM API is introduced to clear EL3 PM subsystem state during kexec. On a graceful reboot, this API is triggered by zynqmp_firmware_shutdown(), while in a crash kernel scenario, it is invoked by zynqmp_firmware_probe() in the reloaded kernel. Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> Reviewed-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com> Link: https://patch.msgid.link/20260729122522.3732875-2-jay.buddhabhatti@amd.com Signed-off-by: Michal Simek <michal.simek@amd.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/xilinx/zynqmp.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 1e3ade42b69f..e697153ff056 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -3,7 +3,7 @@
* Xilinx Zynq MPSoC Firmware layer
*
* Copyright (C) 2014-2022 Xilinx, Inc.
- * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc.
+ * Copyright (C) 2022 - 2026 Advanced Micro Devices, Inc.
*
* Michal Simek <michal.simek@amd.com>
* Davorin Mista <davorin.mista@aggios.com>
@@ -13,6 +13,7 @@
#include <linux/arm-smccc.h>
#include <linux/compiler.h>
+#include <linux/crash_dump.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/mfd/core.h>
@@ -2068,6 +2069,44 @@ static struct attribute *zynqmp_firmware_attrs[] = {
ATTRIBUTE_GROUPS(zynqmp_firmware);
+/**
+ * zynqmp_clear_pm_state() - Clear subsystem state
+ * @dev: Device pointer used for logging
+ *
+ * Clears PM specific data in EL3 firmware.
+ *
+ * Return: Returns status, either success or error
+ */
+static int zynqmp_clear_pm_state(struct device *dev)
+{
+ u32 pm_family_code;
+ int ret;
+
+ /* Get the Family code of platform */
+ ret = zynqmp_pm_get_family_info(&pm_family_code);
+ if (ret < 0)
+ return ret;
+
+ /* Supporting on Versal and Versal Net platforms only */
+ if (pm_family_code == PM_VERSAL_FAMILY_CODE ||
+ pm_family_code == PM_VERSAL_NET_FAMILY_CODE) {
+ /* Check if EL3 firmware supports TF_A_CLEAR_PM_STATE */
+ ret = do_feature_check_call(TF_A_CLEAR_PM_STATE);
+ if (ret >= 0 && ((ret & FIRMWARE_VERSION_MASK) >= PM_API_VERSION_1)) {
+ /* Clear PM specific data in EL3 firmware */
+ ret = zynqmp_pm_invoke_fn(TF_A_CLEAR_PM_STATE, NULL, 0);
+ if (ret)
+ dev_err(dev,
+ "Failed to clear EL3 PM subsystem state: %d\n", ret);
+ } else {
+ dev_warn(dev, "TF_A_CLEAR_PM_STATE is not supported by EL3 firmware: %d\n", ret);
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
static int zynqmp_firmware_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2121,6 +2160,9 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
+ if (is_kdump_kernel())
+ zynqmp_clear_pm_state(dev);
+
/* Check trustzone version number */
ret = zynqmp_pm_get_trustzone_version(&pm_tz_version);
if (ret)
@@ -2154,6 +2196,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
return of_platform_populate(dev->of_node, NULL, NULL, dev);
}
+static void zynqmp_firmware_shutdown(struct platform_device *pdev)
+{
+ zynqmp_clear_pm_state(&pdev->dev);
+}
+
static void zynqmp_firmware_remove(struct platform_device *pdev)
{
struct pm_api_feature_data *feature_data;
@@ -2213,5 +2260,6 @@ static struct platform_driver zynqmp_firmware_driver = {
},
.probe = zynqmp_firmware_probe,
.remove = zynqmp_firmware_remove,
+ .shutdown = zynqmp_firmware_shutdown,
};
module_platform_driver(zynqmp_firmware_driver);