drm/amdgpu: Initialise drm_gem_object_funcs for imported BOs
Subsystems (2)
PATCH 1/1 drm/amdgpu: Initialise drm_gem_object_funcs for imported BOs
For BOs imported from outside of amdgpu, setting of amdgpu_gem_object_funcs was missing in amdgpu_dma_buf_create_obj. Fix by refactoring BO creation and amdgpu_gem_object_funcs setting into single function called from both code paths.
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from struct drm_driver
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++ 3 files changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +6 -7
@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj,return buf; } +/** * amdgpu_dma_buf_create_obj - create BO for DMA-buf import *
@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)struct amdgpu_device *adev =drm_to_adev (dev);struct amdgpu_bo *bo;struct amdgpu_bo_param bp; -int ret; +struct drm_gem_object *obj;memset (&bp,0 ,sizeof (bp)); bp.size = dma_buf->size;
@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv;dma_resv_lock (resv,NULL ); - ret =amdgpu_bo_create (adev, &bp, &bo); -if (ret) + obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (obj)) goto error; + bo =gem_to_amdgpu_bo (obj); bo->allowed_domains =AMDGPU_GEM_DOMAIN_GTT ; bo->preferred_domains =AMDGPU_GEM_DOMAIN_GTT ;if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count =1 ; -dma_resv_unlock (resv); -return &bo->tbo.base; - error:dma_resv_unlock (resv); -return ERR_PTR (ret); +return obj; }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +17 -5
@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp) +{ +struct amdgpu_bo *bo; +int r; + + r =amdgpu_bo_create (adev, bp, &bo); +if (r) +return ERR_PTR (r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; +return &bo->tbo.base; +} +int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj) { -struct amdgpu_bo *bo;struct amdgpu_bo_param bp;int r;
@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: bp.flags = flags; bp.domain = initial_domain; - r =amdgpu_bo_create (adev, &bp, &bo); -if (r) { + *obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (*obj)) { + r =PTR_ERR (*obj);if (r != -ERESTARTSYS ) {if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) { flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;
@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, }return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs;return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5 -0
@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns);/* * GEM objects. */ + +struct amdgpu_bo_param ; +void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Andrey Grodzovsky
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driver
from struct drm_driver")
Quoted 12 lines
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++ 3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, · line 408
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +1
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj,return buf; } +
Unrelated whitespace change.
Quoted 43 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +5
-7/** * amdgpu_dma_buf_create_obj - create BO for DMA-buf import * @@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)struct amdgpu_device *adev =drm_to_adev (dev);struct amdgpu_bo *bo;struct amdgpu_bo_param bp; -int ret; +struct drm_gem_object *obj;memset (&bp,0 ,sizeof (bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv;dma_resv_lock (resv,NULL ); - ret =amdgpu_bo_create (adev, &bp, &bo); -if (ret) + obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (obj)) goto error; + bo =gem_to_amdgpu_bo (obj); bo->allowed_domains =AMDGPU_GEM_DOMAIN_GTT ; bo->preferred_domains =AMDGPU_GEM_DOMAIN_GTT ;if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count =1 ; -dma_resv_unlock (resv); -return &bo->tbo.base; - error:dma_resv_unlock (resv); -return ERR_PTR (ret); +return obj; }/** drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static void amdgpu_gem_object_free(struct drm_gem_object *gobj) · line 56
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-0@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp)
Maybe call this amdgpu_gem_object_do_create() for consistency with amdgpu_object.c and other areas of the code.
Quoted 68 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +15
-5+{ +struct amdgpu_bo *bo; +int r; + + r =amdgpu_bo_create (adev, bp, &bo); +if (r) +return ERR_PTR (r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; +return &bo->tbo.base; +} +int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj) { -struct amdgpu_bo *bo;struct amdgpu_bo_param bp;int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: bp.flags = flags; bp.domain = initial_domain; - r =amdgpu_bo_create (adev, &bp, &bo); -if (r) { + *obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (*obj)) { + r =PTR_ERR (*obj);if (r != -ERESTARTSYS ) {if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) { flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, }return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-1@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns);/* * GEM objects. */ + +struct amdgpu_bo_param ; +void amdgpu_gem_force_release (struct amdgpu_device *adev);int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev, --2.7.4
Quoted 4 lines
_______________________________________________
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
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.
Can you outline why we can't use amdgpu_gem_object_create() directly?
I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Thanks,
Christian.
Quoted 123 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++ 3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +6
-7@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj,return buf; } +/** * amdgpu_dma_buf_create_obj - create BO for DMA-buf import * @@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)struct amdgpu_device *adev =drm_to_adev (dev);struct amdgpu_bo *bo;struct amdgpu_bo_param bp; -int ret; +struct drm_gem_object *obj;memset (&bp,0 ,sizeof (bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv;dma_resv_lock (resv,NULL ); - ret =amdgpu_bo_create (adev, &bp, &bo); -if (ret) + obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (obj)) goto error; + bo =gem_to_amdgpu_bo (obj); bo->allowed_domains =AMDGPU_GEM_DOMAIN_GTT ; bo->preferred_domains =AMDGPU_GEM_DOMAIN_GTT ;if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count =1 ; -dma_resv_unlock (resv); -return &bo->tbo.base; - error:dma_resv_unlock (resv); -return ERR_PTR (ret); +return obj; }/** drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +17
-5@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp) +{ +struct amdgpu_bo *bo; +int r; + + r =amdgpu_bo_create (adev, bp, &bo); +if (r) +return ERR_PTR (r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; +return &bo->tbo.base; +} +int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj) { -struct amdgpu_bo *bo;struct amdgpu_bo_param bp;int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: bp.flags = flags; bp.domain = initial_domain; - r =amdgpu_bo_create (adev, &bp, &bo); -if (r) { + *obj =amdgpu_gem_object_create_raw (adev, &bp); +if (IS_ERR (*obj)) { + r =PTR_ERR (*obj);if (r != -ERESTARTSYS ) {if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ) { flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED ;@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, }return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +3
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns);/* * GEM objects. */ + +struct amdgpu_bo_param ; +void amdgpu_gem_force_release (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); · line 54
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +2
-0int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size,int alignment,u32 initial_domain,u64 flags,enum ttm_bo_type type,struct dma_resv *resv,struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, +struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines · Christian König
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to amdgpu_gem_object_create to reflect this difference which clutters even more the already cluttered argument list. Regarding the extra error handling - you have the 'retry' dance in amdgpu_gem_object_create which jumps back to the middle of amdgpu_bo_param initialization but you don't have it in amdgpu_dma_buf_create_obj which also complicates the reuse of amdgpu_gem_object_create as is.
Andrey
Quoted 125 lines
Thanks,
Christian.Quoted 121 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev,unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +3
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size,
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); · line 54
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +2
-0int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 8 lines · Christian König
Quoted 6 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.
Quoted 7 lines
Quoted 3 lines
Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.
That should be outside of the call to amdgpu_gem_object_create(), similar to how it is outside of the amdgpu_bo_create currently.
Quoted 2 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.
Regarding the extra error handling, that kicks in only when AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED is specified as flags or AMDGPU_GEM_DOMAIN_VRAM as initial domain. Neither is the case here.
Christian.
Quoted 141 lines
Andrey
Quoted 137 lines
Thanks,
Christian.Quoted 132 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22
+++++++++++++++++-----
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv,struct
drm_device*dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 11 lines · Christian König
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 10 lines · Christian König
Quoted 8 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.
So you agree we have to add another argument to amdgpu_gem_object_create (e.g. u32 preferred_domain) which will be 0 for amdgpu_dma_buf_create_obj and equal to initial_domain for all the code path currently calling amdgpu_gem_object_create ?
Quoted 5 lines
Quoted 3 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.
Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Andrey
Quoted 143 lines
Christian.
Quoted 139 lines
Andrey
Quoted 135 lines
Thanks,
Christian.Quoted 130 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev,unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerAm 08.12.20 um 19:44 schrieb Andrey Grodzovsky:
Quoted 16 lines · Christian König
Quoted 14 lines
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.So you agree we have to add another argument to
amdgpu_gem_object_create(e.g. u32preferred_domain) which will be 0 foramdgpu_dma_buf_create_objand equal toinitial_domainfor all the code path currently callingamdgpu_gem_object_create?
No, I just don't see the need for that. We need to overwrite the preferred domain after the function call anyway.
DMA-buf imports are created with the initial domain CPU and then get that overwritten to GTT after creation.
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Yeah, ok that is a rather good argument.
Christian.
Quoted 149 lines
Andrey
Quoted 145 lines
Christian.
Quoted 141 lines
Andrey
Quoted 137 lines
Thanks,
Christian.Quoted 132 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22
+++++++++++++++++-----
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv,struct
drm_device*dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 36 lines · Christian König
Am 08.12.20 um 19:44 schrieb Andrey Grodzovsky:
Quoted 16 lines · Christian König
Quoted 14 lines
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.So you agree we have to add another argument to
amdgpu_gem_object_create(e.g. u32preferred_domain) which will be 0 foramdgpu_dma_buf_create_objand equal toinitial_domainfor all the code path currently callingamdgpu_gem_object_create?No, I just don't see the need for that. We need to overwrite the preferred domain after the function call anyway.
DMA-buf imports are created with the initial domain CPU and then get that overwritten to GTT after creation.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Yeah, ok that is a rather good argument.
Christian.
So should I just keep it as is or you think it's still would be more beneficial to unify them the way you propose ?
Andrey
Quoted 140 lines
Quoted 140 lines
Andrey
Quoted 135 lines
Christian.
Quoted 132 lines
Andrey
Quoted 128 lines
Thanks,
Christian.Quoted 124 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +3
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv,
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); · line 54
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +2
-0struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerAm 08.12.20 um 19:52 schrieb Andrey Grodzovsky:
Quoted 41 lines · Christian König
Quoted 39 lines
Am 08.12.20 um 19:44 schrieb Andrey Grodzovsky:
Quoted 16 lines · Christian König
Quoted 14 lines
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.So you agree we have to add another argument to
amdgpu_gem_object_create(e.g. u32preferred_domain) which will be 0 foramdgpu_dma_buf_create_objand equal toinitial_domainfor all the code path currently callingamdgpu_gem_object_create?No, I just don't see the need for that. We need to overwrite the preferred domain after the function call anyway.
DMA-buf imports are created with the initial domain CPU and then get that overwritten to GTT after creation.
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Yeah, ok that is a rather good argument.
Christian.
So should I just keep it as is or you think it's still would be more beneficial to unify them the way you propose ?
Maybe we should move the error handling into amdgpu_gem_create_ioctl() anyway.
We don't really want that handling in the userptr stuff and for the call from amdgpufb_create_pinned_object() that is actually a bug!
E.g. for the fb emulation we can't fall back from VRAM to GTT like in the create ioctl.
Christian.
Quoted 155 lines
Andrey
Quoted 151 lines
Quoted 150 lines
Andrey
Quoted 145 lines
Christian.
Quoted 141 lines
Andrey
Quoted 137 lines
Thanks,
Christian.Quoted 132 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22
+++++++++++++++++-----
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv,struct
drm_device*dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 49 lines · Christian König
Am 08.12.20 um 19:52 schrieb Andrey Grodzovsky:
Quoted 48 lines · Christian König
Quoted 44 lines
Am 08.12.20 um 19:44 schrieb Andrey Grodzovsky:
Quoted 16 lines · Christian König
Quoted 14 lines
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.So you agree we have to add another argument to
amdgpu_gem_object_create(e.g. u32preferred_domain) which will be 0 foramdgpu_dma_buf_create_objand equal toinitial_domainfor all the code path currently callingamdgpu_gem_object_create?No, I just don't see the need for that. We need to overwrite the preferred domain after the function call anyway.
DMA-buf imports are created with the initial domain CPU and then get that overwritten to GTT after creation.
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Yeah, ok that is a rather good argument.
Christian.
Quoted 7 lines
Quoted 1 line
So should I just keep it as is or you think it's still would be more beneficial to unify them the way you propose ?
Maybe we should move the error handling into
amdgpu_gem_create_ioctl()anyway.We don't really want that handling in the userptr stuff and for the call from
amdgpufb_create_pinned_object()that is actually a bug!E.g. for the fb emulation we can't fall back from VRAM to GTT like in the create ioctl.
What about amdgpu_mode_dumb_create, seems like there GTT domain is also relevant and so the error handling would be needed there too.
Andrey
Quoted 157 lines
Christian.
Quoted 153 lines
Andrey
Quoted 149 lines
Quoted 148 lines
Andrey
Quoted 143 lines
Christian.
Quoted 139 lines
Andrey
Quoted 135 lines
Thanks,
Christian.Quoted 130 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(structdrm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 08.12.20 um 20:11 schrieb Andrey Grodzovsky:
Quoted 53 lines · Christian König
Quoted 51 lines
Am 08.12.20 um 19:52 schrieb Andrey Grodzovsky:
Quoted 49 lines · Christian König
Quoted 36 lines
Am 08.12.20 um 19:44 schrieb Andrey Grodzovsky:
Quoted 16 lines · Christian König
Quoted 14 lines
Am 08.12.20 um 19:26 schrieb Andrey Grodzovsky:
Quoted 13 lines · Christian König
Quoted 9 lines
Am 08.12.20 um 18:10 schrieb Andrey Grodzovsky:
Quoted 4 lines
For BOs imported from outside of amdgpu, setting of
amdgpu_gem_object_funcswas missing inamdgpu_dma_buf_create_obj. Fix by refactoring BO creation andamdgpu_gem_object_funcssetting into single function called from both code paths.Can you outline why we can't use
amdgpu_gem_object_create()directly?I mean we have a bit of extra error handling in there and we need to grab the resv lock and set the domains after creation, but that shouldn't matter and I don't see why that should not work.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
On top of what you mentioned you also have bp.domain/bp.preferred_domain being set differently so you need to add another argument to
amdgpu_gem_object_createto reflect this difference which clutters even more the already cluttered argument list.That should be outside of the call to
amdgpu_gem_object_create(), similar to how it is outside of theamdgpu_bo_createcurrently.So you agree we have to add another argument to
amdgpu_gem_object_create(e.g. u32preferred_domain) which will be 0 foramdgpu_dma_buf_create_objand equal toinitial_domainfor all the code path currently callingamdgpu_gem_object_create?No, I just don't see the need for that. We need to overwrite the preferred domain after the function call anyway.
DMA-buf imports are created with the initial domain CPU and then get that overwritten to GTT after creation.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Regarding the extra error handling - you have the 'retry' dance in
amdgpu_gem_object_createwhich jumps back to the middle ofamdgpu_bo_paraminitialization but you don't have it inamdgpu_dma_buf_create_objwhich also complicates the reuse ofamdgpu_gem_object_createas is.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Regarding the extra error handling, that kicks in only when
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIREDis specified as flags orAMDGPU_GEM_DOMAIN_VRAMas initial domain. Neither is the case here.Yes, still, it makes me a bit uncomfortable relying on internal implementation details of an API function I call to do the thing I expect.
Yeah, ok that is a rather good argument.
Christian.
So should I just keep it as is or you think it's still would be more beneficial to unify them the way you propose ?
Quoted 8 lines
Quoted 5 lines
Maybe we should move the error handling into
amdgpu_gem_create_ioctl()anyway.We don't really want that handling in the userptr stuff and for the call from
amdgpufb_create_pinned_object()that is actually a bug!E.g. for the fb emulation we can't fall back from VRAM to GTT like in the create ioctl.
What about
amdgpu_mode_dumb_create, seems like there GTT domain is also relevant and so the error handling would be needed there too.
Nope, same thing as with the fb emulation:
Quoted 2 lines
domain =
amdgpu_bo_get_preferred_pin_domain(adev, amdgpu_display_supported_domains(adev, flags));
This BO is created for scanout, falling back to GTT because we don't have enough memory or clearing the CPU access flag is most likely a bug here.
Christian.
Quoted 163 lines
Andrey
Quoted 159 lines
Christian.
Quoted 155 lines
Andrey
Quoted 151 lines
Quoted 150 lines
Andrey
Quoted 145 lines
Christian.
Quoted 141 lines
Andrey
Quoted 137 lines
Thanks,
Christian.Quoted 132 lines
This fixes null ptr regression casued by commit
d693def drm: Remove obsolete GEM and PRIME callbacks from structdrm_driverSigned-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c| 13 ++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 22
+++++++++++++++++-----
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 5 +++++3 files changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +0
-0@@ -405,6 +405,7 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_gem_object *gobj, return buf; }+
/**
*amdgpu_dma_buf_create_obj- create BO for DMA-buf import *drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3
-5@@ -424,7 +425,7 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) struct amdgpu_device *adev = drm_to_adev(dev); struct amdgpu_bo *bo; struct amdgpu_bo_param bp; - int ret; + struct drm_gem_object *obj; memset(&bp, 0, sizeof(bp)); bp.size = dma_buf->size;@@ -434,21 +435,19 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf) bp.type = ttm_bo_type_sg; bp.resv = resv; dma_resv_lock(resv, NULL); - ret = amdgpu_bo_create(adev, &bp, &bo); - if (ret) + obj = amdgpu_gem_object_create_raw(adev, &bp); + if (IS_ERR(obj)) goto error; + bo = gem_to_amdgpu_bo(obj); bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; if (dma_buf->ops != &amdgpu_dmabuf_ops) bo->prime_shared_count = 1; - dma_resv_unlock(resv); - return &bo->tbo.base; -error:
dma_resv_unlock(resv);
- returnERR_PTR(ret);
+ return obj;
}
/**drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13
-1@@ -52,13 +52,26 @@ static void amdgpu_gem_object_free(struct drm_gem_object *gobj) } } +struct drm_gem_object *amdgpu_gem_object_create_raw(struct amdgpu_device *adev, + struct amdgpu_bo_param *bp) +{ + struct amdgpu_bo *bo; + int r; + + r = amdgpu_bo_create(adev, bp, &bo); + if (r) + return ERR_PTR(r); + + bo->tbo.base.funcs = &amdgpu_gem_object_funcs; + return &bo->tbo.base; +} + int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj) { - struct amdgpu_bo *bo; struct amdgpu_bo_param bp; int r;@@ -73,8 +86,9 @@ int amdgpu_gem_object_create(struct
amdgpu_device*adev, unsigned long size, retry:
bp.flags = flags;
bp.domain =initial_domain;
- r =amdgpu_bo_create(adev, &bp, &bo);
- if (r) {
+ *obj =amdgpu_gem_object_create_raw(adev, &bp);
+ if (IS_ERR(*obj)) {
+ r =PTR_ERR(*obj);
if (r !=-ERESTARTSYS) {
if (flags &AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED) {
flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -90,8 +104,6 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &bo->tbo.base; - (*obj)->funcs = &amdgpu_gem_object_funcs; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h +5
-0@@ -38,12 +38,17 @@ unsigned long amdgpu_gem_timeout(uint64_t timeout_ns); /** GEM objects. */ + +struct amdgpu_bo_param ; + void amdgpu_gem_force_release(struct amdgpu_device *adev); int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, int alignment, u32 initial_domain, u64 flags, enum ttm_bo_type type, struct dma_resv *resv, struct drm_gem_object **obj); +struct drm_gem_object *amdgpu_gem_object_create_raw (struct amdgpu_device *adev, + struct amdgpu_bo_param *bp); int amdgpu_mode_dumb_create(struct drm_file *file_priv,struct
drm_device*dev,
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