drm/amdgpu: Allow to create BO lists in CS ioctl v2
Subsystems (3)
PATCH v2 1/1 drm/amdgpu: Allow to create BO lists in CS ioctl v2
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling for BO_LIST create and destry IOCTLs in MESA and by this improves performance.
v2: Avoid inserting the temp list into idr struct.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 86 ++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 + 5 files changed, 114 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +11 -0
@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated);void amdgpu_bo_list_put (struct amdgpu_bo_list *list);void amdgpu_bo_list_free (struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, +struct drm_file *filp, +struct drm_amdgpu_bo_list_entry *info, +unsigned num_entries, +int *id, +struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id);/* * GFX stuff
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +54 -32
144 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +46 -5
84 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -69,9 +69,10 @@* - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. +* - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
include/uapi/drm/amdgpu_drm.h +1 -0
@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06struct drm_amdgpu_cs_chunk {__u32 chunk_id;
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): 1531342678-11142-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org
Quoted 268 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 86 ++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 + 5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated);void amdgpu_bo_list_put (struct amdgpu_bo_list *list);void amdgpu_bo_list_free (struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, +struct drm_file *filp, +struct drm_amdgpu_bo_list_entry *info, +unsigned num_entries, +int *id, +struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id);/* * GFX stuff drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +54
-32@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref)kfree_rcu (list, rhead); } -static int amdgpu_bo_list_create (struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info,unsigned num_entries, -int *id) +int *id, +struct amdgpu_bo_list **list_out) {int r;struct amdgpu_fpriv *fpriv = filp->driver_priv;@@ -78,20 +79,25 @@ static int amdgpu_bo_list_create(struct amdgpu_device *adev,return r; } +if (id) {/* idr alloc should be called only after initialization of bo list. */ -mutex_lock (&fpriv->bo_list_lock); - r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); -mutex_unlock (&fpriv->bo_list_lock); -if (r <0 ) { -amdgpu_bo_list_free (list); -return r; +mutex_lock (&fpriv->bo_list_lock); + r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); +mutex_unlock (&fpriv->bo_list_lock); +if (r <0 ) { +amdgpu_bo_list_free (list); +return r; + } + *id = r; } - *id = r; + +if (list_out) + *list_out = list;return 0 ; } -static void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) {struct amdgpu_bo_list *list;@@ -263,53 +269,68 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree (list); } -int amdgpu_bo_list_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp) +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param) { -const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - -struct amdgpu_device *adev = dev->dev_private; -struct amdgpu_fpriv *fpriv = filp->driver_priv; -union drm_amdgpu_bo_list *args = data; -uint32_t handle = args->in.list_handle; -const void __user *uptr =u64_to_user_ptr (args->in.bo_info_ptr); -struct drm_amdgpu_bo_list_entry *info; -struct amdgpu_bo_list *list; -int r; +const void __user *uptr =u64_to_user_ptr (in->bo_info_ptr); +const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - info =kvmalloc_array (args->in.bo_number, + info =kvmalloc_array (in->bo_number,sizeof (struct drm_amdgpu_bo_list_entry ),GFP_KERNEL );if (!info)return -ENOMEM ;/* copy the handle array from userspace to a kernel buffer */ r = -EFAULT ; -if (likely (info_size == args->in.bo_info_size)) { -unsigned long bytes = args->in.bo_number * - args->in.bo_info_size; +if (likely (info_size == in->bo_info_size)) { +unsigned long bytes = in->bo_number * + in->bo_info_size;if (copy_from_user (info, uptr, bytes)) goto error_free; }else { -unsigned long bytes =min (args->in.bo_info_size, info_size); +unsigned long bytes =min (in->bo_info_size, info_size);unsigned i; -memset (info,0 , args->in.bo_number * info_size); -for (i =0 ; i < args->in.bo_number; ++i) { +memset (info,0 , in->bo_number * info_size); +for (i =0 ; i < in->bo_number; ++i) {if (copy_from_user (&info[i], uptr, bytes)) goto error_free; - uptr += args->in.bo_info_size; + uptr += in->bo_info_size; } } + *info_param = info; +return 0 ; + +error_free: +kvfree (info); +return r; +} + +int amdgpu_bo_list_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; +union drm_amdgpu_bo_list *args = data; +uint32_t handle = args->in.list_handle; +struct drm_amdgpu_bo_list_entry *info =NULL ; +struct amdgpu_bo_list *list; +int r; + + r =amdgpu_bo_create_list_entry_array (&args->in, &info); +if (r) + goto error_free; +switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE : r =amdgpu_bo_list_create (adev, filp, info, args->in.bo_number, - &handle); + &handle,NULL );if (r) goto error_free;break ;@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; error_free: -kvfree (info); +if (info) +kvfree (info);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +44
-3@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,return 0 ; } -static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,void *data) +static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, +struct drm_amdgpu_bo_list_in *data) +{ +int r; +struct drm_amdgpu_bo_list_entry *info =NULL ; + + r =amdgpu_bo_create_list_entry_array (data, &info); +if (r) +return r; + + r =amdgpu_bo_list_create (p->adev, p->filp, info, data->bo_number,NULL , &p->bo_list); +if (r) + goto error_free; + +kvfree (info); +return 0 ; + +error_free: +if (info) +kvfree (info); + +return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union drm_amdgpu_cs *cs) {struct amdgpu_fpriv *fpriv = p->filp->driver_priv;struct amdgpu_vm *vm = &fpriv->vm; -union drm_amdgpu_cs *cs = data;uint64_t *chunk_array_user;uint64_t *chunk_array;unsigned size, num_ibs =0 ;@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)break ; +case AMDGPU_CHUNK_ID_BO_HANDLES : + size =sizeof (struct drm_amdgpu_bo_list_in ); +if (p->chunks[i].length_dw *sizeof (uint32_t ) < size) { + ret = -EINVAL ; + goto free_partial_kdata; + } + + ret =amdgpu_cs_bo_handles_chunk (p, p->chunks[i].kdata); +if (ret) + goto free_partial_kdata; + +break ; +case AMDGPU_CHUNK_ID_DEPENDENCIES :case AMDGPU_CHUNK_ID_SYNCOBJ_IN :case AMDGPU_CHUNK_ID_SYNCOBJ_OUT :@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,INIT_LIST_HEAD (&p->validated); - p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +/* p->bo_list could already be assigned if AMDGPU_CHUNK_ID_BO_HANDLES is present */ +if (!p->bo_list) + p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +else +mutex_lock (&p->bo_list->lock); +if (p->bo_list) {amdgpu_bo_list_get_list (p->bo_list, &p->validated);if (p->bo_list->first_userptr != p->bo_list->num_entries)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p) · line 791
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -747,7 +788,7 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)* used by parsing context. **/ static void amdgpu_cs_parser_fini (struct amdgpu_cs_parser *parser,int error, -bool backoff) +bool backoff,int id)
Don't need it after you get bo_list without idr.
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1321
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1{unsigned i;@@ -1277,7 +1318,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); out: -amdgpu_cs_parser_fini (&parser, r, reserved_buffers); +amdgpu_cs_parser_fini (&parser, r, reserved_buffers, cs->in.bo_list_handle);
Don't need it after you get bo_list without idr.
Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -69,9 +69,10 @@* - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. +* - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 525
Quoted 7 lines
include/uapi/drm/amdgpu_drm.h +1
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06struct drm_amdgpu_cs_chunk {__u32 chunk_id;
_______________________________________________
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): 9060133a-b04f-0c59-e806-1c0d407bb56c-5C7GfCeVMHo@public.gmane.org
Hi Andrey,
Could you add compatibility flag or increase kms driver version? So that user space can keep old path when using new one.
Regards,
David Zhou
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Thursday, July 12, 2018 10:31 AM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Olsak, Marek <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Allow to create BO lists in CS ioctl v2
Quoted 278 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 86 ++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 + 5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated);void amdgpu_bo_list_put (struct amdgpu_bo_list *list);void amdgpu_bo_list_free (struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, +struct drm_file *filp, +struct drm_amdgpu_bo_list_entry *info, +unsigned num_entries, +int *id, +struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id);/* * GFX stuff drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-2@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref)kfree_rcu (list, rhead); } -static int amdgpu_bo_list_create (struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info,unsigned num_entries, -int *id) +int *id, +struct amdgpu_bo_list **list_out) {int r; struct amdgpu_fpriv *fpriv = filp->driver_priv; @@ -78,20 +79,25 @@static int amdgpu_bo_list_create(struct
amdgpu_device*adev,
return r;
}drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +12
-8+if (id) {/* idr alloc should be called only after initialization of bo list. */ -mutex_lock (&fpriv->bo_list_lock); - r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); -mutex_unlock (&fpriv->bo_list_lock); -if (r <0 ) { -amdgpu_bo_list_free (list); -return r; +mutex_lock (&fpriv->bo_list_lock); + r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); +mutex_unlock (&fpriv->bo_list_lock); +if (r <0 ) { +amdgpu_bo_list_free (list); +return r; + } + *id = r; } - *id = r; + +if (list_out) + *list_out = list;return 0 ; } -static void amdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, intid)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +39
-22+void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) {struct amdgpu_bo_list *list;@@ -263,53 +269,68 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree (list); } -int amdgpu_bo_list_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp) +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param) { -const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - -struct amdgpu_device *adev = dev->dev_private; -struct amdgpu_fpriv *fpriv = filp->driver_priv; -union drm_amdgpu_bo_list *args = data; -uint32_t handle = args->in.list_handle; -const void __user *uptr =u64_to_user_ptr (args->in.bo_info_ptr); -struct drm_amdgpu_bo_list_entry *info; -struct amdgpu_bo_list *list; -int r; +const void __user *uptr =u64_to_user_ptr (in->bo_info_ptr); +const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - info =kvmalloc_array (args->in.bo_number, + info =kvmalloc_array (in->bo_number,sizeof (struct drm_amdgpu_bo_list_entry ),GFP_KERNEL );if (!info)return -ENOMEM ;/* copy the handle array from userspace to a kernel buffer */ r = -EFAULT ; -if (likely (info_size == args->in.bo_info_size)) { -unsigned long bytes = args->in.bo_number * - args->in.bo_info_size; +if (likely (info_size == in->bo_info_size)) { +unsigned long bytes = in->bo_number * + in->bo_info_size;if (copy_from_user (info, uptr, bytes)) goto error_free; }else { -unsigned long bytes =min (args->in.bo_info_size, info_size); +unsigned long bytes =min (in->bo_info_size, info_size);unsigned i; -memset (info,0 , args->in.bo_number * info_size); -for (i =0 ; i < args->in.bo_number; ++i) { +memset (info,0 , in->bo_number * info_size); +for (i =0 ; i < in->bo_number; ++i) {if (copy_from_user (&info[i], uptr, bytes)) goto error_free; - uptr += args->in.bo_info_size; + uptr += in->bo_info_size; } } + *info_param = info; +return 0 ; + +error_free: +kvfree (info); +return r; +} + +int amdgpu_bo_list_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; +union drm_amdgpu_bo_list *args = data; +uint32_t handle = args->in.list_handle; +struct drm_amdgpu_bo_list_entry *info =NULL ; +struct amdgpu_bo_list *list; +int r; + + r =amdgpu_bo_create_list_entry_array (&args->in, &info); +if (r) + goto error_free; +switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE : r =amdgpu_bo_list_create (adev, filp, info, args->in.bo_number, - &handle); + &handle,NULL );if (r) goto error_free;break ;@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; error_free: -kvfree (info); +if (info) +kvfree (info);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +25
-2@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,return 0 ; } -static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,void *data) +static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, +struct drm_amdgpu_bo_list_in *data) { +int r; +struct drm_amdgpu_bo_list_entry *info =NULL ; + + r =amdgpu_bo_create_list_entry_array (data, &info); +if (r) +return r; + + r =amdgpu_bo_list_create (p->adev, p->filp, info, data->bo_number,NULL , &p->bo_list); +if (r) + goto error_free; + +kvfree (info); +return 0 ; + +error_free: +if (info) +kvfree (info); + +return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union +drm_amdgpu_cs *cs) {struct amdgpu_fpriv *fpriv = p->filp->driver_priv;struct amdgpu_vm *vm = &fpriv->vm; -union drm_amdgpu_cs *cs = data;uint64_t *chunk_array_user;uint64_t *chunk_array;unsigned size, num_ibs = 0;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +13
-0@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)break ; +case AMDGPU_CHUNK_ID_BO_HANDLES : + size =sizeof (struct drm_amdgpu_bo_list_in ); +if (p->chunks[i].length_dw *sizeof (uint32_t ) < size) { + ret = -EINVAL ; + goto free_partial_kdata; + } + + ret =amdgpu_cs_bo_handles_chunk (p, p->chunks[i].kdata); +if (ret) + goto free_partial_kdata; + +break ; +case AMDGPU_CHUNK_ID_DEPENDENCIES :case AMDGPU_CHUNK_ID_SYNCOBJ_IN :case
AMDGPU_CHUNK_ID_SYNCOBJ_OUT:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6
-1@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,INIT_LIST_HEAD (&p->validated); - p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +/* p->bo_list could already be assigned if AMDGPU_CHUNK_ID_BO_HANDLES is present */ +if (!p->bo_list) + p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +else +mutex_lock (&p->bo_list->lock); +if (p->bo_list) {amdgpu_bo_list_get_list (p->bo_list, &p->validated);if (
p->bo_list->first_userptr!=p->bo_list->num_entries) @@
-747,7 +788,7 @@ static intamdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
* used by parsing context.
**/
static void amdgpu_cs_parser_fini(structamdgpu_cs_parser*parser, int error,
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p) · line 791
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1- bool backoff) + bool backoff, int id)
Don't need it after you get bo_list without idr.
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1322
Quoted 10 lines
{ unsigned i;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-1@@ -1277,7 +1318,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); out: -amdgpu_cs_parser_fini (&parser, r, reserved_buffers); +amdgpu_cs_parser_fini (&parser, r, reserved_buffers, +cs->in.bo_list_handle);
Don't need it after you get bo_list without idr.
Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -69,9 +69,10 @@* - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. +* - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex 09741ba..94444ee 100644
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 525
Quoted 7 lines
include/uapi/drm/amdgpu_drm.h +1
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06struct drm_amdgpu_cs_chunk {__u32 chunk_id;
_______________________________________________
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): BY1PR12MB050202D0A4883EDB709D434EB4590-PicGAnIBOobrCwm+z9iKNgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 3 lines · David(ChunMing)
Hi Andrey,
Could you add compatibility flag or increase kms driver version? So that user space can keep old path when using new one.
Sorry for noise, it's already at end of path.
Regards,
David Zhou
Quoted 340 lines
Regards,
David Zhou-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Thursday, July 12, 2018 10:31 AM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Olsak, Marek <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Allow to create BO lists in CS ioctl v2Quoted 278 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 86 ++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 + 5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated);void amdgpu_bo_list_put (struct amdgpu_bo_list *list);void amdgpu_bo_list_free (struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, +struct drm_file *filp, +struct drm_amdgpu_bo_list_entry *info, +unsigned num_entries, +int *id, +struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id);/* * GFX stuff drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-2@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref)kfree_rcu (list, rhead); } -static int amdgpu_bo_list_create (struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info,unsigned num_entries, -int *id) +int *id, +struct amdgpu_bo_list **list_out) {int r; struct amdgpu_fpriv *fpriv = filp->driver_priv; @@ -78,20 +79,25 @@static int amdgpu_bo_list_create(struct
amdgpu_device*adev,return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +12
-8+if (id) {/* idr alloc should be called only after initialization of bo list. */ -mutex_lock (&fpriv->bo_list_lock); - r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); -mutex_unlock (&fpriv->bo_list_lock); -if (r <0 ) { -amdgpu_bo_list_free (list); -return r; +mutex_lock (&fpriv->bo_list_lock); + r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); +mutex_unlock (&fpriv->bo_list_lock); +if (r <0 ) { +amdgpu_bo_list_free (list); +return r; + } + *id = r; } - *id = r; + +if (list_out) + *list_out = list;return 0 ; } -static void amdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, intid)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +39
-22+void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) {struct amdgpu_bo_list *list;@@ -263,53 +269,68 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree (list); } -int amdgpu_bo_list_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp) +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param) { -const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - -struct amdgpu_device *adev = dev->dev_private; -struct amdgpu_fpriv *fpriv = filp->driver_priv; -union drm_amdgpu_bo_list *args = data; -uint32_t handle = args->in.list_handle; -const void __user *uptr =u64_to_user_ptr (args->in.bo_info_ptr); -struct drm_amdgpu_bo_list_entry *info; -struct amdgpu_bo_list *list; -int r; +const void __user *uptr =u64_to_user_ptr (in->bo_info_ptr); +const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - info =kvmalloc_array (args->in.bo_number, + info =kvmalloc_array (in->bo_number,sizeof (struct drm_amdgpu_bo_list_entry ),GFP_KERNEL );if (!info)return -ENOMEM ;/* copy the handle array from userspace to a kernel buffer */ r = -EFAULT ; -if (likely (info_size == args->in.bo_info_size)) { -unsigned long bytes = args->in.bo_number * - args->in.bo_info_size; +if (likely (info_size == in->bo_info_size)) { +unsigned long bytes = in->bo_number * + in->bo_info_size;if (copy_from_user (info, uptr, bytes)) goto error_free; }else { -unsigned long bytes =min (args->in.bo_info_size, info_size); +unsigned long bytes =min (in->bo_info_size, info_size);unsigned i; -memset (info,0 , args->in.bo_number * info_size); -for (i =0 ; i < args->in.bo_number; ++i) { +memset (info,0 , in->bo_number * info_size); +for (i =0 ; i < in->bo_number; ++i) {if (copy_from_user (&info[i], uptr, bytes)) goto error_free; - uptr += args->in.bo_info_size; + uptr += in->bo_info_size; } } + *info_param = info; +return 0 ; + +error_free: +kvfree (info); +return r; +} + +int amdgpu_bo_list_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; +union drm_amdgpu_bo_list *args = data; +uint32_t handle = args->in.list_handle; +struct drm_amdgpu_bo_list_entry *info =NULL ; +struct amdgpu_bo_list *list; +int r; + + r =amdgpu_bo_create_list_entry_array (&args->in, &info); +if (r) + goto error_free; +switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE : r =amdgpu_bo_list_create (adev, filp, info, args->in.bo_number, - &handle); + &handle,NULL );if (r) goto error_free;break ;@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; error_free: -kvfree (info); +if (info) +kvfree (info);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +25
-2@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,return 0 ; } -static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,void *data) +static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, +struct drm_amdgpu_bo_list_in *data) { +int r; +struct drm_amdgpu_bo_list_entry *info =NULL ; + + r =amdgpu_bo_create_list_entry_array (data, &info); +if (r) +return r; + + r =amdgpu_bo_list_create (p->adev, p->filp, info, data->bo_number,NULL , &p->bo_list); +if (r) + goto error_free; + +kvfree (info); +return 0 ; + +error_free: +if (info) +kvfree (info); + +return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union +drm_amdgpu_cs *cs) {struct amdgpu_fpriv *fpriv = p->filp->driver_priv;struct amdgpu_vm *vm = &fpriv->vm; -union drm_amdgpu_cs *cs = data;uint64_t *chunk_array_user;uint64_t *chunk_array;unsigned size, num_ibs = 0;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +13
-0@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)break ; +case AMDGPU_CHUNK_ID_BO_HANDLES : + size =sizeof (struct drm_amdgpu_bo_list_in ); +if (p->chunks[i].length_dw *sizeof (uint32_t ) < size) { + ret = -EINVAL ; + goto free_partial_kdata; + } + + ret =amdgpu_cs_bo_handles_chunk (p, p->chunks[i].kdata); +if (ret) + goto free_partial_kdata; + +break ; +case AMDGPU_CHUNK_ID_DEPENDENCIES :case AMDGPU_CHUNK_ID_SYNCOBJ_IN :case
AMDGPU_CHUNK_ID_SYNCOBJ_OUT:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6
-1@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,INIT_LIST_HEAD (&p->validated); - p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +/* p->bo_list could already be assigned if AMDGPU_CHUNK_ID_BO_HANDLES is present */ +if (!p->bo_list) + p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +else +mutex_lock (&p->bo_list->lock); +if (p->bo_list) {amdgpu_bo_list_get_list (p->bo_list, &p->validated);if (p->bo_list->first_userptr != p->bo_list->num_entries) @@-747,7 +788,7 @@ static int
amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
* used by parsing context.
**/
static void amdgpu_cs_parser_fini(structamdgpu_cs_parser*parser, int error,drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p) · line 791
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1- bool backoff) + bool backoff, int id)Don't need it after you get
bo_listwithout idr.drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1322
Quoted 10 lines
{ unsigned i;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-1@@ -1277,7 +1318,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); out: -amdgpu_cs_parser_fini (&parser, r, reserved_buffers); +amdgpu_cs_parser_fini (&parser, r, reserved_buffers, +cs->in.bo_list_handle);Don't need it after you get
bo_listwithout idr.Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -69,9 +69,10 @@* - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. +* - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex 09741ba..94444ee 100644include/uapi/drm/amdgpu_drm.h +1
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06
Quoted 6 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 525
Quoted 2 lines
include/uapi/drm/amdgpu_drm.h +0
-0struct drm_amdgpu_cs_chunk {__u32 chunk_id;_______________________________________________
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): a43a5f3d-7fef-1721-307e-9135cf494264-5C7GfCeVMHo@public.gmane.org
With more thinking for you performance reason, Can we go further more not to create temp bo list at all? directly add them into parser->validated list?
In fact, if bo array is very long, then overhead of bo list creation in CS is considerable, which will double iterate all BOs compared to original.
From UMD perspective, they don't create bo list for every CS, they could use old created bo_list for next several CS, if there is a new bo, they just add it.
Thanks,
David Zhou
Quoted 347 lines · On 2018年07月12日 12:02, zhoucm1 wrote:
Quoted 3 lines · David(ChunMing)
Hi Andrey,
Could you add compatibility flag or increase kms driver version? So that user space can keep old path when using new one.
Sorry for noise, it's already at end of path.
Regards,
David ZhouQuoted 328 lines
Regards,
David Zhou-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Thursday, July 12, 2018 10:31 AM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Olsak, Marek <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Allow to create BO lists in CS ioctl v2Quoted 266 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c| 86
++++++++++++++++++-----------
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 +5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated); void amdgpu_bo_list_put(struct amdgpu_bo_list *list); void amdgpu_bo_list_free(struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, + struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, + struct drm_file *filp, + struct drm_amdgpu_bo_list_entry *info, + unsigned num_entries, + int *id, + struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id); /** GFX stuff
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-1@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref) kfree_rcu(list, rhead); } -static int amdgpu_bo_list_create(struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev, struct drm_file *filp, struct drm_amdgpu_bo_list_entry *info, unsigned num_entries, - int *id) + int *id, + struct amdgpu_bo_list **list_out) { int r;struct
amdgpu_fpriv*fpriv =filp->driver_priv; @@ -78,20 +79,25 @@
static int amdgpu_bo_list_create(structamdgpu_device*adev, return r;
}
+ if (id) {
/* idr alloc should be called only after initialization of bo list. */ -mutex_lock(&fpriv->bo_list_lock);
- r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); -mutex_unlock(&fpriv->bo_list_lock);
- if (r < 0) {
-amdgpu_bo_list_free(list);
- return r;
+mutex_lock(&fpriv->bo_list_lock);
+ r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL);
+mutex_unlock(&fpriv->bo_list_lock);
+ if (r < 0) {
+amdgpu_bo_list_free(list);
+ return r;
+ }
+ *id = r;
}
- *id = r;
+
+ if (list_out)
+*list_out= list;
return 0;
}
-static voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id)
+voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id){
structamdgpu_bo_list*list;
@@ -263,53 +269,68 @@ voidamdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree(list);
}
-intamdgpu_bo_list_ioctl(struct drm_device *dev, void *data, - struct drm_file *filp)
+int amdgpu_bo_create_list_entry_array(structdrm_amdgpu_bo_list_in*in,
+ structdrm_amdgpu_bo_list_entry**info_param) {
- constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-7- - struct amdgpu_device *adev = dev->dev_private; - struct amdgpu_fpriv *fpriv = filp->driver_priv; - union drm_amdgpu_bo_list *args = data; - uint32_t handle = args->in.list_handle; - const void __user *uptr = u64_to_user_ptr(args->in.bo_info_ptr); -struct
drm_amdgpu_bo_list_entry*info;
- structamdgpu_bo_list*list;
-
int r;
+ const void__user*uptr =u64_to_user_ptr(in->bo_info_ptr); + constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);
- info = kvmalloc_array(args->in.bo_number,
+ info = kvmalloc_array(in->bo_number,
sizeof(struct drm_amdgpu_bo_list_entry),GFP_KERNEL); if (!info)
return-ENOMEM;
/* copy the handle array from userspace to a kernel buffer */ r =-EFAULT;
- if (likely(info_size == args->in.bo_info_size)) {
- unsigned long bytes =args->in.bo_number*
-args->in.bo_info_size;
+ if (likely(info_size == in->bo_info_size)) {
+ unsigned long bytes =in->bo_number*
+in->bo_info_size;
if (copy_from_user(info, uptr, bytes))
gotoerror_free;
} else {
- unsigned long bytes =min(args->in.bo_info_size, info_size); + unsigned long bytes =min(in->bo_info_size, info_size); unsigned i;
-memset(info, 0, args->in.bo_number * info_size); - for (i = 0; i <args->in.bo_number; ++i) {
+memset(info, 0, in->bo_number * info_size);
+ for (i = 0; i <in->bo_number; ++i) {
if (copy_from_user(&info[i], uptr, bytes)) gotoerror_free;
- uptr +=args->in.bo_info_size;
+ uptr +=in->bo_info_size;
}
}
+*info_param= info;
+ return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +21
-0+ +error_free: + kvfree(info); + return r; +} + +int amdgpu_bo_list_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; + union drm_amdgpu_bo_list *args = data; + uint32_t handle = args->in.list_handle; + struct drm_amdgpu_bo_list_entry *info = NULL; + struct amdgpu_bo_list *list; + int r; + + r = amdgpu_bo_create_list_entry_array(&args->in, &info); + if (r) + goto error_free; +switch (
args->in.operation) {
caseAMDGPU_BO_LIST_OP_CREATE:
r =amdgpu_bo_list_create(adev, filp, info, args->in.bo_number, - &handle);
+ &handle, NULL);
if (r)
gotoerror_free;
break;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-0@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, return 0;
error_free:
- kvfree(info);
+ if (info)
+ kvfree(info);
return r;
}drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, return 0; }-static int
amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10
-0+static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, + struct drm_amdgpu_bo_list_in *data) { + int r; + struct drm_amdgpu_bo_list_entry *info = NULL; + + r = amdgpu_bo_create_list_entry_array(data, &info); + if (r) + return r; + + r = amdgpu_bo_list_create(p->adev, p->filp, info,
data->bo_number, NULL,&p->bo_list);
+ if (r)
+ gotoerror_free;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +13
-0+ + kvfree(info); + return 0; + +error_free: + if (info) + kvfree(info); + + return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union +drm_amdgpu_cs *cs){
structamdgpu_fpriv*fpriv =p->filp->driver_priv; structamdgpu_vm*vm =&fpriv->vm;
- uniondrm_amdgpu_cs*cs = data;
uint64_t*chunk_array_user;
uint64_t*chunk_array;
unsigned size,num_ibs= 0;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) break;+ case
AMDGPU_CHUNK_ID_BO_HANDLES:
+ size =sizeof(struct drm_amdgpu_bo_list_in); + if (p->chunks[i].length_dw *sizeof(uint32_t)< size) { + ret =-EINVAL;
+ gotofree_partial_kdata;
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7
-0+ + ret = amdgpu_cs_bo_handles_chunk(p, p->chunks[i].kdata); + if (ret) + goto free_partial_kdata; + + break; +case
AMDGPU_CHUNK_ID_DEPENDENCIES:
caseAMDGPU_CHUNK_ID_SYNCOBJ_IN:
caseAMDGPU_CHUNK_ID_SYNCOBJ_OUT:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-0@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(structamdgpu_cs_parser *p, INIT_LIST_HEAD(&p->validated); - p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); + /* p->bo_list could already be assigned if
AMDGPU_CHUNK_ID_BO_HANDLESis present */
+ if (!p->bo_list)
+p->bo_list=amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); + else
+mutex_lock(&p->bo_list->lock);
+
if (p->bo_list) {
amdgpu_bo_list_get_list(p->bo_list, &p->validated);Quoted 8 lines
if (
p->bo_list->first_userptr!=p->bo_list->num_entries) @@ -747,7 +788,7 @@ static intamdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
* used by parsing context.
**/
static voidamdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, - bool backoff)
+ bool backoff, int id)Don't need it after you get
bo_listwithout idr.Quoted 8 lines
{
unsigned i;
@@ -1277,7 +1318,7 @@ intamdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)r =amdgpu_cs_submit(&parser, cs);
out:
-amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
+ amdgpu_cs_parser_fini(&parser, r,reserved_buffers,
+cs->in.bo_list_handle);Don't need it after you get
bo_listwithout idr.Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 26 lines
return r;
}
diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cindex 06aede1..529500c 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -69,9 +69,10 @@ * - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. + * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LISTcreation.
*/
#define KMS_DRIVER_MAJOR 3drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1-#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0
intamdgpu_vram_limit= 0;(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex 09741ba..94444ee 100644include/uapi/drm/amdgpu_drm.h +0
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va { #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04Quoted 8 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 524
Quoted 4 lines
include/uapi/drm/amdgpu_drm.h +1
-0#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 struct drm_amdgpu_cs_chunk { __u32 chunk_id;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
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
A message that is not in the archive (sent off-list or not yet received): f6b77415-b991-6d4e-d872-934a269c397e-5C7GfCeVMHo@public.gmane.org
Am 12.07.2018 um 06:21 schrieb zhoucm1:
Quoted 1 line
With more thinking for you performance reason, Can we go further more not to create temp bo list at all? directly add them into
parser->validatedlist?
You still need something which is added to the parser->validated list, so creating the array of BOs in unavoidable.
Quoted 3 lines
In fact, if bo array is very long, then overhead of bo list creation in CS is considerable, which will double iterate all BOs compared to original.
From UMD perspective, they don't create bo list for every CS, they could use old created
bo_listfor next several CS, if there is a new bo, they just add it.
And exactly that is the failed concept of bo_lists, it is complete nonsense to do this.
Either you create the list of BOs from scratch for each command submission like Mesa does it in which is exactly the case we try to support efficient here.
Or you use per process BOs which are always valid. Something which we have already implemented as well.
Regards,
Christian.
Quoted 357 lines
Thanks,
David ZhouQuoted 348 lines · On 2018年07月12日 12:02, zhoucm1 wrote:
Quoted 3 lines · David(ChunMing)
Hi Andrey,
Could you add compatibility flag or increase kms driver version? So that user space can keep old path when using new one.
Sorry for noise, it's already at end of path.
Regards,
David ZhouQuoted 329 lines
Regards,
David Zhou-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Thursday, July 12, 2018 10:31 AM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Olsak, Marek <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Allow to create BO lists in CS ioctl v2Quoted 267 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c| 86
++++++++++++++++++-----------
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 +5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated); void amdgpu_bo_list_put(struct amdgpu_bo_list *list); void amdgpu_bo_list_free(struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, + struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, + struct drm_file *filp, + struct drm_amdgpu_bo_list_entry *info, + unsigned num_entries, + int *id, + struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id); /** GFX stuff
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-1@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref) kfree_rcu(list, rhead); } -static int amdgpu_bo_list_create(struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev, struct drm_file *filp, struct drm_amdgpu_bo_list_entry *info, unsigned num_entries, - int *id) + int *id, + struct amdgpu_bo_list **list_out) { int r;struct
amdgpu_fpriv*fpriv =filp->driver_priv; @@ -78,20 +79,25 @@
static int amdgpu_bo_list_create(structamdgpu_device*adev, return r;
}
+ if (id) {
/* idr alloc should be called only after initialization of bo list. */ -mutex_lock(&fpriv->bo_list_lock);
- r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); -mutex_unlock(&fpriv->bo_list_lock);
- if (r < 0) {
-amdgpu_bo_list_free(list);
- return r;
+mutex_lock(&fpriv->bo_list_lock);
+ r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL);
+mutex_unlock(&fpriv->bo_list_lock);
+ if (r < 0) {
+amdgpu_bo_list_free(list);
+ return r;
+ }
+ *id = r;
}
- *id = r;
+
+ if (list_out)
+*list_out= list;
return 0;
}
-static voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id)
+voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id){
structamdgpu_bo_list*list;
@@ -263,53 +269,68 @@ voidamdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree(list);
}
-intamdgpu_bo_list_ioctl(struct drm_device *dev, void *data, - struct drm_file *filp)
+int amdgpu_bo_create_list_entry_array(structdrm_amdgpu_bo_list_in*in,
+ structdrm_amdgpu_bo_list_entry**info_param) {
- constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-7- - struct amdgpu_device *adev = dev->dev_private; - struct amdgpu_fpriv *fpriv = filp->driver_priv; - union drm_amdgpu_bo_list *args = data; - uint32_t handle = args->in.list_handle; - const void __user *uptr = u64_to_user_ptr(args->in.bo_info_ptr); -struct
drm_amdgpu_bo_list_entry*info;
- structamdgpu_bo_list*list;
-
int r;
+ const void__user*uptr =u64_to_user_ptr(in->bo_info_ptr); + constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);
- info = kvmalloc_array(args->in.bo_number,
+ info = kvmalloc_array(in->bo_number,
sizeof(struct drm_amdgpu_bo_list_entry),GFP_KERNEL); if (!info)
return-ENOMEM;
/* copy the handle array from userspace to a kernel buffer */ r =-EFAULT;
- if (likely(info_size == args->in.bo_info_size)) {
- unsigned long bytes =args->in.bo_number*
-args->in.bo_info_size;
+ if (likely(info_size == in->bo_info_size)) {
+ unsigned long bytes =in->bo_number*
+in->bo_info_size;
if (copy_from_user(info, uptr, bytes))
gotoerror_free;
} else {
- unsigned long bytes =min(args->in.bo_info_size, info_size); + unsigned long bytes =min(in->bo_info_size, info_size); unsigned i;
-memset(info, 0, args->in.bo_number * info_size); - for (i = 0; i <args->in.bo_number; ++i) {
+memset(info, 0, in->bo_number * info_size);
+ for (i = 0; i <in->bo_number; ++i) {
if (copy_from_user(&info[i], uptr, bytes)) gotoerror_free;
- uptr +=args->in.bo_info_size;
+ uptr +=in->bo_info_size;
}
}
+*info_param= info;
+ return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +21
-0+ +error_free: + kvfree(info); + return r; +} + +int amdgpu_bo_list_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; + union drm_amdgpu_bo_list *args = data; + uint32_t handle = args->in.list_handle; + struct drm_amdgpu_bo_list_entry *info = NULL; + struct amdgpu_bo_list *list; + int r; + + r = amdgpu_bo_create_list_entry_array(&args->in, &info); + if (r) + goto error_free; +switch (
args->in.operation) {
caseAMDGPU_BO_LIST_OP_CREATE:
r =amdgpu_bo_list_create(adev, filp, info, args->in.bo_number, - &handle);
+ &handle, NULL);
if (r)
gotoerror_free;
break;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-0@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, return 0;
error_free:
- kvfree(info);
+ if (info)
+ kvfree(info);
return r;
}drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, return 0; }-static int
amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10
-0+static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, + struct drm_amdgpu_bo_list_in *data) { + int r; + struct drm_amdgpu_bo_list_entry *info = NULL; + + r = amdgpu_bo_create_list_entry_array(data, &info); + if (r) + return r; + + r = amdgpu_bo_list_create(p->adev, p->filp, info,
data->bo_number, NULL,&p->bo_list);
+ if (r)
+ gotoerror_free;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +13
-0+ + kvfree(info); + return 0; + +error_free: + if (info) + kvfree(info); + + return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union +drm_amdgpu_cs *cs){
structamdgpu_fpriv*fpriv =p->filp->driver_priv; structamdgpu_vm*vm =&fpriv->vm;
- uniondrm_amdgpu_cs*cs = data;
uint64_t*chunk_array_user;
uint64_t*chunk_array;
unsigned size,num_ibs= 0;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) break;+ case
AMDGPU_CHUNK_ID_BO_HANDLES:
+ size =sizeof(struct drm_amdgpu_bo_list_in); + if (p->chunks[i].length_dw *sizeof(uint32_t)< size) { + ret =-EINVAL;
+ gotofree_partial_kdata;
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7
-0+ + ret = amdgpu_cs_bo_handles_chunk(p, p->chunks[i].kdata); + if (ret) + goto free_partial_kdata; + + break; +case
AMDGPU_CHUNK_ID_DEPENDENCIES:
caseAMDGPU_CHUNK_ID_SYNCOBJ_IN:
caseAMDGPU_CHUNK_ID_SYNCOBJ_OUT:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-0@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(structamdgpu_cs_parser *p, INIT_LIST_HEAD(&p->validated); - p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); + /* p->bo_list could already be assigned if
AMDGPU_CHUNK_ID_BO_HANDLESis present */
+ if (!p->bo_list)
+p->bo_list=amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle);
+ else
+mutex_lock(&p->bo_list->lock);
+
if (p->bo_list) {amdgpu_bo_list_get_list(p->bo_list, &p->validated);Quoted 8 lines
if (
p->bo_list->first_userptr!=p->bo_list->num_entries) @@ -747,7 +788,7 @@ static intamdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
* used by parsing context.
**/
static voidamdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, - bool backoff)
+ bool backoff, int id)Don't need it after you get
bo_listwithout idr.Quoted 8 lines
{
unsigned i;
@@ -1277,7 +1318,7 @@ intamdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)r =amdgpu_cs_submit(&parser, cs);
out:
-amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
+ amdgpu_cs_parser_fini(&parser, r,reserved_buffers,
+cs->in.bo_list_handle);Don't need it after you get
bo_listwithout idr.Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 26 lines
return r;
}
diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cindex 06aede1..529500c 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -69,9 +69,10 @@ * - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. + * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LISTcreation.
*/
#define KMS_DRIVER_MAJOR 3drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1-#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0
intamdgpu_vram_limit= 0;(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex 09741ba..94444ee 100644include/uapi/drm/amdgpu_drm.h +0
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va { #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04Quoted 8 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 524
Quoted 4 lines
include/uapi/drm/amdgpu_drm.h +1
-0#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 struct drm_amdgpu_cs_chunk { __u32 chunk_id;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfxQuoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
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
A message that is not in the archive (sent off-list or not yet received): 18352936-c661-dccd-a515-6d2845172470-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 5 lines · Christian König
Am 12.07.2018 um 06:21 schrieb zhoucm1:
Quoted 1 line
With more thinking for you performance reason, Can we go further more not to create temp bo list at all? directly add them into
parser->validatedlist?You still need something which is added to the
parser->validatedlist, so creating the array of BOs in unavoidable.
Quoted 7 lines
Quoted 3 lines
In fact, if bo array is very long, then overhead of bo list creation in CS is considerable, which will double iterate all BOs compared to original.
From UMD perspective, they don't create bo list for every CS, they could use old created
bo_listfor next several CS, if there is a new bo, they just add it.And exactly that is the failed concept of
bo_lists, it is complete nonsense to do this.Either you create the list of BOs from scratch for each command submission like Mesa does it in which is exactly the case we try to support efficient here.
@Kai, do you have comments for what Christian said?
Quoted 2 lines
Or you use per process BOs which are always valid. Something which we have already implemented as well.
Yes, vulkan already use it from 4.15. But pro-ogl still use bo list.
Quoted 366 lines
Regards,
Christian.Quoted 361 lines
Thanks,
David ZhouQuoted 348 lines · On 2018年07月12日 12:02, zhoucm1 wrote:
Quoted 3 lines · David(ChunMing)
Hi Andrey,
Could you add compatibility flag or increase kms driver version? So that user space can keep old path when using new one.
Sorry for noise, it's already at end of path.
Regards,
David ZhouQuoted 329 lines
Regards,
David Zhou-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of zhoucm1
Sent: Thursday, July 12, 2018 10:31 AM
To: Grodzovsky, Andrey <[email protected]>; [email protected]
Cc: Olsak, Marek <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Allow to create BO lists in CS ioctl v2Quoted 267 lines · Andrey Grodzovsky
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c| 86
++++++++++++++++++-----------
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 +5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated); void amdgpu_bo_list_put(struct amdgpu_bo_list *list); void amdgpu_bo_list_free(struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, + struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, + struct drm_file *filp, + struct drm_amdgpu_bo_list_entry *info, + unsigned num_entries, + int *id, + struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id); /** GFX stuff
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-1@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref) kfree_rcu(list, rhead); } -static int amdgpu_bo_list_create(struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev, struct drm_file *filp, struct drm_amdgpu_bo_list_entry *info, unsigned num_entries, - int *id) + int *id, + struct amdgpu_bo_list **list_out) { int r;struct
amdgpu_fpriv*fpriv =filp->driver_priv; @@ -78,20 +79,25 @@
static int amdgpu_bo_list_create(structamdgpu_device*adev, return r;
}
+ if (id) {
/* idr alloc should be called only after initialization of bo list. */ -mutex_lock(&fpriv->bo_list_lock);
- r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL); -mutex_unlock(&fpriv->bo_list_lock);
- if (r < 0) {
-amdgpu_bo_list_free(list);
- return r;
+mutex_lock(&fpriv->bo_list_lock);
+ r =idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL);
+mutex_unlock(&fpriv->bo_list_lock);
+ if (r < 0) {
+amdgpu_bo_list_free(list);
+ return r;
+ }
+ *id = r;
}
- *id = r;
+
+ if (list_out)
+*list_out= list;
return 0;
}
-static voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id)
+voidamdgpu_bo_list_destroy(struct amdgpu_fpriv *fpriv, int id){
structamdgpu_bo_list*list;
@@ -263,53 +269,68 @@ voidamdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree(list);
}
-intamdgpu_bo_list_ioctl(struct drm_device *dev, void *data, - struct drm_file *filp)
+int amdgpu_bo_create_list_entry_array(structdrm_amdgpu_bo_list_in*in,
+ structdrm_amdgpu_bo_list_entry**info_param) {
- constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-7- - struct amdgpu_device *adev = dev->dev_private; - struct amdgpu_fpriv *fpriv = filp->driver_priv; - union drm_amdgpu_bo_list *args = data; - uint32_t handle = args->in.list_handle; - const void __user *uptr = u64_to_user_ptr(args->in.bo_info_ptr); -struct
drm_amdgpu_bo_list_entry*info;
- structamdgpu_bo_list*list;
-
int r;
+ const void__user*uptr =u64_to_user_ptr(in->bo_info_ptr); + constuint32_tinfo_size=sizeof(struct drm_amdgpu_bo_list_entry);
- info = kvmalloc_array(args->in.bo_number,
+ info = kvmalloc_array(in->bo_number,
sizeof(struct drm_amdgpu_bo_list_entry),GFP_KERNEL); if (!info)
return-ENOMEM;
/* copy the handle array from userspace to a kernel buffer */ r =-EFAULT;
- if (likely(info_size == args->in.bo_info_size)) {
- unsigned long bytes =args->in.bo_number*
-args->in.bo_info_size;
+ if (likely(info_size == in->bo_info_size)) {
+ unsigned long bytes =in->bo_number*
+in->bo_info_size;
if (copy_from_user(info, uptr, bytes))
gotoerror_free;
} else {
- unsigned long bytes =min(args->in.bo_info_size, info_size); + unsigned long bytes =min(in->bo_info_size, info_size); unsigned i;
-memset(info, 0, args->in.bo_number * info_size); - for (i = 0; i <args->in.bo_number; ++i) {
+memset(info, 0, in->bo_number * info_size);
+ for (i = 0; i <in->bo_number; ++i) {
if (copy_from_user(&info[i], uptr, bytes)) gotoerror_free;
- uptr +=args->in.bo_info_size;
+ uptr +=in->bo_info_size;
}
}
+*info_param= info;
+ return 0;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +21
-0+ +error_free: + kvfree(info); + return r; +} + +int amdgpu_bo_list_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; + union drm_amdgpu_bo_list *args = data; + uint32_t handle = args->in.list_handle; + struct drm_amdgpu_bo_list_entry *info = NULL; + struct amdgpu_bo_list *list; + int r; + + r = amdgpu_bo_create_list_entry_array(&args->in, &info); + if (r) + goto error_free; +switch (
args->in.operation) {
caseAMDGPU_BO_LIST_OP_CREATE:
r =amdgpu_bo_list_create(adev, filp, info, args->in.bo_number, - &handle);
+ &handle, NULL);
if (r)
gotoerror_free;
break;drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +0
-0@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, return 0;
error_free:
- kvfree(info);
+ if (info)
+ kvfree(info);
return r;
}drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, return 0; }-static int
amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10
-0+static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, + struct drm_amdgpu_bo_list_in *data) { + int r; + struct drm_amdgpu_bo_list_entry *info = NULL; + + r = amdgpu_bo_create_list_entry_array(data, &info); + if (r) + return r; + + r = amdgpu_bo_list_create(p->adev, p->filp, info,
data->bo_number, NULL,&p->bo_list);
+ if (r)
+ gotoerror_free;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +13
-0+ + kvfree(info); + return 0; + +error_free: + if (info) + kvfree(info); + + return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union +drm_amdgpu_cs *cs){
structamdgpu_fpriv*fpriv =p->filp->driver_priv; structamdgpu_vm*vm =&fpriv->vm;
- uniondrm_amdgpu_cs*cs = data;
uint64_t*chunk_array_user;
uint64_t*chunk_array;
unsigned size,num_ibs= 0;drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) break;+ case
AMDGPU_CHUNK_ID_BO_HANDLES:
+ size =sizeof(struct drm_amdgpu_bo_list_in); + if (p->chunks[i].length_dw *sizeof(uint32_t)< size) { + ret =-EINVAL;
+ gotofree_partial_kdata;
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +7
-0+ + ret = amdgpu_cs_bo_handles_chunk(p, p->chunks[i].kdata); + if (ret) + goto free_partial_kdata; + + break; +case
AMDGPU_CHUNK_ID_DEPENDENCIES:
caseAMDGPU_CHUNK_ID_SYNCOBJ_IN:
caseAMDGPU_CHUNK_ID_SYNCOBJ_OUT:drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-0@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(structamdgpu_cs_parser *p, INIT_LIST_HEAD(&p->validated); - p->bo_list = amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle); + /* p->bo_list could already be assigned if
AMDGPU_CHUNK_ID_BO_HANDLESis present */
+ if (!p->bo_list)
+p->bo_list=amdgpu_bo_list_get(fpriv, cs->in.bo_list_handle);
+ else
+mutex_lock(&p->bo_list->lock);
+
if (p->bo_list) {amdgpu_bo_list_get_list(p->bo_list, &p->validated);Quoted 8 lines
if (
p->bo_list->first_userptr!=p->bo_list->num_entries) @@ -747,7 +788,7 @@ static intamdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)
* used by parsing context.
**/
static voidamdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, - bool backoff)
+ bool backoff, int id)Don't need it after you get
bo_listwithout idr.Quoted 8 lines
{
unsigned i;
@@ -1277,7 +1318,7 @@ intamdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)r =amdgpu_cs_submit(&parser, cs);
out:
-amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
+ amdgpu_cs_parser_fini(&parser, r,reserved_buffers,
+cs->in.bo_list_handle);Don't need it after you get
bo_listwithout idr.Otherwise it looks really good to me, Reviewed-by: Chunming Zhou <[email protected]>
Quoted 26 lines
return r;
}
diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.cindex 06aede1..529500c 100644drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -69,9 +69,10 @@ * - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. + * - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LISTcreation.
*/
#define KMS_DRIVER_MAJOR 3drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-1-#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0
intamdgpu_vram_limit= 0;(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex 09741ba..94444ee 100644include/uapi/drm/amdgpu_drm.h +0
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va { #define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04Quoted 8 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 524
Quoted 4 lines
include/uapi/drm/amdgpu_drm.h +1
-0#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06 struct drm_amdgpu_cs_chunk { __u32 chunk_id;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfxQuoted 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
Am 11.07.2018 um 22:57 schrieb Andrey Grodzovsky:
Quoted 69 lines
This change is to support MESA performace optimization. Modify CS IOCTL to allow its input as command buffer and an array of buffer handles to create a temporay bo list and then destroy it when IOCTL completes.
This saves on calling forBO_LISTcreate and destry IOCTLs in MESA and by this improves performance.v2: Avoid inserting the temp list into idr struct.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 86 ++++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 51 +++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- include/uapi/drm/amdgpu_drm.h | 1 + 5 files changed, 114 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +11
-0@@ -732,6 +732,17 @@ void amdgpu_bo_list_get_list(struct amdgpu_bo_list *list, struct list_head *validated);void amdgpu_bo_list_put (struct amdgpu_bo_list *list);void amdgpu_bo_list_free (struct amdgpu_bo_list *list); +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param); + +int amdgpu_bo_list_create (struct amdgpu_device *adev, +struct drm_file *filp, +struct drm_amdgpu_bo_list_entry *info, +unsigned num_entries, +int *id, +struct amdgpu_bo_list **list); + +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id);/* * GFX stuff drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +4
-6@@ -55,11 +55,12 @@ static void amdgpu_bo_list_release_rcu(struct kref *ref)kfree_rcu (list, rhead); } -static int amdgpu_bo_list_create (struct amdgpu_device *adev, +int amdgpu_bo_list_create (struct amdgpu_device *adev,struct drm_file *filp,struct drm_amdgpu_bo_list_entry *info,unsigned num_entries, -int *id) +int *id, +struct amdgpu_bo_list **list_out) {int r;struct amdgpu_fpriv *fpriv = filp->driver_priv;@@ -78,20 +79,25 @@ static int amdgpu_bo_list_create(struct amdgpu_device *adev,return r; } +if (id) {/* idr alloc should be called only after initialization of bo list. */ -mutex_lock (&fpriv->bo_list_lock); - r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); -mutex_unlock (&fpriv->bo_list_lock); -if (r <0 ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c static int amdgpu_bo_list_create(struct amdgpu_device *adev, · line 91
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +8
-2-amdgpu_bo_list_free (list); -return r; +mutex_lock (&fpriv->bo_list_lock); + r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL ); +mutex_unlock (&fpriv->bo_list_lock); +if (r <0 ) { +amdgpu_bo_list_free (list); +return r; + } + *id = r;
Can we move that into the calling or a separate other function?
Would be cleaner to separate the functionality of creating a bo_list structure from inserting it into the IDR.
Quoted 27 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +6
-8} - *id = r; + +if (list_out) + *list_out = list;return 0 ; } -static void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) +void amdgpu_bo_list_destroy (struct amdgpu_fpriv *fpriv,int id) {struct amdgpu_bo_list *list;@@ -263,53 +269,68 @@ void amdgpu_bo_list_free(struct amdgpu_bo_list *list)kfree (list); } -int amdgpu_bo_list_ioctl (struct drm_device *dev,void *data, -struct drm_file *filp) +int amdgpu_bo_create_list_entry_array (struct drm_amdgpu_bo_list_in *in, +struct drm_amdgpu_bo_list_entry **info_param) { -const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry ); - -struct amdgpu_device *adev = dev->dev_private; -struct amdgpu_fpriv *fpriv = filp->driver_priv;
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c void amdgpu_bo_list_free(struct amdgpu_bo_list *list) · line 278
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +2
-6-union drm_amdgpu_bo_list *args = data; -uint32_t handle = args->in.list_handle; -const void __user *uptr =u64_to_user_ptr (args->in.bo_info_ptr); -struct drm_amdgpu_bo_list_entry *info; -struct amdgpu_bo_list *list; -int r; +const void __user *uptr =u64_to_user_ptr (in->bo_info_ptr); +const uint32_t info_size =sizeof (struct drm_amdgpu_bo_list_entry );
Reverse xmas tree order please, e.g. at least "int r;" should be last. I personally also put consts at the beginning of the declarations.
Same problem at a few other occasions.
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c void amdgpu_bo_list_free(struct amdgpu_bo_list *list) · line 281
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +1
-1- info =kvmalloc_array (args->in.bo_number, + info =kvmalloc_array (in->bo_number,sizeof (struct drm_amdgpu_bo_list_entry ),GFP_KERNEL );
We could use info_size here, would make the line a bit shorter.
Quoted 157 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +33
-9if (!info)return -ENOMEM ;/* copy the handle array from userspace to a kernel buffer */ r = -EFAULT ; -if (likely (info_size == args->in.bo_info_size)) { -unsigned long bytes = args->in.bo_number * - args->in.bo_info_size; +if (likely (info_size == in->bo_info_size)) { +unsigned long bytes = in->bo_number * + in->bo_info_size;if (copy_from_user (info, uptr, bytes)) goto error_free; }else { -unsigned long bytes =min (args->in.bo_info_size, info_size); +unsigned long bytes =min (in->bo_info_size, info_size);unsigned i; -memset (info,0 , args->in.bo_number * info_size); -for (i =0 ; i < args->in.bo_number; ++i) { +memset (info,0 , in->bo_number * info_size); +for (i =0 ; i < in->bo_number; ++i) {if (copy_from_user (&info[i], uptr, bytes)) goto error_free; - uptr += args->in.bo_info_size; + uptr += in->bo_info_size; } } + *info_param = info; +return 0 ; + +error_free: +kvfree (info); +return r; +} + +int amdgpu_bo_list_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; +union drm_amdgpu_bo_list *args = data; +uint32_t handle = args->in.list_handle; +struct drm_amdgpu_bo_list_entry *info =NULL ; +struct amdgpu_bo_list *list; +int r; + + r =amdgpu_bo_create_list_entry_array (&args->in, &info); +if (r) + goto error_free; +switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE : r =amdgpu_bo_list_create (adev, filp, info, args->in.bo_number, - &handle); + &handle,NULL );if (r) goto error_free;break ;@@ -345,6 +366,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; error_free: -kvfree (info); +if (info) +kvfree (info);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +45
-4@@ -66,11 +66,34 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,return 0 ; } -static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,void *data) +static int amdgpu_cs_bo_handles_chunk (struct amdgpu_cs_parser *p, +struct drm_amdgpu_bo_list_in *data) +{ +int r; +struct drm_amdgpu_bo_list_entry *info =NULL ; + + r =amdgpu_bo_create_list_entry_array (data, &info); +if (r) +return r; + + r =amdgpu_bo_list_create (p->adev, p->filp, info, data->bo_number,NULL , &p->bo_list); +if (r) + goto error_free; + +kvfree (info); +return 0 ; + +error_free: +if (info) +kvfree (info); + +return r; +} + +static int amdgpu_cs_parser_init (struct amdgpu_cs_parser *p,union drm_amdgpu_cs *cs) {struct amdgpu_fpriv *fpriv = p->filp->driver_priv;struct amdgpu_vm *vm = &fpriv->vm; -union drm_amdgpu_cs *cs = data;uint64_t *chunk_array_user;uint64_t *chunk_array;unsigned size, num_ibs =0 ;@@ -164,6 +187,19 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)break ; +case AMDGPU_CHUNK_ID_BO_HANDLES : + size =sizeof (struct drm_amdgpu_bo_list_in ); +if (p->chunks[i].length_dw *sizeof (uint32_t ) < size) { + ret = -EINVAL ; + goto free_partial_kdata; + } + + ret =amdgpu_cs_bo_handles_chunk (p, p->chunks[i].kdata); +if (ret) + goto free_partial_kdata; + +break ; +case AMDGPU_CHUNK_ID_DEPENDENCIES :case AMDGPU_CHUNK_ID_SYNCOBJ_IN :case AMDGPU_CHUNK_ID_SYNCOBJ_OUT :@@ -534,7 +570,12 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,INIT_LIST_HEAD (&p->validated); - p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +/* p->bo_list could already be assigned if AMDGPU_CHUNK_ID_BO_HANDLES is present */ +if (!p->bo_list) + p->bo_list =amdgpu_bo_list_get (fpriv, cs->in.bo_list_handle); +else +mutex_lock (&p->bo_list->lock); +if (p->bo_list) {amdgpu_bo_list_get_list (p->bo_list, &p->validated);if (p->bo_list->first_userptr != p->bo_list->num_entries)@@ -747,7 +788,7 @@ static int amdgpu_cs_sync_rings(struct amdgpu_cs_parser *p)* used by parsing context. **/ static void amdgpu_cs_parser_fini (struct amdgpu_cs_parser *parser,int error, -bool backoff) +bool backoff,int id) {unsigned i;
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1321
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1
-1@@ -1277,7 +1318,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); out: -amdgpu_cs_parser_fini (&parser, r, reserved_buffers); +amdgpu_cs_parser_fini (&parser, r, reserved_buffers, cs->in.bo_list_handle);
As David noted as well those changes are unnecessary now.
Regards,
Christian.
Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-0return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -69,9 +69,10 @@* - 3.24.0 - Add high priority compute support for gfx9 * - 3.25.0 - Add support for sensor query info (stable pstate sclk/mclk). * - 3.26.0 - GFX9: Process AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE. +* - 3.27.0 - Add new chunk to to AMDGPU_CS to enable BO_LIST creation. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 26 +#define KMS_DRIVER_MINOR 27#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_gem_va { · line 525
Quoted 7 lines
include/uapi/drm/amdgpu_drm.h +1
-0@@ -519,6 +519,7 @@ struct drm_amdgpu_gem_va {#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03#define AMDGPU_CHUNK_ID_SYNCOBJ_IN 0x04#define AMDGPU_CHUNK_ID_SYNCOBJ_OUT 0x05 +#define AMDGPU_CHUNK_ID_BO_HANDLES 0x06struct drm_amdgpu_cs_chunk {__u32 chunk_id;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx