summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2021-12-01 02:23:25 +0300
committerThierry Reding <treding@nvidia.com>2021-12-16 14:07:08 +0100
commit58ed47adcabb4ce13a60f56230074805957822fa (patch)
tree5cab63037994623082528aa19f9e4a620d489b3c
parent555ae37a5dd2a2703a83965dc26bc99a5db2ecbe (diff)
downloadlinux-58ed47adcabb4ce13a60f56230074805957822fa.tar.bz2
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 <digetx@gmail.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/drm.c11
-rw-r--r--drivers/gpu/drm/tegra/gr2d.c10
-rw-r--r--drivers/gpu/drm/tegra/gr3d.c10
-rw-r--r--drivers/gpu/drm/tegra/nvdec.c14
-rw-r--r--drivers/gpu/drm/tegra/vic.c12
5 files changed, 14 insertions, 43 deletions
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 2e7da2a7505d..dc04ce329be3 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -10,6 +10,7 @@
#include <linux/iommu.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <drm/drm_aperture.h>
#include <drm/drm_atomic.h>
@@ -116,6 +117,7 @@ static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
static void tegra_drm_context_free(struct tegra_drm_context *context)
{
context->client->ops->close_channel(context);
+ pm_runtime_put(context->client->base.dev);
kfree(context);
}
@@ -427,13 +429,20 @@ static int tegra_client_open(struct tegra_drm_file *fpriv,
{
int err;
+ err = pm_runtime_resume_and_get(client->base.dev);
+ if (err)
+ return err;
+
err = client->ops->open_channel(client, context);
- if (err < 0)
+ if (err < 0) {
+ pm_runtime_put(client->base.dev);
return err;
+ }
err = idr_alloc(&fpriv->legacy_contexts, context, 1, 0, GFP_KERNEL);
if (err < 0) {
client->ops->close_channel(context);
+ pm_runtime_put(client->base.dev);
return err;
}
diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c
index 2382def93923..e3bb4c99ed39 100644
--- a/drivers/gpu/drm/tegra/gr2d.c
+++ b/drivers/gpu/drm/tegra/gr2d.c
@@ -127,17 +127,10 @@ static int gr2d_open_channel(struct tegra_drm_client *client,
struct tegra_drm_context *context)
{
struct gr2d *gr2d = to_gr2d(client);
- int err;
-
- err = pm_runtime_resume_and_get(client->base.dev);
- if (err)
- return err;
context->channel = host1x_channel_get(gr2d->channel);
- if (!context->channel) {
- pm_runtime_put(client->base.dev);
+ if (!context->channel)
return -ENOMEM;
- }
return 0;
}
@@ -145,7 +138,6 @@ static int gr2d_open_channel(struct tegra_drm_client *client,
static void gr2d_close_channel(struct tegra_drm_context *context)
{
host1x_channel_put(context->channel);
- pm_runtime_put(context->client->base.dev);
}
static int gr2d_is_addr_reg(struct device *dev, u32 class, u32 offset)
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c
index 032d71365494..a1fd3113ea96 100644
--- a/drivers/gpu/drm/tegra/gr3d.c
+++ b/drivers/gpu/drm/tegra/gr3d.c
@@ -136,17 +136,10 @@ static int gr3d_open_channel(struct tegra_drm_client *client,
struct tegra_drm_context *context)
{
struct gr3d *gr3d = to_gr3d(client);
- int err;
-
- err = pm_runtime_resume_and_get(client->base.dev);
- if (err)
- return err;
context->channel = host1x_channel_get(gr3d->channel);
- if (!context->channel) {
- pm_runtime_put(client->base.dev);
+ if (!context->channel)
return -ENOMEM;
- }
return 0;
}
@@ -154,7 +147,6 @@ static int gr3d_open_channel(struct tegra_drm_client *client,
static void gr3d_close_channel(struct tegra_drm_context *context)
{
host1x_channel_put(context->channel);
- pm_runtime_put(context->client->base.dev);
}
static int gr3d_is_addr_reg(struct device *dev, u32 class, u32 offset)
diff --git a/drivers/gpu/drm/tegra/nvdec.c b/drivers/gpu/drm/tegra/nvdec.c
index 15f036e09e5c..79e1e88203cf 100644
--- a/drivers/gpu/drm/tegra/nvdec.c
+++ b/drivers/gpu/drm/tegra/nvdec.c
@@ -291,29 +291,17 @@ static int nvdec_open_channel(struct tegra_drm_client *client,
struct tegra_drm_context *context)
{
struct nvdec *nvdec = to_nvdec(client);
- int err;
-
- err = pm_runtime_get_sync(nvdec->dev);
- if (err < 0) {
- pm_runtime_put(nvdec->dev);
- return err;
- }
context->channel = host1x_channel_get(nvdec->channel);
- if (!context->channel) {
- pm_runtime_put(nvdec->dev);
+ if (!context->channel)
return -ENOMEM;
- }
return 0;
}
static void nvdec_close_channel(struct tegra_drm_context *context)
{
- struct nvdec *nvdec = to_nvdec(context->client);
-
host1x_channel_put(context->channel);
- pm_runtime_put(nvdec->dev);
}
static const struct tegra_drm_client_ops nvdec_ops = {
diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c
index 8ea653860e1a..1e342fa3d27b 100644
--- a/drivers/gpu/drm/tegra/vic.c
+++ b/drivers/gpu/drm/tegra/vic.c
@@ -345,27 +345,17 @@ static int vic_open_channel(struct tegra_drm_client *client,
struct tegra_drm_context *context)
{
struct vic *vic = to_vic(client);
- int err;
-
- err = pm_runtime_resume_and_get(vic->dev);
- if (err < 0)
- return err;
context->channel = host1x_channel_get(vic->channel);
- if (!context->channel) {
- pm_runtime_put(vic->dev);
+ if (!context->channel)
return -ENOMEM;
- }
return 0;
}
static void vic_close_channel(struct tegra_drm_context *context)
{
- struct vic *vic = to_vic(context->client);
-
host1x_channel_put(context->channel);
- pm_runtime_put(vic->dev);
}
static const struct tegra_drm_client_ops vic_ops = {