Add Mali GPU support for Mediatek MT8370 SoC
Subsystems (5)
v5 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 also dropped previous code-review trailers that this patch got previously.
I've tested this patchset on a Mediatek Genio 510 EVK board, with a kernel based on linux-next (tag: next-20250501).
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 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 (3):
dt-bindings: gpu: mali-bifrost: Add compatible for MT8370 SoC 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 | 11 +++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)
---
base-commit: 1c51b1ba38c07e4f999802eb708bf798dd5f5d1b
change-id: 20250115-mt8370-enable-gpu-3b6f595fa63d
Best regards,
Signature · 1 line
Louis-Alexis Eyraud <[email protected]>
PATCH v5 1/3 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
@@ -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
PATCH v5 2/3 drm/panfrost: Add support for Mali on the MT8370 SoC
In reply to Louis-Alexis EyraudAdd 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 | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +11 -0
@@ -846,6 +846,16 @@ static const struct panfrost_compatible mediatek_mt8192_data = { .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; +/* MT8370 uses the same power domains and power supplies as MT8186 */ +static const struct panfrost_compatible mediatek_mt8370_data = { + .num_supplies =ARRAY_SIZE (mediatek_mt8183_b_supplies) -1 , + .supply_names = mediatek_mt8183_b_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 ), + .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" ,
@@ -868,6 +878,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
Re: [PATCH v5 2/3] drm/panfrost: Add support for Mali on the MT8370 SoC
Il 02/05/25 14:17, Louis-Alexis Eyraud ha scritto:
Quoted 15 lines
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_domainsand enablement (one regulator, two power domains) but also sets theFORCE_AARCH64_PGTABLEflag 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.
Quoted 1 line
Signed-off-by Louis-Alexis Eyraud <[email protected]>
Re: [PATCH v5 2/3] drm/panfrost: Add support for Mali on the MT8370 SoC
In reply to Louis-Alexis EyraudQuoted 15 lines · 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_domainsand enablement (one regulator, two power domains) but also sets theFORCE_AARCH64_PGTABLEflag 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.
Quoted 1 line
Signed-off-by Louis-Alexis Eyraud <[email protected]>
With one minor comment fixed below:
drivers/gpu/drm/panfrost/panfrost_drv.c static const struct panfrost_compatible mediatek_mt8192_data = { · line 849
Quoted 13 lines
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/gpu/drm/panfrost/panfrost_drv.c +1
-0@@ -846,6 +846,16 @@ static const struct panfrost_compatible mediatek_mt8192_data = { .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; +/* MT8370 uses the same power domains and power supplies as MT8186 */
This comment is not correct - you've got the power domains of MT8186, but the supplies of MT8183. The comment doesn't actually add much so you could just drop it.
If you're feeling adventurous then one option here is to actually clean up the mediatek entries a little. Instead of referring to particular part numbers we could have:
static const char * const mediatek_2_pm_domains[] = { "core0", "core1" }; static const char * const mediatek_3_pm_domains[] = { "core0", "core1", "core2" }; static const char * const mediatek_5_pm_domains[] = { "core0", "core1", "core2",
"core3", "core4" };
Or even just have the mediatek_5_domains[] array (dropping the '5' in the name) and not use ARRAY_SIZE().
Equally the supplies arrays could be renamed. We have the one with "sram" for legacy and everything else uses {"mali", NULL} but we have two definitions for it (mt8183_b and mt8192).
Thanks,
Steve
Quoted 21 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +10
-0+static const struct panfrost_compatible mediatek_mt8370_data = { + .num_supplies =ARRAY_SIZE (mediatek_mt8183_b_supplies) -1 , + .supply_names = mediatek_mt8183_b_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 ), + .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" ,@@ -868,6 +878,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 }, {} };
Re: [PATCH v5 2/3] drm/panfrost: Add support for Mali on the MT8370 SoC
Hi,
Quoted 46 lines · Steven Price
Quoted 23 lines · 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_domainsand enablement (one regulator, two
power domains) but also sets theFORCE_AARCH64_PGTABLEflag 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.Quoted 2 lines
Signed-off-by: Louis-Alexis Eyraud
<[email protected]>With one minor comment fixed below:
Reviewed-by Steven Price <[email protected]>Quoted 15 lines
---
drivers/gpu/drm/panfrost/panfrost_drv.c | 11 +++++++++++1 file changed, 11 insertions(+)drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0index
f1ec3b02f15a0029d20c7d81046ded59854e885c..8e0a1ae6940c73b7b60233950ae3abdfa843cc8e100644drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0@@ -846,6 +846,16 @@ static const struct panfrost_compatible mediatek_mt8192_data = { .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), };
Quoted 9 lines
Quoted 3 lines
+/* MT8370 uses the same power domains and power supplies as MT8186 */This comment is not correct - you've got the power domains of MT8186, but the supplies of MT8183. The comment doesn't actually add much so you
could just drop it.
I'll remove it.
Quoted 17 lines
If you're feeling adventurous then one option here is to actually clean
up the mediatek entries a little. Instead of referring to particular part numbers we could have:static const char * const mediatek_2_pm_domains[] = { "core0", "core1" };
static const char * const mediatek_3_pm_domains[] = { "core0", "core1", "core2" };
static const char * const mediatek_5_pm_domains[] = { "core0", "core1", "core2",
"core3", "core4" };Or even just have the mediatek_5_domains[] array (dropping the '5' in the name) and not use
ARRAY_SIZE().
Quoted 6 lines
Equally the supplies arrays could be renamed. We have the one with "sram" for legacy and everything else uses {"mali", NULL} but we have two definitions for it (
mt8183_band mt8192).Thanks,
Steve
I'll do the array cleaning as well in a separate patch in the v6.
Regards,
Louis-Alexis
Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/panfrost/panfrost_drv.c +2
-0+static const struct panfrost_compatible mediatek_mt8370_data = { + .num_supplies = ARRAY_SIZE(mediatek_mt8183_b_supplies) -1,
drivers/gpu/drm/panfrost/panfrost_drv.c +7
-0+ .supply_names = mediatek_mt8183_b_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), + .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), +}; +static const struct
of_device_iddt_match[] = {
/* Set first to probe before the generic compatibles */ { .compatible = "amlogic,meson-gxm-mali",drivers/gpu/drm/panfrost/panfrost_drv.c +0
-0@@ -868,6 +878,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},drivers/gpu/drm/panfrost/panfrost_drv.c +1
-0+ { .compatible = "mediatek,mt8370-mali", .data =
&mediatek_mt8370_data},
{ .compatible = "allwinner,sun50i-h616-mali", .data =&allwinner_h616_data},
{}
};
PATCH v5 3/3 arm64: dts: mediatek: mt8370: Enable gpu support
In reply to Louis-Alexis EyraudAdd 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
@@ -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