From: Mikko Perttunen <mperttunen@nvidia.com>
To: thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: digetx@gmail.com, dri-devel@lists.freedesktop.org,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
Mikko Perttunen <mperttunen@nvidia.com>
Subject: [PATCH 05/10] gpu: host1x: Add job done callback
Date: Sun, 5 Nov 2017 13:01:13 +0200 [thread overview]
Message-ID: <20171105110118.15142-6-mperttunen@nvidia.com> (raw)
In-Reply-To: <20171105110118.15142-1-mperttunen@nvidia.com>
Allow job submitters to set a callback to be called when the job has
completed. The jobs are stored and the callbacks called outside the
CDMA lock area to allow the callbacks to do CDMA-requiring operations
like freeing channels.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
drivers/gpu/host1x/cdma.c | 44 +++++++++++++++++++++++++++++++++-----------
include/linux/host1x.h | 4 ++++
2 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index f787cfe69c11..57221d199d33 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -251,17 +251,24 @@ static void stop_cdma_timer_locked(struct host1x_cdma *cdma)
cdma->timeout.client = 0;
}
-/*
- * For all sync queue entries that have already finished according to the
- * current sync point registers:
- * - unpin & unref their mems
- * - pop their push buffer slots
- * - remove them from the sync queue
+/**
+ * update_cdma_locked() - Update CDMA sync queue
+ * @cdma: CDMA instance to update
+ * @done_jobs: List that finished jobs will be added to
+ *
+ * Go through the CDMA's sync queue, and for each job that has been finished,
+ * - unpin it
+ * - pop its push buffer slots
+ * - remove it from the sync queue
+ * - add it to the done_jobs list.
+ *
* This is normally called from the host code's worker thread, but can be
* called manually if necessary.
- * Must be called with the cdma lock held.
+ *
+ * Must be called with the CDMA lock held.
*/
-static void update_cdma_locked(struct host1x_cdma *cdma)
+static void update_cdma_locked(struct host1x_cdma *cdma,
+ struct list_head *done_jobs)
{
bool signal = false;
struct host1x *host1x = cdma_to_host1x(cdma);
@@ -305,8 +312,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma)
signal = true;
}
- list_del(&job->list);
- host1x_job_put(job);
+ list_move_tail(&job->list, done_jobs);
}
if (cdma->event == CDMA_EVENT_SYNC_QUEUE_EMPTY &&
@@ -542,7 +548,23 @@ void host1x_cdma_end(struct host1x_cdma *cdma,
*/
void host1x_cdma_update(struct host1x_cdma *cdma)
{
+ struct host1x_job *job, *tmp;
+ LIST_HEAD(done_jobs);
+
mutex_lock(&cdma->lock);
- update_cdma_locked(cdma);
+ update_cdma_locked(cdma, &done_jobs);
mutex_unlock(&cdma->lock);
+
+ /*
+ * The done callback may want to free the channel, which requires
+ * taking the CDMA lock, so we need to do it outside the above lock
+ * region.
+ */
+ list_for_each_entry_safe(job, tmp, &done_jobs, list) {
+ if (job->done)
+ job->done(job);
+
+ list_del(&job->list);
+ host1x_job_put(job);
+ }
}
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index 630b1a98ab58..f931d28a68ff 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -253,6 +253,10 @@ struct host1x_job {
/* Check if class belongs to the unit */
int (*is_valid_class)(u32 class);
+ /* Job done callback */
+ void (*done)(struct host1x_job *job);
+ void *callback_data;
+
/* Request a SETCLASS to this class */
u32 class;
--
2.14.2
next prev parent reply other threads:[~2017-11-05 11:01 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-05 11:01 [PATCH 00/10] Dynamic Host1x channel allocation Mikko Perttunen
2017-11-05 11:01 ` [PATCH 02/10] gpu: host1x: Print MLOCK state in debug dumps on T186 Mikko Perttunen
2017-11-05 11:01 ` [PATCH 03/10] gpu: host1x: Add lock around channel allocation Mikko Perttunen
2017-11-05 11:01 ` [PATCH 04/10] gpu: host1x: Lock classes during job submission Mikko Perttunen
[not found] ` <20171105110118.15142-5-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-05 16:46 ` Dmitry Osipenko
2017-11-07 12:28 ` Mikko Perttunen
[not found] ` <ef08d3d8-94a7-8804-c339-5310719333f3-/1wQRMveznE@public.gmane.org>
2017-11-07 21:23 ` Dmitry Osipenko
[not found] ` <dc39398b-ea49-6e97-28ba-652f8b49db44-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-05 13:21 ` Mikko Perttunen
[not found] ` <2b4d9283-dabe-9e1f-f8cb-6ddbc16e3f0f-/1wQRMveznE@public.gmane.org>
2017-12-05 13:43 ` Dmitry Osipenko
2017-11-05 11:01 ` Mikko Perttunen [this message]
2017-11-05 11:01 ` [PATCH 08/10] drm/tegra: Implement dynamic channel allocation model Mikko Perttunen
[not found] ` <20171105110118.15142-9-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-05 17:43 ` Dmitry Osipenko
2017-11-07 12:29 ` Mikko Perttunen
[not found] ` <38fcf947-0d5d-e2c7-f49f-9efce5eeb1a3-/1wQRMveznE@public.gmane.org>
2017-11-13 11:49 ` Dmitry Osipenko
2017-11-05 11:01 ` [PATCH 09/10] drm/tegra: Boot VIC in runtime resume Mikko Perttunen
2017-11-05 11:01 ` [PATCH 10/10] gpu: host1x: Optionally block when acquiring channel Mikko Perttunen
[not found] ` <20171105110118.15142-11-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-05 17:14 ` Dmitry Osipenko
[not found] ` <9c5676eb-ba6f-c187-29e4-7b331bd3962f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-07 13:11 ` Mikko Perttunen
2017-11-07 15:29 ` Dmitry Osipenko
[not found] ` <1b35ec93-167b-3436-0ff2-5e2e0886aea7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-10 21:15 ` Dmitry Osipenko
[not found] ` <dcb8c4ef-9eb9-556f-cc96-651a50636afa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-12 11:23 ` Dmitry Osipenko
2017-11-29 9:10 ` Mikko Perttunen
2017-11-29 12:18 ` Dmitry Osipenko
[not found] ` <07e28b40-dd2b-774f-2d07-3b5d6cf08c46-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-29 12:25 ` Mikko Perttunen
[not found] ` <a4adb6ac-b72e-3f9b-fc6c-2a56bc6537ce-/1wQRMveznE@public.gmane.org>
2017-11-29 12:37 ` Dmitry Osipenko
[not found] ` <20171105110118.15142-1-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-05 11:01 ` [PATCH 01/10] gpu: host1x: Parameterize channel aperture size Mikko Perttunen
2017-11-05 11:01 ` [PATCH 06/10] drm/tegra: Deliver job completion callback to client Mikko Perttunen
[not found] ` <20171105110118.15142-7-mperttunen-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-11-16 16:33 ` Dmitry Osipenko
2017-11-16 16:40 ` Dmitry Osipenko
[not found] ` <1afa1ba9-3103-3672-2e15-fb8c7de2520b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-29 9:09 ` Mikko Perttunen
2017-11-05 11:01 ` [PATCH 07/10] drm/tegra: Make syncpoints be per-context Mikko Perttunen
2017-11-07 15:34 ` [PATCH 00/10] Dynamic Host1x channel allocation Dmitry Osipenko
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=20171105110118.15142-6-mperttunen@nvidia.com \
--to=mperttunen@nvidia.com \
--cc=digetx@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox