linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jordan Crouse <jcrouse@codeaurora.org>
To: freedreno@lists.freedesktop.org
Cc: Sushmita Susheelendra <ssusheel@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 4/6] drm/msm: Map buffers on demand on the submit path
Date: Tue,  3 Oct 2017 09:27:04 -0600	[thread overview]
Message-ID: <1507044426-4042-5-git-send-email-jcrouse@codeaurora.org> (raw)
In-Reply-To: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org>

From: Sushmita Susheelendra <ssusheel@codeaurora.org>

Map and pin buffers on demand on the submission path.
This ensures that we only map buffers whose iova are
actually needed for submission as opposed to all
buffers in the buffer list. For instance, the command
buffers, and the reloc buffers for processing relocs.
Also remove unused member valid from the struct
msm_gem_submit.

Signed-off-by: Sushmita Susheelendra <ssusheel@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 58 +++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 2d2aa65..47a9e87 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -256,41 +256,38 @@ static int submit_fence_sync(struct msm_gem_submit *submit, bool no_implicit)
 	return ret;
 }
 
-static int submit_pin_objects(struct msm_gem_submit *submit)
+static int submit_pin_object(struct msm_gem_submit *submit, int i)
 {
-	int i, ret = 0;
-
-	submit->valid = true;
-
-	for (i = 0; i < submit->nr_bos; i++) {
-		struct msm_gem_object *msm_obj = submit->bos[i].obj;
-		uint64_t iova;
+	struct msm_gem_object *msm_obj = submit->bos[i].obj;
+	uint64_t iova;
+	int ret;
 
-		/* if locking succeeded, pin bo: */
-		ret = msm_gem_get_iova(&msm_obj->base,
-				submit->gpu->aspace, &iova);
+	if (submit->bos[i].flags & BO_PINNED)
+		return 0;
 
-		if (ret)
-			break;
+	/* if locking succeeded, pin bo: */
+	ret = msm_gem_get_iova(&msm_obj->base, submit->gpu->aspace, &iova);
+	if (ret)
+		return ret;
 
-		submit->bos[i].flags |= BO_PINNED;
+	submit->bos[i].flags |= BO_PINNED;
 
-		if (iova == submit->bos[i].iova) {
-			submit->bos[i].flags |= BO_VALID;
-		} else {
-			submit->bos[i].iova = iova;
-			/* iova changed, so address in cmdstream is not valid: */
-			submit->bos[i].flags &= ~BO_VALID;
-			submit->valid = false;
-		}
+	if (iova == submit->bos[i].iova) {
+		submit->bos[i].flags |= BO_VALID;
+	} else {
+		submit->bos[i].iova = iova;
+		/* iova changed, so address in cmdstream is not valid: */
+		submit->bos[i].flags &= ~BO_VALID;
 	}
 
-	return ret;
+	return 0;
 }
 
 static int submit_bo(struct msm_gem_submit *submit, uint32_t idx,
 		struct msm_gem_object **obj, uint64_t *iova, bool *valid)
 {
+	int ret;
+
 	if (idx >= submit->nr_bos) {
 		DRM_ERROR("invalid buffer index: %u (out of %u)\n",
 				idx, submit->nr_bos);
@@ -299,6 +296,14 @@ static int submit_bo(struct msm_gem_submit *submit, uint32_t idx,
 
 	if (obj)
 		*obj = submit->bos[idx].obj;
+
+	if (!iova && !valid)
+		return 0;
+
+	ret = submit_pin_object(submit, idx);
+	if (ret)
+		return ret;
+
 	if (iova)
 		*iova = submit->bos[idx].iova;
 	if (valid)
@@ -482,10 +487,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 	if (ret)
 		goto out;
 
-	ret = submit_pin_objects(submit);
-	if (ret)
-		goto out;
-
 	for (i = 0; i < args->nr_cmds; i++) {
 		struct drm_msm_gem_submit_cmd submit_cmd;
 		void __user *userptr =
@@ -536,9 +537,6 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
 		submit->cmd[i].iova = iova + submit_cmd.submit_offset;
 		submit->cmd[i].idx  = submit_cmd.submit_idx;
 
-		if (submit->valid)
-			continue;
-
 		ret = submit_reloc(submit, msm_obj, submit_cmd.submit_offset,
 				submit_cmd.nr_relocs, submit_cmd.relocs);
 		if (ret)
-- 
1.9.1

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

  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 ` Jordan Crouse [this message]
2017-10-03 15:27 ` [PATCH 6/6] drm/msm: Do priority checking during submitqueue create Jordan Crouse

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-5-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 \
    --cc=ssusheel@codeaurora.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).