Skip to contentSkip to conversation

drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe

PATCH Superseded Svyatoslav Ryhel 2 participants 7 messages May 3 – May 15

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe

The gr*d_remove() has pm_runtime_disable, this indicates it should be paired with pm_runtime_enable in the probe instead of being inside gr*d_runtime_resume().

---
Changes in v2:
- remove pm from gr2d_exit along with pm from gr2d_runtime_resume
- move register map initialize before host1x_client_register
---

Ion Agorria (1):
drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

Svyatoslav Ryhel (1):
drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X
client is registered

 drivers/gpu/drm/tegra/gr2d.c | 17 +++++++----------
 drivers/gpu/drm/tegra/gr3d.c | 17 +++++++----------
 2 files changed, 14 insertions(+), 20 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/2 drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered

The host1x_client_register() function is called just prior to register map initialization loop, making the device available to userspace. This may result in userspace attempting to submits a job before the register map is initialized. Address this by moving register initialization before host1x client registration.

---
 drivers/gpu/drm/tegra/gr2d.c | 8 ++++----
 drivers/gpu/drm/tegra/gr3d.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +4 -4
index 21f4dd0fa6af..e4148b034af7 100644
@@ -276,16 +276,16 @@ static int gr2d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
+		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
+
 	err = host1x_client_register(&gr2d->client.base);
 	if (err < 0) {
 		dev_err(dev, "failed to register host1x client: %d\n", err);
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
-		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
-
 	return 0;
 }
 
drivers/gpu/drm/tegra/gr3d.c +4 -4
index 42e9656ab80c..47b0c6c56bfd 100644
@@ -506,6 +506,10 @@ static int gr3d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
+		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
+
 	err = host1x_client_register(&gr3d->client.base);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to register host1x client: %d\n",
@@ -513,10 +517,6 @@ static int gr3d_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
-		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
-
 	return 0;
 }
 
Signature · 1 line
2.51.0
maintainer Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X client is registered

Quoted 67 lines · Svyatoslav Ryhel

The host1x_client_register() function is called just prior to register map initialization loop, making the device available to userspace. This may result in userspace attempting to submits a job before the register map is initialized. Address this by moving register initialization before host1x client registration.

---
 drivers/gpu/drm/tegra/gr2d.c | 8 ++++----
 drivers/gpu/drm/tegra/gr3d.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +4 -4
index 21f4dd0fa6af..e4148b034af7 100644
@@ -276,16 +276,16 @@ static int gr2d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
+		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
+
 	err = host1x_client_register(&gr2d->client.base);
 	if (err < 0) {
 		dev_err(dev, "failed to register host1x client: %d\n", err);
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr2d_addr_regs); i++)
-		set_bit(gr2d_addr_regs[i], gr2d->addr_regs);
-
 	return 0;
 }
 
drivers/gpu/drm/tegra/gr3d.c +4 -4
index 42e9656ab80c..47b0c6c56bfd 100644
@@ -506,6 +506,10 @@ static int gr3d_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	/* initialize address register map */
+	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
+		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
+
 	err = host1x_client_register(&gr3d->client.base);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to register host1x client: %d\n",
@@ -513,10 +517,6 @@ static int gr3d_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	/* initialize address register map */
-	for (i = 0; i < ARRAY_SIZE(gr3d_addr_regs); i++)
-		set_bit(gr3d_addr_regs[i], gr3d->addr_regs);
-
 	return 0;
 }
 
Signature · 1 line
2.51.0
#3 lore raw

PATCH v2 2/2 drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

In reply to Svyatoslav Ryhel

From: Ion Agorria <[email protected]>

The current power management configuration causes GR2G/GR3D to malfunction after resume. Reconfigure all PM actions to be handled within the GR*D probe and remove operations to address this.

Fixes 62fa0a985e2c ("drm/tegra: Enable runtime PM during probe")
---
 drivers/gpu/drm/tegra/gr2d.c | 11 ++++-------
 drivers/gpu/drm/tegra/gr3d.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +4 -7
index e4148b034af7..ffcd076b5831 100644
@@ -100,9 +100,6 @@ static int gr2d_exit(struct host1x_client *client)
 	if (err < 0)
 		return err;
 
-	pm_runtime_dont_use_autosuspend(client->dev);
-	pm_runtime_force_suspend(client->dev);
-
 	host1x_client_iommu_detach(client);
 	host1x_syncpt_put(client->syncpts[0]);
 	host1x_channel_put(gr2d->channel);
@@ -286,6 +283,10 @@ static int gr2d_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	pm_runtime_enable(dev);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_set_autosuspend_delay(dev, 500);
+
 	return 0;
 }
 
@@ -367,10 +368,6 @@ static int __maybe_unused gr2d_runtime_resume(struct device *dev)
 		goto disable_clk;
 	}
 
-	pm_runtime_enable(dev);
-	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_autosuspend_delay(dev, 500);
-
 	return 0;
 
 disable_clk:
drivers/gpu/drm/tegra/gr3d.c +4 -7
index 47b0c6c56bfd..cd5554e2117f 100644
@@ -109,9 +109,6 @@ static int gr3d_exit(struct host1x_client *client)
 	if (err < 0)
 		return err;
 
-	pm_runtime_dont_use_autosuspend(client->dev);
-	pm_runtime_force_suspend(client->dev);
-
 	host1x_client_iommu_detach(client);
 	host1x_syncpt_put(client->syncpts[0]);
 	host1x_channel_put(gr3d->channel);
@@ -517,6 +514,10 @@ static int gr3d_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+
 	return 0;
 }
 
@@ -578,10 +579,6 @@ static int __maybe_unused gr3d_runtime_resume(struct device *dev)
 		goto disable_clk;
 	}
 
-	pm_runtime_enable(dev);
-	pm_runtime_use_autosuspend(dev);
-	pm_runtime_set_autosuspend_delay(dev, 500);
-
 	return 0;
 
 disable_clk:
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH v2 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

нд, 3 трав. 2026 р. о 19:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 31 lines

From: Ion Agorria <[email protected]>

The current power management configuration causes GR2G/GR3D to malfunction after resume. Reconfigure all PM actions to be handled within the GR*D probe and remove operations to address this.

Fixes 62fa0a985e2c ("drm/tegra: Enable runtime PM during probe")
---
 drivers/gpu/drm/tegra/gr2d.c | 11 ++++-------
 drivers/gpu/drm/tegra/gr3d.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +0 -3
index e4148b034af7..ffcd076b5831 100644
@@ -100,9 +100,6 @@ static int gr2d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr2d->channel);

drivers/gpu/drm/tegra/gr2d.c static int gr2d_probe(struct platform_device *pdev) · line 289

Quoted 7 lines
drivers/gpu/drm/tegra/gr2d.c +4 -0
@@ -286,6 +283,10 @@ static int gr2d_probe(struct platform_device *pdev)
                return err;
        }
 
+       pm_runtime_enable(dev);
+       pm_runtime_use_autosuspend(dev);
+       pm_runtime_set_autosuspend_delay(dev, 500);
+

Hello Mikko!

I have used same setup as in VIC. May you please take a look to sashiko's check
https://sashiko.dev/#/patchset/20260502124055.22475-1-clamor95%40gmail.com

I do agree with statement that pm_runtime_enable should be before host1x_client_register since this same approach is widely used in the media subsystem too.

But I am more interested in your thoughts regarding sashiko's gr2d_exit situation reasoning.

Thank you!

Quoted 53 lines
drivers/gpu/drm/tegra/gr2d.c +0 -4
        return 0;
 }
 
@@ -367,10 +368,6 @@ static int __maybe_unused gr2d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
drivers/gpu/drm/tegra/gr3d.c +4 -8
index 47b0c6c56bfd..cd5554e2117f 100644
@@ -109,9 +109,6 @@ static int gr3d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr3d->channel);
@@ -517,6 +514,10 @@ static int gr3d_probe(struct platform_device *pdev)
                return err;
        }
 
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_use_autosuspend(&pdev->dev);
+       pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+
        return 0;
 }
 
@@ -578,10 +579,6 @@ static int __maybe_unused gr3d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
--

2.51.0

maintainer
#5 lore raw

Re: [PATCH v2 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

Quoted 35 lines · Svyatoslav Ryhel

нд, 3 трав. 2026 р. о 19:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 34 lines

From: Ion Agorria <[email protected]>

The current power management configuration causes GR2G/GR3D to malfunction after resume. Reconfigure all PM actions to be handled within the GR*D probe and remove operations to address this.

Fixes 62fa0a985e2c ("drm/tegra: Enable runtime PM during probe")
---
 drivers/gpu/drm/tegra/gr2d.c | 11 ++++-------
 drivers/gpu/drm/tegra/gr3d.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +0 -3
index e4148b034af7..ffcd076b5831 100644
@@ -100,9 +100,6 @@ static int gr2d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr2d->channel);
@@ -286,6 +283,10 @@ static int gr2d_probe(struct platform_device *pdev)
                return err;
        }
 
Quoted 6 lines

drivers/gpu/drm/tegra/gr2d.c static int gr2d_probe(struct platform_device *pdev) · line 289

Quoted 4 lines
drivers/gpu/drm/tegra/gr2d.c +4 -0
+       pm_runtime_enable(dev);
+       pm_runtime_use_autosuspend(dev);
+       pm_runtime_set_autosuspend_delay(dev, 500);
+

Hello Mikko!

Hello!

Quoted 7 lines

I have used same setup as in VIC. May you please take a look to sashiko's check
https://sashiko.dev/#/patchset/20260502124055.22475-1-clamor95%40gmail.com

I do agree with statement that pm_runtime_enable should be before host1x_client_register since this same approach is widely used in the media subsystem too.

Yep, I agree as well.

Quoted 3 lines

But I am more interested in your thoughts regarding sashiko's gr2d_exit situation reasoning.

It sounds accurate to me, there is probably a real issue. I expect there to be in general some driver unbind related issues, since it (particularly when the device is in use) isn't really being tested.

FWIW, in an ideal world, it would probably make more sense to do the IOMMU handling on the platform device side, since the device's memory accesses are not related to host1x. But we can't really do that right now.

For the time being, I don't think fixing this is particularly critical since other things will go wrong as well if root causes .exit to happen while the engine is executing. I can't say offhand what the proper full solution would be.

Thanks
Mikko

Quoted 56 lines

Thank you!

Quoted 53 lines
drivers/gpu/drm/tegra/gr2d.c +0 -4
        return 0;
 }
 
@@ -367,10 +368,6 @@ static int __maybe_unused gr2d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
drivers/gpu/drm/tegra/gr3d.c +4 -8
index 47b0c6c56bfd..cd5554e2117f 100644
@@ -109,9 +109,6 @@ static int gr3d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr3d->channel);
@@ -517,6 +514,10 @@ static int gr3d_probe(struct platform_device *pdev)
                return err;
        }
 
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_use_autosuspend(&pdev->dev);
+       pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+
        return 0;
 }
 
@@ -578,10 +579,6 @@ static int __maybe_unused gr3d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
--

2.51.0

#6 lore raw

Re: [PATCH v2 2/2] drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove

чт, 14 трав. 2026 р. о 07:07 Mikko Perttunen <[email protected]> пише:

Quoted 69 lines · Svyatoslav Ryhel
Quoted 35 lines

нд, 3 трав. 2026 р. о 19:38 Svyatoslav Ryhel <[email protected]> пише:

Quoted 34 lines

From: Ion Agorria <[email protected]>

The current power management configuration causes GR2G/GR3D to malfunction after resume. Reconfigure all PM actions to be handled within the GR*D probe and remove operations to address this.

Fixes 62fa0a985e2c ("drm/tegra: Enable runtime PM during probe")
---
 drivers/gpu/drm/tegra/gr2d.c | 11 ++++-------
 drivers/gpu/drm/tegra/gr3d.c | 11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +0 -3
index e4148b034af7..ffcd076b5831 100644
@@ -100,9 +100,6 @@ static int gr2d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr2d->channel);
@@ -286,6 +283,10 @@ static int gr2d_probe(struct platform_device *pdev)
                return err;
        }
 
Quoted 6 lines

drivers/gpu/drm/tegra/gr2d.c static int gr2d_probe(struct platform_device *pdev) · line 289

Quoted 4 lines
drivers/gpu/drm/tegra/gr2d.c +4 -0
+       pm_runtime_enable(dev);
+       pm_runtime_use_autosuspend(dev);
+       pm_runtime_set_autosuspend_delay(dev, 500);
+

Hello Mikko!

Hello!

Quoted 7 lines

I have used same setup as in VIC. May you please take a look to sashiko's check
https://sashiko.dev/#/patchset/20260502124055.22475-1-clamor95%40gmail.com

I do agree with statement that pm_runtime_enable should be before host1x_client_register since this same approach is widely used in the media subsystem too.

Yep, I agree as well.

Quoted 3 lines

But I am more interested in your thoughts regarding sashiko's gr2d_exit situation reasoning.

It sounds accurate to me, there is probably a real issue. I expect there to be in general some driver unbind related issues, since it (particularly when the device is in use) isn't really being tested.

FWIW, in an ideal world, it would probably make more sense to do the IOMMU handling on the platform device side, since the device's memory accesses are not related to host1x. But we can't really do that right now.

Quoted 5 lines

For the time being, I don't think fixing this is particularly critical since other things will go wrong as well if root causes .exit to happen while the engine is executing. I can't say offhand what the proper full solution would be.

Thank you for sharing your thoughts on this topic. I will adjust accordingly in v3

Quoted 63 lines

Thanks
Mikko

Quoted 56 lines

Thank you!

Quoted 53 lines
drivers/gpu/drm/tegra/gr2d.c +0 -4
        return 0;
 }
 
@@ -367,10 +368,6 @@ static int __maybe_unused gr2d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
drivers/gpu/drm/tegra/gr3d.c +4 -8
index 47b0c6c56bfd..cd5554e2117f 100644
@@ -109,9 +109,6 @@ static int gr3d_exit(struct host1x_client *client)
        if (err < 0)
                return err;
 
-       pm_runtime_dont_use_autosuspend(client->dev);
-       pm_runtime_force_suspend(client->dev);
-
        host1x_client_iommu_detach(client);
        host1x_syncpt_put(client->syncpts[0]);
        host1x_channel_put(gr3d->channel);
@@ -517,6 +514,10 @@ static int gr3d_probe(struct platform_device *pdev)
                return err;
        }
 
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_use_autosuspend(&pdev->dev);
+       pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+
        return 0;
 }
 
@@ -578,10 +579,6 @@ static int __maybe_unused gr3d_runtime_resume(struct device *dev)
                goto disable_clk;
        }
 
-       pm_runtime_enable(dev);
-       pm_runtime_use_autosuspend(dev);
-       pm_runtime_set_autosuspend_delay(dev, 500);
-
        return 0;
 
 disable_clk:
--

2.51.0