All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: mediatek: Disable ACP to fix 3D on MT8192
@ 2022-01-10 18:13 ` Alyssa Rosenzweig
  0 siblings, 0 replies; 42+ messages in thread
From: Alyssa Rosenzweig @ 2022-01-10 18:13 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Michael Turquette, Stephen Boyd, Matthias Brugger, Ikjoon Jang,
	Chun-Jie Chen, Weiyi Lu, Alyssa Rosenzweig, linux-clk,
	linux-arm-kernel, Nick Fan, Nicolas Boichat

Set a mysterious chicken bit in the MT8192 clock driver (!) to get the
Mali GPU on MT8192 to work. This workaround is from the downstream Mali
driver shipped in ChromeOS. The change there is unsuitable for mainline
but good as a reference for the hardware behaviour:

https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2781271/5

That links to an internal Google issue tracker which I assume has more
information on the bug. I would appreciate if someone from Google or
MediaTek could explain what this change actually does and why it's
necessary on MT8192.

At any rate, this register logically belongs to the MT8192 "infra" clock
device, so it makes sense to set it there too. This avoids adding any
platform-specific hacks to the 3D driver, either mainline (Panfrost) or
legacy (kbase).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Cc: Nick Fan <Nick.Fan@mediatek.com>
Cc: Nicolas Boichat <drinkcat@chromium.org>
---
 drivers/clk/mediatek/clk-mt8192.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-mt8192.c
index cbc7c6dbe0f4..e3673494d08d 100644
--- a/drivers/clk/mediatek/clk-mt8192.c
+++ b/drivers/clk/mediatek/clk-mt8192.c
@@ -1179,6 +1179,10 @@ static const struct mtk_pll_data plls[] = {
 
 static struct clk_onecell_data *top_clk_data;
 
+/* Control registers in the infra block used to set a chicken bit */
+#define INFRA_CTRL 0x290
+#define INFRA_CTRL_DISABLE_MFG2ACP BIT(9)
+
 static void clk_mt8192_top_init_early(struct device_node *node)
 {
 	int i;
@@ -1224,6 +1228,29 @@ static int clk_mt8192_top_probe(struct platform_device *pdev)
 	return of_clk_add_provider(node, of_clk_src_onecell_get, top_clk_data);
 }
 
+/*
+ * Disable ACP on the infra clock. Setting this quirk is required for 3D to
+ * work correctly. Without this quirk, any work queued to the Mali GPU faults,
+ * for example raising a Data Invalid Fault. This suggests the GPU is failing
+ * to read back the contents of shared CPU/GPU memory correctly, perhaps due to
+ * a MT8192 platform integration issue breaking memory or caches.
+ *
+ * Relevant downstream change:
+ * https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2781271/5
+ */
+static int clk_mt8192_infra_disable_mfg2acp(struct platform_device *pdev)
+{
+	void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
+	void __iomem *infra_ctrl = base + INFRA_CTRL;
+
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	writel(readl(infra_ctrl) | INFRA_CTRL_DISABLE_MFG2ACP, infra_ctrl);
+
+	return 0;
+}
+
 static int clk_mt8192_infra_probe(struct platform_device *pdev)
 {
 	struct clk_onecell_data *clk_data;
@@ -1238,6 +1265,10 @@ static int clk_mt8192_infra_probe(struct platform_device *pdev)
 	if (r)
 		return r;
 
+	r = clk_mt8192_infra_disable_mfg2acp(pdev);
+	if (r)
+		return r;
+
 	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 }
 
-- 
2.30.2


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

end of thread, other threads:[~2022-02-17 21:41 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 18:13 [PATCH] clk: mediatek: Disable ACP to fix 3D on MT8192 Alyssa Rosenzweig
2022-01-10 18:13 ` Alyssa Rosenzweig
2022-01-10 18:13 ` Alyssa Rosenzweig
2022-01-14  2:08 ` Stephen Boyd
2022-01-14  2:08   ` Stephen Boyd
2022-01-14  2:08   ` Stephen Boyd
2022-01-14 13:23 ` Robin Murphy
2022-01-14 13:23   ` Robin Murphy
2022-01-14 13:23   ` Robin Murphy
2022-01-14 13:47   ` Alyssa Rosenzweig
2022-01-14 13:47     ` Alyssa Rosenzweig
2022-01-14 13:47     ` Alyssa Rosenzweig
2022-01-18  7:19     ` Chen-Yu Tsai
2022-01-18  7:19       ` Chen-Yu Tsai
2022-01-18  7:19       ` Chen-Yu Tsai
2022-01-18 15:01       ` Robin Murphy
2022-01-18 15:01         ` Robin Murphy
2022-01-18 15:01         ` Robin Murphy
2022-01-19  2:18         ` Stephen Boyd
2022-01-19  2:18           ` Stephen Boyd
2022-01-19  2:18           ` Stephen Boyd
2022-01-20 14:22           ` Robin Murphy
2022-01-20 14:22             ` Robin Murphy
2022-01-20 14:22             ` Robin Murphy
2022-01-20 14:27             ` Alyssa Rosenzweig
2022-01-20 14:27               ` Alyssa Rosenzweig
2022-01-20 14:27               ` Alyssa Rosenzweig
2022-02-15 10:44               ` AngeloGioacchino Del Regno
2022-02-15 10:44                 ` AngeloGioacchino Del Regno
2022-02-15 10:44                 ` AngeloGioacchino Del Regno
2022-02-15 15:21                 ` Robin Murphy
2022-02-15 15:21                   ` Robin Murphy
2022-02-15 15:21                   ` Robin Murphy
2022-02-15 16:12                   ` AngeloGioacchino Del Regno
2022-02-15 16:12                     ` AngeloGioacchino Del Regno
2022-02-15 16:12                     ` AngeloGioacchino Del Regno
2022-02-17 21:40                   ` Stephen Boyd
2022-02-17 21:40                     ` Stephen Boyd
2022-02-17 21:40                     ` Stephen Boyd
2022-01-14 22:55   ` Stephen Boyd
2022-01-14 22:55     ` Stephen Boyd
2022-01-14 22:55     ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.