drm/i915: Before pageflip, also wait for shared dmabuf fences.
Subsystems (3)
PATCH 1/1 drm/i915: Before pageflip, also wait for shared dmabuf fences.
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
This patch was tested to behave properly with intel-kms + radeon/amdgpu/nouveau-kms for correct prime sync during pageflipping under DRI3/Present.
Should fix https://bugs.freedesktop.org/show_bug.cgi?id=95472
at least for page-flipped presentation.
--- drivers/gpu/drm/i915/intel_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +2 -2
@@ -12043,7 +12043,7 @@ static void intel_mmio_flip_work_func(struct work_struct *w)/* For framebuffer backed by dmabuf, wait for fence */ resv =i915_gem_object_get_dmabuf_resv (obj);if (resv) -WARN_ON (reservation_object_wait_timeout_rcu (resv, false, false, +WARN_ON (reservation_object_wait_timeout_rcu (resv, true, false,MAX_SCHEDULE_TIMEOUT ) <0 );intel_pipe_update_start (crtc);
@@ -14700,7 +14700,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,if (resv) {long lret; - lret =reservation_object_wait_timeout_rcu (resv, false, true, + lret =reservation_object_wait_timeout_rcu (resv, true, true,MAX_SCHEDULE_TIMEOUT );if (lret == -ERESTARTSYS )return lret;
Signature · 6 lines
2.7.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Mario Kleiner
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Chris Wilson
Quoted 4 lines · Mario Kleiner
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
Quoted 6 lines
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
thanks,
-mario
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 14 lines · Mario Kleiner
Quoted 6 lines · Chris Wilson
Quoted 4 lines · Mario Kleiner
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
Quoted 6 lines
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Quoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them. In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on multiple engines through the virtue of the shared fences, and to serialise after writes by waiting on the exclusive fence. (So we can have concurrent reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)
In the near future, i915 flips will wait on the common reservation object not only for dma-bufs, but also its own GEM objects.
Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
i915.ko requires the client to mark which buffers are written to.
In ttm, there are ttm_validate_buffer objects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to be amdgpu_bo_list_set().
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20160908162346.GA5479-aII6DKEyn0pWYbfKqPwjAkR8Iwp7RQ6xAL8bYrjMMd8@public.gmane.org
Quoted 50 lines · Chris Wilson
Quoted 14 lines · Mario Kleiner
Quoted 6 lines · Chris Wilson
Quoted 4 lines · Mario Kleiner
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
Quoted 6 lines
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Quoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them. In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on multiple engines through the virtue of the shared fences, and to serialise after writes by waiting on the exclusive fence. (So we can have concurrent reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)
In the near future, i915 flips will wait on the common reservation object not only for dma-bufs, but also its own GEM objects.
Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
Quoted 6 lines
i915.ko requires the client to mark which buffers are written to.
In ttm, there are
ttm_validate_bufferobjects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to beamdgpu_bo_list_set().
This all makes sense to me.
Christian, why is amdgpu setting only shared fences? Can we fix that?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): abccc8ac-10c6-ab22-c59d-f43ee48ba78d-otUistvHUpPR7s880joybQ@public.gmane.org
Am 09.09.2016 um 03:15 schrieb Michel Dänzer:
Quoted 47 lines · Chris Wilson
Quoted 46 lines · Mario Kleiner
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Mario Kleiner
Quoted 4 lines
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Quoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them. In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on multiple engines through the virtue of the shared fences, and to serialise after writes by waiting on the exclusive fence. (So we can have concurrent reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)
In the near future, i915 flips will wait on the common reservation object not only for dma-bufs, but also its own GEM objects.
Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
i915.ko requires the client to mark which buffers are written to.
Quoted 7 lines
Quoted 4 lines
In ttm, there are
ttm_validate_bufferobjects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to beamdgpu_bo_list_set().This all makes sense to me.
Christian, why is amdgpu setting only shared fences? Can we fix that?
No, amdgpu relies on the fact that we even allow concurrent write accesses by userspace.
E.g. one part of the buffer can be rendered by one engine while another part could be rendered by another engine.
Just imagine X which is composing a buffer with both the 3D engine as well as the DMA engine.
All engines need to run in parallel and you need to wait for all of them to finish before scanout.
Everybody which needs exclusive access to the reservation object (like scanouts do) needs to wait for all fences, not just the exclusive one.
The Intel driver clearly needs to be fixed here.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 62 lines · Christian König
Am 09.09.2016 um 03:15 schrieb Michel Dänzer:
Quoted 44 lines · Chris Wilson
Quoted 43 lines · Mario Kleiner
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Mario Kleiner
Quoted 4 lines
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Quoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them. In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on multiple engines through the virtue of the shared fences, and to serialise after writes by waiting on the exclusive fence. (So we can have concurrent reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)
In the near future, i915 flips will wait on the common reservation object not only for dma-bufs, but also its own GEM objects.
Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
i915.ko requires the client to mark which buffers are written to.
Quoted 7 lines
Quoted 4 lines
In ttm, there are
ttm_validate_bufferobjects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to beamdgpu_bo_list_set().This all makes sense to me.
Christian, why is amdgpu setting only shared fences? Can we fix that?
No, amdgpu relies on the fact that we even allow concurrent write accesses by userspace.
E.g. one part of the buffer can be rendered by one engine while another part could be rendered by another engine.
Just imagine X which is composing a buffer with both the 3D engine as well as the DMA engine.
Quoted 8 lines
All engines need to run in parallel and you need to wait for all of them to finish before scanout.
Everybody which needs exclusive access to the reservation object (like scanouts do) needs to wait for all fences, not just the exclusive one.
The Intel driver clearly needs to be fixed here.
If you are not using implicit fencing, you have to pass explicit fences instead.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20160913093945.GA25204-aII6DKEyn0pWYbfKqPwjAkR8Iwp7RQ6xAL8bYrjMMd8@public.gmane.org
Am 13.09.2016 um 11:39 schrieb Chris Wilson:
Quoted 65 lines · Christian König
Quoted 64 lines
Am 09.09.2016 um 03:15 schrieb Michel Dänzer:
Quoted 44 lines · Chris Wilson
Quoted 43 lines · Mario Kleiner
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Mario Kleiner
Quoted 4 lines
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so this breaks the ability to schedule parallel operations across engine. -Chris
Quoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them. In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on multiple engines through the virtue of the shared fences, and to serialise after writes by waiting on the exclusive fence. (So we can have concurrent reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)
In the near future, i915 flips will wait on the common reservation object not only for dma-bufs, but also its own GEM objects.
Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
i915.ko requires the client to mark which buffers are written to.
Quoted 7 lines
Quoted 4 lines
In ttm, there are
ttm_validate_bufferobjects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to beamdgpu_bo_list_set().This all makes sense to me.
Christian, why is amdgpu setting only shared fences? Can we fix that?
No, amdgpu relies on the fact that we even allow concurrent write accesses by userspace.
E.g. one part of the buffer can be rendered by one engine while another part could be rendered by another engine.
Just imagine X which is composing a buffer with both the 3D engine as well as the DMA engine.
All engines need to run in parallel and you need to wait for all of them to finish before scanout.
Quoted 7 lines
Quoted 5 lines
Everybody which needs exclusive access to the reservation object (like scanouts do) needs to wait for all fences, not just the exclusive one.
The Intel driver clearly needs to be fixed here.
If you are not using implicit fencing, you have to pass explicit fences instead.
Which is exactly what we do, but only for the driver internally command submissions.
All command submissions from the same process can run concurrently with amdgpu, only when we see a fence from another driver or process we wait for it to complete before starting to run a command submission.
Other drivers can't make any assumption on what a shared access is actually doing (e.g. writing or reading) with a buffer.
So the model i915.ko is using the reservation object and it's shared fences is certainly not correct and needs to be fixed.
Regards,
Christian.
Quoted 2 lines
-Chris
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 88 lines · Christian König
Am 13.09.2016 um 11:39 schrieb Chris Wilson:
Quoted 72 lines · Christian König
Quoted 71 lines
Am 09.09.2016 um 03:15 schrieb Michel Dänzer:
Quoted 51 lines · Chris Wilson
Quoted 50 lines · Mario Kleiner
Quoted 14 lines · Chris Wilson
Quoted 5 lines · Mario Kleiner
Quoted 4 lines
amdgpu-kms uses shared fences for its prime exported dmabufs, instead of an exclusive fence. Therefore we need to wait for all fences of the dmabuf reservation object to prevent unsynchronized rendering and flipping.
Quoted 8 lines
No. Fix the root cause as this affects not just flips but copies - this implies that everybody using the resv object must wait for all fences. The resv object is not just used for prime, but all fencing, so
this breaks the ability to schedule parallel operations across engine.
-ChrisQuoted 4 lines
Ok. I think i now understand the difference, but let's check: The exclusive fence is essentially acting a bit like a write-lock, and the shared fences as readers-locks? So you can have multiple readers but only one writer at a time?
That's how we (i915.ko and I hope the rest of the world) are using them.
In the model where here is just one reservation object on the GEM object, that reservation object is then shared between internal driver scheduling and external. We are reliant on being able to use buffers on
multiple engines through the virtue of the shared fences, and to serialise
after writes by waiting on the exclusive fence. (So we can have concurrent
reads on the display engine, render engines and on the CPU - or alternatively an exclusive writer.)In the near future, i915 flips will wait on the common reservation object
not only for dma-bufs, but also its own GEM objects.Quoted 5 lines
Ie.:
Writer must wait for all fences before starting write access to a buffer, then attach the exclusive fence and signal it on end of write access. E.g., write to renderbuffer, write to texture etc.
Yes.
Quoted 3 lines
Readers must wait for exclusive fence, then attach a shared fence per reader and signal it on end of read access? E.g., read from texture, fb, scanout?
Yes.
Quoted 3 lines
Is that correct? In that case we'd have a missing exclusive fence in amdgpu for the linear target dmabuf? Probably beyond my level of knowledge to fix this?
i915.ko requires the client to mark which buffers are written to.
Quoted 7 lines
Quoted 4 lines
In ttm, there are
ttm_validate_bufferobjects which mark whether they should be using shared or exclusive fences. Afaict, in amdgpu they are all set to shared, the relevant user interface seems to beamdgpu_bo_list_set().This all makes sense to me.
Christian, why is amdgpu setting only shared fences? Can we fix that?
No, amdgpu relies on the fact that we even allow concurrent write accesses by userspace.
E.g. one part of the buffer can be rendered by one engine while another part could be rendered by another engine.
Just imagine X which is composing a buffer with both the 3D engine as well as the DMA engine.
All engines need to run in parallel and you need to wait for all of them to finish before scanout.
Quoted 7 lines
Quoted 5 lines
Everybody which needs exclusive access to the reservation object (like scanouts do) needs to wait for all fences, not just the exclusive one.
The Intel driver clearly needs to be fixed here.
If you are not using implicit fencing, you have to pass explicit fences instead.
Which is exactly what we do, but only for the driver internally command submissions.
All command submissions from the same process can run concurrently with amdgpu, only when we see a fence from another driver or process we wait for it to complete before starting to run a command submission.
Quoted 5 lines
Other drivers can't make any assumption on what a shared access is actually doing (e.g. writing or reading) with a buffer.
So the model i915.ko is using the reservation object and it's shared fences is certainly not correct and needs to be fixed.
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
FWIW, we seem to have the same issue with radeon vs. amdgpu: radeon only seems to wait for exclusive fences, so e.g. running Xorg on amdgpu and using PRIME slave scanout on radeon leaves artifacts.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 7aafce92-8bcf-1c5c-45de-9e8ecda85239-otUistvHUpPR7s880joybQ@public.gmane.org
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 3 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
I absolutely don't mind switching to them to writing/reading semantics, but amdgpu really needs multiple writers at the same time.
So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 3 lines
FWIW, we seem to have the same issue with radeon vs. amdgpu: radeon only seems to wait for exclusive fences, so e.g. running Xorg on amdgpu and using PRIME slave scanout on radeon leaves artifacts.
Yeah, I know. See radeon_display.c radeon_flip_work_func().
We pretty much need the same patch here I've done for amdgpu as well.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
Quoted 8 lines
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
I absolutely don't mind switching to them to writing/reading semantics, but amdgpu really needs multiple writers at the same time.
So in this case the writing side of a reservation object needs to be a collection of fences as well.
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): CAKMK7uG3j54NzwjxmWuSmP787r+QN-Cu5T8R-naX6S9RvvKemw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Am 21.09.2016 um 13:04 schrieb Daniel Vetter:
Quoted 17 lines
Quoted 7 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 3 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
Quoted 8 lines
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
I absolutely don't mind switching to them to writing/reading semantics, but amdgpu really needs multiple writers at the same time.
So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 9 lines
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync.
Nope, that isn't true.
We use multiple writers without implicit syncing between processes in the amdgpu stack perfectly fine.
See amdgpu_sync.c for the implementation. What we do there is taking a look at all the fences associated with a reservation object and only sync to those who are from another process.
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Regards,
Christian.
Quoted 1 line
-Daniel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 44 lines · Christian König
Am 21.09.2016 um 13:04 schrieb Daniel Vetter:
Quoted 23 lines
Quoted 13 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
Quoted 6 lines
I absolutely don't mind switching to them to writing/reading semantics, but
amdgpu really needs multiple writers at the same time.So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 9 lines
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync.
Nope, that isn't true.
We use multiple writers without implicit syncing between processes in the amdgpu stack perfectly fine.
See
amdgpu_sync.cfor the implementation. What we do there is taking a look at all the fences associated with a reservation object and only sync to those who are from another process.
Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not sync_file fds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by struct reservation_object.
Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing), and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever). Since you're doing explicit syncing for internal stuff anyway you can still opt to ignore the exclusive fences if you want to (driven by a flag or something similar).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): CAKMK7uH6N2Kgwkf-11iwdqDAUrFmreYKLLeTGXmEh+N0DQ4tJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 56 lines · Daniel Vetter
Quoted 42 lines · Christian König
Am 21.09.2016 um 13:04 schrieb Daniel Vetter:
Quoted 21 lines
Quoted 12 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
Quoted 6 lines
I absolutely don't mind switching to them to writing/reading semantics, but
amdgpu really needs multiple writers at the same time.So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 9 lines
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync.
Nope, that isn't true.
We use multiple writers without implicit syncing between processes in the amdgpu stack perfectly fine.
See
amdgpu_sync.cfor the implementation. What we do there is taking a look at all the fences associated with a reservation object and only sync to those who are from another process.Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not
sync_filefds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by structreservation_object.
Quoted 6 lines
Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing),
Err, the current issue is actually that amdgpu never sets an exclusive fence, only ever shared ones. :)
Quoted 2 lines
and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever).
Still, it occurred to me in the meantime that amdgpu setting the exclusive fence for buffers shared via PRIME (no matter if it's a write or read operation) might be a solution. Christian, what do you think?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 9d1f4872-cabd-bd1b-7f10-6e4230a1f58c-otUistvHUpPR7s880joybQ@public.gmane.org
Am 21.09.2016 um 17:07 schrieb Michel Dänzer:
Quoted 52 lines · Daniel Vetter
Quoted 51 lines
Quoted 38 lines · Christian König
Am 21.09.2016 um 13:04 schrieb Daniel Vetter:
Quoted 18 lines
Quoted 10 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 3 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
Quoted 6 lines
I absolutely don't mind switching to them to writing/reading semantics, but
amdgpu really needs multiple writers at the same time.So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 9 lines
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync.
Nope, that isn't true.
We use multiple writers without implicit syncing between processes in the amdgpu stack perfectly fine.
See
amdgpu_sync.cfor the implementation. What we do there is taking a look at all the fences associated with a reservation object and only sync to those who are from another process.Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not
sync_filefds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by structreservation_object.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing),
Err, the current issue is actually that amdgpu never sets an exclusive fence, only ever shared ones. :)
Actually amdgpu does set the exclusive fence for buffer migrations, cause that is an operation user space doesn't know about and so it needs to be "exclusive" access to the buffer.
Quoted 5 lines
Quoted 2 lines
and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever).
Still, it occurred to me in the meantime that amdgpu setting the exclusive fence for buffers shared via PRIME (no matter if it's a write or read operation) might be a solution. Christian, what do you think?
The problem is that we don't have one fence, but many.
E.g. there can be many operation on a buffer at the same time and we need to wait for all of them to complete before it can be displayed.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 5c2048ff-0e20-ddf3-2d73-9a3acb38e7ff-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 40 lines · Christian König
Am 21.09.2016 um 17:07 schrieb Michel Dänzer:
Quoted 24 lines · Daniel Vetter
Quoted 23 lines
Quoted 10 lines · Christian König
We use multiple writers without implicit syncing between processes in the
amdgpu stack perfectly fine.See
amdgpu_sync.cfor the implementation. What we do there is taking a look
at all the fences associated with a reservation object and only sync to those who are from another process.Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not
sync_filefds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by structreservation_object.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing),
Err, the current issue is actually that amdgpu never sets an exclusive fence, only ever shared ones. :)
Actually amdgpu does set the exclusive fence for buffer migrations, cause that is an operation user space doesn't know about and so it needs to be "exclusive" access to the buffer.
Quoted 2 lines
Quoted 2 lines
and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever).
Quoted 8 lines
Quoted 3 lines
Still, it occurred to me in the meantime that amdgpu setting the exclusive fence for buffers shared via PRIME (no matter if it's a write or read operation) might be a solution. Christian, what do you think?
The problem is that we don't have one fence, but many.
E.g. there can be many operation on a buffer at the same time and we need to wait for all of them to complete before it can be displayed.
Maybe in theory, but with the problem we have in practice right now, the amdgpu GPU should only ever access the shared BO with the same engine.
Anyway, this should be solvable by setting some kind of meta-fence as the exclusive fence, which can internally be mapped to multiple fences, maybe up to one for each ring which can access the BO?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 21.09.2016 um 17:29 schrieb Michel Dänzer:
Quoted 42 lines · Christian König
Quoted 41 lines
Am 21.09.2016 um 17:07 schrieb Michel Dänzer:
Quoted 23 lines · Daniel Vetter
Quoted 22 lines
Quoted 9 lines · Christian König
We use multiple writers without implicit syncing between processes in the
amdgpu stack perfectly fine.See
amdgpu_sync.cfor the implementation. What we do there is taking a look
at all the fences associated with a reservation object and only sync to those who are from another process.Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not
sync_filefds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by structreservation_object.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing),
Err, the current issue is actually that amdgpu never sets an exclusive fence, only ever shared ones. :)
Actually amdgpu does set the exclusive fence for buffer migrations, cause that is an operation user space doesn't know about and so it needs to be "exclusive" access to the buffer.
Quoted 5 lines
Quoted 2 lines
and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever).
Still, it occurred to me in the meantime that amdgpu setting the exclusive fence for buffers shared via PRIME (no matter if it's a write or read operation) might be a solution. Christian, what do you think?
Quoted 6 lines
Quoted 4 lines
The problem is that we don't have one fence, but many.
E.g. there can be many operation on a buffer at the same time and we need to wait for all of them to complete before it can be displayed.
Maybe in theory, but with the problem we have in practice right now, the amdgpu GPU should only ever access the shared BO with the same engine.
That clearly won't work. Take a look at what both Mesa and the pro stack do with the BO before it is displayed makes it mandatory to execute things in parallel (at least for the not shared case).
Quoted 3 lines
Anyway, this should be solvable by setting some kind of meta-fence as the exclusive fence, which can internally be mapped to multiple fences, maybe up to one for each ring which can access the BO?
I've thought about that as well, but this approach would also only work when we keep a collection of fences and not just an array because of the scheduler.
For a quick workaround I suggest to just serialize all accesses to BO shared with different drivers, but essentially I think it is a perfectly valid requirement to have multiple writers to one BO.
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Christian König
For a quick workaround I suggest to just serialize all accesses to BO shared with different drivers, but essentially I think it is a perfectly valid requirement to have multiple writers to one BO.
It is, but it's not possible with implicit sync. If you want parallel write access to the same shared buffer, you _must_ carry around some explicit fences. Within amdgpu you can use driver-specific cookies, for shared buffer we now have sync_file. But multiple writers with implicit sync simply fundamentally doesn't work. Because you have no idea with which writer, touching the same subrange you want to touch.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20160922063625.GD22164-XQyZGdhdUcTMwUGJfOwWj/ooFf0ArEBIu+b9c/[email protected]
Am 22.09.2016 um 08:36 schrieb Daniel Vetter:
Quoted 10 lines · Christian König
Quoted 3 lines
For a quick workaround I suggest to just serialize all accesses to BO shared with different drivers, but essentially I think it is a perfectly valid requirement to have multiple writers to one BO.
It is, but it's not possible with implicit sync. If you want parallel write access to the same shared buffer, you _must_ carry around some explicit fences. Within amdgpu you can use driver-specific cookies, for shared buffer we now have
sync_file. But multiple writers with implicit sync simply fundamentally doesn't work. Because you have no idea with which writer, touching the same subrange you want to touch.
You don't need to separate the BO into subranges which are touched by different engines for allowing multiple writers.
AMD hardware and I'm pretty sure others as well are perfectly capable of writing to the same memory from multiple engines and even multiple GPUs at the same time.
For a good hint of what is possible see the public AMD ISA documentation about atomic operations, but that is only the start of it.
The crux here is that we need to assume that we will have implicit and explicit sync mixed for backward compatibility.
This implies that we need some mechanism like amdgpu uses in it's sync implementation where every fence is associated with an owner which denotes the domain in which implicit sync happens. If you leave this domain you will automatically run into explicit sync.
Currently we define the borders of this domain in amdgpu on process boundary to keep things like DRI2/DRI3 working as expected.
I really don't see how you want to solve this with a single explicit fence for each reservation object. As long as you have multiple concurrently running operations accessing the same buffer you need to keep one fence for each operation no matter what.
Regards,
Christian.
Quoted 1 line
-Daniel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 37 lines · Christian König
Am 22.09.2016 um 08:36 schrieb Daniel Vetter:
Quoted 8 lines · Christian König
Quoted 5 lines
For a quick workaround I suggest to just serialize all accesses to BO shared
with different drivers, but essentially I think it is a perfectly valid requirement to have multiple writers to one BO.Quoted 7 lines
It is, but it's not possible with implicit sync. If you want parallel write access to the same shared buffer, you _must_ carry around some explicit fences. Within amdgpu you can use driver-specific cookies, for shared buffer we now have
sync_file. But multiple writers with implicit sync simply fundamentally doesn't work. Because you have no idea with which
writer, touching the same subrange you want to touch.You don't need to separate the BO into subranges which are touched by different engines for allowing multiple writers.
AMD hardware and I'm pretty sure others as well are perfectly capable of writing to the same memory from multiple engines and even multiple GPUs at the same time.
For a good hint of what is possible see the public AMD ISA documentation about atomic operations, but that is only the start of it.
The crux here is that we need to assume that we will have implicit and explicit sync mixed for backward compatibility.
This implies that we need some mechanism like amdgpu uses in it's sync implementation where every fence is associated with an owner which denotes the domain in which implicit sync happens. If you leave this domain you will automatically run into explicit sync.
Quoted 7 lines
Currently we define the borders of this domain in amdgpu on process boundary to keep things like DRI2/DRI3 working as expected.
I really don't see how you want to solve this with a single explicit fence for each reservation object. As long as you have multiple concurrently running operations accessing the same buffer you need to keep one fence for each operation no matter what.
I can't make sense of what you're saying, and I suspect we put different meaning to different words. So let me define here:
- implicit fencing: Userspace does not track read/writes to buffers, but only the kernel does that. This is the assumption DRI2/3 has. Since synchronization is by necessity on a per-buffer level you can only have 1 writer. In the kernel the cross-driver interface for this is struct reservation_object attached to dma-bufs. If you don't fill out/wait for the exclusive fence in there, you're driver is _not_ doing (cross-device) implicit fencing.
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
Given that I'm not sure what you mean with "one explicit fence per reservation_object", since explicit fencing should not attach anything (at least not any exclusive fences) to a reservation_object. It does sound a bit like you have the meaning the other way round (as in explicit fencing = the kernel explicitly takes care of fencing, but it's explicit as in explicit fences visible to userspace). -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 22.09.2016 um 14:26 schrieb Daniel Vetter:
Quoted 45 lines
Quoted 33 lines · Christian König
Am 22.09.2016 um 08:36 schrieb Daniel Vetter:
Quoted 5 lines · Christian König
Quoted 4 lines
For a quick workaround I suggest to just serialize all accesses to BO shared
with different drivers, but essentially I think it is a perfectly valid requirement to have multiple writers to one BO.Quoted 7 lines
It is, but it's not possible with implicit sync. If you want parallel write access to the same shared buffer, you _must_ carry around some explicit fences. Within amdgpu you can use driver-specific cookies, for shared buffer we now have
sync_file. But multiple writers with implicit sync simply fundamentally doesn't work. Because you have no idea with which
writer, touching the same subrange you want to touch.You don't need to separate the BO into subranges which are touched by different engines for allowing multiple writers.
AMD hardware and I'm pretty sure others as well are perfectly capable of writing to the same memory from multiple engines and even multiple GPUs at the same time.
For a good hint of what is possible see the public AMD ISA documentation about atomic operations, but that is only the start of it.
The crux here is that we need to assume that we will have implicit and explicit sync mixed for backward compatibility.
This implies that we need some mechanism like amdgpu uses in it's sync implementation where every fence is associated with an owner which denotes the domain in which implicit sync happens. If you leave this domain you will automatically run into explicit sync.
Quoted 7 lines
Currently we define the borders of this domain in amdgpu on process boundary to keep things like DRI2/DRI3 working as expected.
I really don't see how you want to solve this with a single explicit fence for each reservation object. As long as you have multiple concurrently running operations accessing the same buffer you need to keep one fence for each operation no matter what.
I can't make sense of what you're saying, and I suspect we put different meaning to different words. So let me define here:
Quoted 7 lines
- implicit fencing: Userspace does not track read/writes to buffers, but only the kernel does that. This is the assumption DRI2/3 has. Since synchronization is by necessity on a per-buffer level you can only have 1 writer. In the kernel the cross-driver interface for this is struct
reservation_objectattached to dma-bufs. If you don't fill out/wait for the exclusive fence in there, you're driver is _not_ doing (cross-device) implicit fencing.
I can confirm that my understanding of implicit fencing is exactly the same as yours.
Quoted 5 lines
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
No, that is clearly not my understanding of explicit fencing.
Userspace doesn't necessarily need to pass around distinct fence objects with all of it's protocols and the kernel is still responsible for inserting stalls whenever an userspace protocol or application requires this semantics.
Otherwise you will never be able to use explicit fencing on the Linux desktop with protocols like DRI2/DRI3.
I would expect that every driver in the system waits for all fences of a reservation object as long as it isn't told otherwise by providing a distinct fence object with the IOCTL in question.
Regards,
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Christian König
Quoted 5 lines
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
No, that is clearly not my understanding of explicit fencing.
Quoted 7 lines
Userspace doesn't necessarily need to pass around distinct fence objects with all of it's protocols and the kernel is still responsible for inserting stalls whenever an userspace protocol or application requires this semantics.
Otherwise you will never be able to use explicit fencing on the Linux desktop with protocols like DRI2/DRI3.
This is about mixing them. Explicit fencing still means userspace has an explicit piece, separate from buffers, (either sync_file fd, or a driver-specific cookie, or similar).
Quoted 3 lines
I would expect that every driver in the system waits for all fences of a reservation object as long as it isn't told otherwise by providing a distinct fence object with the IOCTL in question.
Yup agreed. This way if your explicitly-fencing driver reads a shared buffer passed over a protocol that does implicit fencing (like DRI2/3), then it will work.
The other interop direction is explicitly-fencing driver passes a buffer to a consumer which expects implicit fencing. In that case you must attach the right fence to the exclusive slot, but _only_ in that case. Otherwise you end up stalling your explicitly-fencing userspace, since implicit fencing doesn't allow more than 1 writer. For amdgpu one possible way to implement this might be to count how many users a dma-buf has, and if it's more than just the current context set the exclusive fence. Or do an uabi revision and let userspace decide (or at least overwrite it).
But the current approach in amdgpu_sync.c of declaring a fence as exclusive after the fact (if owners don't match) just isn't how reservation_object works. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-) -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 24 lines
Quoted 8 lines · Christian König
Quoted 5 lines
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
No, that is clearly not my understanding of explicit fencing.
Quoted 7 lines
Userspace doesn't necessarily need to pass around distinct fence objects with all of it's protocols and the kernel is still responsible for inserting stalls whenever an userspace protocol or application requires this semantics.
Otherwise you will never be able to use explicit fencing on the Linux desktop with protocols like DRI2/DRI3.
This is about mixing them. Explicit fencing still means userspace has an explicit piece, separate from buffers, (either
sync_filefd, or a driver-specific cookie, or similar).Quoted 3 lines
I would expect that every driver in the system waits for all fences of a reservation object as long as it isn't told otherwise by providing a distinct fence object with the IOCTL in question.
Quoted 8 lines
Yup agreed. This way if your explicitly-fencing driver reads a shared buffer passed over a protocol that does implicit fencing (like DRI2/3), then it will work.
The other interop direction is explicitly-fencing driver passes a buffer to a consumer which expects implicit fencing. In that case you must attach the right fence to the exclusive slot, but _only_ in that case.
Ok well sounds like you are close to understand why I can't do exactly this: There simply is no right fence I could attach.
When amdgpu makes the command submissions it doesn't necessarily know that the buffer will be exported and shared with another device later on.
So when the buffer is exported and given to the other device you might have a whole bunch of fences which run concurrently and not in any serial order.
Quoted 6 lines
Otherwise you end up stalling your explicitly-fencing userspace, since implicit fencing doesn't allow more than 1 writer. For amdgpu one possible way to implement this might be to count how many users a dma-buf has, and if it's more than just the current context set the exclusive fence. Or do an uabi revision and let userspace decide (or at least overwrite it).
I mean I can pick one fence and wait for the rest to finish manually, but that would certainly defeat the whole effort, doesn't it?
I completely agree that you have only 1 writer with implicit fencing, but when you switch from explicit fencing back to implicit fencing you can have multiple ones.
Quoted 5 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)
Well as far as I can see there is no way I can fix amdgpu in this case.
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Regards,
Christian.
Quoted 1 line
-Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): d2430ff8-43bd-bff2-9b02-847cabfd56c0-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 38 lines · Christian König
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 25 lines
Quoted 8 lines · Christian König
Quoted 5 lines
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
No, that is clearly not my understanding of explicit fencing.
Quoted 8 lines
Userspace doesn't necessarily need to pass around distinct fence objects with all of it's protocols and the kernel is still responsible for inserting
stalls whenever an userspace protocol or application requires this semantics.Otherwise you will never be able to use explicit fencing on the Linux desktop with protocols like DRI2/DRI3.
This is about mixing them. Explicit fencing still means userspace has an explicit piece, separate from buffers, (either
sync_filefd, or a driver-specific cookie, or similar).Quoted 3 lines
I would expect that every driver in the system waits for all fences of a reservation object as long as it isn't told otherwise by providing a distinct fence object with the IOCTL in question.
Quoted 8 lines
Yup agreed. This way if your explicitly-fencing driver reads a shared buffer passed over a protocol that does implicit fencing (like DRI2/3), then it will work.
The other interop direction is explicitly-fencing driver passes a buffer to a consumer which expects implicit fencing. In that case you must attach the right fence to the exclusive slot, but _only_ in that case.
Ok well sounds like you are close to understand why I can't do exactly
this: There simply is no right fence I could attach.
Quoted 6 lines
When amdgpu makes the command submissions it doesn't necessarily know that the buffer will be exported and shared with another device later on.
So when the buffer is exported and given to the other device you might have a whole bunch of fences which run concurrently and not in any serial order.
I feel like you're thinking too much of buffers shared between GPUs as being short-lived and only shared late. In the use-cases I know about, shared buffers are created separately and shared ahead of time, the actual rendering work is done to non-shared buffers and then just copied to the shared buffers for transfer between GPUs. These copies are always performed by the same context in such a way that they should always be performed by the same HW engine and thus implicitly serialized.
Do you have any specific use-cases in mind where buffers are only shared between GPUs after the rendering operations creating the buffer contents to be shared have already been submitted?
Quoted 9 lines
Quoted 6 lines
Otherwise you end up stalling your explicitly-fencing userspace, since implicit fencing doesn't allow more than 1 writer. For amdgpu one possible way to implement this might be to count how many users a dma-buf has, and if it's more than just the current context set the exclusive fence. Or do an uabi revision and let userspace decide (or at least overwrite it).
I mean I can pick one fence and wait for the rest to finish manually, but that would certainly defeat the whole effort, doesn't it?
I'm afraid it's not clear to me why it would. Can you elaborate?
Quoted 11 lines
Quoted 5 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)Well as far as I can see there is no way I can fix amdgpu in this case.
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Anyway, we need a solution for this between radeon and amdgpu, and I don't think a solution which involves those drivers using reservation object semantics between them which are different from all other drivers is a good idea.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 54 lines · Michel Dänzer
Quoted 38 lines · Christian König
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 25 lines
Quoted 8 lines · Christian König
Quoted 5 lines
- explicit fencing: Userspace passes around distinct fence objects for any work going on on the gpu. The kernel doesn't insert any stall of it's own (except for moving buffer objects around ofc). This is what Android. This also seems to be what amdgpu is doing within one process/owner.
No, that is clearly not my understanding of explicit fencing.
Quoted 8 lines
Userspace doesn't necessarily need to pass around distinct fence objects with all of it's protocols and the kernel is still responsible for inserting
stalls whenever an userspace protocol or application requires this semantics.Otherwise you will never be able to use explicit fencing on the Linux desktop with protocols like DRI2/DRI3.
This is about mixing them. Explicit fencing still means userspace has an explicit piece, separate from buffers, (either
sync_filefd, or a driver-specific cookie, or similar).Quoted 3 lines
I would expect that every driver in the system waits for all fences of a reservation object as long as it isn't told otherwise by providing a distinct fence object with the IOCTL in question.
Quoted 8 lines
Yup agreed. This way if your explicitly-fencing driver reads a shared buffer passed over a protocol that does implicit fencing (like DRI2/3), then it will work.
The other interop direction is explicitly-fencing driver passes a buffer to a consumer which expects implicit fencing. In that case you must attach the right fence to the exclusive slot, but _only_ in that case.
Ok well sounds like you are close to understand why I can't do exactly
this: There simply is no right fence I could attach.Quoted 6 lines
When amdgpu makes the command submissions it doesn't necessarily know that the buffer will be exported and shared with another device later on.
So when the buffer is exported and given to the other device you might have a whole bunch of fences which run concurrently and not in any serial order.
I feel like you're thinking too much of buffers shared between GPUs as being short-lived and only shared late. In the use-cases I know about, shared buffers are created separately and shared ahead of time, the actual rendering work is done to non-shared buffers and then just copied to the shared buffers for transfer between GPUs. These copies are always performed by the same context in such a way that they should always be performed by the same HW engine and thus implicitly serialized.
Quoted 3 lines
Do you have any specific use-cases in mind where buffers are only shared between GPUs after the rendering operations creating the buffer contents to be shared have already been submitted?
Yeah, it should be known which buffer you use (at least in userspace, maybe not in the kernel) for which you need implicit fencing. At least with DRI2/3 it's really obvious which buffers are shared. Same holds for external images and other imported buffers.
Yes that means you need to keep track of a few things in userspace, and you need to add a special flag to CS to make sure the kernel does set the exclusive fence.
Quoted 21 lines
Quoted 9 lines
Quoted 6 lines
Otherwise you end up stalling your explicitly-fencing userspace, since implicit fencing doesn't allow more than 1 writer. For amdgpu one possible way to implement this might be to count how many users a dma-buf has, and if it's more than just the current context set the exclusive fence. Or do an uabi revision and let userspace decide (or at least overwrite it).
I mean I can pick one fence and wait for the rest to finish manually, but that would certainly defeat the whole effort, doesn't it?
I'm afraid it's not clear to me why it would. Can you elaborate?
Quoted 8 lines
Quoted 5 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)Well as far as I can see there is no way I can fix amdgpu in this case.
Quoted 8 lines
Quoted 3 lines
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Anyway, we need a solution for this between radeon and amdgpu, and I don't think a solution which involves those drivers using reservation object semantics between them which are different from all other drivers is a good idea.
Afaik there's also amd+intel machines out there, so really the only option is to either fix amdgpu to correctly set exclusive fences on shared buffers (with the help of userspace hints). Or change all the existing drivers. No idea what's simpler to do, since I don't know about amdgpu userspace.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Michel Dänzer
Quoted 13 lines · Christian König
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 6 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)Well as far as I can see there is no way I can fix amdgpu in this case.
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Quoted 6 lines
Quoted 4 lines
Anyway, we need a solution for this between radeon and amdgpu, and I don't think a solution which involves those drivers using reservation object semantics between them which are different from all other drivers is a good idea.
Afaik there's also amd+intel machines out there,
Sure, what I meant was that even if we didn't care about those (which we do), we'd still need a solution between our own drivers.
Quoted 3 lines
so really the only option is to either fix amdgpu to correctly set exclusive fences on shared buffers (with the help of userspace hints). Or change all the existing drivers.
I got some fresh perspective on the problem while taking a walk, and I'm now fairly convinced that neither amdgpu userspace nor other drivers need to be modified:
It occurred to me that all the information we need is already there in the exclusive and shared fences set by amdgpu. We just need to use it differently to match the expectations of other drivers.
We should be able to set some sort of "pseudo" fence as the exclusive fence of the reservation object. When we are asked by another driver to wait for this fence to signal, we take the current "real" exclusive fence (which we can keep track of e.g. in our BO struct) and shared fences, and wait for all of those to signal; then we mark the "pseudo" exclusive fence as signalled.
Am I missing anything which would prevent this from working?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 40 lines · Michel Dänzer
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Michel Dänzer
Quoted 13 lines · Christian König
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 6 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)Well as far as I can see there is no way I can fix amdgpu in this case.
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Quoted 6 lines
Quoted 4 lines
Anyway, we need a solution for this between radeon and amdgpu, and I don't think a solution which involves those drivers using reservation object semantics between them which are different from all other drivers is a good idea.
Afaik there's also amd+intel machines out there,
Sure, what I meant was that even if we didn't care about those (which we do), we'd still need a solution between our own drivers.
Quoted 3 lines
so really the only option is to either fix amdgpu to correctly set exclusive fences on shared buffers (with the help of userspace hints). Or change all the existing drivers.
I got some fresh perspective on the problem while taking a walk, and I'm now fairly convinced that neither amdgpu userspace nor other drivers need to be modified:
It occurred to me that all the information we need is already there in the exclusive and shared fences set by amdgpu. We just need to use it differently to match the expectations of other drivers.
Quoted 8 lines
We should be able to set some sort of "pseudo" fence as the exclusive fence of the reservation object. When we are asked by another driver to wait for this fence to signal, we take the current "real" exclusive fence (which we can keep track of e.g. in our BO struct) and shared fences, and wait for all of those to signal; then we mark the "pseudo" exclusive fence as signalled.
Am I missing anything which would prevent this from working?
One thing to make sure is that you don't change the (real, private stored) fences you're waiting on over the lifetime of the public exclusive fence. That might lead to some hilarity wrt potentially creating fence depency loops. But I think as long as you guarantee that the private internal fences are always amdgpu ones, and never anything imported from a different driver even that should be fine. Not because this would break the loops, but since amgpud has a hangcheck it can still gurantee that the fence eventually fires even if there is a loop.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20160926080419.GV20761-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org
Hi
This has discussion has gone a little quiet
Was there any agreement about what needed doing to get this working for i965/amdgpu?
Regards
Mike
Quoted 60 lines · On Mon, 26 Sep 2016 at 09:04 Daniel Vetter <[email protected]> wrote:
Quoted 40 lines · Michel Dänzer
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Michel Dänzer
Quoted 13 lines · Christian König
Am 22.09.2016 um 15:05 schrieb Daniel Vetter:
Quoted 6 lines
But the current approach in
amdgpu_sync.cof declaring a fence as exclusive after the fact (if owners don't match) just isn't howreservation_objectworks. You can of course change that, but that means you must change all drivers implementing support for implicit fencing of dma-buf. Fixing amdgpu will be easier ;-)Well as far as I can see there is no way I can fix amdgpu in this case.
The handling clearly needs to be changed on the receiving side of the reservation objects if I don't completely want to disable concurrent access to BOs in amdgpu.
Quoted 6 lines
Quoted 4 lines
Anyway, we need a solution for this between radeon and amdgpu, and I don't think a solution which involves those drivers using reservation object semantics between them which are different from all other drivers is a good idea.
Afaik there's also amd+intel machines out there,
Sure, what I meant was that even if we didn't care about those (which we do), we'd still need a solution between our own drivers.
Quoted 3 lines
so really the only option is to either fix amdgpu to correctly set exclusive fences on shared buffers (with the help of userspace hints). Or change all the existing drivers.
I got some fresh perspective on the problem while taking a walk, and I'm now fairly convinced that neither amdgpu userspace nor other drivers need to be modified:
It occurred to me that all the information we need is already there in the exclusive and shared fences set by amdgpu. We just need to use it differently to match the expectations of other drivers.
Quoted 8 lines
We should be able to set some sort of "pseudo" fence as the exclusive fence of the reservation object. When we are asked by another driver to wait for this fence to signal, we take the current "real" exclusive fence (which we can keep track of e.g. in our BO struct) and shared fences, and wait for all of those to signal; then we mark the "pseudo" exclusive fence as signalled.
Am I missing anything which would prevent this from working?
One thing to make sure is that you don't change the (real, private stored) fences you're waiting on over the lifetime of the public exclusive fence. That might lead to some hilarity wrt potentially creating fence depency loops. But I think as long as you guarantee that the private internal fences are always amdgpu ones, and never anything imported from a different driver even that should be fine. Not because this would break the loops, but since amgpud has a hangcheck it can still gurantee that the fence eventually fires even if there is a loop.
-Daniel
Quoted 8 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAHbf0-HZ6EotqwgvkxRTdRF97xB3qBA=DRKAzaAXguV_PR_P8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 5 lines · Mike Lothian
This has discussion has gone a little quiet
Was there any agreement about what needed doing to get this working for i965/amdgpu?
Christian, do you see anything which could prevent the solution I outlined from working?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): d74d34a7-5221-d282-d9d1-b0e1007fc0c7-otUistvHUpPR7s880joybQ@public.gmane.org
Am 11.10.2016 um 05:58 schrieb Michel Dänzer:
Quoted 7 lines · Mike Lothian
Quoted 4 lines
This has discussion has gone a little quiet
Was there any agreement about what needed doing to get this working for i965/amdgpu?
Christian, do you see anything which could prevent the solution I outlined from working?
I thought about that approach as well, but unfortunately it also has a couple of downsides. Especially keeping the exclusive fence set while we actually don't need it isn't really clean either.
I'm currently a bit busy with other tasks and so put Nayan on a road to get a bit into the kernel driver (he asked for that anyway).
Implementing the simple workaround to sync when we export the DMA-buf should be something like 20 lines of code and fortunately Nayan has an I+A system and so can actually test it.
If it turns out to be more problematic or somebody really starts to need it I'm going to hack on that myself a bit more.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): c77a2cb9-1f0e-f1a3-aedd-a111cd6ba8e8-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 4 lines · Christian König
Am 11.10.2016 um 05:58 schrieb Michel Dänzer:
Quoted 3 lines · Mike Lothian
Quoted 2 lines
This has discussion has gone a little quiet
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Was there any agreement about what needed doing to get this working for i965/amdgpu?
Christian, do you see anything which could prevent the solution I outlined from working?
I thought about that approach as well, but unfortunately it also has a couple of downsides. Especially keeping the exclusive fence set while we actually don't need it isn't really clean either.
I was wondering if it's possible to have a singleton pseudo exclusive fence which is used for all BOs. That might keep the overhead acceptably low.
Quoted 9 lines
I'm currently a bit busy with other tasks and so put Nayan on a road to get a bit into the kernel driver (he asked for that anyway).
Implementing the simple workaround to sync when we export the DMA-buf should be something like 20 lines of code and fortunately Nayan has an I+A system and so can actually test it.
If it turns out to be more problematic or somebody really starts to need it I'm going to hack on that myself a bit more.
If you mean only syncing when a DMA-buf is exported, that's not enough, as I explained before. The BOs being shared are long-lived, and synchronization between GPUs is required for every command stream submission.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi
Just another gentle ping to see where you are with this?
Cheers
Mike
Quoted 35 lines · On Wed, 12 Oct 2016 at 01:40 Michel Dänzer <[email protected]> wrote:
Quoted 4 lines · Christian König
Am 11.10.2016 um 05:58 schrieb Michel Dänzer:
Quoted 3 lines · Mike Lothian
Quoted 2 lines
This has discussion has gone a little quiet
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Was there any agreement about what needed doing to get this working for i965/amdgpu?
Christian, do you see anything which could prevent the solution I outlined from working?
I thought about that approach as well, but unfortunately it also has a couple of downsides. Especially keeping the exclusive fence set while we actually don't need it isn't really clean either.
I was wondering if it's possible to have a singleton pseudo exclusive fence which is used for all BOs. That might keep the overhead acceptably low.
Quoted 9 lines
I'm currently a bit busy with other tasks and so put Nayan on a road to get a bit into the kernel driver (he asked for that anyway).
Implementing the simple workaround to sync when we export the DMA-buf should be something like 20 lines of code and fortunately Nayan has an I+A system and so can actually test it.
If it turns out to be more problematic or somebody really starts to need it I'm going to hack on that myself a bit more.
If you mean only syncing when a DMA-buf is exported, that's not enough, as I explained before. The BOs being shared are long-lived, and synchronization between GPUs is required for every command stream submission.
Quoted 4 lines
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): CAHbf0-GGMWZrhB+PKpc-QbD__6fqB4pQVFfN+gzLWNhi+DuG3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 2 lines · Mike Lothian
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 7 lines · Michel Dänzer
Quoted 2 lines · Mike Lothian
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
ftrace confirms the i915 driver's pageflip function is waiting on the fence in reservation_object_wait_timeout_rcu() as it should.
That entry->tv.shared needs to be set false for such buffers in amdgpu_bo_list_set() makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.
I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?
All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
-mario
Quoted 1 line
From
2a8d7fcd36da30305fa675df311c697162792597Mon Sep 17 00:00:00 2001
From: Mario Kleiner <[email protected]>
Date: Wed, 26 Oct 2016 10:58:00 +0200
Subject: [PATCH] drm/amdgpu: Attach exclusive fence to prime exported bo's.
External clients which import our bo's wait only for exclusive dmabuf-fences, not on shared ones, so attach fences on such exported buffers as exclusive ones, not shared ones.
-> Backup commit. Work in progress.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -459,6 +459,7 @@ struct amdgpu_bo {u64 metadata_flags;void *metadata;u32 metadata_size; +bool prime_exported;/* list of all virtual address to which this bo * is associated to */
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +4 -1
@@ -132,7 +132,10 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev, entry->priority =min (info[i].bo_priority,AMDGPU_BO_LIST_MAX_PRIORITY ); entry->tv.bo = &entry->robj->tbo; - entry->tv.shared = true; + entry->tv.shared = !entry->robj->prime_exported; + +if (entry->robj->prime_exported) +DRM_DEBUG_PRIME ("Exclusive fence for exported prime bo %p\n" , entry->robj);if (entry->robj->prefered_domains ==AMDGPU_GEM_DOMAIN_GDS ) gds_obj = entry->robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6 -0
@@ -494,6 +494,12 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, tv.bo = &bo_va->bo->tbo; tv.shared = true; + +if (bo_va->bo->prime_exported) { +DRM_DEBUG_PRIME ("Update for exported prime bo %p\n" , bo_va->bo); +/* tv.shared = false; */ + } +list_add (&tv.head, &list);amdgpu_vm_get_pd_bo (bo_va->vm, &list, &vm_pd);
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +3 -0
@@ -121,5 +121,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm))return ERR_PTR (-EPERM ); + bo->prime_exported = true; +DRM_DEBUG_PRIME ("Exporting prime bo %p\n" , bo); +return drm_gem_prime_export (dev, gobj, flags); }
Signature · 1 line
2.7.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 7eb19a73-a558-d2e6-bd8d-34fe95045dfd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Am 28.10.2016 um 19:37 schrieb Mario Kleiner:
Quoted 12 lines · Michel Dänzer
Quoted 7 lines · Mike Lothian
Quoted 2 lines
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
Yeah, that's pretty much what I had in mind as well. You additionally need to wait for the shared fences when you export the BO for the first time, but that's only a nitpick.
Quoted 6 lines
ftrace confirms the i915 driver's pageflip function is waiting on the fence in
reservation_object_wait_timeout_rcu()as it should.That
entry->tv.sharedneeds to be set false for such buffers inamdgpu_bo_list_set()makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to
amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?
Yes, exactly. VM updates doesn't matter for anybody else than amdgpu. Additional to that we don't even add a fence to the shared slot we reserve (could probably drop that for optimization).
Please remove the debugging stuff and the extra code on the VM updates and add a reservation_object_wait_timeout_rcu() to the export path and we should be good to go.
Regards,
Christian.
Quoted 4 lines
All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
-mario
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 39 lines · Christian König
Am 28.10.2016 um 19:37 schrieb Mario Kleiner:
Quoted 11 lines · Michel Dänzer
Quoted 7 lines · Mike Lothian
Quoted 2 lines
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Quoted 6 lines
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
Yeah, that's pretty much what I had in mind as well. You additionally need to wait for the shared fences when you export the BO for the first time, but that's only a nitpick.
Quoted 9 lines
ftrace confirms the i915 driver's pageflip function is waiting on the fence in
reservation_object_wait_timeout_rcu()as it should.That
entry->tv.sharedneeds to be set false for such buffers inamdgpu_bo_list_set()makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.Quoted 6 lines
I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to
amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?
Quoted 8 lines
Yes, exactly. VM updates doesn't matter for anybody else than amdgpu. Additional to that we don't even add a fence to the shared slot we reserve (could probably drop that for optimization).
Please remove the debugging stuff and the extra code on the VM updates and add a
reservation_object_wait_timeout_rcu()to the export path and we should be good to go.
Done. Patch v2 just sent out after retesting with Tonga only and Intel + Tonga renderoffload. Would be cool if we could get this into 4.9-rc.
Ideally also backported to 4.8, given it is a simple change, as that would be the next official kernel for *buntu 16.04-LTS and derivatives, but that's probably breaking the rules as it doesn't fix a regression?
thanks,
-mario
Quoted 10 lines
Regards,
Christian.Quoted 5 lines
All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
-mario
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 31 lines · Mario Kleiner
Quoted 5 lines · Michel Dänzer
Quoted 2 lines · Mike Lothian
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
ftrace confirms the i915 driver's pageflip function is waiting on the fence in
reservation_object_wait_timeout_rcu()as it should.That
entry->tv.sharedneeds to be set false for such buffers inamdgpu_bo_list_set()makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to
amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
[...]
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, · line 128
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +3
-0@@ -121,5 +121,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm))return ERR_PTR (-EPERM ); + bo->prime_exported = true; +DRM_DEBUG_PRIME ("Exporting prime bo %p\n" , bo); +return drm_gem_prime_export (dev, gobj, flags); }
This will take effect in non-PRIME cases as well, at least DRI3 and GL<->[other API] interop off the top of my head. Is that okay?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Mario
That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider
Thanks for your work on this, the stutter is much more manageable than the tearing was
I've attached the patch that applies cleanly to 4.10-wip
Quoted 33 lines · On Fri, 28 Oct 2016 at 18:37 Mario Kleiner <[email protected]> wrote:
Quoted 7 lines · Michel Dänzer
Quoted 2 lines · Mike Lothian
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
ftrace confirms the i915 driver's pageflip function is waiting on the fence in
reservation_object_wait_timeout_rcu()as it should.That
entry->tv.sharedneeds to be set false for such buffers inamdgpu_bo_list_set()makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to
amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?
Quoted 5 lines
All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
-mario
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -391,6 +391,7 @@ struct amdgpu_bo {u64 metadata_flags;void *metadata;u32 metadata_size; +bool prime_exported;/* list of all virtual address to which this bo * is associated to */
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +4 -1
@@ -132,7 +132,10 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev, entry->priority =min (info[i].bo_priority,AMDGPU_BO_LIST_MAX_PRIORITY ); entry->tv.bo = &entry->robj->tbo; - entry->tv.shared = true; + entry->tv.shared = !entry->robj->prime_exported; + +if (entry->robj->prime_exported) +DRM_DEBUG_PRIME ("Exclusive fence for exported prime bo %p\n" , entry->robj);if (entry->robj->prefered_domains ==AMDGPU_GEM_DOMAIN_GDS ) gds_obj = entry->robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6 -0
@@ -504,6 +504,12 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, tv.bo = &bo_va->bo->tbo; tv.shared = true; + +if (bo_va->bo->prime_exported) { +DRM_DEBUG_PRIME ("Update for exported prime bo %p\n" , bo_va->bo); +/* tv.shared = false; */ + } +list_add (&tv.head, &list);amdgpu_vm_get_pd_bo (bo_va->vm, &list, &vm_pd);
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +3 -0
@@ -121,5 +121,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev,if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm))return ERR_PTR (-EPERM ); + bo->prime_exported = true; +DRM_DEBUG_PRIME ("Exporting prime bo %p\n" , bo); +return drm_gem_prime_export (dev, gobj, flags); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
I turned on vsync and everything works great in tomb raider
:D
Thanks again to everyone who made this possible
Quoted 49 lines · On Fri, 28 Oct 2016 at 19:37 Mike Lothian…
Hi Mario
That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider
Thanks for your work on this, the stutter is much more manageable than the tearing was
I've attached the patch that applies cleanly to 4.10-wip
On Fri, 28 Oct 2016 at 18:37 Mario Kleiner <[email protected]> wrote:
Quoted 7 lines · Michel Dänzer
Quoted 2 lines · Mike Lothian
Just another gentle ping to see where you are with this?
I haven't got a chance to look into this any further.
Fwiw., as a proof of concept, the attached experimental patch does work as tested on Intel HD Haswell + AMD R9 380 Tonga under amdgpu and DRI3/Present when applied to drm-next (updated from a few days ago). With DRI_PRIME=1 tearing for page-flipped fullscreen windows is gone under all loads. The tearing with "windowed" windows now looks as expected for regular tearing not related to Prime.
ftrace confirms the i915 driver's pageflip function is waiting on the fence in
reservation_object_wait_timeout_rcu()as it should.That
entry->tv.sharedneeds to be set false for such buffers inamdgpu_bo_list_set()makes sense to me, as that is part of the buffer validation for command stream submission. There are other places in the driver where tv.shared is set, which i didn't check so far.I don't know which of these would need to be updated with a "exported bo" check as well, e.g., for video decoding or maybe gpu compute? Adding or removing the check to
amdgpu_gem_va_update_vm(), e.g., made no difference. I assume that makes sense because that functions seems to deal with amdgpu internal vm page tables or page table entries for such a bo, not with something visible to external clients?
Quoted 6 lines
All i can say is it fixes 3D rendering under DRI3 + Prime + pageflipping without causing any obvious new problems.
-mario
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CAHbf0-EY2OM_HgxTjmMi4-f5TQ8fkqf5XYBxHZtJVsnSpxPyyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 6 lines · Mike Lothian
I turned on vsync and everything works great in tomb raider
:D
Thanks again to everyone who made this possible
Quoted 8 lines
On Fri, 28 Oct 2016 at 19:37 Mike Lothian <[email protected] <mailto:[email protected]>> wrote:
Hi Mario
That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider
I wonder if the stutter might be due to the dGPU writing another frame before the iGPU is done processing the previous one. Christian, does the amdgpu scheduler wait for shared fences of shared BOs to signal before submitting jobs using them to the GPU?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): c45e2f4c-c075-47b6-7e02-3bd98748c83a-otUistvHUpPR7s880joybQ@public.gmane.org
Am 31.10.2016 um 07:44 schrieb Michel Dänzer:
Quoted 12 lines · Mike Lothian
Quoted 11 lines
I turned on vsync and everything works great in tomb raider
:D
Thanks again to everyone who made this possible
On Fri, 28 Oct 2016 at 19:37 Mike Lothian <[email protected] <mailto:[email protected]>> wrote:
Hi Mario
Quoted 7 lines
Quoted 3 lines
That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider
I wonder if the stutter might be due to the dGPU writing another frame before the iGPU is done processing the previous one. Christian, does the amdgpu scheduler wait for shared fences of shared BOs to signal before submitting jobs using them to the GPU?
Yeah, that should work. We wait for both the exclusive as well as all shared fences before CS or pageflip.
Only on CS we filter the shared fences so that we don't necessary wait for submissions from the same process.
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 21 lines · Christian König
Am 31.10.2016 um 07:44 schrieb Michel Dänzer:
Quoted 12 lines · Mike Lothian
Quoted 11 lines
I turned on vsync and everything works great in tomb raider
:D
Thanks again to everyone who made this possible
On Fri, 28 Oct 2016 at 19:37 Mike Lothian <[email protected] <mailto:[email protected]>> wrote:
Hi Mario
Quoted 7 lines
Quoted 3 lines
That fixes the tearing, it's been replaced with a strange stutter, like it's only showing half the number of frames being reported - it's really noticeable in tomb raider
I wonder if the stutter might be due to the dGPU writing another frame before the iGPU is done processing the previous one. Christian, does the amdgpu scheduler wait for shared fences of shared BOs to signal before submitting jobs using them to the GPU?
Quoted 5 lines
Yeah, that should work. We wait for both the exclusive as well as all shared fences before CS or pageflip.
Only on CS we filter the shared fences so that we don't necessary wait for submissions from the same process.
Note that it can be the same process (Xorg) in the RandR 1.4 multihead case. But it sounds like Mike's stutter can't be due to the issue I was thinking of.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 60 lines · Michel Dänzer
Quoted 59 lines · Daniel Vetter
Quoted 42 lines · Christian König
Am 21.09.2016 um 13:04 schrieb Daniel Vetter:
Quoted 21 lines
Quoted 12 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
Looks like there are different interpretations of the semantics of exclusive vs. shared fences. Where are these semantics documented?
Yeah, I think as well that this is the primary question here.
IIRC the fences were explicitly called exclusive/shared instead of writing/reading on purpose.
Quoted 6 lines
I absolutely don't mind switching to them to writing/reading semantics, but
amdgpu really needs multiple writers at the same time.So in this case the writing side of a reservation object needs to be a collection of fences as well.
Quoted 9 lines
You can't have multiple writers with implicit syncing. That confusion is exactly why we called them shared/exclusive. Multiple writers generally means that you do some form of fencing in userspace (unsync'ed gl buffer access is the common one). What you do for private buffers doesn't matter, but when you render into a shared/winsys buffer you really need to set the exclusive fence (and there can only ever be one). So probably needs some userspace adjustments to make sure you don't accidentally set an exclusive write hazard when you don't really want that implicit sync.
Nope, that isn't true.
We use multiple writers without implicit syncing between processes in the amdgpu stack perfectly fine.
See
amdgpu_sync.cfor the implementation. What we do there is taking a look at all the fences associated with a reservation object and only sync to those who are from another process.Quoted 5 lines
Then we use implicit syncing for command submissions in the form of "dependencies". E.g. for each CS we report back an identifier of that submission to user space and on the next submission you can give this identifier as dependency which needs to be satisfied before the command submission can start running.
This is called explicit fencing. Implemented with a driver-private primitive (and not
sync_filefds like on android), but still conceptually explicit fencing. Implicit fencing really only can handle one writer, at least as currently implemented by structreservation_object.Quoted 2 lines
This was done to allow multiple engines (3D, DMA, Compute) to compose a buffer while still allow compatibility with protocols like DRI2/DRI3.
Quoted 6 lines
Quoted 3 lines
Instead of the current solution you need to stop attaching exclusive fences to non-shared buffers (which are coordinated using the driver-private explicit fencing you're describing),
Err, the current issue is actually that amdgpu never sets an exclusive fence, only ever shared ones. :)
Well since you sometimes sync and sometimes not sync it is kinda a special case of semi-exclusive fence (even if attached to the shared slots).
Quoted 7 lines
Quoted 3 lines
and only attach exclusive fences to shared buffers (DRI2/3, PRIME, whatever).
Still, it occurred to me in the meantime that amdgpu setting the exclusive fence for buffers shared via PRIME (no matter if it's a write or read operation) might be a solution. Christian, what do you think?
Yup, that's what I mean. And it shouldn't cause a problem since for shared buffers (at least for protocols where implicit fencing is required), since for those you really can't have multiple concurrent writers. And with the special checks in amdgpu_sync.c that's what's happening in reality, only difference is that the filtering/selection of what is considered and exclusive fences happens when you sync, and not when you attach them. And that breaks reservation_object assumptions.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines · Christian König
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
FWIW, we seem to have the same issue with radeon vs. amdgpu: radeon only seems to wait for exclusive fences, so e.g. running Xorg on amdgpu and using PRIME slave scanout on radeon leaves artifacts.
Yeah, I know. See
radeon_display.cradeon_flip_work_func().We pretty much need the same patch here I've done for amdgpu as well.
Actually, the PRIME slave can't scan out from the shared BOs directly (recall the recent discussion we had about that with Mario), but has to copy from the shared BO to a dedicated scanout BO. These copies need to be synchronized with the primary GPU's copies to the shared BO.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): f0e034f9-db22-6577-97c7-dd8d3e851226-otUistvHUpPR7s880joybQ@public.gmane.org
Am 21.09.2016 um 17:13 schrieb Michel Dänzer:
Quoted 5 lines · Christian König
Quoted 4 lines
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 3 lines
FWIW, we seem to have the same issue with radeon vs. amdgpu: radeon only seems to wait for exclusive fences, so e.g. running Xorg on amdgpu and using PRIME slave scanout on radeon leaves artifacts.
Quoted 7 lines
Quoted 3 lines
Yeah, I know. See
radeon_display.cradeon_flip_work_func().We pretty much need the same patch here I've done for amdgpu as well.
Actually, the PRIME slave can't scan out from the shared BOs directly (recall the recent discussion we had about that with Mario), but has to copy from the shared BO to a dedicated scanout BO. These copies need to be synchronized with the primary GPU's copies to the shared BO.
Yeah, that thought came to my mind before as well.
Buffer migrations by the kernel caused by a prime export actually set the exclusive fence.
So this shouldn't be an issue in practice when the displaying GPU needs to copy from the BO again anyway.
The only case I can see when this can happen is when the BO is composed directly in system memory by the engines and not migrated there.
Could be that we run into this issue more often in the future, because that is pretty much what we want to have for 4K UVD decode.
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 17 lines · Christian König
Am 21.09.2016 um 17:13 schrieb Michel Dänzer:
Quoted 6 lines · Christian König
Quoted 5 lines
Am 21.09.2016 um 11:56 schrieb Michel Dänzer:
Quoted 4 lines
FWIW, we seem to have the same issue with radeon vs. amdgpu: radeon only
seems to wait for exclusive fences, so e.g. running Xorg on amdgpu and using PRIME slave scanout on radeon leaves artifacts.Quoted 7 lines
Quoted 3 lines
Yeah, I know. See
radeon_display.cradeon_flip_work_func().We pretty much need the same patch here I've done for amdgpu as well.
Actually, the PRIME slave can't scan out from the shared BOs directly (recall the recent discussion we had about that with Mario), but has to copy from the shared BO to a dedicated scanout BO. These copies need to be synchronized with the primary GPU's copies to the shared BO.
Yeah, that thought came to my mind before as well.
Quoted 8 lines
Buffer migrations by the kernel caused by a prime export actually set the exclusive fence.
So this shouldn't be an issue in practice when the displaying GPU needs to copy from the BO again anyway.
The only case I can see when this can happen is when the BO is composed directly in system memory by the engines and not migrated there.
There is no migration going on in the steady state, just the primary GPU writing to the shared BO and the slave GPU reading from it. If those operations aren't properly synchronized, there is at least intermittent tearing, but there can even be artifacts which stay until that area is updated again.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel