Skip to contentSkip to conversation

Add Mali GPU support for Mediatek MT8370 SoC

PATCH In review Louis-Alexis Eyraud 2 participants 9 messages May 9, 2025 – Jun 20, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v6 cover Add Mali GPU support for Mediatek MT8370 SoC

This patchset adds the support of the ARM Mali G57 MC2 GPU (Valhall-JM, dual core), integrated in the Mediatek MT8370 SoC, to the panfrost driver and to the mt8370.dtsi include file.

Since v4 patchset was sent, the [1] patchset adds in panfrost driver the AARCH64_4K page table format support and enablement for Mediatek SoC with integrated Arm Mali-G57, already supported in panfrost driver (like MT8188, MT8192, MT8195, MT8390, MT8395...).
As MT8370 SoC is a less powerful variant of MT8390 (same GPU but with one less core for MT8370), I've reworked the second patch ('drm/panfrost: Add support for Mali on the MT8370 SoC') to enable the AARCH64_4K mode on this SoC as well by adding specific MT8370 platform data to set the needed flag.
The previous patch revision uses MT8186 platform data because despite having different GPU architecture (Mali G52 2EE MC2 for MT8186, making them not compatible), using the same plaform data, for describing the same power management features only, was okay.
But now, the platform data also contains the GPU configuration quirk bitfield that needs to be modified to enable the AARCH64_4K page table format, and in order not to change MT8186 behaviour, I add specific MT8370 platform data.

I've tested this patchset on a Mediatek Genio 510 EVK board, with a kernel based on linux-next (tag: next-20250502).

The panfrost driver probed with the following messages:

```
panfrost 13000000.gpu: clock rate = 390000000
panfrost 13000000.gpu: mali-g57 id 0x9093 major 0x0 minor 0x0 status 0x0
panfrost 13000000.gpu: features: 00000000,000019f7, issues: 00000003,
  80000400
panfrost 13000000.gpu: Features: L2:0x08130206 Shader:0x00000000
  Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7
panfrost 13000000.gpu: shader_present=0x5 l2_present=0x1
[drm] Initialized panfrost 1.3.0 for 13000000.gpu on minor 0
```

Running glmark2-es2-drm is also OK:

```
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    Mali-G57 (Panfrost)
    GL_VERSION:     OpenGL ES 3.1 Mesa 25.0.3-1
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   1200x1920 fullscreen
=======================================================
[build] use-vbo=false: FPS: 952 FrameTime: 1.051 ms
[build] use-vbo=true: FPS: 983 FrameTime: 1.018 ms
[texture] texture-filter=nearest: FPS: 906 FrameTime: 1.105 ms
[texture] texture-filter=linear: FPS: 908 FrameTime: 1.102 ms
[texture] texture-filter=mipmap: FPS: 883 FrameTime: 1.134 ms
[shading] shading=gouraud: FPS: 838 FrameTime: 1.194 ms
[shading] shading=blinn-phong-inf: FPS: 778 FrameTime: 1.287 ms
[shading] shading=phong: FPS: 583 FrameTime: 1.717 ms
[shading] shading=cel: FPS: 553 FrameTime: 1.809 ms
[bump] bump-render=high-poly: FPS: 573 FrameTime: 1.747 ms
[bump] bump-render=normals: FPS: 868 FrameTime: 1.153 ms
[bump] bump-render=height: FPS: 707 FrameTime: 1.415 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 454 FrameTime: 2.204 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 172 FrameTime:
  5.843 ms
[pulsar] light=false:quads=5:texture=false: FPS: 770 FrameTime:
  1.300 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:
  FPS: 161 FrameTime: 6.235 ms
[desktop] effect=shadow:windows=4: FPS: 484 FrameTime: 2.069 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction
  =0.5:update-method=map: FPS: 512 FrameTime: 1.955 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction
  =0.5:update-method=subdata: FPS: 513 FrameTime: 1.952 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction
  =0.5:update-method=map: FPS: 577 FrameTime: 1.735 ms
[ideas] speed=duration: FPS: 448 FrameTime: 2.235 ms
[jellyfish] <default>: FPS: 226 FrameTime: 4.440 ms
[terrain] <default>: FPS: 38 FrameTime: 26.861 ms
[shadow] <default>: FPS: 328 FrameTime: 3.051 ms
[refract] <default>: FPS: 72 FrameTime: 13.937 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 844 FrameTime:
  1.186 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 685 FrameTime: 
  1.462 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 833 FrameTime:
  1.201 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 830 FrameTime:
  1.205 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 525 FrameTime:
  1.905 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 837
  FrameTime: 1.195 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 835 
  FrameTime: 1.199 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 550
  FrameTime: 1.820 ms
=======================================================
                                  glmark2 Score: 611 
=======================================================
```

[1] https://lore.kernel.org/dri-devel/[email protected]/

---
Changes in v6:
- Add two new patches to commonize and drop duplicated data related to
the power domain and supplies definitions for Mediatek SoC
- Remove useless comment and rework MT8370 platform data to use mediatek_pm_domains and default_supplies arrays in 'drm/panfrost: Add
support for Mali on the MT8370 SoC'
- Update code-review trailer
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Rebase on linux-next (tqg: next-2020501)
- Rework 'drm/panfrost: Add support for Mali on the MT8370 SoC' patch
to have MT8370 support with its AARCH64_4K page table format support enabled
- Drop code-review trailers from 'drm/panfrost: Add support for Mali on
the MT8370 SoC' patch due to major changes in content and commit message
- Add ack trailer for 'dt-bindings: gpu: mali-bifrost: Add compatible
for MT8370 SoC' patch
- Add glmark2-es2-drm benchmark results in cover letter
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Add warning comment in mt8370.dtsi about GPU node override
- Reword "dt-bindings: gpu: mali-bifrost: Add compatible for MT8370
SoC" commit message
- Add code-review trailers
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Rebased on linux-next (tag: next-20250207)
- Remove prerequisite change/patch ids
- Reword commit messages to better explicit compatible needs
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rework "drm/panfrost: Add support for Mali on the MT8370 SoC" to avoid
data structure duplication, as requested by Krzysztof Kozlowski
- Reword commit messages to use imperative mood and make new compatible
need more explicit
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis-Alexis Eyraud (5):
dt-bindings: gpu: mali-bifrost: Add compatible for MT8370 SoC drm/panfrost: Drop duplicated Mediatek supplies arrays drm/panfrost: Commonize Mediatek power domain array definitions drm/panfrost: Add support for Mali on the MT8370 SoC
arm64: dts: mediatek: mt8370: Enable gpu support

 .../devicetree/bindings/gpu/arm,mali-bifrost.yaml  |  5 +-
 arch/arm64/boot/dts/mediatek/mt8370.dtsi           | 16 ++++++
 drivers/gpu/drm/panfrost/panfrost_drv.c            | 61 ++++++++++++----------
 3 files changed, 53 insertions(+), 29 deletions(-)

---
base-commit: 1c51b1ba38c07e4f999802eb708bf798dd5f5d1b
change-id: 20250115-mt8370-enable-gpu-3b6f595fa63d

Best regards,

Signature · 1 line
Louis-Alexis Eyraud <[email protected]>
#1 lore raw

PATCH v6 1/5 dt-bindings: gpu: mali-bifrost: Add compatible for MT8370 SoC

Add a compatible for the MediaTek MT8370 SoC, with an integrated ARM Mali G57 MC2 GPU (Valhall-JM, dual core). None of the already existing SoC specific compatibles is usable as fallback, as those either do not match the number of cores (and number of power domains), or are for a different GPU architecture.

---
 Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml +4 -1
index 019bd28a29f19bb4f7a9c32434b208b6d04db221..5726b79fd0f9de8914f724929f462409e088ec31 100644
@@ -40,6 +40,7 @@ properties:
           - enum:
               - mediatek,mt8188-mali
               - mediatek,mt8192-mali
+              - mediatek,mt8370-mali
           - const: arm,mali-valhall-jm # Mali Valhall GPU model/revision is fully discoverable
 
   reg:
@@ -221,7 +222,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: mediatek,mt8186-mali
+            enum:
+              - mediatek,mt8186-mali
+              - mediatek,mt8370-mali
     then:
       properties:
         power-domains:
Signature · 1 line
2.49.0
#2 lore raw

PATCH v6 2/5 drm/panfrost: Drop duplicated Mediatek supplies arrays

In reply to Louis-Alexis Eyraud

In the panfrost driver, the platform data of several Mediatek SoC declares and uses custom supplies array definitions (mediatek_mt8192_supplies, mediatek_mt8183_b_supplies), that are the same as default_supplies (used by default platform data).

So drop these duplicated definitions and use default_supplies instead. Also, rename mediatek_mt8183_supplies to a more generic name too (legacy_supplies).

---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +11 -13
index f1ec3b02f15a0029d20c7d81046ded59854e885c..7b899a9b2120c608e61dab9ca831ab8e907e8139 100644
@@ -797,19 +797,18 @@ static const struct panfrost_compatible amlogic_data = {
  * On new devicetrees please use the _b variant with a single and
  * coupled regulators instead.
  */
-static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL };
+static const char * const legacy_supplies[] = { "mali", "sram", NULL };
 static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" };
 static const struct panfrost_compatible mediatek_mt8183_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1,
-	.supply_names = mediatek_mt8183_supplies,
+	.num_supplies = ARRAY_SIZE(legacy_supplies) - 1,
+	.supply_names = legacy_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 };
 
-static const char * const mediatek_mt8183_b_supplies[] = { "mali", NULL };
 static const struct panfrost_compatible mediatek_mt8183_b_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
@@ -817,8 +816,8 @@ static const struct panfrost_compatible mediatek_mt8183_b_data = {
 
 static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" };
 static const struct panfrost_compatible mediatek_mt8186_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains),
 	.pm_domain_names = mediatek_mt8186_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
@@ -826,20 +825,19 @@ static const struct panfrost_compatible mediatek_mt8186_data = {
 
 /* MT8188 uses the same power domains and power supplies as MT8183 */
 static const struct panfrost_compatible mediatek_mt8188_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
 
-static const char * const mediatek_mt8192_supplies[] = { "mali", NULL };
 static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2",
 							   "core3", "core4" };
 static const struct panfrost_compatible mediatek_mt8192_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8192_supplies) - 1,
-	.supply_names = mediatek_mt8192_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains),
 	.pm_domain_names = mediatek_mt8192_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
Signature · 1 line
2.49.0
maintainer Reviewed-by on v6 2/5
#3 lore raw

Re: [PATCH v6 2/5] drm/panfrost: Drop duplicated Mediatek supplies arrays

Quoted 10 lines · Louis-Alexis Eyraud

In the panfrost driver, the platform data of several Mediatek SoC declares and uses custom supplies array definitions (mediatek_mt8192_supplies, mediatek_mt8183_b_supplies), that are the same as default_supplies (used by default platform data).

So drop these duplicated definitions and use default_supplies instead. Also, rename mediatek_mt8183_supplies to a more generic name too (legacy_supplies).

Thanks for doing this.

Quoted 70 lines
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +11 -13
index f1ec3b02f15a0029d20c7d81046ded59854e885c..7b899a9b2120c608e61dab9ca831ab8e907e8139 100644
@@ -797,19 +797,18 @@ static const struct panfrost_compatible amlogic_data = {
  * On new devicetrees please use the _b variant with a single and
  * coupled regulators instead.
  */
-static const char * const mediatek_mt8183_supplies[] = { "mali", "sram", NULL };
+static const char * const legacy_supplies[] = { "mali", "sram", NULL };
 static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" };
 static const struct panfrost_compatible mediatek_mt8183_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies) - 1,
-	.supply_names = mediatek_mt8183_supplies,
+	.num_supplies = ARRAY_SIZE(legacy_supplies) - 1,
+	.supply_names = legacy_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 };
 
-static const char * const mediatek_mt8183_b_supplies[] = { "mali", NULL };
 static const struct panfrost_compatible mediatek_mt8183_b_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
@@ -817,8 +816,8 @@ static const struct panfrost_compatible mediatek_mt8183_b_data = {
 
 static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" };
 static const struct panfrost_compatible mediatek_mt8186_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains),
 	.pm_domain_names = mediatek_mt8186_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
@@ -826,20 +825,19 @@ static const struct panfrost_compatible mediatek_mt8186_data = {
 
 /* MT8188 uses the same power domains and power supplies as MT8183 */
 static const struct panfrost_compatible mediatek_mt8188_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) - 1,
-	.supply_names = mediatek_mt8183_b_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
 	.pm_domain_names = mediatek_mt8183_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
 
-static const char * const mediatek_mt8192_supplies[] = { "mali", NULL };
 static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2",
 							   "core3", "core4" };
 static const struct panfrost_compatible mediatek_mt8192_data = {
-	.num_supplies = ARRAY_SIZE(mediatek_mt8192_supplies) - 1,
-	.supply_names = mediatek_mt8192_supplies,
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
 	.num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains),
 	.pm_domain_names = mediatek_mt8192_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
#4 lore raw

PATCH v6 3/5 drm/panfrost: Commonize Mediatek power domain array definitions

In reply to Louis-Alexis Eyraud

In the panfrost driver, the platform data of several Mediatek SoC declares and uses several different power domains arrays according to GPU core number present in the SoC:
- mediatek_mt8186_pm_domains (2 cores)
- mediatek_mt8183_pm_domains (3 cores)
- mediatek_mt8192_pm_domains (5 cores)

As they all are fixed arrays, starting with the same entries and the platform data also has a power domains array length field (num_pm_domains), they can be replaced by a single array, containing all entries, if the num_pm_domains field of the platform data is also set to the matching core number.

So, create a generic power domain array (mediatek_pm_domains) and use it in the mt8183(b), mt8186, mt8188 and mt8192 platform data instead.

---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +12 -15
index 7b899a9b2120c608e61dab9ca831ab8e907e8139..21b28bef84015793d9dba6b1e585891dc0dfcb6d 100644
@@ -789,6 +789,8 @@ static const struct panfrost_compatible amlogic_data = {
 	.vendor_quirk = panfrost_gpu_amlogic_quirk,
 };
 
+static const char * const mediatek_pm_domains[] = { "core0", "core1", "core2",
+						    "core3", "core4" };
 /*
  * The old data with two power supplies for MT8183 is here only to
  * keep retro-compatibility with older devicetrees, as DVFS will
@@ -798,48 +800,43 @@ static const struct panfrost_compatible amlogic_data = {
  * coupled regulators instead.
  */
 static const char * const legacy_supplies[] = { "mali", "sram", NULL };
-static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" };
 static const struct panfrost_compatible mediatek_mt8183_data = {
 	.num_supplies = ARRAY_SIZE(legacy_supplies) - 1,
 	.supply_names = legacy_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 };
 
 static const struct panfrost_compatible mediatek_mt8183_b_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 };
 
-static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" };
 static const struct panfrost_compatible mediatek_mt8186_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains),
-	.pm_domain_names = mediatek_mt8186_pm_domains,
+	.num_pm_domains = 2,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 };
 
-/* MT8188 uses the same power domains and power supplies as MT8183 */
 static const struct panfrost_compatible mediatek_mt8188_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
 
-static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2",
-							   "core3", "core4" };
 static const struct panfrost_compatible mediatek_mt8192_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains),
-	.pm_domain_names = mediatek_mt8192_pm_domains,
+	.num_pm_domains = 5,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
Signature · 1 line
2.49.0
maintainer Reviewed-by on v6 3/5
#5 lore raw

Re: [PATCH v6 3/5] drm/panfrost: Commonize Mediatek power domain array definitions

Quoted 13 lines · Louis-Alexis Eyraud

In the panfrost driver, the platform data of several Mediatek SoC declares and uses several different power domains arrays according to GPU core number present in the SoC:
- mediatek_mt8186_pm_domains (2 cores)
- mediatek_mt8183_pm_domains (3 cores)
- mediatek_mt8192_pm_domains (5 cores)

As they all are fixed arrays, starting with the same entries and the platform data also has a power domains array length field (num_pm_domains), they can be replaced by a single array, containing all entries, if the num_pm_domains field of the platform data is also set to the matching core number.

Quoted 4 lines

So, create a generic power domain array (mediatek_pm_domains) and use it in the mt8183(b), mt8186, mt8188 and mt8192 platform data instead.

Quoted 77 lines
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
drivers/gpu/drm/panfrost/panfrost_drv.c +12 -15
index 7b899a9b2120c608e61dab9ca831ab8e907e8139..21b28bef84015793d9dba6b1e585891dc0dfcb6d 100644
@@ -789,6 +789,8 @@ static const struct panfrost_compatible amlogic_data = {
 	.vendor_quirk = panfrost_gpu_amlogic_quirk,
 };
 
+static const char * const mediatek_pm_domains[] = { "core0", "core1", "core2",
+						    "core3", "core4" };
 /*
  * The old data with two power supplies for MT8183 is here only to
  * keep retro-compatibility with older devicetrees, as DVFS will
@@ -798,48 +800,43 @@ static const struct panfrost_compatible amlogic_data = {
  * coupled regulators instead.
  */
 static const char * const legacy_supplies[] = { "mali", "sram", NULL };
-static const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" };
 static const struct panfrost_compatible mediatek_mt8183_data = {
 	.num_supplies = ARRAY_SIZE(legacy_supplies) - 1,
 	.supply_names = legacy_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 };
 
 static const struct panfrost_compatible mediatek_mt8183_b_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 };
 
-static const char * const mediatek_mt8186_pm_domains[] = { "core0", "core1" };
 static const struct panfrost_compatible mediatek_mt8186_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8186_pm_domains),
-	.pm_domain_names = mediatek_mt8186_pm_domains,
+	.num_pm_domains = 2,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 };
 
-/* MT8188 uses the same power domains and power supplies as MT8183 */
 static const struct panfrost_compatible mediatek_mt8188_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains),
-	.pm_domain_names = mediatek_mt8183_pm_domains,
+	.num_pm_domains = 3,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
 
-static const char * const mediatek_mt8192_pm_domains[] = { "core0", "core1", "core2",
-							   "core3", "core4" };
 static const struct panfrost_compatible mediatek_mt8192_data = {
 	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
 	.supply_names = default_supplies,
-	.num_pm_domains = ARRAY_SIZE(mediatek_mt8192_pm_domains),
-	.pm_domain_names = mediatek_mt8192_pm_domains,
+	.num_pm_domains = 5,
+	.pm_domain_names = mediatek_pm_domains,
 	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
#6 lore raw

PATCH v6 4/5 drm/panfrost: Add support for Mali on the MT8370 SoC

In reply to Louis-Alexis Eyraud

Add a compatible for the MediaTek MT8370 SoC, with an integrated ARM Mali G57 MC2 GPU (Valhall-JM, dual core), with new platform data for its support in the panfrost driver.
It uses the same data as MT8186 for the power management features to describe power supplies, pm_domains and enablement (one regulator, two power domains) but also sets the FORCE_AARCH64_PGTABLE flag in the GPU configuration quirks bitfield to enable AARCH64 4K page table format mode.
As MT8186 and MT8370 SoC have different GPU architecture (Mali G52 2EE MC2 for MT8186), making them not compatible, and this mode is only enabled for Mediatek SoC that are Mali G57 based (compatible with mediatek,mali-mt8188 or mediatek,mali-8192), having specific platform data allows to set this flag for MT8370 without modifying MT8186 configuration and behaviour.

---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +10 -0
index 21b28bef84015793d9dba6b1e585891dc0dfcb6d..07cd67baa81bfccabf3b1a29f7d78702038bb2cd 100644
@@ -841,6 +841,15 @@ static const struct panfrost_compatible mediatek_mt8192_data = {
 	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
 };
 
+static const struct panfrost_compatible mediatek_mt8370_data = {
+	.num_supplies = ARRAY_SIZE(default_supplies) - 1,
+	.supply_names = default_supplies,
+	.num_pm_domains = 2,
+	.pm_domain_names = mediatek_pm_domains,
+	.pm_features = BIT(GPU_PM_CLK_DIS) | BIT(GPU_PM_VREG_OFF),
+	.gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE),
+};
+
 static const struct of_device_id dt_match[] = {
 	/* Set first to probe before the generic compatibles */
 	{ .compatible = "amlogic,meson-gxm-mali",
@@ -863,6 +872,7 @@ static const struct of_device_id dt_match[] = {
 	{ .compatible = "mediatek,mt8186-mali", .data = &mediatek_mt8186_data },
 	{ .compatible = "mediatek,mt8188-mali", .data = &mediatek_mt8188_data },
 	{ .compatible = "mediatek,mt8192-mali", .data = &mediatek_mt8192_data },
+	{ .compatible = "mediatek,mt8370-mali", .data = &mediatek_mt8370_data },
 	{ .compatible = "allwinner,sun50i-h616-mali", .data = &allwinner_h616_data },
 	{}
 };
Signature · 1 line
2.49.0
#7 lore raw

PATCH v6 5/5 arm64: dts: mediatek: mt8370: Enable gpu support

In reply to Louis-Alexis Eyraud

Add a new gpu node in mt8370.dtsi to enable support for the ARM Mali G57 MC2 GPU (Valhall-JM) found on the MT8370 SoC, using the Panfrost driver.

On a Mediatek Genio 510 EVK board, the panfrost driver probed with the following message:

```
panfrost 13000000.gpu: clock rate = 390000000
panfrost 13000000.gpu: mali-g57 id 0x9093 major 0x0 minor 0x0 status 0x0
panfrost 13000000.gpu: features: 00000000,000019f7, issues: 00000003,
   80000400
panfrost 13000000.gpu: Features: L2:0x08130206 Shader:0x00000000
   Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7
panfrost 13000000.gpu: shader_present=0x5 l2_present=0x1
[drm] Initialized panfrost 1.3.0 for 13000000.gpu on minor 0
```
---
 arch/arm64/boot/dts/mediatek/mt8370.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/mediatek/mt8370.dtsi +16 -0
index cf1a3759451ff899ce9e63e5a00f192fb483f6e5..7ac8b8d0349455922a73f35db607b2b27cad23d7 100644
@@ -59,6 +59,22 @@ &cpu_little3_cooling_map0 {
 				<&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
 };
 
+/*
+ * Please note that overriding compatibles is a discouraged practice and is a
+ * clear indication of nodes not being, well, compatible!
+ *
+ * This is a special case, where the GPU is the same as MT8188, but with one
+ * of the cores fused out in this lower-binned SoC.
+ */
+&gpu {
+	compatible = "mediatek,mt8370-mali", "arm,mali-valhall-jm";
+
+	power-domains = <&spm MT8188_POWER_DOMAIN_MFG2>,
+			<&spm MT8188_POWER_DOMAIN_MFG3>;
+
+	power-domain-names = "core0", "core1";
+};
+
 &ppi_cluster0 {
 	affinity = <&cpu0 &cpu1 &cpu2 &cpu3>;
 };
Signature · 1 line
2.49.0
maintainer
#8 lore raw
In reply to Louis-Alexis Eyraud

All 5 patches push to drm-misc-next.

Thanks,
Steve

Quoted 162 lines · Louis-Alexis Eyraud

This patchset adds the support of the ARM Mali G57 MC2 GPU (Valhall-JM, dual core), integrated in the Mediatek MT8370 SoC, to the panfrost driver and to the mt8370.dtsi include file.

Since v4 patchset was sent, the [1] patchset adds in panfrost driver the AARCH64_4K page table format support and enablement for Mediatek SoC with integrated Arm Mali-G57, already supported in panfrost driver (like MT8188, MT8192, MT8195, MT8390, MT8395...).
As MT8370 SoC is a less powerful variant of MT8390 (same GPU but with one less core for MT8370), I've reworked the second patch ('drm/panfrost: Add support for Mali on the MT8370 SoC') to enable the AARCH64_4K mode on this SoC as well by adding specific MT8370 platform data to set the needed flag.
The previous patch revision uses MT8186 platform data because despite having different GPU architecture (Mali G52 2EE MC2 for MT8186, making them not compatible), using the same plaform data, for describing the same power management features only, was okay.
But now, the platform data also contains the GPU configuration quirk bitfield that needs to be modified to enable the AARCH64_4K page table format, and in order not to change MT8186 behaviour, I add specific MT8370 platform data.

I've tested this patchset on a Mediatek Genio 510 EVK board, with a kernel based on linux-next (tag: next-20250502).

The panfrost driver probed with the following messages:

```
panfrost 13000000.gpu: clock rate = 390000000
panfrost 13000000.gpu: mali-g57 id 0x9093 major 0x0 minor 0x0 status 0x0
panfrost 13000000.gpu: features: 00000000,000019f7, issues: 00000003,
  80000400
panfrost 13000000.gpu: Features: L2:0x08130206 Shader:0x00000000
  Tiler:0x00000809 Mem:0x1 MMU:0x00002830 AS:0xff JS:0x7
panfrost 13000000.gpu: shader_present=0x5 l2_present=0x1
[drm] Initialized panfrost 1.3.0 for 13000000.gpu on minor 0
```

Running glmark2-es2-drm is also OK:

```
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    Mali-G57 (Panfrost)
    GL_VERSION:     OpenGL ES 3.1 Mesa 25.0.3-1
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   1200x1920 fullscreen
=======================================================
[build] use-vbo=false: FPS: 952 FrameTime: 1.051 ms
[build] use-vbo=true: FPS: 983 FrameTime: 1.018 ms
[texture] texture-filter=nearest: FPS: 906 FrameTime: 1.105 ms
[texture] texture-filter=linear: FPS: 908 FrameTime: 1.102 ms
[texture] texture-filter=mipmap: FPS: 883 FrameTime: 1.134 ms
[shading] shading=gouraud: FPS: 838 FrameTime: 1.194 ms
[shading] shading=blinn-phong-inf: FPS: 778 FrameTime: 1.287 ms
[shading] shading=phong: FPS: 583 FrameTime: 1.717 ms
[shading] shading=cel: FPS: 553 FrameTime: 1.809 ms
[bump] bump-render=high-poly: FPS: 573 FrameTime: 1.747 ms
[bump] bump-render=normals: FPS: 868 FrameTime: 1.153 ms
[bump] bump-render=height: FPS: 707 FrameTime: 1.415 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 454 FrameTime: 2.204 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 172 FrameTime:
  5.843 ms
[pulsar] light=false:quads=5:texture=false: FPS: 770 FrameTime:
  1.300 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:
  FPS: 161 FrameTime: 6.235 ms
[desktop] effect=shadow:windows=4: FPS: 484 FrameTime: 2.069 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction
  =0.5:update-method=map: FPS: 512 FrameTime: 1.955 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction
  =0.5:update-method=subdata: FPS: 513 FrameTime: 1.952 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction
  =0.5:update-method=map: FPS: 577 FrameTime: 1.735 ms
[ideas] speed=duration: FPS: 448 FrameTime: 2.235 ms
[jellyfish] <default>: FPS: 226 FrameTime: 4.440 ms
[terrain] <default>: FPS: 38 FrameTime: 26.861 ms
[shadow] <default>: FPS: 328 FrameTime: 3.051 ms
[refract] <default>: FPS: 72 FrameTime: 13.937 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 844 FrameTime:
  1.186 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 685 FrameTime: 
  1.462 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 833 FrameTime:
  1.201 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 830 FrameTime:
  1.205 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 525 FrameTime:
  1.905 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 837
  FrameTime: 1.195 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 835 
  FrameTime: 1.199 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 550
  FrameTime: 1.820 ms
=======================================================
                                  glmark2 Score: 611 
=======================================================
```

[1] https://lore.kernel.org/dri-devel/[email protected]/

---
Changes in v6:
- Add two new patches to commonize and drop duplicated data related to
the power domain and supplies definitions for Mediatek SoC
- Remove useless comment and rework MT8370 platform data to use mediatek_pm_domains and default_supplies arrays in 'drm/panfrost: Add
support for Mali on the MT8370 SoC'
- Update code-review trailer
- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Rebase on linux-next (tqg: next-2020501)
- Rework 'drm/panfrost: Add support for Mali on the MT8370 SoC' patch
to have MT8370 support with its AARCH64_4K page table format support enabled
- Drop code-review trailers from 'drm/panfrost: Add support for Mali on
the MT8370 SoC' patch due to major changes in content and commit message
- Add ack trailer for 'dt-bindings: gpu: mali-bifrost: Add compatible
for MT8370 SoC' patch
- Add glmark2-es2-drm benchmark results in cover letter
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Add warning comment in mt8370.dtsi about GPU node override
- Reword "dt-bindings: gpu: mali-bifrost: Add compatible for MT8370
SoC" commit message
- Add code-review trailers
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Rebased on linux-next (tag: next-20250207)
- Remove prerequisite change/patch ids
- Reword commit messages to better explicit compatible needs
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Rework "drm/panfrost: Add support for Mali on the MT8370 SoC" to avoid
data structure duplication, as requested by Krzysztof Kozlowski
- Reword commit messages to use imperative mood and make new compatible
need more explicit
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis-Alexis Eyraud (5):
dt-bindings: gpu: mali-bifrost: Add compatible for MT8370 SoC drm/panfrost: Drop duplicated Mediatek supplies arrays drm/panfrost: Commonize Mediatek power domain array definitions drm/panfrost: Add support for Mali on the MT8370 SoC
arm64: dts: mediatek: mt8370: Enable gpu support

 .../devicetree/bindings/gpu/arm,mali-bifrost.yaml  |  5 +-
 arch/arm64/boot/dts/mediatek/mt8370.dtsi           | 16 ++++++
 drivers/gpu/drm/panfrost/panfrost_drv.c            | 61 ++++++++++++----------
 3 files changed, 53 insertions(+), 29 deletions(-)

---
base-commit: 1c51b1ba38c07e4f999802eb708bf798dd5f5d1b
change-id: 20250115-mt8370-enable-gpu-3b6f595fa63d

Best regards,