drm/amdgpu: restrict userptr even more
Subsystems (3)
PATCH 1/4 drm/amdgpu: restrict userptr even more
From: Christian König <[email protected]>
Don't allow them to be GEM imported into another process.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +6 -0
@@ -112,7 +112,13 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,struct amdgpu_fpriv *fpriv = file_priv->driver_priv;struct amdgpu_vm *vm = &fpriv->vm;struct amdgpu_bo_va *bo_va; +struct mm_struct *mm;int r; + + mm =amdgpu_ttm_tt_get_usermm (abo->tbo.ttm); +if (mm && mm != current->mm) +return -EPERM ; + r =amdgpu_bo_reserve (abo, false);if (r)return r;
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1504026462-1788-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/4 drm/amdgpu: add support for per VM BOs v2
From: Christian König <[email protected]>
Per VM BOs are handled like VM PDs and PTs. They are always valid and don't need to be specified in the BO lists.
v2: validate PDs/PTs first
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 79 ++++++++++++++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ++- 3 files changed, 60 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -813,7 +813,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p) } - r =amdgpu_vm_clear_moved (adev, vm, &p->job->sync); + r =amdgpu_vm_handle_moved (adev, vm, &p->job->sync);if (amdgpu_vm_debug && p->bo_list) {/* Invalidate all BOs to test for userspace bugs */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +56 -23
147 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3 -2
@@ -249,8 +249,9 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev,int amdgpu_vm_clear_freed (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct dma_fence **fence); -int amdgpu_vm_clear_moved (struct amdgpu_device *adev,struct amdgpu_vm *vm, -struct amdgpu_sync *sync); +int amdgpu_vm_handle_moved (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct amdgpu_sync *sync);int amdgpu_vm_bo_update (struct amdgpu_device *adev,struct amdgpu_bo_va *bo_va,bool clear);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: add IOCTL interface for per VM BOs v2
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Add the IOCTL interface so that applications can allocate per VM BOs.
Still WIP since not all corner cases are tested yet, but this reduces average CS overhead for 10K BOs from 21ms down to 48us.
v2: add some extra checks, remove the WIP tag
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 63 ++++++++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 3 +- include/uapi/drm/amdgpu_drm.h | 2 + 5 files changed, 55 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -3
@@ -457,9 +457,10 @@ struct amdgpu_sa_bo {*/ 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,bool kernel, -struct drm_gem_object **obj); +int alignment,u32 initial_domain, +u64 flags,bool kernel, +struct reservation_object *resv, +struct drm_gem_object **obj); int amdgpu_mode_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1 -1
@@ -144,7 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |AMDGPU_GEM_CREATE_VRAM_CLEARED , - true, &gobj); + true, NULL, &gobj);if (ret) {pr_err ("failed to allocate framebuffer (%d)\n" , aligned_size);return -ENOMEM ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +46 -17
171 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +2 -1
@@ -136,7 +136,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, {struct amdgpu_bo *bo =gem_to_amdgpu_bo (gobj); -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) +if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm) || + bo->flags &AMDGPU_GEM_CREATE_LOCAL )return ERR_PTR (-EPERM );return drm_gem_prime_export (dev, gobj, flags);
include/uapi/drm/amdgpu_drm.h +2 -0
@@ -89,6 +89,8 @@ extern "C" {#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)/* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)struct drm_amdgpu_gem_create_in {/** the requested memory size */
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1504026462-1788-3-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
RE: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Quoted 301 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Tuesday, August 29, 2017 1:08 PM
To: [email protected]
Subject: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2From: Christian König <[email protected]>
Add the IOCTL interface so that applications can allocate per VM BOs.
Still WIP since not all corner cases are tested yet, but this reduces average CS overhead for 10K BOs from 21ms down to 48us.
v2: add some extra checks, remove the WIP tag
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 63 ++++++++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 3 +- include/uapi/drm/amdgpu_drm.h | 2 + 5 files changed, 55 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-3@@ -457,9 +457,10 @@ struct amdgpu_sa_bo {*/ 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,bool kernel, -struct drm_gem_object **obj); +int alignment,u32 initial_domain, +u64 flags,bool kernel, +struct reservation_object *resv, +struct drm_gem_object **obj); int amdgpu_mode_dumb_create(struct drm_file *file_priv,drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0struct drm_device *dev,drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +0
-0@@ -144,7 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED|
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS|
AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-1- true, &gobj); + true, NULL, &gobj);if (ret) {pr_err ("failed to allocate framebuffer (%d)\n" , aligned_size);return -ENOMEM ;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5
-4@@ -44,11 +44,12 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj) }int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, -u64 flags,bool kernel, -struct drm_gem_object **obj) +int alignment,u32 initial_domain, +u64 flags,bool kernel, +struct reservation_object *resv, +struct drm_gem_object **obj) { -struct amdgpu_bo *robj; +struct amdgpu_bo *bo;int r;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1*obj =NULL ;@@ -59,7 +60,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: r =amdgpu_bo_create (adev, size, alignment, kernel, initial_domain, - flags,NULL ,NULL ,0 , &robj); + flags,NULL , resv,0 , &bo);if (r) {if (r != -ERESTARTSYS ) {if (
initial_domain==AMDGPU_GEM_DOMAIN_VRAM) {drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1@@ -71,7 +72,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &robj->gem_base; + *obj = &bo->gem_base;return 0 ;}
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-0@@ -119,6 +120,10 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, if (mm && mm != current->mm) return -EPERM; +if (abo->flags &AMDGPU_GEM_CREATE_LOCAL && + abo->tbo.resv != vm->root.base.bo->tbo.resv) +return -EPERM ; + r =amdgpu_bo_reserve (abo, false);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1return r;@@ -142,13 +147,14 @@ void amdgpu_gem_object_close(structdrm_gem_object *obj, struct amdgpu_vm *vm = &fpriv->vm;struct amdgpu_bo_list_entry vm_pd; -struct list_head list; +struct list_head list, duplicates;struct ttm_validate_buffer tv;struct ww_acquire_ctx ticket;struct amdgpu_bo_va *bo_va;int r;INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); tv.bo = &bo->tbo;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1tv.shared = true;@@ -156,7 +162,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,amdgpu_vm_get_pd_bo (vm, &list, &vm_pd); - r =ttm_eu_reserve_buffers (&ticket, &list, false,NULL ); + r =ttm_eu_reserve_buffers (&ticket, &list, false, &duplicates);if (r) { dev_err(adev->dev, "leaking bo va because "drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0"we fail to reserve bo (%d)\n", r);@@ -191,9 +197,12 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) {struct amdgpu_device *adev = dev->dev_private; +struct amdgpu_fpriv *fpriv = filp->driver_priv; +struct amdgpu_vm *vm = &fpriv->vm;union drm_amdgpu_gem_create *args = data;uint64_t flags = args->in.domain_flags;uint64_t size = args->in.bo_size; +struct reservation_object *resv =NULL ;struct drm_gem_object *gobj;uint32_t handle;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1int r;@@ -202,7 +211,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_NO_CPU_ACCESS |AMDGPU_GEM_CREATE_CPU_GTT_USWC | -AMDGPU_GEM_CREATE_VRAM_CLEARED )) +AMDGPU_GEM_CREATE_VRAM_CLEARED | +AMDGPU_GEM_CREATE_LOCAL )) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +17
-1/* reject invalid gem domains */ @@ -229,9 +239,25 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, } size =roundup (size,PAGE_SIZE ); +if (flags &AMDGPU_GEM_CREATE_LOCAL ) { + r =amdgpu_bo_reserve (vm->root.base.bo, false); +if (r) +return r; + + resv = vm->root.base.bo->tbo.resv; + } + r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), - flags, false, &gobj); + flags, false, resv, &gobj); +if (flags &AMDGPU_GEM_CREATE_LOCAL ) { +if (!r) { +struct amdgpu_bo *abo =gem_to_amdgpu_bo (gobj); + + abo->parent =amdgpu_bo_ref (vm->root.base.bo); + } +amdgpu_bo_unreserve (vm->root.base.bo); + }if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-3return r;@@ -273,9 +299,8 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, }/* create a gem object to contain this object in */ - r =amdgpu_gem_object_create (adev, args->size,0 , -AMDGPU_GEM_DOMAIN_CPU ,0 , -0 , &gobj); + r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +0 ,0 ,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1return r;@@ -527,7 +552,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, struct amdgpu_bo_list_entry vm_pd;struct ttm_validate_buffer tv;struct ww_acquire_ctx ticket; -struct list_head list; +struct list_head list, duplicates;uint64_t va_flags;int r =0 ;@@ -563,6 +588,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, }INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates);if ((args->operation !=AMDGPU_VA_OP_CLEAR ) && !(args->flags &AMDGPU_VM_PAGE_PRT )) {drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1gobj =drm_gem_object_lookup (filp, args->handle);@@ -579,7 +605,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd); - r =ttm_eu_reserve_buffers (&ticket, &list, true,NULL ); + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates);if (r) goto error_unref;@@ -645,6 +671,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { + struct amdgpu_device *adev = dev->dev_private;struct drm_amdgpu_gem_op *args = data;struct drm_gem_object *gobj;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0struct amdgpu_bo *robj;@@ -692,6 +719,9 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, if (robj->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM) robj->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; +if (robj->flags &AMDGPU_GEM_CREATE_LOCAL ) +amdgpu_vm_bo_invalidate (adev, robj, true); +drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-2amdgpu_bo_unreserve (robj);break ;default :@@ -721,8 +751,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , - ttm_bo_type_device, - &gobj); + false,NULL , &gobj);if (r)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0return -ENOMEM ;drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +2
-1@@ -136,7 +136,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, {struct amdgpu_bo *bo =gem_to_amdgpu_bo (gobj); -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) +if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm) || + bo->flags &AMDGPU_GEM_CREATE_LOCAL )return ERR_PTR (-EPERM );drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +0
-0return drm_gem_prime_export (dev, gobj, flags);include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h extern "C" { · line 93
Quoted 5 lines
include/uapi/drm/amdgpu_drm.h +2
-0@@ -89,6 +89,8 @@ extern "C" {#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)/* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)
I'm not crazy about the name LOCAL. Maybe something like ALWAYS_VALID?
Alex
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +0
-1struct drm_amdgpu_gem_create_in {/** the requested memory size */ --2.7.4
_______________________________________________
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
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB16532A33114CD81C3389D05EF79F0-rpdhrqHFk06apTa93KjAaQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 294 lines
Quoted 294 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Tuesday, August 29, 2017 1:08 PM
To: [email protected]
Subject: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2From: Christian König <[email protected]>
Add the IOCTL interface so that applications can allocate per VM BOs.
Still WIP since not all corner cases are tested yet, but this reduces average CS overhead for 10K BOs from 21ms down to 48us.
v2: add some extra checks, remove the WIP tag
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 63 ++++++++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 3 +- include/uapi/drm/amdgpu_drm.h | 2 + 5 files changed, 55 insertions(+), 22 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +4
-3@@ -457,9 +457,10 @@ struct amdgpu_sa_bo {*/ 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,bool kernel, -struct drm_gem_object **obj); +int alignment,u32 initial_domain, +u64 flags,bool kernel, +struct reservation_object *resv, +struct drm_gem_object **obj); int amdgpu_mode_dumb_create(struct drm_file *file_priv,struct
drm_device*dev,drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +0
-0@@ -144,7 +144,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED|
AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS|
AMDGPU_GEM_CREATE_VRAM_CLEARED,drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +1
-1- true, &gobj); + true, NULL, &gobj);if (ret) {pr_err ("failed to allocate framebuffer (%d)\n" , aligned_size);return -ENOMEM ;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5
-4@@ -44,11 +44,12 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj) }int amdgpu_gem_object_create (struct amdgpu_device *adev,unsigned long size, -int alignment,u32 initial_domain, -u64 flags,bool kernel, -struct drm_gem_object **obj) +int alignment,u32 initial_domain, +u64 flags,bool kernel, +struct reservation_object *resv, +struct drm_gem_object **obj) { -struct amdgpu_bo *robj; +struct amdgpu_bo *bo;int r;*obj = NULL;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1@@ -59,7 +60,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, retry: r =amdgpu_bo_create (adev, size, alignment, kernel, initial_domain, - flags,NULL ,NULL ,0 , &robj); + flags,NULL , resv,0 , &bo);if (r) {if (r != -ERESTARTSYS ) {if (
initial_domain==AMDGPU_GEM_DOMAIN_VRAM) {drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1@@ -71,7 +72,7 @@ int amdgpu_gem_object_create(struct amdgpu_device *adev, unsigned long size, } return r; } - *obj = &robj->gem_base; + *obj = &bo->gem_base;return 0 ;}drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-0@@ -119,6 +120,10 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, if (mm && mm != current->mm) return -EPERM; +if (abo->flags &AMDGPU_GEM_CREATE_LOCAL && + abo->tbo.resv != vm->root.base.bo->tbo.resv) +return -EPERM ; + r =amdgpu_bo_reserve (abo, false);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1@@ -142,13 +147,14 @@ void amdgpu_gem_object_close(structdrm_gem_object *obj, struct amdgpu_vm *vm = &fpriv->vm;struct amdgpu_bo_list_entry vm_pd; -struct list_head list; +struct list_head list, duplicates;struct ttm_validate_buffer tv;struct ww_acquire_ctx ticket;struct amdgpu_bo_va *bo_va;int r;INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates); tv.bo = &bo->tbo;tv.shared = true;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1@@ -156,7 +162,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,amdgpu_vm_get_pd_bo (vm, &list, &vm_pd); - r =ttm_eu_reserve_buffers (&ticket, &list, false,NULL ); + r =ttm_eu_reserve_buffers (&ticket, &list, false, &duplicates);if (r) { dev_err(adev->dev, "leaking bo va because ""we fail to reserve bo (%d)\n", r);
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -191,9 +197,12 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) {struct amdgpu_device *adev = dev->dev_private; +struct amdgpu_fpriv *fpriv = filp->driver_priv; +struct amdgpu_vm *vm = &fpriv->vm;union drm_amdgpu_gem_create *args = data;uint64_t flags = args->in.domain_flags;uint64_t size = args->in.bo_size; +struct reservation_object *resv =NULL ;struct drm_gem_object *gobj;uint32_t handle;int r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1@@ -202,7 +211,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |AMDGPU_GEM_CREATE_NO_CPU_ACCESS |AMDGPU_GEM_CREATE_CPU_GTT_USWC | -AMDGPU_GEM_CREATE_VRAM_CLEARED )) +AMDGPU_GEM_CREATE_VRAM_CLEARED | +AMDGPU_GEM_CREATE_LOCAL )) return -EINVAL;/* reject invalid gem domains */
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +17
-1@@ -229,9 +239,25 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, } size =roundup (size,PAGE_SIZE ); +if (flags &AMDGPU_GEM_CREATE_LOCAL ) { + r =amdgpu_bo_reserve (vm->root.base.bo, false); +if (r) +return r; + + resv = vm->root.base.bo->tbo.resv; + } + r =amdgpu_gem_object_create (adev, size, args->in.alignment, (u32)(0xffffffff & args->in.domains), - flags, false, &gobj); + flags, false, resv, &gobj); +if (flags &AMDGPU_GEM_CREATE_LOCAL ) { +if (!r) { +struct amdgpu_bo *abo =gem_to_amdgpu_bo (gobj); + + abo->parent =amdgpu_bo_ref (vm->root.base.bo); + } +amdgpu_bo_unreserve (vm->root.base.bo); + }if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-3@@ -273,9 +299,8 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, }/* create a gem object to contain this object in */ - r =amdgpu_gem_object_create (adev, args->size,0 , -AMDGPU_GEM_DOMAIN_CPU ,0 , -0 , &gobj); + r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_CPU , +0 ,0 ,NULL , &gobj);if (r)return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1@@ -527,7 +552,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, struct amdgpu_bo_list_entry vm_pd;struct ttm_validate_buffer tv;struct ww_acquire_ctx ticket; -struct list_head list; +struct list_head list, duplicates;uint64_t va_flags;int r =0 ;@@ -563,6 +588,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, }INIT_LIST_HEAD (&list); +INIT_LIST_HEAD (&duplicates);if ((args->operation !=AMDGPU_VA_OP_CLEAR ) && !(args->flags &AMDGPU_VM_PAGE_PRT )) {gobj = drm_gem_object_lookup(filp, args->handle);drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1@@ -579,7 +605,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd); - r =ttm_eu_reserve_buffers (&ticket, &list, true,NULL ); + r =ttm_eu_reserve_buffers (&ticket, &list, true, &duplicates);if (r) goto error_unref;@@ -645,6 +671,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev,void *data, int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { + struct amdgpu_device *adev = dev->dev_private;struct drm_amdgpu_gem_op *args = data;struct drm_gem_object *gobj;struct
amdgpu_bo*robj;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-0@@ -692,6 +719,9 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, if (robj->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM) robj->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; +if (robj->flags &AMDGPU_GEM_CREATE_LOCAL ) +amdgpu_vm_bo_invalidate (adev, robj, true); +amdgpu_bo_unreserve(robj); break; default:drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-2@@ -721,8 +751,7 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv, r =amdgpu_gem_object_create (adev, args->size,0 ,AMDGPU_GEM_DOMAIN_VRAM ,AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED , - ttm_bo_type_device, - &gobj); + false,NULL , &gobj);if (r)return
-ENOMEM;drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +2
-1@@ -136,7 +136,8 @@ struct dma_buf *amdgpu_gem_prime_export(struct drm_device *dev, {struct amdgpu_bo *bo =gem_to_amdgpu_bo (gobj); -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) +if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm) || + bo->flags &AMDGPU_GEM_CREATE_LOCAL )return ERR_PTR (-EPERM );
Quoted 13 lines
include/uapi/drm/amdgpu_drm.h extern "C" { · line 93
Quoted 12 lines
return drm_gem_prime_export(dev, gobj, flags);include/uapi/drm/amdgpu_drm.h +2
-0@@ -89,6 +89,8 @@ extern "C" {#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)/* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?
Works for me as well. Dave any other opinion?
If everybody is ok with ALWAYS_VALID I'm going to use that one.
Christian.
Quoted 8 lines
Alex
Quoted 5 lines
include/uapi/drm/amdgpu_drm.h +0
-1struct drm_amdgpu_gem_create_in {/** the requested memory size */ --2.7.4
Quoted 8 lines
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
_______________________________________________
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): c7a4040d-6458-96a2-8096-498be5d0cf5d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Quoted 12 lines · Christian König
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h extern "C" { · line 93
Quoted 9 lines
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
include/uapi/drm/amdgpu_drm.h +2
-0@@ -89,6 +89,8 @@ extern "C" {#define AMDGPU_GEM_CREATE_SHADOW (1 << 4)/* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?
Quoted 3 lines
Works for me as well. Dave any other opinion?
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.
FWIW, I like LOCAL better than ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it cannot be used outside of the GPUVM it was created in.
I don't feel strongly about it though, feel free to go with either.
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): f2c9784d-880b-00da-cdcd-b794dc43b1da-otUistvHUpPR7s880joybQ@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Quoted 15 lines · Michel Dänzer
Quoted 14 lines · Christian König
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 10 lines
Review extern "C" { · line 93
Quoted 9 lines
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
(quoted diff) +2
-0@@ -89,6 +89,8 @@ extern "C" { #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) /* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?Works for me as well. Dave any other opinion?
Quoted 7 lines
Quoted 1 line
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.FWIW, I like LOCAL better than
ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it cannot be used outside of the GPUVM it was created in.I don't feel strongly about it though, feel free to go with either.
Another idea:
/* The BO can only be used in the VM it was created in */
#define AMDGPU_GEM_CREATE_UNSHAREABLE (1 << 6)
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): 4c0b0f45-43c7-f831-d407-8d2ffba4c586-otUistvHUpPR7s880joybQ@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Am 30.08.2017 um 08:46 schrieb Michel Dänzer:
Quoted 20 lines · Michel Dänzer
Quoted 19 lines · Christian König
Quoted 11 lines
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 10 lines
Review extern "C" { · line 93
Quoted 9 lines
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
(quoted diff) +2
-0@@ -89,6 +89,8 @@ extern "C" { #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) /* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?Quoted 3 lines
Works for me as well. Dave any other opinion?
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.FWIW, I like LOCAL better than
ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it cannot be used outside of the GPUVM it was created in.
Quoted 5 lines
Quoted 1 line
I don't feel strongly about it though, feel free to go with either.
Another idea:
/* The BO can only be used in the VM it was created in */
#defineAMDGPU_GEM_CREATE_UNSHAREABLE(1 << 6)
That in turn doesn't note that it is always available.
Additional to that I only limited sharing the BO because of the bad performance and memory usage. In theory we could share them pretty well.
How about VM_LOCAL ?
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): c6cdb302-94a8-8136-ab77-a4831c35b16d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Quoted 29 lines · Christian König
Am 30.08.2017 um 08:46 schrieb Michel Dänzer:
Quoted 22 lines · Michel Dänzer
Quoted 21 lines · Christian König
Quoted 13 lines
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 4 lines
Quoted 4 lines
From: amd-gfx [mailto:[email protected]] On Behalf
Of Christian KönigQuoted 8 lines
Review extern "C" { · line 93
Quoted 6 lines
(quoted diff) +2
-0@@ -89,6 +89,8 @@ extern "C" { #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) /* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?Quoted 3 lines
Works for me as well. Dave any other opinion?
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.FWIW, I like LOCAL better than
ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it cannot be used outside of the GPUVM it was created in.Quoted 5 lines
Quoted 1 line
I don't feel strongly about it though, feel free to go with either.
Another idea:
/* The BO can only be used in the VM it was created in */
#defineAMDGPU_GEM_CREATE_UNSHAREABLE(1 << 6)
Quoted 6 lines
That in turn doesn't note that it is always available.
Additional to that I only limited sharing the BO because of the bad performance and memory usage. In theory we could share them pretty well.
How about
VM_LOCAL?
Hmm, well if such BOs might become shareable in the future, ALWAYS_VALID might be best after all.
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): 83b68536-fdcc-ddeb-dbe4-c3c03c97e7da-otUistvHUpPR7s880joybQ@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Am 30.08.2017 um 09:39 schrieb Michel Dänzer:
Quoted 29 lines · Christian König
Quoted 28 lines
Am 30.08.2017 um 08:46 schrieb Michel Dänzer:
Quoted 27 lines · Michel Dänzer
Quoted 14 lines · Christian König
Quoted 13 lines
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 12 lines
Review extern "C" { · line 93
Quoted 10 lines
From: amd-gfx [mailto:[email protected]] On Behalf
Of Christian König(quoted diff) +2
-0@@ -89,6 +89,8 @@ extern "C" { #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) /* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?Quoted 8 lines
Quoted 3 lines
Works for me as well. Dave any other opinion?
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.FWIW, I like LOCAL better than
ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it cannot be used outside of the GPUVM it was created in.I don't feel strongly about it though, feel free to go with either.
Another idea:
/* The BO can only be used in the VM it was created in */
#defineAMDGPU_GEM_CREATE_UNSHAREABLE(1 << 6)
Quoted 8 lines
Quoted 6 lines
That in turn doesn't note that it is always available.
Additional to that I only limited sharing the BO because of the bad performance and memory usage. In theory we could share them pretty well.
How about
VM_LOCAL?Hmm, well if such BOs might become shareable in the future,
ALWAYS_VALIDmight be best after all.
Well this would be misleading as well, cause when you share them with another process they need to be specified in the BO list again.
In other words in the process who created the BO it is always valid, but other processes need to specify it manually again.
This makes me think that we indeed should mention _VM_ in the name. Maybe _VM_ALWAYS_VALID?
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): 5bc9d4ee-95ff-5482-8a8a-03c421b71319-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Re: [PATCH 3/4] drm/amdgpu: add IOCTL interface for per VM BOs v2
Quoted 36 lines · Christian König
Am 30.08.2017 um 09:39 schrieb Michel Dänzer:
Quoted 35 lines · Christian König
Quoted 34 lines
Am 30.08.2017 um 08:46 schrieb Michel Dänzer:
Quoted 23 lines · Michel Dänzer
Quoted 22 lines · Christian König
Quoted 13 lines
Am 29.08.2017 um 19:20 schrieb Deucher, Alexander:
Quoted 4 lines
Quoted 4 lines
From: amd-gfx [mailto:[email protected]] On Behalf
Of Christian KönigQuoted 8 lines
Review extern "C" { · line 93
Quoted 6 lines
(quoted diff) +2
-0@@ -89,6 +89,8 @@ extern "C" { #define AMDGPU_GEM_CREATE_SHADOW (1 << 4) /* Flag that allocating the BO should use linear VRAM */ #define AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS (1 << 5) +/* Flag that BO is local in the VM */ +#define AMDGPU_GEM_CREATE_LOCAL (1 << 6)I'm not crazy about the name LOCAL. Maybe something like
ALWAYS_VALID?Quoted 3 lines
Works for me as well. Dave any other opinion?
If everybody is ok with
ALWAYS_VALIDI'm going to use that one.FWIW, I like LOCAL better than
ALWAYS_VALID. The latter suggests that the BO is valid under any circumstances, whereas LOCAL indicates that it
cannot be used outside of the GPUVM it was created in.Quoted 5 lines
Quoted 1 line
I don't feel strongly about it though, feel free to go with either.
Another idea:
/* The BO can only be used in the VM it was created in */
#defineAMDGPU_GEM_CREATE_UNSHAREABLE(1 << 6)That in turn doesn't note that it is always available.
Additional to that I only limited sharing the BO because of the bad performance and memory usage. In theory we could share them pretty well.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How about
VM_LOCAL?Hmm, well if such BOs might become shareable in the future,
ALWAYS_VALIDmight be best after all.Well this would be misleading as well, cause when you share them with another process they need to be specified in the BO list again.
Seems fine to me: The flag is only relevant for the original creator of the BO; if the BO is later imported somewhere else, it will be clear that the imported BO must be in the BO list (it's not possible to even determine there that this flag was passed when the BO was originally created).
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
PATCH 4/4 drm/amdgpu: bump version for support of local BOs
In reply to a message not in the archiveFrom: Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -69,9 +69,10 @@* - 3.17.0 - Add AMDGPU_NUM_VRAM_CPU_PAGE_FAULTS. * - 3.18.0 - Export gpu always on cu bitmap * - 3.19.0 - Add support for UVD MJPEG decode +* - 3.20.0 - Add support for local BOs */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 19 +#define KMS_DRIVER_MINOR 20#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx