OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Valentin Haudiquet <valentin.haudiquet@canonical.com>
To: opensbi@lists.infradead.org
Cc: troy.mitchell@linux.spacemit.com, xianbin.zhu@linux.spacemit.com,
	anup@brainfault.org, ganboing@gmail.com,
	samuel.holland@sifive.com, heinrich.schuchardt@canonical.com,
	Valentin Haudiquet <valentin.haudiquet@canonical.com>
Subject: [PATCH 1/3] platform: generic: spacemit: k3: de-vote cluster power-downs and ungate DMASYS before CCI enable
Date: Mon, 31 Aug 2026 22:07:50 +0200	[thread overview]
Message-ID: <20260831200832.404000-2-valentin.haudiquet@canonical.com> (raw)
In-Reply-To: <20260831200832.404000-1-valentin.haudiquet@canonical.com>

The v3 patch enables CCI-550 snoop/DVM requests for all seven slave
interfaces before de-voting cluster power-downs.  Clusters that are
still voted for power-down cause the CCI status change-pending
busy-wait to hang indefinitely when snoop/DVM is enabled on their
slave interfaces.

De-vote power-down for all four clusters and the boot hart's core
BEFORE enabling CCI.  Also deassert DMASYS reset and enable its clock
before CCI: the DMA engine sits behind the AIDMA CCI slave interface,
and if DMASYS is held in reset the CCI busy-wait hangs when enabling
snoop/DVM on that interface.

Add DMASYS_RESET and DMASYS_CLK_EN register definitions to k3.h.

Signed-off-by: Valentin Haudiquet <valentin.haudiquet@canonical.com>
---
 platform/generic/include/spacemit/k3.h |  5 +++
 platform/generic/spacemit/k3.c         | 50 ++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/platform/generic/include/spacemit/k3.h b/platform/generic/include/spacemit/k3.h
index f444d064..ed1637b9 100644
--- a/platform/generic/include/spacemit/k3.h
+++ b/platform/generic/include/spacemit/k3.h
@@ -124,4 +124,9 @@
 #define PLAT_CCI_K3_CLUSTER3_0_IFACE_IX	5
 #define PLAT_CCI_K3_CLUSTER3_1_IFACE_IX	6
 
+/* DMASYS reset and clock enable */
+#define DMASYS_RESET				(0xd8440000 + 0x22c)
+#define DMASYS_CLK_EN				(0xd8440000 + 0x234)
+#define DMASYS_RESET_DEASSERT			BIT(0)
+#define DMASYS_CLK_EN_BIT			BIT(0)
 #endif /* __RISCV_SPACEMIT_K3_H__ */
diff --git a/platform/generic/spacemit/k3.c b/platform/generic/spacemit/k3.c
index 967d09bf..12c991b6 100644
--- a/platform/generic/spacemit/k3.c
+++ b/platform/generic/spacemit/k3.c
@@ -56,14 +56,39 @@ static void spacemit_k3_hart_init(u32 hartid)
 	}
 }
 
-/* The boot hart is already running, so it is never started by the HSM. */
-static void spacemit_k3_keep_boot_hart_powered(void)
+/*
+ * De-vote power-down for all four clusters.  This must happen BEFORE
+ * CCI snoop/DVM enable: clusters still in power-down vote cause the
+ * CCI busy-wait to hang when enabling snoop/DVM on their slave interfaces.
+ */
+static void spacemit_k3_keep_all_clusters_powered(void)
 {
 	u32 value;
+	int i;
 
-	value = readl((void *)(unsigned long)PMU_CX_CAPMP_IDLE_CFG0);
-	value &= ~CLUSTER_PWR_DOWN_VALUE;
-	writel(value, (void *)(unsigned long)PMU_CX_CAPMP_IDLE_CFG0);
+	static const u32 cluster_idle_regs[] = {
+		PMU_CX_CAPMP_IDLE_CFG0,   /* cluster 0 (harts 0-3)  */
+		PMU_CX_CAPMP_IDLE_CFG4,   /* cluster 1 (harts 4-7)  */
+		PMU_CX_CAPMP_IDLE_CFG8,   /* cluster 2 (harts 8-11) */
+		PMU_CX_CAPMP_IDLE_CFG12,  /* cluster 3 (harts 12-15) */
+	};
+
+	for (i = 0; i < 4; i++) {
+		value = readl((void *)(unsigned long)cluster_idle_regs[i]);
+		value &= ~CLUSTER_PWR_DOWN_VALUE;
+		writel(value, (void *)(unsigned long)cluster_idle_regs[i]);
+	}
+}
+
+/*
+ * De-vote the boot hart's core-level power-down.  The cluster-level
+ * de-vote for cluster 0 is already done by keep_all_clusters_powered();
+ * this clears the per-core idle config so the boot hart is never
+ * powered down by the PMU.
+ */
+static void spacemit_k3_keep_boot_hart_powered(void)
+{
+	u32 value;
 
 	value = readl((void *)(unsigned long)PMU_AP_CORE0_IDLE_CFG);
 	value &= ~PMU_AP_IDLE_PWRDOWN_K3_MASK;
@@ -88,10 +113,21 @@ static void spacemit_k3_pre_init(void)
 	writel((u32)entry, (void *)(unsigned long)C3_RVBADDR_LO_ADDR);
 	writel((u32)(entry >> 32), (void *)(unsigned long)C3_RVBADDR_HI_ADDR);
 
+	/* De-vote all cluster power-downs BEFORE CCI enable. */
+	spacemit_k3_keep_all_clusters_powered();
+	spacemit_k3_keep_boot_hart_powered();
+
+	/*
+	 * Deassert DMASYS reset and enable its clock before CCI: the DMA
+	 * engine sits behind the AIDMA CCI slave interface.  If DMASYS is
+	 * held in reset or its clock is gated, the CCI busy-wait hangs when
+	 * enabling snoop/DVM on that interface.
+	 */
+	writel(DMASYS_RESET_DEASSERT, (void *)(unsigned long)DMASYS_RESET);
+	writel(DMASYS_CLK_EN_BIT, (void *)(unsigned long)DMASYS_CLK_EN);
+
 	for (i = 0; i < array_size(cci_map); i++)
 		cci_enable_snoop_dvm_reqs(cci_map, i);
-
-	spacemit_k3_keep_boot_hart_powered();
 }
 
 static int spacemit_k3_early_init(bool cold_boot)
-- 
2.53.0


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

  parent reply	other threads:[~2026-08-31 20:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27  9:19 [PATCH v3 0/5] platform: generic: spacemit: add K3 platform support Troy Mitchell
2026-08-27  9:19 ` [PATCH v3 1/5] lib: sbi: select expected trap handler per hart Troy Mitchell
2026-08-31  2:21   ` Alvin Chang
2026-09-01  5:45     ` Troy Mitchell
2026-08-27  9:19 ` [PATCH v3 2/5] platform: generic: spacemit: k1: rename cache flush operation Troy Mitchell
2026-08-27  9:19 ` [PATCH v3 3/5] platform: generic: spacemit: k1: move hart init to nascent hook Troy Mitchell
2026-08-27  9:19 ` [PATCH v3 4/5] platform: generic: spacemit: k1: refactor platform support Troy Mitchell
2026-08-27  9:19 ` [PATCH v3 5/5] platform: generic: spacemit: k3: add " Troy Mitchell
     [not found] ` <20260831200832.404000-1-valentin.haudiquet@canonical.com>
2026-08-31 20:07   ` Valentin Haudiquet [this message]
2026-09-01  2:25     ` [PATCH 1/3] platform: generic: spacemit: k3: de-vote cluster power-downs and ungate DMASYS before CCI enable Troy Mitchell
2026-08-31 20:07   ` [PATCH 2/3] platform: generic: spacemit: k3: override cold_boot_allowed for hart 0 only Valentin Haudiquet
2026-09-01  5:45     ` Troy Mitchell
2026-08-31 20:07   ` [PATCH 3/3] platform: generic: spacemit: k3: wake A100 core 8 for ESOS/RPMI services Valentin Haudiquet
2026-09-01  2:25     ` Troy Mitchell
2026-09-01  5:48   ` [PATCH 0/3] platform: generic: spacemit: k3: follow-up fixes Troy Mitchell
2026-09-02  8:41     ` Bo Gan
2026-09-02  9:38       ` Troy Mitchell
2026-09-02 11:42         ` Valentin Haudiquet
2026-09-01 22:41   ` [PATCH v3 0/5] platform: generic: spacemit: add K3 platform support Bo Gan
2026-09-02  5:51     ` Bo Gan

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=20260831200832.404000-2-valentin.haudiquet@canonical.com \
    --to=valentin.haudiquet@canonical.com \
    --cc=anup@brainfault.org \
    --cc=ganboing@gmail.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=opensbi@lists.infradead.org \
    --cc=samuel.holland@sifive.com \
    --cc=troy.mitchell@linux.spacemit.com \
    --cc=xianbin.zhu@linux.spacemit.com \
    /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