All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm/a6xx: add a6xx_gpu_state_get
@ 2018-12-20 18:46 Chia-I Wu
       [not found] ` <20181220184645.102974-1-olvaffe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Chia-I Wu @ 2018-12-20 18:46 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

It gets the generic states from the adreno core.

This also adds a missing NULL check in msm_gpu_open.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 44 +++++++++++++++++++++++++++
 drivers/gpu/drm/msm/msm_debugfs.c     |  2 +-
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 631257c297fd..dff3367aa432 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -778,6 +778,48 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)
 	return (unsigned long)busy_time;
 }
 
+struct a6xx_gpu_state {
+	struct msm_gpu_state base;
+};
+
+static struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)
+{
+	struct a6xx_gpu_state *a6xx_state = kzalloc(sizeof(*a6xx_state),
+			GFP_KERNEL);
+
+	if (!a6xx_state)
+		return ERR_PTR(-ENOMEM);
+
+	/* Temporarily disable hardware clock gating before reading the hw */
+	a6xx_set_hwcg(gpu, false);
+
+	/* get the generic state from the adreno core */
+	adreno_gpu_state_get(gpu, &(a6xx_state->base));
+
+	a6xx_set_hwcg(gpu, true);
+
+	return &a6xx_state->base;
+}
+
+static void a6xx_gpu_state_destroy(struct kref *kref)
+{
+	struct msm_gpu_state *state = container_of(kref,
+		struct msm_gpu_state, ref);
+	struct a6xx_gpu_state *a6xx_state = container_of(state,
+		struct a6xx_gpu_state, base);
+
+	adreno_gpu_state_destroy(state);
+	kfree(a6xx_state);
+}
+
+static int a6xx_gpu_state_put(struct msm_gpu_state *state)
+{
+	if (IS_ERR_OR_NULL(state))
+		return 1;
+
+	return kref_put(&state->ref, a6xx_gpu_state_destroy);
+}
+
 static const struct adreno_gpu_funcs funcs = {
 	.base = {
 		.get_param = adreno_get_param,
@@ -794,6 +836,8 @@ static const struct adreno_gpu_funcs funcs = {
 		.show = a6xx_show,
 #endif
 		.gpu_busy = a6xx_gpu_busy,
+		.gpu_state_get = a6xx_gpu_state_get,
+		.gpu_state_put = a6xx_gpu_state_put,
 		.gpu_get_freq = a6xx_gmu_get_freq,
 		.gpu_set_freq = a6xx_gmu_set_freq,
 	},
diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c
index f0da0d3c8a80..ee80856c4476 100644
--- a/drivers/gpu/drm/msm/msm_debugfs.c
+++ b/drivers/gpu/drm/msm/msm_debugfs.c
@@ -75,7 +75,7 @@ static int msm_gpu_open(struct inode *inode, struct file *file)
 	struct msm_gpu_show_priv *show_priv;
 	int ret;
 
-	if (!gpu)
+	if (!gpu || !gpu->funcs->gpu_state_get)
 		return -ENODEV;
 
 	show_priv = kmalloc(sizeof(*show_priv), GFP_KERNEL);
-- 
2.20.1.415.g653613c723-goog

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-20 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-20 18:46 [PATCH] drm/msm/a6xx: add a6xx_gpu_state_get Chia-I Wu
     [not found] ` <20181220184645.102974-1-olvaffe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-12-20 19:46   ` Jordan Crouse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.