Skip to contentSkip to conversation

drm/radeon: make 64bit fences more robust

PATCH In review Christian König 4 participants 13 messages Sep 10, 2012 – Sep 11, 2012

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

PATCH 1/1 drm/radeon: make 64bit fences more robust

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
 drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +3 -3
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
 	do {
 		seq = radeon_fence_read(rdev, ring);
 		seq |= last_seq & 0xffffffff00000000LL;
-		if (seq < last_seq) {
+		if (seq < (last_seq - 0x80000000LL)) {
 			seq += 0x100000000LL;
 		}
 
@@ -811,8 +811,8 @@ static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
 	rdev->fence_drv[ring].cpu_addr = NULL;
 	rdev->fence_drv[ring].gpu_addr = 0;
 	for (i = 0; i < RADEON_NUM_RINGS; ++i)
-		rdev->fence_drv[ring].sync_seq[i] = 0;
-	atomic64_set(&rdev->fence_drv[ring].last_seq, 0);
+		rdev->fence_drv[ring].sync_seq[i] = 0x100000000LL;
+	atomic64_set(&rdev->fence_drv[ring].last_seq, 0x100000000LL);
 	rdev->fence_drv[ring].last_activity = jiffies;
 	rdev->fence_drv[ring].initialized = false;
 }
Signature · 6 lines
1.7.9.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 21 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
 drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +0 -0
index 7b737b9..4781e13 100644

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
 	do {
 		seq = radeon_fence_read(rdev, ring);
 		seq |= last_seq & 0xffffffff00000000LL;
-		if (seq < last_seq) {
+		if (seq < (last_seq - 0x80000000LL)) {
 			seq += 0x100000000LL;
 		}

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Signature · 2 lines
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer
#2 lore raw
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
  drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
  	do {
  		seq = radeon_fence_read(rdev, ring);
  		seq |= last_seq & 0xffffffff00000000LL;
-		if (seq < last_seq) {
+		if (seq < (last_seq - 0x80000000LL)) {
  			seq += 0x100000000LL;
  		}

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 1 line
		if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Christian.

#3 lore raw
Quoted 58 lines · Christian König
Quoted 29 lines · Michel Dänzer
Quoted 27 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
  drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +0 -0
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev,
 int ring)
        do {
                seq = radeon_fence_read(rdev, ring);
                seq |= last_seq & 0xffffffff00000000LL;
Quoted 8 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
-               if (seq < last_seq) {
+               if (seq < (last_seq - 0x80000000LL)) {
                        seq += 0x100000000LL;
                }

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 1 line
                if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

Quoted 6 lines

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Christian.

If fence read ever gave the value 0 then your patch is postponing the issue until last fence reach >= 0x1 8000 0001 (which will takes month/years of uptime to happen :)). Having a log of all emitted fence value and all read en fence value would probably be helpful so we have a better clue of what's going on.

Sadly i don't think we don't receive fence in order but rather that we sometimes receive a 0 value fence, if we did receive fence out of order than the issue would also have happen with previous code.

Otherwise patch is ack but please add a better comment about fence value most likely being 0 for unknow reasons or receive out of order (thought i don't think so).

Cheers,
Jerome

#4 lore raw
In reply to Christian König
Quoted 40 lines · Christian König
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
  drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
  	do {
  		seq = radeon_fence_read(rdev, ring);
  		seq |= last_seq & 0xffffffff00000000LL;
-		if (seq < last_seq) {
+		if (seq < (last_seq - 0x80000000LL)) {
  			seq += 0x100000000LL;
  		}

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 6 lines
Quoted 1 line
		if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

Maybe some kind of race involving radeon_fence_write()?

Quoted 8 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Without knowing exactly what kind of hardware fence value pattern caused the problem, we can't be sure that the wraparound handling will work reliably, or that the values going backwards won't cause other problems. I think it would be good to get more real-world data on that.

Signature · 2 lines
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer
#5 lore raw
Quoted 56 lines · Michel Dänzer
Quoted 40 lines · Christian König
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
  drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
   do {
           seq = radeon_fence_read(rdev, ring);
           seq |= last_seq & 0xffffffff00000000LL;
-          if (seq < last_seq) {
+          if (seq < (last_seq - 0x80000000LL)) {
                   seq += 0x100000000LL;
           }

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 6 lines
Quoted 1 line
            if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

Maybe some kind of race involving radeon_fence_write()?

Quoted 5 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

Quoted 9 lines
Quoted 3 lines

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Without knowing exactly what kind of hardware fence value pattern caused the problem, we can't be sure that the wraparound handling will work reliably, or that the values going backwards won't cause other problems. I think it would be good to get more real-world data on that.

As i said in my email this patch just postpone the issue to last_fence

Quoted 1 line

= 0x1 8000 0001 if fence value we read back is sometimes randomly 0.

If we received fence value out of order (which i highly doubt as old code would have had same issue thought on smaller scale) then if fence value 0x1 8000 0001 is received before fence value 0x1 8000 0000 we are right back to all future fence considered as signalled (again this will take month of uptime).

All this probably lead to questioning the usefulness of 64bits fence.

Cheers,
Jerome

#6 lore raw
Quoted 67 lines · Jerome Glisse
Quoted 56 lines · Michel Dänzer
Quoted 40 lines · Christian König
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
  drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
   do {
           seq = radeon_fence_read(rdev, ring);
           seq |= last_seq & 0xffffffff00000000LL;
-          if (seq < last_seq) {
+          if (seq < (last_seq - 0x80000000LL)) {
                   seq += 0x100000000LL;
           }

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 6 lines
Quoted 1 line
            if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

Maybe some kind of race involving radeon_fence_write()?

Quoted 5 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

Quoted 9 lines
Quoted 3 lines

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Without knowing exactly what kind of hardware fence value pattern caused the problem, we can't be sure that the wraparound handling will work reliably, or that the values going backwards won't cause other problems. I think it would be good to get more real-world data on that.

Quoted 7 lines

As i said in my email this patch just postpone the issue to last_fence

Quoted 1 line

= 0x1 8000 0001 if fence value we read back is sometimes randomly 0.

If we received fence value out of order (which i highly doubt as old code would have had same issue thought on smaller scale) then if fence value 0x1 8000 0001 is received before fence value 0x1 8000 0000 we are right back to all future fence considered as signalled (again this will take month of uptime).

Actually thinking back about it if fence are just received out of order then this patch corner case is if we received 0x1 ffff ffff after receiving 0x1 0000 0000, what will happen is that the 0x1 0000 0000 is the wrap over that will trigger upper 32bits to be incremented so fence become 0x2 0000 0000 then we got 0xffff ffff which with | become 0x2 ffff ffff then we get next fence value 0x0000 0001 and again we increment upper 32bits so last seq become 0x3 0000 0001.

Again this will happen after month of uptime and all it does is decrement the amount of uptime for which 64bit fence are fine ie at worst we over increment by 0x2 0000 0000 instead of 0x1 0000 0000 on wrap around.

Cheers,
Jerome

Quoted 5 lines

All this probably lead to questioning the usefulness of 64bits fence.

Cheers,
Jerome

maintainer
#7 lore raw
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Can we start fences off so we wrap around after say 15-20 minutes? that would ensure

a) its tested
b) we see failure in a lifetime.

Dave.

#8 lore raw
Quoted 11 lines · Dave Airlie
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Quoted 7 lines

Can we start fences off so we wrap around after say 15-20 minutes? that would ensure

a) its tested
b) we see failure in a lifetime.

Dave.

IIRC normal desktop with continuous activities was around 400 fence/minutes.

Anyway it all depends on what is wrong. Do we sometime get a 0 as fence value or do we get fence value in wrong order. Depending on that the wrap around is a different issue see my previous mails.

Cheers,
Jerome

#9 lore raw
Quoted 20 lines · Jerome Glisse
Quoted 11 lines · Dave Airlie
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Quoted 7 lines

Can we start fences off so we wrap around after say 15-20 minutes? that would ensure

a) its tested
b) we see failure in a lifetime.

Dave.

Quoted 8 lines

IIRC normal desktop with continuous activities was around 400 fence/minutes.

Anyway it all depends on what is wrong. Do we sometime get a 0 as fence value or do we get fence value in wrong order. Depending on that the wrap around is a different issue see my previous mails.

Cheers,
Jerome

s/minutes/seconds

Jerome

#10 lore raw
In reply to Jerome Glisse
Quoted 70 lines · Jerome Glisse
Quoted 62 lines · Jerome Glisse
Quoted 53 lines · Michel Dänzer
Quoted 36 lines · Christian König
Quoted 17 lines · Michel Dänzer
Quoted 16 lines · Christian König

Only increase the higher 32bits if we really detect a wrap around.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=54129
https://bugs.freedesktop.org/show_bug.cgi?id=54662

Possible fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=846505
https://bugzilla.redhat.com/show_bug.cgi?id=845639

---
   drivers/gpu/drm/radeon/radeon_fence.c |    6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 15 lines

drivers/gpu/drm/radeon/radeon_fence.c void radeon_fence_process(struct radeon_device *rdev, int ring) · line 165

Quoted 12 lines
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 7b737b9..4781e13 100644
@@ -160,7 +160,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
    do {
            seq = radeon_fence_read(rdev, ring);
            seq |= last_seq & 0xffffffff00000000LL;
-          if (seq < last_seq) {
+          if (seq < (last_seq - 0x80000000LL)) {
                    seq += 0x100000000LL;
            }

Can you provide a bit more explanation for this change? In particular, how could the code previously detect a wraparound when there was none, and why is this the proper fix?

Honestly I also don't really understand how this bug happened in the first place.

Quoted 8 lines

We extend the 32bit fences supported by hardware by testing if a previously read fence value is smaller than the value we read now:

Quoted 1 line
             if (seq < last_seq) {

But the problem seems to be that on some systems we do get fence values that are decreasing, e.g. instead of 5, 6, 7, 8 we get 5, 7, 6, 8 (or maybe 5, 6, 0, 7, 8 because somebody accidentally overwrites the fence value).

Maybe some kind of race involving radeon_fence_write()?

Quoted 5 lines

It might be related to a hardware bug, or the algorithm is flawed in a way I currently don't see. Anyway the old code we had wasn't so picky about such problems and the patch just tries to make the current code as robust as the old code was, which indeed seems to solve the problems we see.

Quoted 8 lines
Quoted 3 lines

The wrap around detection still works (tested by setting the initial fence value to 0xfffffff0 and letting it wrap around shortly after start), so I think it we can safely commit this.

Without knowing exactly what kind of hardware fence value pattern caused the problem, we can't be sure that the wraparound handling will work reliably, or that the values going backwards won't cause other problems. I think it would be good to get more real-world data on that.

Quoted 7 lines

As i said in my email this patch just postpone the issue to last_fence

Quoted 1 line

= 0x1 8000 0001 if fence value we read back is sometimes randomly 0.

If we received fence value out of order (which i highly doubt as old code would have had same issue thought on smaller scale) then if fence value 0x1 8000 0001 is received before fence value 0x1 8000 0000 we are right back to all future fence considered as signalled (again this will take month of uptime).

Quoted 7 lines

Actually thinking back about it if fence are just received out of order then this patch corner case is if we received 0x1 ffff ffff after receiving 0x1 0000 0000, what will happen is that the 0x1 0000 0000 is the wrap over that will trigger upper 32bits to be incremented so fence become 0x2 0000 0000 then we got 0xffff ffff which with | become 0x2 ffff ffff then we get next fence value 0x0000 0001 and again we increment upper 32bits so last seq become 0x3 0000 0001.

Good point.

Quoted 4 lines

Again this will happen after month of uptime and all it does is decrement the amount of uptime for which 64bit fence are fine ie at worst we over increment by 0x2 0000 0000 instead of 0x1 0000 0000 on wrap around.

How about this idea: Instead of increasing the upper 32bits we just use the upper 32bits of the last emitted fence value? E.g. see the attached patch. That both should handle random zero and out of order values more gracefully.

Additionally I think that the reason we haven't had this before is that this corruption might only happens on hw (re-)initialisation, e.g. boot and resume.

Currently I'm hacking together a small test app that just emits an IB with some NOP instructions, if I'm not completely wrong that should gives us a very high fence rate, so we might be able to actually test the wrap around a bit more.

Christian.

Quoted 9 lines

Cheers,
Jerome

Quoted 4 lines

All this probably lead to questioning the usefulness of 64bits fence.

Cheers,
Jerome

From 8737d17a45e04d7c111abb5e79e48577b224fae6 Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Christian=20K=C3=B6nig?= <[email protected]>
Date: Sun, 9 Sep 2012 11:45:19 +0200
Subject: [PATCH] drm/radeon: make 64bit fences more robust v2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Only increase the higher 32bits if we really detect a wrap around.

v2: instead of increasing the higher 32bits just use the higher
32bits from the last emitted fence.

---
 drivers/gpu/drm/radeon/radeon_fence.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +4 -2
index 7b737b9..a263513 100644
@@ -161,10 +161,12 @@ void radeon_fence_process(struct radeon_device *rdev, int ring)
 		seq = radeon_fence_read(rdev, ring);
 		seq |= last_seq & 0xffffffff00000000LL;
 		if (seq < last_seq) {
-			seq += 0x100000000LL;
+			seq &= 0xffffffff;
+			seq |= rdev->fence_drv[ring].sync_seq[ring] &
+				0xffffffff00000000LL;
 		}
 
-		if (seq == last_seq) {
+		if (seq <= last_seq) {
 			break;
 		}
 		/* If we loop over we don't want to return without
Signature · 1 line
1.7.9.5

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

#11 lore raw
Quoted 5 lines · Christian König

How about this idea: Instead of increasing the upper 32bits we just use the upper 32bits of the last emitted fence value?
E.g. see the attached patch. That both should handle random zero and out of order values more gracefully.

I like this idea.

Signature · 2 lines
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer
#12 lore raw
Quoted 9 lines · Michel Dänzer
Quoted 5 lines · Christian König

How about this idea: Instead of increasing the upper 32bits we just use the upper 32bits of the last emitted fence value?
E.g. see the attached patch. That both should handle random zero and out of order values more gracefully.

I like this idea.

Yeah this patch is better.

Cheers,
Jerome