mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: <linux-kernel@vger.kernel.org>, <monstr@monstr.eu>,
	<michal.simek@amd.com>, <git@amd.com>
Cc: Ulf Hansson <ulfh@kernel.org>,
	"moderated list:ARM/ZYNQ ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 1/6] firmware: xilinx: Use late_initcall for pm_init_finalize
Date: Thu, 19 Nov 2026 14:17:25 +0100	[thread overview]
Message-ID: <b22f67ed91d6a49f240a63bb57a87dfda2ddf062.1795094242.git.michal.simek@amd.com> (raw)
In-Reply-To: <cover.1795094242.git.michal.simek@amd.com>

The current implementation uses the driver sync_state callback to call
zynqmp_pm_init_finalize(). This callback only fires when all consumers
of the firmware node have probed their drivers. If any consumer device
has its driver disabled or built as a never-loaded module, sync_state
never fires and pm_init_finalize is never called.

This causes PMUFW to remain in UNINITIALIZED state, leading to IPI
deadlock during CPU idle on ZynqMP platforms.

Replace sync_state with late_initcall to guarantee pm_init_finalize is
called. By late_initcall time, all built-in drivers including the
console UART have probed and requested their power domains, avoiding
any race with early console.

Removing of_genpd_sync_state() from the firmware driver is safe
because the genpd framework automatically sets up its own sync_state
handler on the firmware driver via dev_set_drv_sync_state() when the
PM domain driver registers with of_genpd_add_provider_onecell().
Power domain cleanup continues to work independently without the
firmware driver explicitly calling of_genpd_sync_state().

Fixes: 3da405ead651 ("firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver")
Signed-off-by: Ronak Jain <ronak.jain@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---

 drivers/firmware/xilinx/zynqmp.c | 41 ++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d76660c55354..22ee6ccdb02c 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -21,7 +21,6 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
-#include <linux/pm_domain.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/hashtable.h>
@@ -2370,19 +2369,6 @@ static void zynqmp_firmware_remove(struct platform_device *pdev)
 	platform_device_unregister(em_dev);
 }
 
-static void zynqmp_firmware_sync_state(struct device *dev)
-{
-	struct device_node *np = dev->of_node;
-
-	if (!of_device_is_compatible(np, "xlnx,zynqmp-firmware"))
-		return;
-
-	of_genpd_sync_state(np);
-
-	if (zynqmp_pm_init_finalize())
-		dev_warn(dev, "failed to release power management to firmware\n");
-}
-
 static const struct platform_fw_data platform_fw_data_versal = {
 	.family_code = PM_VERSAL_FAMILY_CODE,
 };
@@ -2408,10 +2394,35 @@ static struct platform_driver zynqmp_firmware_driver = {
 		.name = "zynqmp_firmware",
 		.of_match_table = zynqmp_firmware_of_match,
 		.dev_groups = zynqmp_firmware_groups,
-		.sync_state = zynqmp_firmware_sync_state,
 	},
 	.probe = zynqmp_firmware_probe,
 	.remove = zynqmp_firmware_remove,
 	.shutdown = zynqmp_firmware_shutdown,
 };
 module_platform_driver(zynqmp_firmware_driver);
+
+/*
+ * pm_init_finalize was previously called from the firmware driver's
+ * sync_state callback, but sync_state can be blocked indefinitely if
+ * any device consumer never probes. Use late_initcall to ensure
+ * pm_init_finalize is called reliably regardless of consumer
+ * probe status.
+ */
+static int __init zynqmp_pm_init_finalize_late(void)
+{
+	u32 pm_family_code;
+	int ret;
+
+	ret = zynqmp_pm_get_family_info(&pm_family_code);
+	if (ret)
+		return ret;
+
+	if (pm_family_code != PM_ZYNQMP_FAMILY_CODE)
+		return 0;
+
+	if (zynqmp_pm_init_finalize())
+		pr_warn("zynqmp: failed to release power management to firmware\n");
+
+	return 0;
+}
+late_initcall(zynqmp_pm_init_finalize_late);
-- 
2.43.0


  reply	other threads:[~2026-11-19 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
2026-11-19 13:17 ` Michal Simek [this message]
2026-11-19 13:17 ` [PATCH 2/6] firmware: xilinx: Call va_start after pm feature check Michal Simek
2026-11-19 13:17 ` [PATCH 3/6] firmware: xilinx: Add comments about number of arguments Michal Simek
2026-11-19 13:17 ` [PATCH 4/6] firmware: xilinx: Call pm sysfs out of dev_groups Michal Simek
2026-11-19 13:17 ` [PATCH 5/6] firmware: xilinx: Change debugfs pm_api_ret size to PAYLOAD_ARG_CNT Michal Simek
2026-11-19 13:17 ` [PATCH 6/6] firmware: xilinx: Bound debugfs clock name formatting Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b22f67ed91d6a49f240a63bb57a87dfda2ddf062.1795094242.git.michal.simek@amd.com \
    --to=michal.simek@amd.com \
    --cc=git@amd.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=monstr@monstr.eu \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®