<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, 19 Feb 2018 at 13:58 Christian König <<a href="mailto:ckoenig.leichtzumerken@gmail.com" target="_blank">ckoenig.leichtzumerken@gmail.<wbr>com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">To be able to use DRI_PRIME with amdgpu and i915 we add all our fences<br>
only as exclusive ones.<br>
<br>
Disable that behavior when sharing between amdgpu itself cause it<br>
hinders concurrent execution.<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_prime.c | 31 ++++++++++++++++++++----------<wbr>-<br>
 1 file changed, 20 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_prime.c<br>
index f6d7f6404a07..8ce74a1d9966 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_prime.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/<wbr>amdgpu_prime.c<br>
@@ -30,6 +30,8 @@<br>
 #include <drm/amdgpu_drm.h><br>
 #include <linux/dma-buf.h><br>
<br>
+static const struct dma_buf_ops amdgpu_dmabuf_ops;<br>
+<br>
 struct sg_table *amdgpu_gem_prime_get_sg_<wbr>table(struct drm_gem_object *obj)<br>
 {<br>
        struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);<br>
@@ -129,20 +131,27 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,<br>
        if (unlikely(r != 0))<br>
                goto error_detach;<br>
<br>
-       /*<br>
-        * Wait for all shared fences to complete before we switch to future<br>
-        * use of exclusive fence on this prime shared bo.<br>
-        */<br>
-       r = reservation_object_wait_<wbr>timeout_rcu(bo->tbo.resv, true, false,<br>
-                                               MAX_SCHEDULE_TIMEOUT);<br>
-       if (unlikely(r < 0)) {<br>
-               DRM_DEBUG_PRIME("Fence wait failed: %li\n", r);<br>
-               goto error_unreserve;<br>
+<br>
+       if (dma_buf->ops != &amdgpu_dmabuf_ops) {<br>
+               /*<br>
+                * Wait for all shared fences to complete before we switch to future<br>
+                * use of exclusive fence on this prime shared bo.<br>
+                */<br>
+               r = reservation_object_wait_<wbr>timeout_rcu(bo->tbo.resv,<br>
+                                                       true, false,<br>
+                                                       MAX_SCHEDULE_TIMEOUT);<br>
+               if (unlikely(r < 0)) {<br>
+                       DRM_DEBUG_PRIME("Fence wait failed: %li\n", r);<br>
+                       goto error_unreserve;<br>
+               }<br>
        }<br>
<br>
        /* pin buffer into GTT */<br>
        r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT, NULL);<br>
-       if (likely(r == 0))<br>
+       if (r)<br>
+               goto error_unreserve;<br>
+<br>
+       if (dma_buf->ops != &amdgpu_dmabuf_ops)<br>
                bo->prime_shared_count++;<br>
<br>
 error_unreserve:<br>
@@ -166,7 +175,7 @@ static void amdgpu_gem_map_detach(struct dma_buf *dma_buf,<br>
                goto error;<br>
<br>
        amdgpu_bo_unpin(bo);<br>
-       if (bo->prime_shared_count)<br>
+       if (dma_buf->ops != &amdgpu_dmabuf_ops && bo->prime_shared_count)<br>
                bo->prime_shared_count--;<br>
        amdgpu_bo_unreserve(bo);<br>
<br>
--<br>
2.14.1<br>
<br>
______________________________<wbr>_________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a></blockquote><div><br></div><div>Hi</div><div><br></div><div>This patch causes tearing / stuttering on my i915/amdgpu prime setup</div><div><br></div><div>Reverting this patch and some of  "[PATCH 3/3] drm/amdgpu: further mitigate workaround for i915" to get it to compile, gets things working again</div><div><br></div><div>Sorry for not noticing this sooner</div><div><br></div><div>Let me know if you'd like me to test any follow up patches</div><div><br></div><div>Cheers</div><div><br></div><div>Mike</div></div></div>