drm/tegra: gr2d/gr3d: Move pm_runtime_enable to gr*d_probe
v3 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 v3:
- pm_runtime_enable moved before host1x_client_register
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 | 19 +++++++++---------- drivers/gpu/drm/tegra/gr3d.c | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-)
Signature · 1 line
2.51.0
PATCH v3 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
@@ -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
@@ -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
PATCH v3 2/2 drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove
In reply to Svyatoslav RyhelFrom: 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.
--- drivers/gpu/drm/tegra/gr2d.c | 13 ++++++------- drivers/gpu/drm/tegra/gr3d.c | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/gpu/drm/tegra/gr2d.c +6 -7
@@ -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);
@@ -280,12 +277,18 @@ static int gr2d_probe(struct platform_device *pdev)for (i =0 ; i <ARRAY_SIZE (gr2d_addr_regs); i++)set_bit (gr2d_addr_regs[i], gr2d->addr_regs); +pm_runtime_enable (dev); + err =host1x_client_register (&gr2d->client.base);if (err <0 ) { +pm_runtime_disable (dev);dev_err (dev,"failed to register host1x client: %d\n" , err);return err; } +pm_runtime_use_autosuspend (dev); +pm_runtime_set_autosuspend_delay (dev,500 ); +return 0 ; }
@@ -367,10 +370,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 +6 -7
@@ -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);
@@ -510,13 +507,19 @@ static int gr3d_probe(struct platform_device *pdev)for (i =0 ; i <ARRAY_SIZE (gr3d_addr_regs); i++)set_bit (gr3d_addr_regs[i], gr3d->addr_regs); +pm_runtime_enable (&pdev->dev); + err =host1x_client_register (&gr3d->client.base);if (err <0 ) { +pm_runtime_disable (&pdev->dev);dev_err (&pdev->dev,"failed to register host1x client: %d\n" , err);return err; } +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_set_autosuspend_delay (&pdev->dev,500 ); +return 0 ; }
@@ -578,10 +581,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
Thierry Reding
maintainerQuoted 16 lines · Svyatoslav Ryhel
The gr*d_remove() has
pm_runtime_disable, this indicates it should be paired withpm_runtime_enablein the probe instead of being inside gr*d_runtime_resume().---
Changes in v3:
-pm_runtime_enablemoved beforehost1x_client_registerChanges in v2:
- remove pm fromgr2d_exitalong with pm fromgr2d_runtime_resume
- move register map initialize beforehost1x_client_register
---Ion Agorria (1):
drm/tegra: gr2d/gr3d: Contain PM in the gr*d_probe/gr*d_remove
Quoted 7 lines
Svyatoslav Ryhel (1):
drm/tegra: gr2d/gr3d: Initialize address register map before HOST1X
client is registereddrivers/gpu/drm/tegra/gr2d.c | 19 +++++++++---------- drivers/gpu/drm/tegra/gr3d.c | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-)
Both patches applied, thanks.
Thierry