Skip to content

Commit 58ed47a

Browse files
digetxthierryreding
authored andcommitted
drm/tegra: Consolidate runtime PM management of older UAPI codepath
Move runtime PM management of older UAPI code paths into the common place. This removes boilerplate code from client drivers. Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 555ae37 commit 58ed47a

File tree

5 files changed

+14
-43
lines changed

5 files changed

+14
-43
lines changed

drivers/gpu/drm/tegra/drm.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/iommu.h>
1111
#include <linux/module.h>
1212
#include <linux/platform_device.h>
13+
#include <linux/pm_runtime.h>
1314

1415
#include <drm/drm_aperture.h>
1516
#include <drm/drm_atomic.h>
@@ -116,6 +117,7 @@ static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
116117
static void tegra_drm_context_free(struct tegra_drm_context *context)
117118
{
118119
context->client->ops->close_channel(context);
120+
pm_runtime_put(context->client->base.dev);
119121
kfree(context);
120122
}
121123

@@ -427,13 +429,20 @@ static int tegra_client_open(struct tegra_drm_file *fpriv,
427429
{
428430
int err;
429431

432+
err = pm_runtime_resume_and_get(client->base.dev);
433+
if (err)
434+
return err;
435+
430436
err = client->ops->open_channel(client, context);
431-
if (err < 0)
437+
if (err < 0) {
438+
pm_runtime_put(client->base.dev);
432439
return err;
440+
}
433441

434442
err = idr_alloc(&fpriv->legacy_contexts, context, 1, 0, GFP_KERNEL);
435443
if (err < 0) {
436444
client->ops->close_channel(context);
445+
pm_runtime_put(client->base.dev);
437446
return err;
438447
}
439448

drivers/gpu/drm/tegra/gr2d.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,17 @@ static int gr2d_open_channel(struct tegra_drm_client *client,
127127
struct tegra_drm_context *context)
128128
{
129129
struct gr2d *gr2d = to_gr2d(client);
130-
int err;
131-
132-
err = pm_runtime_resume_and_get(client->base.dev);
133-
if (err)
134-
return err;
135130

136131
context->channel = host1x_channel_get(gr2d->channel);
137-
if (!context->channel) {
138-
pm_runtime_put(client->base.dev);
132+
if (!context->channel)
139133
return -ENOMEM;
140-
}
141134

142135
return 0;
143136
}
144137

145138
static void gr2d_close_channel(struct tegra_drm_context *context)
146139
{
147140
host1x_channel_put(context->channel);
148-
pm_runtime_put(context->client->base.dev);
149141
}
150142

151143
static int gr2d_is_addr_reg(struct device *dev, u32 class, u32 offset)

drivers/gpu/drm/tegra/gr3d.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,17 @@ static int gr3d_open_channel(struct tegra_drm_client *client,
136136
struct tegra_drm_context *context)
137137
{
138138
struct gr3d *gr3d = to_gr3d(client);
139-
int err;
140-
141-
err = pm_runtime_resume_and_get(client->base.dev);
142-
if (err)
143-
return err;
144139

145140
context->channel = host1x_channel_get(gr3d->channel);
146-
if (!context->channel) {
147-
pm_runtime_put(client->base.dev);
141+
if (!context->channel)
148142
return -ENOMEM;
149-
}
150143

151144
return 0;
152145
}
153146

154147
static void gr3d_close_channel(struct tegra_drm_context *context)
155148
{
156149
host1x_channel_put(context->channel);
157-
pm_runtime_put(context->client->base.dev);
158150
}
159151

160152
static int gr3d_is_addr_reg(struct device *dev, u32 class, u32 offset)

drivers/gpu/drm/tegra/nvdec.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,29 +291,17 @@ static int nvdec_open_channel(struct tegra_drm_client *client,
291291
struct tegra_drm_context *context)
292292
{
293293
struct nvdec *nvdec = to_nvdec(client);
294-
int err;
295-
296-
err = pm_runtime_get_sync(nvdec->dev);
297-
if (err < 0) {
298-
pm_runtime_put(nvdec->dev);
299-
return err;
300-
}
301294

302295
context->channel = host1x_channel_get(nvdec->channel);
303-
if (!context->channel) {
304-
pm_runtime_put(nvdec->dev);
296+
if (!context->channel)
305297
return -ENOMEM;
306-
}
307298

308299
return 0;
309300
}
310301

311302
static void nvdec_close_channel(struct tegra_drm_context *context)
312303
{
313-
struct nvdec *nvdec = to_nvdec(context->client);
314-
315304
host1x_channel_put(context->channel);
316-
pm_runtime_put(nvdec->dev);
317305
}
318306

319307
static const struct tegra_drm_client_ops nvdec_ops = {

drivers/gpu/drm/tegra/vic.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,27 +345,17 @@ static int vic_open_channel(struct tegra_drm_client *client,
345345
struct tegra_drm_context *context)
346346
{
347347
struct vic *vic = to_vic(client);
348-
int err;
349-
350-
err = pm_runtime_resume_and_get(vic->dev);
351-
if (err < 0)
352-
return err;
353348

354349
context->channel = host1x_channel_get(vic->channel);
355-
if (!context->channel) {
356-
pm_runtime_put(vic->dev);
350+
if (!context->channel)
357351
return -ENOMEM;
358-
}
359352

360353
return 0;
361354
}
362355

363356
static void vic_close_channel(struct tegra_drm_context *context)
364357
{
365-
struct vic *vic = to_vic(context->client);
366-
367358
host1x_channel_put(context->channel);
368-
pm_runtime_put(vic->dev);
369359
}
370360

371361
static const struct tegra_drm_client_ops vic_ops = {

0 commit comments

Comments
 (0)