Skip to content

Commit 28b1622

Browse files
digetxthierryreding
authored andcommitted
drm/tegra: nvdec: Stop channel on suspend
CDMA must be stopped before hardware is suspended. Add channel stopping to RPM suspend callback. Add system level suspend-resume callbacks. Runtime PM initialization is moved to host1x client init phase because RPM callback now uses host1x channel that is available only when host1x client is registered. Reviewed-by: Ulf Hansson <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 1e15f5b commit 28b1622

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/gpu/drm/tegra/nvdec.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ static int nvdec_init(struct host1x_client *client)
113113
goto free_channel;
114114
}
115115

116+
pm_runtime_enable(client->dev);
117+
pm_runtime_use_autosuspend(client->dev);
118+
pm_runtime_set_autosuspend_delay(client->dev, 500);
119+
116120
err = tegra_drm_register_client(tegra, drm);
117121
if (err < 0)
118-
goto free_syncpt;
122+
goto disable_rpm;
119123

120124
/*
121125
* Inherit the DMA parameters (such as maximum segment size) from the
@@ -125,7 +129,10 @@ static int nvdec_init(struct host1x_client *client)
125129

126130
return 0;
127131

128-
free_syncpt:
132+
disable_rpm:
133+
pm_runtime_dont_use_autosuspend(client->dev);
134+
pm_runtime_force_suspend(client->dev);
135+
129136
host1x_syncpt_put(client->syncpts[0]);
130137
free_channel:
131138
host1x_channel_put(nvdec->channel);
@@ -150,10 +157,15 @@ static int nvdec_exit(struct host1x_client *client)
150157
if (err < 0)
151158
return err;
152159

160+
pm_runtime_dont_use_autosuspend(client->dev);
161+
pm_runtime_force_suspend(client->dev);
162+
153163
host1x_syncpt_put(client->syncpts[0]);
154164
host1x_channel_put(nvdec->channel);
155165
host1x_client_iommu_detach(client);
156166

167+
nvdec->channel = NULL;
168+
157169
if (client->group) {
158170
dma_unmap_single(nvdec->dev, nvdec->falcon.firmware.phys,
159171
nvdec->falcon.firmware.size, DMA_TO_DEVICE);
@@ -268,6 +280,8 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev)
268280
{
269281
struct nvdec *nvdec = dev_get_drvdata(dev);
270282

283+
host1x_channel_stop(nvdec->channel);
284+
271285
clk_disable_unprepare(nvdec->clk);
272286

273287
return 0;
@@ -412,10 +426,6 @@ static int nvdec_probe(struct platform_device *pdev)
412426
goto exit_falcon;
413427
}
414428

415-
pm_runtime_enable(&pdev->dev);
416-
pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
417-
pm_runtime_use_autosuspend(&pdev->dev);
418-
419429
return 0;
420430

421431
exit_falcon:
@@ -436,18 +446,15 @@ static int nvdec_remove(struct platform_device *pdev)
436446
return err;
437447
}
438448

439-
if (pm_runtime_enabled(&pdev->dev))
440-
pm_runtime_disable(&pdev->dev);
441-
else
442-
nvdec_runtime_suspend(&pdev->dev);
443-
444449
falcon_exit(&nvdec->falcon);
445450

446451
return 0;
447452
}
448453

449454
static const struct dev_pm_ops nvdec_pm_ops = {
450455
SET_RUNTIME_PM_OPS(nvdec_runtime_suspend, nvdec_runtime_resume, NULL)
456+
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
457+
pm_runtime_force_resume)
451458
};
452459

453460
struct platform_driver tegra_nvdec_driver = {

0 commit comments

Comments
 (0)