From: Jordan Crouse <jcrouse@codeaurora.org>
To: freedreno@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 6/6] drm/msm: Do priority checking during submitqueue create
Date: Tue, 3 Oct 2017 09:27:06 -0600 [thread overview]
Message-ID: <1507044426-4042-7-git-send-email-jcrouse@codeaurora.org> (raw)
In-Reply-To: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org>
Now that the priority must be set in the submitqueue we can check
at create time that the requested priority is valid.
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
drivers/gpu/drm/msm/msm_gem_submit.c | 8 +++++---
drivers/gpu/drm/msm/msm_submitqueue.c | 25 +++++++++++++++++++------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 47a9e87..5b9210b 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -421,7 +421,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
struct msm_gpu_submitqueue *queue;
int out_fence_fd = -1;
unsigned i;
- int ret, ring;
+ int ret;
if (!gpu)
return -ENXIO;
@@ -439,6 +439,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
if (!queue)
return -ENOENT;
+ if (queue->prio >= gpu->nr_rings)
+ return -EINVAL;
+
if (args->flags & MSM_SUBMIT_FENCE_FD_IN) {
in_fence = sync_file_get_fence(args->fence_fd);
@@ -545,8 +548,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
submit->nr_cmds = i;
- ring = clamp_t(uint32_t, queue->prio, 0, gpu->nr_rings - 1);
- submit->ring = gpu->rb[ring];
+ submit->ring = gpu->rb[queue->prio];
submit->fence = msm_fence_alloc(queue->fctx);
if (IS_ERR(submit->fence)) {
diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c
index f23b43e..da4bee8 100644
--- a/drivers/gpu/drm/msm/msm_submitqueue.c
+++ b/drivers/gpu/drm/msm/msm_submitqueue.c
@@ -64,6 +64,7 @@ void msm_submitqueue_close(struct msm_file_private *ctx)
int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
u32 prio, u32 flags, u32 *id)
{
+ struct msm_drm_private *priv = drm->dev_private;
struct msm_gpu_submitqueue *queue;
char name[32];
int ret = 0;
@@ -77,7 +78,13 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
kref_init(&queue->ref);
queue->flags = flags;
- queue->prio = prio;
+
+ if (priv->gpu) {
+ if (prio >= priv->gpu->nr_rings)
+ return -EINVAL;
+
+ queue->prio = prio;
+ }
write_lock(&ctx->queuelock);
@@ -114,18 +121,24 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx)
{
+ struct msm_drm_private *priv = drm->dev_private;
+ int default_prio;
+
if (!ctx)
return 0;
+ /*
+ * Select priority 2 as the "default priority" unless nr_rings is less
+ * than 2 and then pick the lowest pirority
+ */
+ default_prio = priv->gpu ?
+ clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1) : 0;
+
INIT_LIST_HEAD(&ctx->submitqueues);
rwlock_init(&ctx->queuelock);
- /*
- * Add the "default" submitqueue with id 0
- * "low" priority (2) and no flags
- */
- return msm_submitqueue_create(drm, ctx, 2, 0, NULL);
+ return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL);
}
int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id)
--
1.9.1
prev parent reply other threads:[~2017-10-03 15:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 15:27 [PATCH 0/6] drm/msm: Fixes and updates for 4.15 Jordan Crouse
[not found] ` <1507044426-4042-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-10-03 15:27 ` [PATCH 1/6] drm/msm: Fix race condition in the submit path Jordan Crouse
2017-10-03 15:27 ` [PATCH 2/6] drm/msm: dump a rd GPUADDR header for all buffers in the command Jordan Crouse
2017-10-03 15:27 ` [PATCH 5/6] drm/msm: Change MSM_DRM_SUBMITQUEUE_CLOSE Jordan Crouse
2017-10-03 15:27 ` [PATCH 3/6] drm/msm: Map command buffers to kernel only if required Jordan Crouse
2017-10-03 15:27 ` [PATCH 4/6] drm/msm: Map buffers on demand on the submit path Jordan Crouse
2017-10-03 15:27 ` Jordan Crouse [this message]
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=1507044426-4042-7-git-send-email-jcrouse@codeaurora.org \
--to=jcrouse@codeaurora.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).