Skip to contentSkip to conversation

drm/radeon: disable semaphores for UVD V1

PATCH Applied Christian König 3 participants 7 messages May 1, 2015

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

PATCH 1/2 drm/radeon: disable semaphores for UVD V1

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

Hardware doesn't seem to work correctly, just block userspace in this case.

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

---
 drivers/gpu/drm/radeon/radeon_asic.c |  2 +-
 drivers/gpu/drm/radeon/radeon_asic.h |  4 ++++
 drivers/gpu/drm/radeon/uvd_v1_0.c    | 14 ++------------
 drivers/gpu/drm/radeon/uvd_v2_2.c    | 29 +++++++++++++++++++++++++++++
 4 files changed, 36 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_asic.c +1 -1
index fafd8ce..8dbf508 100644
@@ -1202,7 +1202,7 @@ static struct radeon_asic rs780_asic = {
 static struct radeon_asic_ring rv770_uvd_ring = {
 	.ib_execute = &uvd_v1_0_ib_execute,
 	.emit_fence = &uvd_v2_2_fence_emit,
-	.emit_semaphore = &uvd_v1_0_semaphore_emit,
+	.emit_semaphore = &uvd_v2_2_semaphore_emit,
 	.cs_parse = &radeon_uvd_cs_parse,
 	.ring_test = &uvd_v1_0_ring_test,
 	.ib_test = &uvd_v1_0_ib_test,
drivers/gpu/drm/radeon/radeon_asic.h +4 -0
index cf0a90b..a3ca8cd 100644
@@ -949,6 +949,10 @@ void uvd_v1_0_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
 int uvd_v2_2_resume(struct radeon_device *rdev);
 void uvd_v2_2_fence_emit(struct radeon_device *rdev,
 			 struct radeon_fence *fence);
+bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
+			     struct radeon_ring *ring,
+			     struct radeon_semaphore *semaphore,
+			     bool emit_wait);
 
 /* uvd v3.1 */
 bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev,
drivers/gpu/drm/radeon/uvd_v1_0.c +2 -12
index e72b3cb..c6b1cbc 100644
@@ -466,18 +466,8 @@ bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev,
 			     struct radeon_semaphore *semaphore,
 			     bool emit_wait)
 {
-	uint64_t addr = semaphore->gpu_addr;
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
-	radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
-	radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
-	radeon_ring_write(ring, emit_wait ? 1 : 0);
-
-	return true;
+	/* disable semaphores for UVD V1 hardware */
+	return false;
 }
 
 /**
drivers/gpu/drm/radeon/uvd_v2_2.c +29 -0
index 8919351..7ed778c 100644
@@ -60,6 +60,35 @@ void uvd_v2_2_fence_emit(struct radeon_device *rdev,
 }
 
 /**
+ * uvd_v2_2_semaphore_emit - emit semaphore command
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ * @semaphore: semaphore to emit commands for
+ * @emit_wait: true if we should emit a wait command
+ *
+ * Emit a semaphore command (either wait or signal) to the UVD ring.
+ */
+bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
+			     struct radeon_ring *ring,
+			     struct radeon_semaphore *semaphore,
+			     bool emit_wait)
+{
+	uint64_t addr = semaphore->gpu_addr;
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
+	radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
+	radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
+	radeon_ring_write(ring, emit_wait ? 1 : 0);
+
+	return true;
+}
+
+/**
  * uvd_v2_2_resume - memory controller programming
  *
  * @rdev: radeon_device pointer
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/2 drm/radeon: fix userptr BO unpin bug

From: "monk.liu" <[email protected]>

Fixing a memory leak with userptrs.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +9 -4
index b292aca..e661841 100644
@@ -606,13 +606,18 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 	dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
 	for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
+		int len = sg->length >> PAGE_SHIFT;
 		struct page *page = sg_page(sg);
+		while (len > 0) {
+			if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
+				set_page_dirty(page);
 
-		if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
-			set_page_dirty(page);
+			mark_page_accessed(page);
+			page_cache_release(page);
 
-		mark_page_accessed(page);
-		page_cache_release(page);
+			page++;
+			len--;
+		}
 	}
 
 	sg_free_table(ttm->sg);
Signature · 6 lines
1.9.1

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

Re: [PATCH 2/2] drm/radeon: fix userptr BO unpin bug

Quoted 16 lines · Christian König

From: "monk.liu" <[email protected]>

Fixing a memory leak with userptrs.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +0 -0
index b292aca..e661841 100644

drivers/gpu/drm/radeon/radeon_ttm.c static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm) · line 611

Quoted 6 lines
drivers/gpu/drm/radeon/radeon_ttm.c +2 -0
@@ -606,13 +606,18 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
        dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
        for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
+               int len = sg->length >> PAGE_SHIFT;
                struct page *page = sg_page(sg);
+               while (len > 0) {

This is a really awkward loop... IMO it'd be a lot clearer as

for (i = 0; i < sg->length >> PAGE_SHIFT; i++, page++)

[Also I assume that sg->length is never less than a page?]

Quoted 19 lines
drivers/gpu/drm/radeon/radeon_ttm.c +7 -5
+                       if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
+                               set_page_dirty(page);
 
-               if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
-                       set_page_dirty(page);
+                       mark_page_accessed(page);
+                       page_cache_release(page);
 
-               mark_page_accessed(page);
-               page_cache_release(page);
+                       page++;
+                       len--;
+               }
        }
 
        sg_free_table(ttm->sg);
--

1.9.1

Quoted 4 lines

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

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

Applied
#3 lore raw
In reply to Christian König
Quoted 8 lines · Christian König

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

Hardware doesn't seem to work correctly, just block userspace in this case.

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

Applied both to my stable tree. I had to fix the missing defines on this patch.

Alex

From 485325a1dd906bfbb2dd2e5982771985c82fd760 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <[email protected]>
Date: Fri, 1 May 2015 12:34:12 +0200
Subject: [PATCH 1/2] drm/radeon: disable semaphores for UVD V1 (v2)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Hardware doesn't seem to work correctly, just block userspace in this case.

v2: add missing defines

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

---
 drivers/gpu/drm/radeon/radeon_asic.c |  2 +-
 drivers/gpu/drm/radeon/radeon_asic.h |  4 ++++
 drivers/gpu/drm/radeon/rv770d.h      |  3 +++
 drivers/gpu/drm/radeon/uvd_v1_0.c    | 14 ++------------
 drivers/gpu/drm/radeon/uvd_v2_2.c    | 29 +++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_asic.c +1 -1
index fafd8ce..8dbf508 100644
@@ -1202,7 +1202,7 @@ static struct radeon_asic rs780_asic = {
 static struct radeon_asic_ring rv770_uvd_ring = {
 	.ib_execute = &uvd_v1_0_ib_execute,
 	.emit_fence = &uvd_v2_2_fence_emit,
-	.emit_semaphore = &uvd_v1_0_semaphore_emit,
+	.emit_semaphore = &uvd_v2_2_semaphore_emit,
 	.cs_parse = &radeon_uvd_cs_parse,
 	.ring_test = &uvd_v1_0_ring_test,
 	.ib_test = &uvd_v1_0_ib_test,
drivers/gpu/drm/radeon/radeon_asic.h +4 -0
index cf0a90b..a3ca8cd 100644
@@ -949,6 +949,10 @@ void uvd_v1_0_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
 int uvd_v2_2_resume(struct radeon_device *rdev);
 void uvd_v2_2_fence_emit(struct radeon_device *rdev,
 			 struct radeon_fence *fence);
+bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
+			     struct radeon_ring *ring,
+			     struct radeon_semaphore *semaphore,
+			     bool emit_wait);
 
 /* uvd v3.1 */
 bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev,
drivers/gpu/drm/radeon/rv770d.h +3 -0
index 3cf1e29..9ef2064 100644
@@ -989,6 +989,9 @@
 			 ((n) & 0x3FFF) << 16)
 
 /* UVD */
+#define UVD_SEMA_ADDR_LOW				0xef00
+#define UVD_SEMA_ADDR_HIGH				0xef04
+#define UVD_SEMA_CMD					0xef08
 #define UVD_GPCOM_VCPU_CMD				0xef0c
 #define UVD_GPCOM_VCPU_DATA0				0xef10
 #define UVD_GPCOM_VCPU_DATA1				0xef14
drivers/gpu/drm/radeon/uvd_v1_0.c +2 -12
index e72b3cb..c6b1cbc 100644
@@ -466,18 +466,8 @@ bool uvd_v1_0_semaphore_emit(struct radeon_device *rdev,
 			     struct radeon_semaphore *semaphore,
 			     bool emit_wait)
 {
-	uint64_t addr = semaphore->gpu_addr;
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
-	radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
-	radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
-
-	radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
-	radeon_ring_write(ring, emit_wait ? 1 : 0);
-
-	return true;
+	/* disable semaphores for UVD V1 hardware */
+	return false;
 }
 
 /**
drivers/gpu/drm/radeon/uvd_v2_2.c +29 -0
index 8919351..7ed778c 100644
@@ -60,6 +60,35 @@ void uvd_v2_2_fence_emit(struct radeon_device *rdev,
 }
 
 /**
+ * uvd_v2_2_semaphore_emit - emit semaphore command
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ * @semaphore: semaphore to emit commands for
+ * @emit_wait: true if we should emit a wait command
+ *
+ * Emit a semaphore command (either wait or signal) to the UVD ring.
+ */
+bool uvd_v2_2_semaphore_emit(struct radeon_device *rdev,
+			     struct radeon_ring *ring,
+			     struct radeon_semaphore *semaphore,
+			     bool emit_wait)
+{
+	uint64_t addr = semaphore->gpu_addr;
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
+	radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
+	radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
+
+	radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
+	radeon_ring_write(ring, emit_wait ? 1 : 0);
+
+	return true;
+}
+
+/**
  * uvd_v2_2_resume - memory controller programming
  *
  * @rdev: radeon_device pointer
Signature · 1 line
1.8.3.1

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

#4 lore raw
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Christian König

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

Hardware doesn't seem to work correctly, just block userspace in this case.

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

Applied both to my stable tree. I had to fix the missing defines on this patch.

Ups, thanks for doing this. I've once more send out the wrong version of the patch. But your changes look like they should work as well.

Christian.

Quoted 2 lines

Alex

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

#5 lore raw
Quoted 15 lines · Christian König
Quoted 14 lines · Alex Deucher
Quoted 10 lines · Christian König

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

Hardware doesn't seem to work correctly, just block userspace in this case.

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

Quoted 6 lines
Quoted 2 lines

Applied both to my stable tree. I had to fix the missing defines on this patch.

Ups, thanks for doing this. I've once more send out the wrong version of the patch. But your changes look like they should work as well.

I can swap it out if you have a preferred version.

Alex

Quoted 7 lines

Christian.

Quoted 2 lines

Alex

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

#6 lore raw
Quoted 12 lines · Alex Deucher
Quoted 10 lines · Christian König
Quoted 9 lines · Alex Deucher
Quoted 7 lines · Christian König

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

Hardware doesn't seem to work correctly, just block userspace in this case.

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

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Applied both to my stable tree. I had to fix the missing defines on this patch.

Ups, thanks for doing this. I've once more send out the wrong version of the patch. But your changes look like they should work as well.

I can swap it out if you have a preferred version.

No, keep it as it is. My version was just emitting the semaphore using the FW instead of programming the regs directly.

This is actually the documented way how to do it, but IIRC we had problems with this and so we are using the direct way ever since shortly after releasing it.

No need to switch it back without a good reason, that could just cause trouble.

Christian.

Quoted 7 lines

Alex

Quoted 4 lines

Christian.

Quoted 1 line

Alex

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