* [PATCH 0/3] drm/panfrost: Enable the GPU timestamp counter on MT8188
@ 2026-10-03 20:01 Michał Kopeć
2026-10-03 20:01 ` [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle Michał Kopeć
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michał Kopeć @ 2026-10-03 20:01 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Adrián Larumbe
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, devicetree, linux-mediatek,
linux-arm-kernel, linux-kernel, Michał Kopeć
On MT8188 the GPU timestamp counter reads zero until a register in the
MFG configuration block routes the SoC system timer to it, and the
setting is lost whenever the GPU power domain is turned off. As a
result, the SYSTEM_TIMESTAMP query and the timestamps written by jobs
are always zero, which breaks timestamp queries in userspace drivers.
This series adds an optional mediatek,mfgcfg phandle to the Mali
binding, uses it in panfrost to set the register on every power-up,
and adds it to the MT8188 GPU node. Without the phandle the driver
behaves as before.
MT8370 shares the GPU node and the MFG block with MT8188, so the
binding allows the phandle there too, but the driver only enables the
quirk on MT8188, where it was tested.
Patch 3 is meant for the MediaTek tree; patches 1 and 2 can go through
drm-misc.
Tested on the Lenovo Chromebook Duet Gen 9 (Ciri, MT8188): the 13 MHz
counter advances by 100 ms over a 100 ms sleep, also after resuming
from deep suspend.
Michał Kopeć (3):
dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle
drm/panfrost: Enable the GPU timestamp counter on MT8188
arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU
.../bindings/gpu/arm,mali-bifrost.yaml | 17 ++++++++
arch/arm64/boot/dts/mediatek/mt8188.dtsi | 1 +
drivers/gpu/drm/panfrost/panfrost_device.h | 1 +
drivers/gpu/drm/panfrost/panfrost_drv.c | 1 +
drivers/gpu/drm/panfrost/panfrost_gpu.c | 39 +++++++++++++++++++
drivers/gpu/drm/panfrost/panfrost_gpu.h | 1 +
6 files changed, 60 insertions(+)
base-commit: 70456f05d4b6396b22048c4b8cd3cb98ecf9f9e3
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle
2026-10-03 20:01 [PATCH 0/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
@ 2026-10-03 20:01 ` Michał Kopeć
2026-10-09 7:01 ` Krzysztof Kozlowski
2026-10-03 20:01 ` [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
2026-10-03 20:01 ` [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU Michał Kopeć
2 siblings, 1 reply; 7+ messages in thread
From: Michał Kopeć @ 2026-10-03 20:01 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Adrián Larumbe
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, devicetree, linux-mediatek,
linux-arm-kernel, linux-kernel, Michał Kopeć
On MT8188 the GPU timestamp counter only counts once a register in the
MFG configuration block routes the SoC system timer to it, and the
setting is lost whenever the GPU power domain is turned off. The GPU
driver has to restore it on every power-up, so it needs a reference to
that block.
Add an optional mediatek,mfgcfg phandle. Allow it on MT8370 as well,
which shares the GPU and the MFG block with MT8188 and its GPU node in
mt8188.dtsi. It is optional so that existing devicetrees stay valid;
without it the timestamp counter reads zero, as before.
Signed-off-by: Michał Kopeć <michal@nozomi.space>
---
.../bindings/gpu/arm,mali-bifrost.yaml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml
index 9db9f84ad964b..08c1c22a270cb 100644
--- a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml
+++ b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml
@@ -122,6 +122,12 @@ properties:
nvmem-cells:
maxItems: 1
+ mediatek,mfgcfg:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to the MFG configuration block, which routes the SoC system
+ timer to the GPU timestamp counter.
+
required:
- compatible
- reg
@@ -226,6 +232,17 @@ allOf:
required:
- power-domains
- power-domain-names
+ - if:
+ properties:
+ compatible:
+ not:
+ contains:
+ enum:
+ - mediatek,mt8188-mali
+ - mediatek,mt8370-mali
+ then:
+ properties:
+ mediatek,mfgcfg: false
- if:
properties:
compatible:
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188
2026-10-03 20:01 [PATCH 0/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
2026-10-03 20:01 ` [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle Michał Kopeć
@ 2026-10-03 20:01 ` Michał Kopeć
2026-10-03 20:10 ` sashiko-bot
2026-10-03 20:01 ` [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU Michał Kopeć
2 siblings, 1 reply; 7+ messages in thread
From: Michał Kopeć @ 2026-10-03 20:01 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Adrián Larumbe
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, devicetree, linux-mediatek,
linux-arm-kernel, linux-kernel, Michał Kopeć
On MediaTek SoCs the GPU timestamp counter is fed by the SoC system timer
only once the TOP_TSVALUEB enable bits are set in the MFGCFG block. The
setting is lost whenever the GPU power domain is turned off.
Without it, GPU_TIMESTAMP reads zero, so the SYSTEM_TIMESTAMP query and
timestamps written by jobs are always zero, which breaks timestamp
queries in userspace drivers.
Look up the MFGCFG block from the mediatek,mfgcfg phandle and set the
bits from the vendor quirk hook, which runs on every power-up, as the
downstream kbase driver does. Without the phandle nothing changes.
Signed-off-by: Michał Kopeć <michal@nozomi.space>
---
drivers/gpu/drm/panfrost/panfrost_device.h | 1 +
drivers/gpu/drm/panfrost/panfrost_drv.c | 1 +
drivers/gpu/drm/panfrost/panfrost_gpu.c | 39 ++++++++++++++++++++++
drivers/gpu/drm/panfrost/panfrost_gpu.h | 1 +
4 files changed, 42 insertions(+)
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index 1fe1554f2652b..0a73939a023c3 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -134,6 +134,7 @@ struct panfrost_device {
int mmu_irq;
void __iomem *iomem;
+ struct regmap *mtk_mfgcfg;
struct clk *clock;
struct clk *bus_clock;
struct clk *bus_ace_clock;
diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 70c05210ea846..e811652e2384d 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -1133,6 +1133,7 @@ static const struct panfrost_compatible mediatek_mt8188_data = {
.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),
+ .vendor_quirk = panfrost_gpu_mt8188_quirk,
};
static const struct panfrost_compatible mediatek_mt8192_data = {
diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c
index 29ac0dce5ff89..971abc9cc222c 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gpu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c
@@ -9,8 +9,11 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
#include <drm/drm_print.h>
@@ -114,6 +117,40 @@ void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev)
gpu_write(pfdev, GPU_PWR_OVERRIDE1, 0xfff | (0x20 << 16));
}
+#define MTK_MFG_TIMESTAMP 0x130
+#define MTK_MFG_TIMESTAMP_TOP_TSVALUEB_EN 0x3
+
+void panfrost_gpu_mt8188_quirk(struct panfrost_device *pfdev)
+{
+ /*
+ * The GPU timestamp counter only counts once MFGCFG routes the SoC
+ * system timer to it. The setting is lost whenever the GPU power
+ * domain is turned off, so it has to be restored on every power-up.
+ */
+ if (pfdev->mtk_mfgcfg)
+ regmap_write(pfdev->mtk_mfgcfg, MTK_MFG_TIMESTAMP,
+ MTK_MFG_TIMESTAMP_TOP_TSVALUEB_EN);
+}
+
+static void panfrost_gpu_get_mtk_mfgcfg(struct panfrost_device *pfdev)
+{
+ struct device_node *np;
+ struct regmap *regmap;
+
+ np = of_parse_phandle(pfdev->base.dev->of_node, "mediatek,mfgcfg", 0);
+ if (!np)
+ return;
+
+ regmap = device_node_to_regmap(np);
+ of_node_put(np);
+ if (IS_ERR(regmap)) {
+ dev_warn(pfdev->base.dev, "failed to get MFGCFG: %pe\n", regmap);
+ return;
+ }
+
+ pfdev->mtk_mfgcfg = regmap;
+}
+
static void panfrost_gpu_init_quirks(struct panfrost_device *pfdev)
{
u32 quirks = 0;
@@ -519,6 +556,8 @@ int panfrost_gpu_init(struct panfrost_device *pfdev)
{
int err;
+ panfrost_gpu_get_mtk_mfgcfg(pfdev);
+
err = panfrost_gpu_soft_reset(pfdev);
if (err)
return err;
diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.h b/drivers/gpu/drm/panfrost/panfrost_gpu.h
index b4fef11211d5f..2b974576b96e9 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gpu.h
+++ b/drivers/gpu/drm/panfrost/panfrost_gpu.h
@@ -23,5 +23,6 @@ unsigned long long panfrost_cycle_counter_read(struct panfrost_device *pfdev);
unsigned long long panfrost_timestamp_read(struct panfrost_device *pfdev);
void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev);
+void panfrost_gpu_mt8188_quirk(struct panfrost_device *pfdev);
#endif
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU
2026-10-03 20:01 [PATCH 0/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
2026-10-03 20:01 ` [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle Michał Kopeć
2026-10-03 20:01 ` [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
@ 2026-10-03 20:01 ` Michał Kopeć
2026-10-03 20:12 ` sashiko-bot
2 siblings, 1 reply; 7+ messages in thread
From: Michał Kopeć @ 2026-10-03 20:01 UTC (permalink / raw)
To: Boris Brezillon, Steven Price, Adrián Larumbe
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, devicetree, linux-mediatek,
linux-arm-kernel, linux-kernel, Michał Kopeć
The GPU driver needs the MFG configuration block to enable the GPU
timestamp counter, which otherwise reads zero.
Signed-off-by: Michał Kopeć <michal@nozomi.space>
---
arch/arm64/boot/dts/mediatek/mt8188.dtsi | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8188.dtsi b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
index 14a320f0c70cb..b4be89bf55bf7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8188.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
@@ -2266,6 +2266,7 @@ gpu: gpu@13000000 {
<GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH 0>,
<GIC_SPI 381 IRQ_TYPE_LEVEL_HIGH 0>;
interrupt-names = "job", "mmu", "gpu";
+ mediatek,mfgcfg = <&mfgcfg>;
nvmem-cells = <&gpu_speedbin>;
nvmem-cell-names = "speed-bin";
operating-points-v2 = <&gpu_opp_table>;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188
2026-10-03 20:01 ` [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
@ 2026-10-03 20:10 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-10-03 20:10 UTC (permalink / raw)
To: Michał Kopeć; +Cc: devicetree, dri-devel, conor+dt, robh
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/panfrost: missing error propagation for MFGCFG regmap prevents probe deferral
--
commit 93148a7d7b8819bdd74ff76c5e5b0fcc15b88cbf
Author: Michał Kopeć <michal@nozomi.space>
drm/panfrost: Enable the GPU timestamp counter on MT8188
This commit adds a vendor quirk to enable the GPU timestamp counter on
MediaTek MT8188 SoCs. It looks up the MFGCFG block regmap from the device
tree and sets the required enable bits on power-up to ensure timestamps
are correctly reported.
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c
> index 29ac0dce5ff89..971abc9cc222c 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gpu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c
[ ... ]
> +static void panfrost_gpu_get_mtk_mfgcfg(struct panfrost_device *pfdev)
> +{
> + struct device_node *np;
> + struct regmap *regmap;
> +
> + np = of_parse_phandle(pfdev->base.dev->of_node, "mediatek,mfgcfg", 0);
> + if (!np)
> + return;
> +
> + regmap = device_node_to_regmap(np);
> + of_node_put(np);
> + if (IS_ERR(regmap)) {
> + dev_warn(pfdev->base.dev, "failed to get MFGCFG: %pe\n", regmap);
> + return;
[Severity: Medium]
Should this function return the error code from device_node_to_regmap()
instead of returning void?
If device_node_to_regmap() returns an error pointer (for example, due to probe
deferral or memory allocation failure), the error is swallowed and the probe
path continues without the regmap. This can cause the GPU timestamp counter to
break silently, leaving userspace queries reading zero.
> + }
> +
> + pfdev->mtk_mfgcfg = regmap;
> +}
[ ... ]
> @@ -519,6 +556,8 @@ int panfrost_gpu_init(struct panfrost_device *pfdev)
> {
> int err;
>
> + panfrost_gpu_get_mtk_mfgcfg(pfdev);
> +
[Severity: Medium]
Since panfrost_gpu_get_mtk_mfgcfg() doesn't return an error, panfrost_gpu_init()
proceeds despite the failure to acquire the MFGCFG regmap.
Would it be better to propagate the error here so that the driver can properly
defer probe or fail robustly when the necessary resources aren't available?
> err = panfrost_gpu_soft_reset(pfdev);
> if (err)
> return err;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003200132.866240-1-michal@nozomi.space?part=2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU
2026-10-03 20:01 ` [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU Michał Kopeć
@ 2026-10-03 20:12 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-10-03 20:12 UTC (permalink / raw)
To: Michał Kopeć; +Cc: robh, conor+dt, dri-devel, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/panfrost: missing GPU timestamp quirk on MT8370
--
commit ad326344199c9c294e6415c92318bcef828d8630
Author: Michał Kopeć <michal@nozomi.space>
arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU
This commit adds the MFGCFG phandle to the GPU node in the MT8188 device
tree. The GPU driver requires this configuration block to enable the GPU
timestamp counter, which otherwise reads zero.
> diff --git a/arch/arm64/boot/dts/mediatek/mt8188.dtsi b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
> index 14a320f0c70cb..b4be89bf55bf7 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8188.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
> @@ -2266,6 +2266,7 @@ gpu: gpu@13000000 {
> <GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH 0>,
> <GIC_SPI 381 IRQ_TYPE_LEVEL_HIGH 0>;
> interrupt-names = "job", "mmu", "gpu";
> + mediatek,mfgcfg = <&mfgcfg>;
[Severity: Medium]
Since we are enabling the GPU timestamp counter via the MFG configuration
block for the MT8188, does the MT8370 SoC also need its corresponding quirk
updated in the panfrost driver to avoid breaking userspace timestamp queries?
Looking at drivers/gpu/drm/panfrost/panfrost_drv.c, the mediatek_mt8370_data
struct is defined as:
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),
};
This struct lacks .vendor_quirk = panfrost_gpu_mt8188_quirk.
When the driver probes on MT8370 using the mediatek,mt8370-mali compatible,
the missing quirk means the MFG configuration block is never enabled. As a
result, the GPU timestamp counter will read zero on the MT8370 SoC.
Could this be an omission, or is it intentional to skip the vendor quirk
for MT8370?
> nvmem-cells = <&gpu_speedbin>;
> nvmem-cell-names = "speed-bin";
> operating-points-v2 = <&gpu_opp_table>;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261003200132.866240-1-michal@nozomi.space?part=3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle
2026-10-03 20:01 ` [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle Michał Kopeć
@ 2026-10-09 7:01 ` Krzysztof Kozlowski
0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-10-09 7:01 UTC (permalink / raw)
To: Michał Kopeć
Cc: Boris Brezillon, Steven Price, Adrián Larumbe, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, dri-devel, devicetree, linux-mediatek,
linux-arm-kernel, linux-kernel
On Sat, Oct 03, 2026 at 10:01:30PM +0200, Michał Kopeć wrote:
> On MT8188 the GPU timestamp counter only counts once a register in the
> MFG configuration block routes the SoC system timer to it, and the
> setting is lost whenever the GPU power domain is turned off. The GPU
> driver has to restore it on every power-up, so it needs a reference to
> that block.
This looks rather like power domain issue, e.g. missing restore of
registers. Otherwise next time there will be one more phandle and then
one more, each for one register being lost during power down.
>
> Add an optional mediatek,mfgcfg phandle. Allow it on MT8370 as well,
> which shares the GPU and the MFG block with MT8188 and its GPU node in
> mt8188.dtsi. It is optional so that existing devicetrees stay valid;
> without it the timestamp counter reads zero, as before.
>
> Signed-off-by: Michał Kopeć <michal@nozomi.space>
> ---
> .../bindings/gpu/arm,mali-bifrost.yaml | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-10-09 7:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-03 20:01 [PATCH 0/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
2026-10-03 20:01 ` [PATCH 1/3] dt-bindings: gpu: mali-bifrost: Add the MT8188 MFGCFG phandle Michał Kopeć
2026-10-09 7:01 ` Krzysztof Kozlowski
2026-10-03 20:01 ` [PATCH 2/3] drm/panfrost: Enable the GPU timestamp counter on MT8188 Michał Kopeć
2026-10-03 20:10 ` sashiko-bot
2026-10-03 20:01 ` [PATCH 3/3] arm64: dts: mediatek: mt8188: Add the MFGCFG phandle to the GPU Michał Kopeć
2026-10-03 20:12 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox