This is consistent with the calling sequence in unmap_queues_cpsch(). Change-Id: Ieb6714422c812d4f6ebbece34e339871471e4b5e Signed-off-by: Yong Zhao <Yong.Zhao@xxxxxxx> --- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 18 +++++++++++++++-- .../gpu/drm/amd/amdkfd/kfd_packet_manager.c | 20 +++++-------------- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 7 ++++++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 510f2d1bb8bb..fd7d90136b94 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -1302,6 +1302,8 @@ static int unmap_sdma_queues(struct device_queue_manager *dqm) static int map_queues_cpsch(struct device_queue_manager *dqm) { int retval; + uint64_t rl_ib_gpu_addr; + size_t rl_ib_size; if (!dqm->sched_running) return 0; @@ -1310,15 +1312,27 @@ static int map_queues_cpsch(struct device_queue_manager *dqm) if (dqm->active_runlist) return 0; - retval = pm_send_runlist(&dqm->packets, &dqm->queues); + retval = pm_create_runlist_ib(&dqm->packets, &dqm->queues, + &rl_ib_gpu_addr, &rl_ib_size); + if (retval) + goto fail_create_runlist_ib; + + pr_debug("runlist IB address: 0x%llX\n", rl_ib_gpu_addr); + + retval = pm_send_runlist(&dqm->packets, &dqm->queues, + rl_ib_gpu_addr, rl_ib_size); pr_debug("%s sent runlist\n", __func__); if (retval) { pr_err("failed to execute runlist\n"); - return retval; + goto fail_create_runlist_ib; } dqm->active_runlist = true; return retval; + +fail_create_runlist_ib: + pm_destroy_runlist_ib(&dqm->packets); + return retval; } /* dqm->lock mutex has to be locked before calling this function */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c index 4a9433257428..6ec54e9f9392 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c @@ -116,7 +116,7 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm, return retval; } -static int pm_create_runlist_ib(struct packet_manager *pm, +int pm_create_runlist_ib(struct packet_manager *pm, struct list_head *queues, uint64_t *rl_gpu_addr, size_t *rl_size_bytes) @@ -149,7 +149,6 @@ static int pm_create_runlist_ib(struct packet_manager *pm, /* build map process packet */ if (proccesses_mapped >= pm->dqm->processes_count) { pr_debug("Not enough space left in runlist IB\n"); - pm_destroy_runlist_ib(pm); return -ENOMEM; } @@ -299,20 +298,13 @@ int pm_send_set_resources(struct packet_manager *pm, return retval; } -int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) +int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues, + uint64_t rl_ib_gpu_addr, size_t rl_ib_size) { - uint64_t rl_gpu_ib_addr; uint32_t *rl_buffer; - size_t rl_ib_size, packet_size_dwords; + size_t packet_size_dwords; int retval; - retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr, - &rl_ib_size); - if (retval) - goto fail_create_runlist_ib; - - pr_debug("runlist IB address: 0x%llX\n", rl_gpu_ib_addr); - packet_size_dwords = pm->pmf->runlist_size / sizeof(uint32_t); mutex_lock(&pm->lock); @@ -321,7 +313,7 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) if (retval) goto fail_acquire_packet_buffer; - retval = pm->pmf->runlist(pm, rl_buffer, rl_gpu_ib_addr, + retval = pm->pmf->runlist(pm, rl_buffer, rl_ib_gpu_addr, rl_ib_size / sizeof(uint32_t), false); if (retval) goto fail_create_runlist; @@ -336,8 +328,6 @@ int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) kq_rollback_packet(pm->priv_queue); fail_acquire_packet_buffer: mutex_unlock(&pm->lock); -fail_create_runlist_ib: - pm_destroy_runlist_ib(pm); return retval; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 389cda7c8f1a..6accb605b9f0 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -980,7 +980,8 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm); void pm_uninit(struct packet_manager *pm); int pm_send_set_resources(struct packet_manager *pm, struct scheduling_resources *res); -int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues); +int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues, + uint64_t rl_ib_gpu_addr, size_t rl_ib_size); int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address, uint32_t fence_value); @@ -989,6 +990,10 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type, uint32_t filter_param, bool reset, unsigned int sdma_engine); +int pm_create_runlist_ib(struct packet_manager *pm, + struct list_head *queues, + uint64_t *rl_gpu_addr, + size_t *rl_size_bytes); void pm_destroy_runlist_ib(struct packet_manager *pm); /* Following PM funcs can be shared among VI and AI */ -- 2.17.1 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx