Skip to contentSkip to conversation

drm/radeon: fix surface sync in fence on cayman

PATCH In review Alex Deucher 3 participants 5 messages Jan 16, 2014

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

PATCH 1/2 drm/radeon: fix surface sync in fence on cayman

We need to set the engine bit to select the ME and also set the full cache bit. Should help stability on TN and cayman.

---
 drivers/gpu/drm/radeon/ni.c  | 7 +++----
 drivers/gpu/drm/radeon/nid.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ni.c +3 -4
index 9f11a55..04e9516 100644
@@ -1319,13 +1319,12 @@ void cayman_fence_ring_emit(struct radeon_device *rdev,
 {
 	struct radeon_ring *ring = &rdev->ring[fence->ring];
 	u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
+	u32 cp_coher_cntl = PACKET3_FULL_CACHE_ENA | PACKET3_TC_ACTION_ENA |
+		PACKET3_SH_ACTION_ENA;
 
 	/* flush read cache over gart for this vmid */
-	radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
-	radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2);
-	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-	radeon_ring_write(ring, PACKET3_TC_ACTION_ENA | PACKET3_SH_ACTION_ENA);
+	radeon_ring_write(ring, PACKET3_ENGINE_ME | cp_coher_cntl);
 	radeon_ring_write(ring, 0xFFFFFFFF);
 	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, 10); /* poll interval */
drivers/gpu/drm/radeon/nid.h +1 -0
index 22421bc..d996033 100644
@@ -1154,6 +1154,7 @@
 #              define PACKET3_DB_ACTION_ENA        (1 << 26)
 #              define PACKET3_SH_ACTION_ENA        (1 << 27)
 #              define PACKET3_SX_ACTION_ENA        (1 << 28)
+#              define PACKET3_ENGINE_ME            (1 << 31)
 #define	PACKET3_ME_INITIALIZE				0x44
 #define		PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
 #define	PACKET3_COND_WRITE				0x45
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 2/2 drm/radeon: set the full cache bit for fences on r7xx+

Needed to properly flush the read caches for fences.

---
 drivers/gpu/drm/radeon/r600.c  | 13 +++++++------
 drivers/gpu/drm/radeon/r600d.h |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/r600.c +7 -6
index ad99bae..3dce370 100644
@@ -2706,14 +2706,17 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
 			  struct radeon_fence *fence)
 {
 	struct radeon_ring *ring = &rdev->ring[fence->ring];
+	u32 cp_coher_cntl = PACKET3_TC_ACTION_ENA | PACKET3_VC_ACTION_ENA |
+		PACKET3_SH_ACTION_ENA;
+
+	if (rdev->family >= CHIP_RV770)
+		cp_coher_cntl |= PACKET3_FULL_CACHE_ENA;
 
 	if (rdev->wb.use_event) {
 		u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
 		/* flush read cache over gart */
 		radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-		radeon_ring_write(ring, PACKET3_TC_ACTION_ENA |
-					PACKET3_VC_ACTION_ENA |
-					PACKET3_SH_ACTION_ENA);
+		radeon_ring_write(ring, cp_coher_cntl);
 		radeon_ring_write(ring, 0xFFFFFFFF);
 		radeon_ring_write(ring, 0);
 		radeon_ring_write(ring, 10); /* poll interval */
@@ -2727,9 +2730,7 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
 	} else {
 		/* flush read cache over gart */
 		radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-		radeon_ring_write(ring, PACKET3_TC_ACTION_ENA |
-					PACKET3_VC_ACTION_ENA |
-					PACKET3_SH_ACTION_ENA);
+		radeon_ring_write(ring, cp_coher_cntl);
 		radeon_ring_write(ring, 0xFFFFFFFF);
 		radeon_ring_write(ring, 0);
 		radeon_ring_write(ring, 10); /* poll interval */
drivers/gpu/drm/radeon/r600d.h +1 -0
index 3fca4b9..37455f6 100644
@@ -1582,6 +1582,7 @@
 #              define PACKET3_CP_DMA_CMD_DAIC      (1 << 29)
 #define	PACKET3_SURFACE_SYNC				0x43
 #              define PACKET3_CB0_DEST_BASE_ENA    (1 << 6)
+#              define PACKET3_FULL_CACHE_ENA       (1 << 20) /* r7xx+ only */
 #              define PACKET3_TC_ACTION_ENA        (1 << 23)
 #              define PACKET3_VC_ACTION_ENA        (1 << 24)
 #              define PACKET3_CB_ACTION_ENA        (1 << 25)
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Alex Deucher
Quoted 22 lines · Alex Deucher

We need to set the engine bit to select the ME and also set the full cache bit. Should help stability on TN and cayman.

---
 drivers/gpu/drm/radeon/ni.c  | 7 +++----
 drivers/gpu/drm/radeon/nid.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ni.c +2 -0
index 9f11a55..04e9516 100644
@@ -1319,13 +1319,12 @@ void cayman_fence_ring_emit(struct radeon_device *rdev,
 {
 	struct radeon_ring *ring = &rdev->ring[fence->ring];
 	u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
+	u32 cp_coher_cntl = PACKET3_FULL_CACHE_ENA | PACKET3_TC_ACTION_ENA |
+		PACKET3_SH_ACTION_ENA;
 

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev, · line 1330

Quoted 10 lines
drivers/gpu/drm/radeon/ni.c +1 -4
 	/* flush read cache over gart for this vmid */
-	radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
-	radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2);
-	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-	radeon_ring_write(ring, PACKET3_TC_ACTION_ENA | PACKET3_SH_ACTION_ENA);
+	radeon_ring_write(ring, PACKET3_ENGINE_ME | cp_coher_cntl);
 	radeon_ring_write(ring, 0xFFFFFFFF);
 	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, 10); /* poll interval */

Doesn't this also need to be changed in cayman_ring_ib_execute() ?

drivers/gpu/drm/radeon/nid.h line 1157

Quoted 9 lines
drivers/gpu/drm/radeon/nid.h +1 -0
index 22421bc..d996033 100644
@@ -1154,6 +1154,7 @@
 #              define PACKET3_DB_ACTION_ENA        (1 << 26)
 #              define PACKET3_SH_ACTION_ENA        (1 << 27)
 #              define PACKET3_SX_ACTION_ENA        (1 << 28)
+#              define PACKET3_ENGINE_ME            (1 << 31)

Technically (1 << 31) is undefined. It should be (1U << 31).

-Tom

Quoted 10 lines
drivers/gpu/drm/radeon/nid.h +0 -0
 #define	PACKET3_ME_INITIALIZE				0x44
 #define		PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
 #define	PACKET3_COND_WRITE				0x45
Signature · 6 lines
1.8.3.1

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

-----Original Message-----
From: Tom Stellard [mailto:[email protected]]
Sent: Thursday, January 16, 2014 6:25 PM
To: Alex Deucher
Cc: [email protected]; Deucher, Alexander; [email protected]
Subject: Re: [PATCH 1/2] drm/radeon: fix surface sync in fence on cayman

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct

Quoted 16 lines · Alex Deucher

We need to set the engine bit to select the ME and also set the full cache bit. Should help stability on TN and cayman.

---
 drivers/gpu/drm/radeon/ni.c  | 7 +++----
 drivers/gpu/drm/radeon/nid.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ni.c +0 -0
index 9f11a55..04e9516 100644
@@ -1319,13 +1319,12 @@ void cayman_fence_ring_emit(struct

radeon_device *rdev,

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 4 lines
drivers/gpu/drm/radeon/ni.c +1 -0
 {
 	struct radeon_ring *ring = &rdev->ring[fence->ring];
 	u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
+	u32 cp_coher_cntl = PACKET3_FULL_CACHE_ENA |

PACKET3_TC_ACTION_ENA |

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 5 lines
drivers/gpu/drm/radeon/ni.c +1 -2
+		PACKET3_SH_ACTION_ENA;
 
 	/* flush read cache over gart for this vmid */
-	radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
-	radeon_ring_write(ring, (CP_COHER_CNTL2 -

PACKET3_SET_CONFIG_REG_START) >> 2);

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 3 lines
drivers/gpu/drm/radeon/ni.c +0 -2
-	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-	radeon_ring_write(ring, PACKET3_TC_ACTION_ENA |

PACKET3_SH_ACTION_ENA);

Quoted 6 lines

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev, · line 1330

Quoted 4 lines
drivers/gpu/drm/radeon/ni.c +1 -0
+	radeon_ring_write(ring, PACKET3_ENGINE_ME | cp_coher_cntl);
 	radeon_ring_write(ring, 0xFFFFFFFF);
 	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, 10); /* poll interval */

Doesn't this also need to be changed in cayman_ring_ib_execute() ?

Oh, yeah. That also emits a surface sync packet. I'm not sure why we need one there, but I'll fix that up too.

Quoted 13 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/nid.h

drivers/gpu/drm/radeon/nid.h line 1157

Quoted 8 lines

index 22421bc..d996033 100644

drivers/gpu/drm/radeon/nid.h +1 -0
@@ -1154,6 +1154,7 @@
 #              define PACKET3_DB_ACTION_ENA        (1 << 26)
 #              define PACKET3_SH_ACTION_ENA        (1 << 27)
 #              define PACKET3_SX_ACTION_ENA        (1 << 28)
+#              define PACKET3_ENGINE_ME            (1 << 31)

Technically (1 << 31) is undefined. It should be (1U << 31).

Hmmm... a lot of drivers do this pretty regularly. I guess gcc does the right thing?

Alex

Quoted 13 lines

-Tom

Quoted 10 lines
drivers/gpu/drm/radeon/nid.h +0 -1
 #define	PACKET3_ME_INITIALIZE				0x44
 #define		PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
 #define	PACKET3_COND_WRITE				0x45
--

1.8.3.1

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

#4 lore raw
Quoted 65 lines · Alexander
Quoted 41 lines

-----Original Message-----
From: Tom Stellard [mailto:[email protected]]
Sent: Thursday, January 16, 2014 6:25 PM
To: Alex Deucher
Cc: [email protected]; Deucher, Alexander; [email protected]
Subject: Re: [PATCH 1/2] drm/radeon: fix surface sync in fence on cayman

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct

Quoted 16 lines · Alex Deucher

We need to set the engine bit to select the ME and also set the full cache bit. Should help stability on TN and cayman.

---
 drivers/gpu/drm/radeon/ni.c  | 7 +++----
 drivers/gpu/drm/radeon/nid.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ni.c +0 -0
index 9f11a55..04e9516 100644
@@ -1319,13 +1319,12 @@ void cayman_fence_ring_emit(struct

radeon_device *rdev,

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 4 lines
drivers/gpu/drm/radeon/ni.c +1 -0
 {
 	struct radeon_ring *ring = &rdev->ring[fence->ring];
 	u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
+	u32 cp_coher_cntl = PACKET3_FULL_CACHE_ENA |

PACKET3_TC_ACTION_ENA |

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 5 lines
drivers/gpu/drm/radeon/ni.c +1 -2
+		PACKET3_SH_ACTION_ENA;
 
 	/* flush read cache over gart for this vmid */
-	radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
-	radeon_ring_write(ring, (CP_COHER_CNTL2 -

PACKET3_SET_CONFIG_REG_START) >> 2);

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev,

Quoted 3 lines
drivers/gpu/drm/radeon/ni.c +0 -2
-	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
-	radeon_ring_write(ring, PACKET3_TC_ACTION_ENA |

PACKET3_SH_ACTION_ENA);

Quoted 6 lines

drivers/gpu/drm/radeon/ni.c void cayman_fence_ring_emit(struct radeon_device *rdev, · line 1330

Quoted 4 lines
drivers/gpu/drm/radeon/ni.c +1 -0
+	radeon_ring_write(ring, PACKET3_ENGINE_ME | cp_coher_cntl);
 	radeon_ring_write(ring, 0xFFFFFFFF);
 	radeon_ring_write(ring, 0);
 	radeon_ring_write(ring, 10); /* poll interval */

Doesn't this also need to be changed in cayman_ring_ib_execute() ?

Oh, yeah. That also emits a surface sync packet. I'm not sure why we need one there, but I'll fix that up too.

Quoted 13 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/nid.h

drivers/gpu/drm/radeon/nid.h line 1157

Quoted 8 lines

index 22421bc..d996033 100644

drivers/gpu/drm/radeon/nid.h +1 -0
@@ -1154,6 +1154,7 @@
 #              define PACKET3_DB_ACTION_ENA        (1 << 26)
 #              define PACKET3_SH_ACTION_ENA        (1 << 27)
 #              define PACKET3_SX_ACTION_ENA        (1 << 28)
+#              define PACKET3_ENGINE_ME            (1 << 31)

Technically (1 << 31) is undefined. It should be (1U << 31).

Quoted 2 lines

Hmmm... a lot of drivers do this pretty regularly. I guess gcc does the right thing?

Yes, I've seen this all over the place, and I'm sure most compilers do what everyone expects here.

-Tom

Quoted 17 lines

Alex

Quoted 13 lines

-Tom

Quoted 10 lines
drivers/gpu/drm/radeon/nid.h +0 -1
 #define	PACKET3_ME_INITIALIZE				0x44
 #define		PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
 #define	PACKET3_COND_WRITE				0x45
--

1.8.3.1

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