All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: etnaviv@lists.freedesktop.org
Cc: patchwork-lst@pengutronix.de, kernel@pengutronix.de,
	dri-devel@lists.freedesktop.org,
	Russell King <linux+etnaviv@armlinux.org.uk>
Subject: [PATCH 26/27] drm/etnaviv: couple runtime PM management to submit object lifetime
Date: Fri,  1 Dec 2017 11:36:23 +0100	[thread overview]
Message-ID: <20171201103624.6565-27-l.stach@pengutronix.de> (raw)
In-Reply-To: <20171201103624.6565-1-l.stach@pengutronix.de>

As long as there is an active submit, we want the GPU to stay awake. This
is slightly complicated by the fact that we really want to wake the GPU
at the last possible moment to achieve maximum power savings.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.h        |  1 +
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c |  3 +++
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c        | 30 +++-------------------------
 3 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
index fe99f0c0d068..be72a9833f2b 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
@@ -106,6 +106,7 @@ struct etnaviv_gem_submit {
 	struct dma_fence *out_fence, *in_fence;
 	struct list_head node; /* GPU active submit list */
 	struct etnaviv_cmdbuf cmdbuf;
+	bool runtime_resumed;
 	u32 exec_state;
 	u32 flags;
 	unsigned int nr_pmrs;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 5a351b0f1087..1f8202bca061 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -355,6 +355,9 @@ static void submit_cleanup(struct kref *kref)
 			container_of(kref, struct etnaviv_gem_submit, refcount);
 	unsigned i;
 
+	if (submit->runtime_resumed)
+		pm_runtime_put_autosuspend(submit->gpu->dev);
+
 	if (submit->cmdbuf.suballoc)
 		etnaviv_cmdbuf_free(&submit->cmdbuf);
 
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index b0f4c0e68645..9becadb07efe 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1210,14 +1210,6 @@ static void retire_worker(struct work_struct *work)
 		list_del(&submit->node);
 
 		etnaviv_submit_put(submit);
-		/*
-		 * We need to balance the runtime PM count caused by
-		 * each submission.  Upon submission, we increment
-		 * the runtime PM counter, and allocate one event.
-		 * So here, we put the runtime PM count for each
-		 * completed event.
-		 */
-		pm_runtime_put_autosuspend(gpu->dev);
 	}
 
 	gpu->retired_fence = fence;
@@ -1289,17 +1281,6 @@ int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
 		return -ETIMEDOUT;
 }
 
-int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu)
-{
-	return pm_runtime_get_sync(gpu->dev);
-}
-
-void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu)
-{
-	pm_runtime_mark_last_busy(gpu->dev);
-	pm_runtime_put_autosuspend(gpu->dev);
-}
-
 static void sync_point_perfmon_sample(struct etnaviv_gpu *gpu,
 	struct etnaviv_event *event, unsigned int flags)
 {
@@ -1366,9 +1347,10 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	unsigned int i, nr_events = 1, event[3];
 	int ret;
 
-	ret = etnaviv_gpu_pm_get_sync(gpu);
+	ret = pm_runtime_get_sync(gpu->dev);
 	if (ret < 0)
 		return ret;
+	submit->runtime_resumed = true;
 
 	/*
 	 * if there are performance monitor requests we need to have
@@ -1383,7 +1365,7 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	ret = event_alloc(gpu, nr_events, event);
 	if (ret) {
 		DRM_ERROR("no free events\n");
-		goto out_pm_put;
+		return ret;
 	}
 
 	mutex_lock(&gpu->lock);
@@ -1420,18 +1402,12 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 
 	list_add_tail(&submit->node, &gpu->active_submit_list);
 
-	/* We're committed to adding this command buffer, hold a PM reference */
-	pm_runtime_get_noresume(gpu->dev);
-
 	hangcheck_timer_reset(gpu);
 	ret = 0;
 
 out_unlock:
 	mutex_unlock(&gpu->lock);
 
-out_pm_put:
-	etnaviv_gpu_pm_put(gpu);
-
 	return ret;
 }
 
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-12-01 10:58 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 10:35 [PATCH 00/27] Etnaviv job lifetime issue fixes Lucas Stach
2017-12-01 10:35 ` [PATCH 01/27] drm/etnaviv: fix GPU vs sync point race Lucas Stach
2017-12-01 11:33   ` Philipp Zabel
2017-12-11  7:47   ` Christian Gmeiner
2017-12-01 10:35 ` [PATCH 02/27] drm/etnaviv: split obj locks in different classes depending on the obj type Lucas Stach
2017-12-01 11:33   ` Philipp Zabel
2017-12-11  7:48   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 03/27] drm/etnaviv: add lockdep annotation for userptr object population Lucas Stach
2017-12-11 10:46   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 04/27] drm/etnaviv: fold __etnaviv_gem_new into caller Lucas Stach
2017-12-01 11:34   ` Philipp Zabel
2017-12-11 10:47   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 05/27] drm/etnaviv: change return type of etnaviv_gem_obj_add to void Lucas Stach
2017-12-01 11:34   ` Philipp Zabel
2017-12-11 10:47   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 06/27] drm/etnaviv: get rid of userptr worker Lucas Stach
2017-12-01 16:38   ` Philipp Zabel
2017-12-01 16:51     ` Russell King - ARM Linux
2017-12-01 17:02       ` Lucas Stach
2017-12-01 10:36 ` [PATCH 07/27] drm/etnaviv: remove -EAGAIN handling from submit path Lucas Stach
2017-12-01 16:39   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 08/27] drm/etnaviv: remove stale TODO in etnaviv_gpu_submit Lucas Stach
2017-12-11 10:49   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 09/27] drm/etnaviv: don't flush workqueue in etnaviv_gpu_wait_obj_inactive Lucas Stach
2017-12-01 16:39   ` Philipp Zabel
2017-12-01 16:59   ` Russell King - ARM Linux
2017-12-01 17:12     ` Lucas Stach
2017-12-01 10:36 ` [PATCH 10/27] drm/etnaviv: remove switch_context member from etnaviv_gpu Lucas Stach
2017-12-01 16:40   ` Philipp Zabel
2017-12-11 10:51   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 11/27] drm/etnaviv: move workqueue to be per GPU Lucas Stach
2017-12-01 16:42   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 12/27] drm/etnaviv: hold GPU lock while inserting END command Lucas Stach
2017-12-01 16:43   ` Philipp Zabel
2017-12-11 10:48   ` Christian Gmeiner
2017-12-01 10:36 ` [PATCH 13/27] drm/etnaviv: add lockdep annotations to buffer manipulation functions Lucas Stach
2017-12-01 16:47   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 14/27] drm/etnaviv: simplify submit_create Lucas Stach
2017-12-01 16:47   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 15/27] drm/etnaviv: move object fence attachment to gem_submit path Lucas Stach
2017-12-11  9:17   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 16/27] drm/etnaviv: rename submit fence to out_fence Lucas Stach
2017-12-01 10:36 ` [PATCH 17/27] drm/etnaviv: attach in fence to submit and move fence wait to fence_sync Lucas Stach
2017-12-11  9:20   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 18/27] drm/etnaviv: move object unpinning to submit cleanup Lucas Stach
2017-12-11  9:23   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 19/27] drm/etnaviv: move ww_acquire_ctx out of submit object Lucas Stach
2017-12-15 18:34   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 20/27] drm/etnaviv: refcount the " Lucas Stach
2017-12-11 12:41   ` Philipp Zabel
2017-12-01 10:36 ` [PATCH 21/27] drm/etnaviv: move PMRs to " Lucas Stach
2017-12-01 10:36 ` [PATCH 22/27] drm/etnaviv: move exec_state " Lucas Stach
2017-12-01 10:36 ` [PATCH 23/27] drm/etnaviv: use submit exec_state for perfmon sampling Lucas Stach
2017-12-01 10:36 ` [PATCH 24/27] drm/etnaviv: move cmdbuf into submit object Lucas Stach
2017-12-01 10:36 ` [PATCH 25/27] drm/etnaviv: move GPU active handling to bo pin/unpin Lucas Stach
2017-12-01 10:36 ` Lucas Stach [this message]
2017-12-01 10:36 ` [PATCH 27/27] drm/etnaviv: re-enable perfmon support Lucas Stach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171201103624.6565-27-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=patchwork-lst@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.