drm/amdkfd: Use 64 bit sdma_bitmap
Subsystems (3)
PATCH 1/4 drm/amdkfd: Use 64 bit sdma_bitmap
From: Oak Zeng <[email protected]>
Maximumly support 64 sdma queues
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +++++----- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -5
@@ -885,7 +885,7 @@ static int initialize_nocpsch(struct device_queue_manager *dqm) } dqm->vmid_bitmap = (1 << dqm->dev->vm_info.vmid_num_kfd) -1 ; - dqm->sdma_bitmap = (1 <<get_num_sdma_queues (dqm)) -1 ; + dqm->sdma_bitmap = (1ULL <<get_num_sdma_queues (dqm)) -1 ;return 0 ; }
@@ -923,8 +923,8 @@ static int allocate_sdma_queue(struct device_queue_manager *dqm,if (dqm->sdma_bitmap ==0 )return -ENOMEM ; - bit =ffs (dqm->sdma_bitmap) -1 ; - dqm->sdma_bitmap &= ~(1 << bit); + bit =__ffs64 (dqm->sdma_bitmap); + dqm->sdma_bitmap &= ~(1ULL << bit); *sdma_queue_id = bit;return 0 ;
@@ -935,7 +935,7 @@ static void deallocate_sdma_queue(struct device_queue_manager *dqm, {if (sdma_queue_id >=get_num_sdma_queues (dqm))return ; - dqm->sdma_bitmap |= (1 << sdma_queue_id); + dqm->sdma_bitmap |= (1ULL << sdma_queue_id); } static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,
@@ -1041,7 +1041,7 @@ static int initialize_cpsch(struct device_queue_manager *dqm) dqm->queue_count = dqm->processes_count =0 ; dqm->sdma_queue_count =0 ; dqm->active_runlist = false; - dqm->sdma_bitmap = (1 <<get_num_sdma_queues (dqm)) -1 ; + dqm->sdma_bitmap = (1ULL <<get_num_sdma_queues (dqm)) -1 ;INIT_WORK (&dqm->hw_exception_work, kfd_process_hw_exception);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +1 -1
@@ -188,7 +188,7 @@ struct device_queue_manager {unsigned int total_queue_count;unsigned int next_pipe_to_allocate;unsigned int *allocated_queues; -unsigned int sdma_bitmap; +uint64_t sdma_bitmap;unsigned int vmid_bitmap;uint64_t pipelines_addr;struct kfd_mem_obj *pipeline_mem;
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): 1542136254-5561-1-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdkfd: Added more SDMA queue type
From: Oak Zeng <[email protected]>
The new types are used to allocate SDMA queue on specific SDMA engine
--- include/uapi/linux/kfd_ioctl.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
include/uapi/linux/kfd_ioctl.h +7 -3
@@ -35,9 +35,13 @@ struct kfd_ioctl_get_version_args { };/* For kfd_ioctl_create_queue_args.queue_type. */ -#define KFD_IOC_QUEUE_TYPE_COMPUTE 0 -#define KFD_IOC_QUEUE_TYPE_SDMA 1 -#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2 +#define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0 +#define KFD_IOC_QUEUE_TYPE_SDMA 0x1 +#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2 +#define KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (e) (0x10000 + (e)) +#define KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE (e) (0x20000 + (e)) +#define KFD_IOC_QUEUE_TYPE_SDMA_ENGINE_MAX (KFD_IOC_QUEUE_TYPE_SDMA_ENGINE(0xffff)) +#define KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE_MAX (KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE(0xffff))#define KFD_MAX_QUEUE_PERCENTAGE 100#define KFD_MAX_QUEUE_PRIORITY 15
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): 1542136254-5561-2-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org
Alex Deucher
Acked-byRe: [PATCH 2/4] drm/amdkfd: Added more SDMA queue type
Quoted 9 lines · Oak Zeng
From: Oak Zeng <[email protected]>
The new types are used to allocate SDMA queue on specific SDMA engine
Change-Id Ica4cd7013eb86103a92cec2f74d96ac037b5ecbdSigned-off-by Oak Zeng <[email protected]>Reviewd-by Felix Kuehling <[email protected]>
Typo: Reviewed-by
With that fixed:
Quoted 28 lines
--- include/uapi/linux/kfd_ioctl.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)include/uapi/linux/kfd_ioctl.h +7
-4@@ -35,9 +35,13 @@ struct kfd_ioctl_get_version_args { };/* For kfd_ioctl_create_queue_args.queue_type. */ -#define KFD_IOC_QUEUE_TYPE_COMPUTE 0 -#define KFD_IOC_QUEUE_TYPE_SDMA 1 -#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2 +#define KFD_IOC_QUEUE_TYPE_COMPUTE 0x0 +#define KFD_IOC_QUEUE_TYPE_SDMA 0x1 +#define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 0x2 +#define KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (e) (0x10000 + (e)) +#define KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE (e) (0x20000 + (e)) +#define KFD_IOC_QUEUE_TYPE_SDMA_ENGINE_MAX (KFD_IOC_QUEUE_TYPE_SDMA_ENGINE(0xffff)) +#define KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE_MAX (KFD_IOC_QUEUE_TYPE_SDMA_AQL_ENGINE(0xffff))#define KFD_MAX_QUEUE_PERCENTAGE 100#define KFD_MAX_QUEUE_PRIORITY 15 --2.7.4
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
PATCH 3/4 drm/amdkfd: Allocate SDMA queue on specif engine
In reply to a message not in the archiveFrom: Oak Zeng <[email protected]>
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 26 +++++++++++++------ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 30 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +18 -8
@@ -143,7 +143,8 @@ static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,return 0 ; } -static int set_queue_properties_from_user (struct queue_properties *q_properties, +static int set_queue_properties_from_user (struct kfd_dev *dev, +struct queue_properties *q_properties,struct kfd_ioctl_create_queue_args *args) {if (args->queue_percentage >KFD_MAX_QUEUE_PERCENTAGE ) {
@@ -213,12 +214,21 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties, q_properties->ctx_save_restore_area_size = args->ctx_save_restore_size; q_properties->ctl_stack_size = args->ctl_stack_size;if (args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE || - args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) + args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) { q_properties->type =KFD_QUEUE_TYPE_COMPUTE ; -else if (args->queue_type ==KFD_IOC_QUEUE_TYPE_SDMA ) + }else if (args->queue_type ==KFD_IOC_QUEUE_TYPE_SDMA ) { + q_properties->sdma_engine_id = + dev->device_info->num_sdma_engines; q_properties->type =KFD_QUEUE_TYPE_SDMA ; -else + }else if (args->queue_type >=KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (0 ) && + args->queue_type <KFD_IOC_QUEUE_TYPE_SDMA_ENGINE ( + dev->device_info->num_sdma_engines)) { + q_properties->sdma_engine_id = + args->queue_type -KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (0 ); + q_properties->type =KFD_QUEUE_TYPE_SDMA ; + }else {return -ENOTSUPP ; + }if (args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) q_properties->format =KFD_QUEUE_FORMAT_AQL ;
@@ -265,10 +275,6 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,pr_debug ("Creating queue ioctl\n" ); - err =set_queue_properties_from_user (&q_properties, args); -if (err) -return err; -pr_debug ("Looking for gpu id 0x%x\n" , args->gpu_id); dev =kfd_device_by_id (args->gpu_id);if (!dev) {
@@ -276,6 +282,10 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,return -EINVAL ; } + err =set_queue_properties_from_user (dev, &q_properties, args); +if (err) +return err; +mutex_lock (&p->mutex); pdd =kfd_bind_process_to_device (dev, p);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +26 -4
@@ -916,14 +916,34 @@ static int stop_nocpsch(struct device_queue_manager *dqm) }static int allocate_sdma_queue (struct device_queue_manager *dqm, +unsigned int sdma_engine_id,unsigned int *sdma_queue_id) { -int bit; +int bit =-1 ;if (dqm->sdma_bitmap ==0 )return -ENOMEM ; - bit =__ffs64 (dqm->sdma_bitmap); +/* If sdma_engine_id is valid, +* allocate queue on specific engine +*/ +if (sdma_engine_id <get_num_sdma_engines (dqm)) { +unsigned int i; + +for (i = sdma_engine_id; i <get_num_sdma_queues (dqm); + i +=get_num_sdma_engines (dqm)) { +if (dqm->sdma_bitmap & (1 <<i)) { + bit = i; +break ; + } + } +if (bit ==-1 ) +return -EBUSY ; +/* Otherwise allocate from any engine */ + }else { + bit =__ffs64 (dqm->sdma_bitmap); + } + dqm->sdma_bitmap &= ~(1ULL << bit); *sdma_queue_id = bit;
@@ -949,7 +969,8 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,if (!mqd_mgr)return -ENOMEM ; - retval =allocate_sdma_queue (dqm, &q->sdma_id); + retval =allocate_sdma_queue (dqm, q->properties.sdma_engine_id, + &q->sdma_id);if (retval)return retval;
@@ -1168,7 +1189,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, }if (q->properties.type ==KFD_QUEUE_TYPE_SDMA ) { - retval =allocate_sdma_queue (dqm, &q->sdma_id); + retval =allocate_sdma_queue (dqm, q->properties.sdma_engine_id, + &q->sdma_id);if (retval) goto out_unlock; q->properties.sdma_queue_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): 1542136254-5561-3-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org
Alex Deucher
Acked-byRe: [PATCH 3/4] drm/amdkfd: Allocate SDMA queue on specif engine
Quoted 6 lines · Oak Zeng
From: Oak Zeng <[email protected]>
Change-Id I32e0304cdf6ceeed12ea8d0af62f44e1ab20bffbSigned-off-by Oak Zeng <[email protected]>Reviewd-by Felix Kuehling <[email protected]>
Typo: Reviewed-by
Also, in the patch title, "specific"
With those fixed:
Quoted 130 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 26 +++++++++++++------ .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 30 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +18
-8@@ -143,7 +143,8 @@ static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,return 0 ; } -static int set_queue_properties_from_user (struct queue_properties *q_properties, +static int set_queue_properties_from_user (struct kfd_dev *dev, +struct queue_properties *q_properties,struct kfd_ioctl_create_queue_args *args) {if (args->queue_percentage >KFD_MAX_QUEUE_PERCENTAGE ) {@@ -213,12 +214,21 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties, q_properties->ctx_save_restore_area_size = args->ctx_save_restore_size; q_properties->ctl_stack_size = args->ctl_stack_size;if (args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE || - args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) + args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) { q_properties->type =KFD_QUEUE_TYPE_COMPUTE ; -else if (args->queue_type ==KFD_IOC_QUEUE_TYPE_SDMA ) + }else if (args->queue_type ==KFD_IOC_QUEUE_TYPE_SDMA ) { + q_properties->sdma_engine_id = + dev->device_info->num_sdma_engines; q_properties->type =KFD_QUEUE_TYPE_SDMA ; -else + }else if (args->queue_type >=KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (0 ) && + args->queue_type <KFD_IOC_QUEUE_TYPE_SDMA_ENGINE ( + dev->device_info->num_sdma_engines)) { + q_properties->sdma_engine_id = + args->queue_type -KFD_IOC_QUEUE_TYPE_SDMA_ENGINE (0 ); + q_properties->type =KFD_QUEUE_TYPE_SDMA ; + }else {return -ENOTSUPP ; + }if (args->queue_type ==KFD_IOC_QUEUE_TYPE_COMPUTE_AQL ) q_properties->format =KFD_QUEUE_FORMAT_AQL ;@@ -265,10 +275,6 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,pr_debug ("Creating queue ioctl\n" ); - err =set_queue_properties_from_user (&q_properties, args); -if (err) -return err; -pr_debug ("Looking for gpu id 0x%x\n" , args->gpu_id); dev =kfd_device_by_id (args->gpu_id);if (!dev) {@@ -276,6 +282,10 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,return -EINVAL ; } + err =set_queue_properties_from_user (dev, &q_properties, args); +if (err) +return err; +mutex_lock (&p->mutex); pdd =kfd_bind_process_to_device (dev, p);drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +26
-5@@ -916,14 +916,34 @@ static int stop_nocpsch(struct device_queue_manager *dqm) }static int allocate_sdma_queue (struct device_queue_manager *dqm, +unsigned int sdma_engine_id,unsigned int *sdma_queue_id) { -int bit; +int bit =-1 ;if (dqm->sdma_bitmap ==0 )return -ENOMEM ; - bit =__ffs64 (dqm->sdma_bitmap); +/* If sdma_engine_id is valid, +* allocate queue on specific engine +*/ +if (sdma_engine_id <get_num_sdma_engines (dqm)) { +unsigned int i; + +for (i = sdma_engine_id; i <get_num_sdma_queues (dqm); + i +=get_num_sdma_engines (dqm)) { +if (dqm->sdma_bitmap & (1 <<i)) { + bit = i; +break ; + } + } +if (bit ==-1 ) +return -EBUSY ; +/* Otherwise allocate from any engine */ + }else { + bit =__ffs64 (dqm->sdma_bitmap); + } + dqm->sdma_bitmap &= ~(1ULL << bit); *sdma_queue_id = bit;@@ -949,7 +969,8 @@ static int create_sdma_queue_nocpsch(struct device_queue_manager *dqm,if (!mqd_mgr)return -ENOMEM ; - retval =allocate_sdma_queue (dqm, &q->sdma_id); + retval =allocate_sdma_queue (dqm, q->properties.sdma_engine_id, + &q->sdma_id);if (retval)return retval;@@ -1168,7 +1189,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, }if (q->properties.type ==KFD_QUEUE_TYPE_SDMA ) { - retval =allocate_sdma_queue (dqm, &q->sdma_id); + retval =allocate_sdma_queue (dqm, q->properties.sdma_engine_id, + &q->sdma_id);if (retval) goto out_unlock; q->properties.sdma_queue_id = --2.7.4
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
PATCH 4/4 drm/amdkfd: Add sdma allocation debug message
In reply to a message not in the archiveFrom: Oak Zeng <[email protected]>
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -0
@@ -1197,6 +1197,9 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, q->sdma_id /get_num_sdma_engines (dqm); q->properties.sdma_engine_id = q->sdma_id %get_num_sdma_engines (dqm); +pr_debug ("SDMA id is: %d\n" , q->sdma_id); +pr_debug ("SDMA queue id: %d\n" , q->properties.sdma_queue_id); +pr_debug ("SDMA engine id: %d\n" , q->properties.sdma_engine_id); } retval =allocate_doorbell (qpd, q);
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): 1542136254-5561-4-git-send-email-ozeng-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/4] drm/amdkfd: Add sdma allocation debug message
Hi Alex,
Those 4 patches internally passed Felix's code review. Those are required for MI100 but are general changes so I think it is better to check into drm-next.
Thanks,
Oak
Quoted 14 lines · Oak
From: Oak Zeng <[email protected]>
Change-Id I47ec79eceac810f7031eaf88d267fc8370501c27Signed-off-by Oak Zeng <[email protected]>Reviewd-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, · line 1205
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-0@@ -1197,6 +1197,9 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, q->sdma_id /get_num_sdma_engines (dqm); q->properties.sdma_engine_id = q->sdma_id %get_num_sdma_engines (dqm); +pr_debug ("SDMA id is: %d\n" , q->sdma_id); +pr_debug ("SDMA queue id: %d\n" , q->properties.sdma_queue_id); +pr_debug ("SDMA engine id: %d\n" , q->properties.sdma_engine_id); } retval =allocate_doorbell (qpd, q);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
Acked-byRe: [PATCH 4/4] drm/amdkfd: Add sdma allocation debug message
In reply to a message not in the archiveQuoted 6 lines · Oak Zeng
From: Oak Zeng <[email protected]>
Change-Id I47ec79eceac810f7031eaf88d267fc8370501c27Signed-off-by Oak Zeng <[email protected]>Reviewd-by Felix Kuehling <[email protected]>
Typo: Reviewed-by
Also please add a patch description.
With that fixed:
Quoted 21 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3
-1@@ -1197,6 +1197,9 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, q->sdma_id /get_num_sdma_engines (dqm); q->properties.sdma_engine_id = q->sdma_id %get_num_sdma_engines (dqm); +pr_debug ("SDMA id is: %d\n" , q->sdma_id); +pr_debug ("SDMA queue id: %d\n" , q->properties.sdma_queue_id); +pr_debug ("SDMA engine id: %d\n" , q->properties.sdma_engine_id); } retval =allocate_doorbell (qpd, q); --2.7.4
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