public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] bus: fsl-mc: wait for the MC firmware to complete its boot
@ 2026-04-01 14:45 Ioana Ciornei
  2026-04-04 16:54 ` Christophe Leroy (CS GROUP)
  0 siblings, 1 reply; 2+ messages in thread
From: Ioana Ciornei @ 2026-04-01 14:45 UTC (permalink / raw)
  To: chleroy, linuxppc-dev, linux-kernel; +Cc: Ioana Ciornei

There are use cases in which the Management Complex firmware boot
process is started by the bootloader which does not wait for the boot to
complete. This is mainly done in order to reduce the overall boot time
of a DPAA2 based SoC.

In this kind of circumstance, the fsl-mc bus driver needs to make sure
that the MC firmware boot process is finished before proceeding to the
usual operations such as interrogating the firmware to gather all
existent DPAA2 objects, creating the fsl-mc devices on the bus etc.

Add this kind of check early in the boot process of the fsl-mc bus and
defer the probe in case the firmware is still in its boot process.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 46 +++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index d54dd80c6503..64d75eed0d34 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -66,6 +66,13 @@ struct fsl_mc_addr_translation_range {
 #define GCR1_P1_STOP	BIT(31)
 #define GCR1_P2_STOP	BIT(30)
 
+#define FSL_MC_GSR		0x8
+#define FSL_MC_GSR_BOOT_DONE	BIT(0)
+#define FSL_MC_GSR_MCS_MASK	GENMASK(7, 0)
+#define FSL_MC_GSR_MCS_ERR_MASK	GENMASK(7, 1)
+#define FSL_MC_GSR_BC_MASK	GENMASK(15, 8)
+#define FSL_MC_GSR_BC_SHIFT	8
+
 #define FSL_MC_FAPR	0x28
 #define MC_FAPR_PL	BIT(18)
 #define MC_FAPR_BMT	BIT(17)
@@ -990,6 +997,41 @@ static int get_mc_addr_translation_ranges(struct device *dev,
 	return 0;
 }
 
+static u32 fsl_mc_read_gsr(struct fsl_mc *mc)
+{
+	return readl(mc->fsl_mc_regs + FSL_MC_GSR);
+}
+
+static int fsl_mc_firmware_check(struct platform_device *pdev)
+{
+	struct fsl_mc *mc = platform_get_drvdata(pdev);
+	u32 gsr, boot_done, boot_code, mcs;
+
+	gsr = fsl_mc_read_gsr(mc);
+	boot_code = (gsr & FSL_MC_GSR_BC_MASK) >> FSL_MC_GSR_BC_SHIFT;
+	if (boot_code == 0xDD) {
+		dev_err(&pdev->dev,
+			"fsl-mc: DPL processing was not started, DPAA2 will not work!\n");
+		return -EOPNOTSUPP;
+	}
+
+	boot_done = gsr & FSL_MC_GSR_BOOT_DONE;
+	if (!boot_done) {
+		dev_dbg(&pdev->dev,
+			"fsl-mc: DPL processing in progress, defer probe\n");
+		return -EPROBE_DEFER;
+	}
+
+	mcs = gsr & FSL_MC_GSR_MCS_MASK;
+	if (mcs & FSL_MC_GSR_MCS_ERR_MASK) {
+		dev_err(&pdev->dev,
+			"fsl-mc: MC boot completed with error 0x%x\n", mcs);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * fsl_mc_bus_probe - callback invoked when the root MC bus is being
  * added
@@ -1054,6 +1096,10 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 		       mc->fsl_mc_regs + FSL_MC_GCR1);
 	}
 
+	error = fsl_mc_firmware_check(pdev);
+	if (error)
+		return error;
+
 	/*
 	 * Get physical address of MC portal for the root DPRC:
 	 */
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bus: fsl-mc: wait for the MC firmware to complete its boot
  2026-04-01 14:45 [PATCH] bus: fsl-mc: wait for the MC firmware to complete its boot Ioana Ciornei
@ 2026-04-04 16:54 ` Christophe Leroy (CS GROUP)
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-04-04 16:54 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Ioana Ciornei; +Cc: Christophe Leroy


On Wed, 01 Apr 2026 17:45:08 +0300, Ioana Ciornei wrote:
> There are use cases in which the Management Complex firmware boot
> process is started by the bootloader which does not wait for the boot to
> complete. This is mainly done in order to reduce the overall boot time
> of a DPAA2 based SoC.
> 
> In this kind of circumstance, the fsl-mc bus driver needs to make sure
> that the MC firmware boot process is finished before proceeding to the
> usual operations such as interrogating the firmware to gather all
> existent DPAA2 objects, creating the fsl-mc devices on the bus etc.
> 
> [...]

Applied, thanks!

[1/1] bus: fsl-mc: wait for the MC firmware to complete its boot
      commit: 208858b1b48eba83d073542372329cf8ed606526

Best regards,
-- 
Christophe Leroy (CS GROUP) <chleroy@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-04 16:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01 14:45 [PATCH] bus: fsl-mc: wait for the MC firmware to complete its boot Ioana Ciornei
2026-04-04 16:54 ` Christophe Leroy (CS GROUP)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox