Skip to contentSkip to conversation

drm/radeon: add extra check in radeon_ttm_tt_unpin_userptr

PATCH In review Christian König 2 participants 6 messages Mar 31, 2015 – Apr 8, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drm/radeon: add extra check in radeon_ttm_tt_unpin_userptr

From: Christian König <[email protected]>

We somehow try to free the SG table twice.

Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=89734

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_ttm.c +4 -0
index d02aa1d..b292aca 100644
@@ -598,6 +598,10 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 	enum dma_data_direction direction = write ?
 		DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
+	/* double check that we don't free the table twice */
+	if (!ttm->sg->sgl)
+		return;
+
 	/* free the sg table and pages again */
 	dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/4 drm/radeon: fix wait in radeon_mn_invalidate_range_start

From: Christian König <[email protected]>

We need to wait for all fences, not just the exclusive one.

---
 drivers/gpu/drm/radeon/radeon_mn.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/radeon_mn.c +4 -7
index a69bd44..572b4db 100644
@@ -122,7 +122,6 @@ static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
 	it = interval_tree_iter_first(&rmn->objects, start, end);
 	while (it) {
 		struct radeon_bo *bo;
-		struct fence *fence;
 		int r;
 
 		bo = container_of(it, struct radeon_bo, mn_it);
@@ -134,12 +133,10 @@ static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
 			continue;
 		}
 
-		fence = reservation_object_get_excl(bo->tbo.resv);
-		if (fence) {
-			r = radeon_fence_wait((struct radeon_fence *)fence, false);
-			if (r)
-				DRM_ERROR("(%d) failed to wait for user bo\n", r);
-		}
+		r = reservation_object_wait_timeout_rcu(bo->tbo.resv, true,
+			false, MAX_SCHEDULE_TIMEOUT);
+		if (r)
+			DRM_ERROR("(%d) failed to wait for user bo\n", r);
 
 		radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_CPU);
 		r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 3/4 drm/radeon: add userptr config option

In reply to Christian König

From: Christian König <[email protected]>

This allows selecting CONFIG_MMU_NOTIFIER if it isn't already selected.

---
 drivers/gpu/drm/radeon/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/radeon/Kconfig +8 -0
index 970f8e9..421ae13 100644
@@ -1,3 +1,11 @@
+config DRM_RADEON_USERPTR
+	bool "Always enable userptr support"
+	depends on DRM_RADEON
+	select MMU_NOTIFIER
+	help
+	  This option selects CONFIG_MMU_NOTIFIER if it isn't already
+	  selected to enabled full userptr support.
+
 config DRM_RADEON_UMS
 	bool "Enable userspace modesetting on radeon (DEPRECATED)"
 	depends on DRM_RADEON
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 4/4 drm/radeon: allow creating overlapping userptrs

In reply to Christian König

From: Christian König <[email protected]>

Similar to the Intel implementation, but instead of just falling back to a global linear list when we have an overlapping userptr request we accumulate all overlapping userptrs in a local list.

---
 drivers/gpu/drm/radeon/radeon.h    |   2 +-
 drivers/gpu/drm/radeon/radeon_mn.c | 102 +++++++++++++++++++++++++++----------
 2 files changed, 76 insertions(+), 28 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -1
index 35ab65d..a0c272e 100644
@@ -507,7 +507,7 @@ struct radeon_bo {
 	pid_t				pid;
 
 	struct radeon_mn		*mn;
-	struct interval_tree_node	mn_it;
+	struct list_head		mn_list;
 };
 #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
 
drivers/gpu/drm/radeon/radeon_mn.c +75 -27

162 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/4
#4 lore raw
In reply to Christian König
Quoted 8 lines · Christian König

From: Christian König <[email protected]>

We somehow try to free the SG table twice.

Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=89734

For the series:

I've added the first two to my -fixes tree.

Alex

Quoted 20 lines
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_ttm.c +4 -1
index d02aa1d..b292aca 100644
@@ -598,6 +598,10 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
        enum dma_data_direction direction = write ?
                DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
+       /* double check that we don't free the table twice */
+       if (!ttm->sg->sgl)
+               return;
+
        /* free the sg table and pages again */
        dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
--
Quoted 2 lines

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 6 lines · Alex Deucher
Quoted 4 lines · Christian König

From: Christian König <[email protected]>

We somehow try to free the SG table twice.

Quoted 8 lines
Quoted 4 lines

Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=89734

For the series:

I've added the first two to my -fixes tree.

Could you add the other two to your -next tree? You probably need to merge with -fixes to do so.

Regards,
Christian.

Quoted 22 lines

Alex

Quoted 19 lines
---
  drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/gpu/drm/radeon/radeon_ttm.c +4 -0
index d02aa1d..b292aca 100644
@@ -598,6 +598,10 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
         enum dma_data_direction direction = write ?
                 DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
 
+       /* double check that we don't free the table twice */
+       if (!ttm->sg->sgl)
+               return;
+
         /* free the sg table and pages again */
         dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
Quoted 3 lines
Quoted 3 lines

--
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel