drm/amdgpu: implement amdgpu_gem_map_(attach/detach)
Subsystems (2)
PATCH 1/2 drm/amdgpu: implement amdgpu_gem_map_(attach/detach)
Instead of the pin/unpin callback implement the attach/detach ones.
Functional identical, but allows us access to the attachment.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 52 ++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -2
@@ -393,8 +393,6 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, int flags);struct drm_gem_object *amdgpu_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf); -int amdgpu_gem_prime_pin (struct drm_gem_object *obj); -void amdgpu_gem_prime_unpin (struct drm_gem_object *obj);struct reservation_object *amdgpu_gem_prime_res_obj (struct drm_gem_object *);void *amdgpu_gem_prime_vmap (struct drm_gem_object *obj);void amdgpu_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
@@ -885,8 +885,6 @@ static struct drm_driver kms_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = amdgpu_gem_prime_export, .gem_prime_import = amdgpu_gem_prime_import, - .gem_prime_pin = amdgpu_gem_prime_pin, - .gem_prime_unpin = amdgpu_gem_prime_unpin, .gem_prime_res_obj = amdgpu_gem_prime_res_obj, .gem_prime_get_sg_table = amdgpu_gem_prime_get_sg_table, .gem_prime_import_sg_table = amdgpu_gem_prime_import_sg_table,
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +34 -18
91 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ 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): 20180219135755.1714-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: mitigate workaround for i915
To be able to use DRI_PRIME with amdgpu and i915 we add all our fences only as exclusive ones.
Disable that behavior when sharing between amdgpu itself cause it hinders concurrent execution.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +20 -11
@@ -30,6 +30,8 @@#include <drm/amdgpu_drm.h> #include <linux/dma-buf.h> +static const struct dma_buf_ops amdgpu_dmabuf_ops; +struct sg_table *amdgpu_gem_prime_get_sg_table (struct drm_gem_object *obj) {struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj);
@@ -129,20 +131,27 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,if (unlikely (r !=0 )) goto error_detach; -/* -* Wait for all shared fences to complete before we switch to future -* use of exclusive fence on this prime shared bo. -*/ - r =reservation_object_wait_timeout_rcu (bo->tbo.resv, true, false, -MAX_SCHEDULE_TIMEOUT ); -if (unlikely (r <0 )) { -DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); - goto error_unreserve; + +if (dma_buf->ops != &amdgpu_dmabuf_ops) { +/* +* Wait for all shared fences to complete before we switch to future +* use of exclusive fence on this prime shared bo. +*/ + r =reservation_object_wait_timeout_rcu (bo->tbo.resv, + true, false, +MAX_SCHEDULE_TIMEOUT ); +if (unlikely (r <0 )) { +DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); + goto error_unreserve; + } }/* pin buffer into GTT */ r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); -if (likely (r ==0 )) +if (r) + goto error_unreserve; + +if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count++; error_unreserve:
@@ -166,7 +175,7 @@ static void amdgpu_gem_map_detach(struct dma_buf *dma_buf, goto error;amdgpu_bo_unpin (bo); -if (bo->prime_shared_count) +if (dma_buf->ops != &amdgpu_dmabuf_ops && bo->prime_shared_count) bo->prime_shared_count--;amdgpu_bo_unreserve (bo);
Signature · 6 lines
2.14.1 _______________________________________________ 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): 20180219135755.1714-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: mitigate workaround for i915
Quoted 82 lines · On Mon, 19 Feb 2018 at 13:58 Christian König <ckoenig.leichtzumerken@gmail.…
To be able to use
DRI_PRIMEwith amdgpu and i915 we add all our fences only as exclusive ones.Disable that behavior when sharing between amdgpu itself cause it hinders concurrent execution.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +2
-0@@ -30,6 +30,8 @@#include <drm/amdgpu_drm.h> #include <linux/dma-buf.h> +static const struct dma_buf_ops amdgpu_dmabuf_ops; +struct sg_table *amdgpu_gem_prime_get_sg_table (struct drm_gem_object *obj) {struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +0
-2@@ -129,20 +131,27 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf, if (unlikely(r != 0)) goto error_detach; -/* -* Wait for all shared fences to complete before we switch to future
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +4
-7-* use of exclusive fence on this prime shared bo. -*/ - r =reservation_object_wait_timeout_rcu (bo->tbo.resv, true, false, -MAX_SCHEDULE_TIMEOUT ); -if (unlikely (r <0 )) { -DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); - goto error_unreserve; + +if (dma_buf->ops != &amdgpu_dmabuf_ops) { +/* +* Wait for all shared fences to complete before we switch to future
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +14
-3+* use of exclusive fence on this prime shared bo. +*/ + r =reservation_object_wait_timeout_rcu (bo->tbo.resv, + true, false, +MAX_SCHEDULE_TIMEOUT ); +if (unlikely (r <0 )) { +DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); + goto error_unreserve; + } }/* pin buffer into GTT */ r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); -if (likely (r ==0 )) +if (r) + goto error_unreserve; + +if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count++; error_unreserve:@@ -166,7 +175,7 @@ static void amdgpu_gem_map_detach(struct dma_buf *dma_buf, goto error;amdgpu_bo_unpin (bo); -if (bo->prime_shared_count) +if (dma_buf->ops != &amdgpu_dmabuf_ops && bo->prime_shared_count) bo->prime_shared_count--;amdgpu_bo_unreserve (bo); --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi
This patch causes tearing / stuttering on my i915/amdgpu prime setup
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
Sorry for not noticing this sooner
Let me know if you'd like me to test any follow up patches
Cheers
Mike
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Reviewed-byQuoted 5 lines · Christian König
Instead of the pin/unpin callback implement the attach/detach ones.
Functional identical, but allows us access to the attachment.
Signed-off-by Christian König <[email protected]>
Series is:
Quoted 132 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 52 ++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-2@@ -393,8 +393,6 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, int flags);struct drm_gem_object *amdgpu_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf); -int amdgpu_gem_prime_pin (struct drm_gem_object *obj); -void amdgpu_gem_prime_unpin (struct drm_gem_object *obj);struct reservation_object *amdgpu_gem_prime_res_obj (struct drm_gem_object *);void *amdgpu_gem_prime_vmap (struct drm_gem_object *obj);void amdgpu_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr);drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-2@@ -885,8 +885,6 @@ static struct drm_driver kms_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = amdgpu_gem_prime_export, .gem_prime_import = amdgpu_gem_prime_import, - .gem_prime_pin = amdgpu_gem_prime_pin, - .gem_prime_unpin = amdgpu_gem_prime_unpin, .gem_prime_res_obj = amdgpu_gem_prime_res_obj, .gem_prime_get_sg_table = amdgpu_gem_prime_get_sg_table, .gem_prime_import_sg_table = amdgpu_gem_prime_import_sg_table,drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +34
-19@@ -113,49 +113,65 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,return &bo->gem_base; } -int amdgpu_gem_prime_pin (struct drm_gem_object *obj) +static int amdgpu_gem_map_attach (struct dma_buf *dma_buf, +struct device *target_dev, +struct dma_buf_attachment *attach) { +struct drm_gem_object *obj = dma_buf->priv;struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj); -long ret =0 ; +long r; - ret =amdgpu_bo_reserve (bo, false); -if (unlikely (ret !=0 )) -return ret; + r =drm_gem_map_attach (dma_buf, target_dev, attach); +if (r) +return r; + + r =amdgpu_bo_reserve (bo, false); +if (unlikely (r !=0 )) + goto error_detach;/* * Wait for all shared fences to complete before we switch to future * use of exclusive fence on this prime shared bo. */ - ret =reservation_object_wait_timeout_rcu (bo->tbo.resv, true, false, -MAX_SCHEDULE_TIMEOUT ); -if (unlikely (ret <0 )) { -DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , ret); -amdgpu_bo_unreserve (bo); -return ret; + r =reservation_object_wait_timeout_rcu (bo->tbo.resv, true, false, +MAX_SCHEDULE_TIMEOUT ); +if (unlikely (r <0 )) { +DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); + goto error_unreserve; }/* pin buffer into GTT */ - ret =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); -if (likely (ret ==0 )) + r =amdgpu_bo_pin (bo,AMDGPU_GEM_DOMAIN_GTT ,NULL ); +if (likely (r ==0 )) bo->prime_shared_count++; +error_unreserve:amdgpu_bo_unreserve (bo); -return ret; + +error_detach: +if (r) +drm_gem_map_detach (dma_buf, attach); +return r; } -void amdgpu_gem_prime_unpin (struct drm_gem_object *obj) +static void amdgpu_gem_map_detach (struct dma_buf *dma_buf, +struct dma_buf_attachment *attach) { +struct drm_gem_object *obj = dma_buf->priv;struct amdgpu_bo *bo =gem_to_amdgpu_bo (obj);int ret =0 ; ret =amdgpu_bo_reserve (bo, true);if (unlikely (ret !=0 )) -return ; + goto error;amdgpu_bo_unpin (bo);if (bo->prime_shared_count) bo->prime_shared_count--;amdgpu_bo_unreserve (bo); + +error: +drm_gem_map_detach (dma_buf, attach); }struct reservation_object *amdgpu_gem_prime_res_obj (struct drm_gem_object *obj)@@ -194,8 +210,8 @@ static int amdgpu_gem_begin_cpu_access(struct dma_buf *dma_buf, }static const struct dma_buf_ops amdgpu_dmabuf_ops = { - .attach = drm_gem_map_attach, - .detach = drm_gem_map_detach, + .attach = amdgpu_gem_map_attach, + .detach = amdgpu_gem_map_detach, .map_dma_buf = drm_gem_map_dma_buf, .unmap_dma_buf = drm_gem_unmap_dma_buf, .release = drm_gem_dmabuf_release, --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx