All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
To: airlied@linux.ie
Cc: nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: [RFC PATCH v1 03/16] drm/nouveau: add reservation to nouveau_gem_ioctl_cpu_prep
Date: Wed, 14 May 2014 16:57:40 +0200	[thread overview]
Message-ID: <20140514145740.21163.22977.stgit@patser> (raw)
In-Reply-To: <20140514145134.21163.32350.stgit@patser>

Apart from some code inside ttm itself and nouveau_bo_vma_del,
this is the only place where ttm_bo_wait is used without a reservation.
Fix this so we can remove the fence_lock later on.

After the switch to rcu the reservation lock will be
removed again.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
---
 drivers/gpu/drm/nouveau/nouveau_gem.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index c90c0dc0afe8..6e1c58a880fe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -886,17 +886,31 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
 	struct drm_gem_object *gem;
 	struct nouveau_bo *nvbo;
 	bool no_wait = !!(req->flags & NOUVEAU_GEM_CPU_PREP_NOWAIT);
-	int ret = -EINVAL;
+	int ret;
+	struct nouveau_fence *fence = NULL;
 
 	gem = drm_gem_object_lookup(dev, file_priv, req->handle);
 	if (!gem)
 		return -ENOENT;
 	nvbo = nouveau_gem_object(gem);
 
-	spin_lock(&nvbo->bo.bdev->fence_lock);
-	ret = ttm_bo_wait(&nvbo->bo, true, true, no_wait);
-	spin_unlock(&nvbo->bo.bdev->fence_lock);
+	ret = ttm_bo_reserve(&nvbo->bo, true, false, false, 0);
+	if (!ret) {
+		spin_lock(&nvbo->bo.bdev->fence_lock);
+		ret = ttm_bo_wait(&nvbo->bo, true, true, true);
+		if (!no_wait && ret)
+			fence = nouveau_fence_ref(nvbo->bo.sync_obj);
+		spin_unlock(&nvbo->bo.bdev->fence_lock);
+
+		ttm_bo_unreserve(&nvbo->bo);
+	}
 	drm_gem_object_unreference_unlocked(gem);
+
+	if (fence) {
+		ret = nouveau_fence_wait(fence, true, no_wait);
+		nouveau_fence_unref(&fence);
+	}
+
 	return ret;
 }

  parent reply	other threads:[~2014-05-14 14:57 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 14:57 [RFC PATCH v1 00/16] Convert all ttm drivers to use the new reservation interface Maarten Lankhorst
2014-05-14 14:57 ` [RFC PATCH v1 01/16] drm/ttm: add interruptible parameter to ttm_eu_reserve_buffers Maarten Lankhorst
2014-05-14 14:57 ` [RFC PATCH v1 02/16] drm/ttm: kill off some members to ttm_validate_buffer Maarten Lankhorst
2014-05-14 14:57 ` Maarten Lankhorst [this message]
2014-05-14 14:57 ` [RFC PATCH v1 04/16] drm/nouveau: require reservations for nouveau_fence_sync and nouveau_bo_fence Maarten Lankhorst
2014-05-14 14:57 ` [RFC PATCH v1 05/16] drm/ttm: call ttm_bo_wait while inside a reservation Maarten Lankhorst
2014-05-14 14:57 ` [RFC PATCH v1 06/16] drm/ttm: kill fence_lock Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 07/16] drm/nouveau: rework to new fence interface Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 08/16] drm/radeon: use common fence implementation for fences Maarten Lankhorst
2014-05-14 15:29   ` Christian König
     [not found]     ` <53738BCC.2070809-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2014-05-15  1:06       ` Maarten Lankhorst
2014-05-15  1:06         ` Maarten Lankhorst
     [not found]         ` <5374131D.4010906-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-05-15  9:21           ` Christian König
2014-05-15  9:21             ` Christian König
2014-05-15  9:38             ` Maarten Lankhorst
     [not found]               ` <53748AFA.8010109-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-05-15  9:42                 ` Christian König
2014-05-15  9:42                   ` Christian König
2014-05-15 13:04                   ` Maarten Lankhorst
     [not found]                     ` <5374BB4A.6070102-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-05-15 13:19                       ` Christian König
2014-05-15 13:19                         ` Christian König
     [not found]                         ` <5374BEE2.4060608-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2014-05-15 14:18                           ` Maarten Lankhorst
2014-05-15 14:18                             ` Maarten Lankhorst
     [not found]                             ` <5374CC9A.9090905-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-05-15 15:48                               ` Christian König
2014-05-15 15:48                                 ` Christian König
2014-05-15 15:58                                 ` Maarten Lankhorst
2014-05-15 16:13                                   ` Christian König
2014-05-19  8:00                                     ` Maarten Lankhorst
2014-05-19  8:27                                       ` Christian König
2014-05-19 10:10                                         ` Maarten Lankhorst
2014-05-19 12:30                                           ` Christian König
     [not found]                                             ` <5379F96C.1060806-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2014-05-19 13:35                                               ` Maarten Lankhorst
2014-05-19 13:35                                                 ` Maarten Lankhorst
2014-05-19 14:25                                                 ` Christian König
     [not found]                                                   ` <537A144F.1070909-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2014-06-02 10:09                                                     ` [RFC PATCH v1.2 " Maarten Lankhorst
2014-06-02 10:09                                                       ` Maarten Lankhorst
2014-06-02 10:45                                                       ` Christian König
2014-06-02 13:14                                                         ` [RFC PATCH v1.3 08/16 1/2] drm/radeon: add timeout argument to radeon_fence_wait_seq Maarten Lankhorst
     [not found]                                                           ` <538C78B3.8080502-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2014-06-02 13:27                                                             ` Christian König
2014-06-02 13:27                                                               ` Christian König
2014-06-03  7:50                                                               ` [RFC PATCH v1.4 " Maarten Lankhorst
     [not found]                                                         ` <538C55CA.6050804-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2014-06-02 13:16                                                           ` [RFC PATCH v1.3 08/16 2/2] drm/radeon: use common fence implementation for fences Maarten Lankhorst
2014-06-02 13:16                                                             ` Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 09/16] drm/qxl: rework to new fence interface Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 10/16] drm/vmwgfx: get rid of different types of fence_flags entirely Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 11/16] drm/vmwgfx: rework to new fence interface Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 12/16] drm/ttm: flip the switch, and convert to dma_fence Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 13/16] drm/nouveau: use rcu in nouveau_gem_ioctl_cpu_prep Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 14/16] drm/radeon: use rcu waits in some ioctls Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 15/16] drm/vmwgfx: use rcu in vmw_user_dmabuf_synccpu_grab Maarten Lankhorst
2014-05-14 14:58 ` [RFC PATCH v1 16/16] drm/ttm: use rcu in core ttm Maarten Lankhorst

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=20140514145740.21163.22977.stgit@patser \
    --to=maarten.lankhorst@canonical.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.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 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.