From: Jay Cornwall jay.cornwall@amd.com
dqm->queue_count tracks queues in the active state only. In a few places this count is modified unconditionally, leading to an incorrect value when the UPDATE_QUEUE ioctl is used to make a queue inactive.
Signed-off-by: Jay Cornwall jay.cornwall@amd.com Reviewed-by: Ben Goz ben.goz@amd.com Signed-off-by: Oded Gabbay oded.gabbay@amd.com --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 ecc78ec..36b95e1 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -167,7 +167,8 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, }
list_add(&q->list, &qpd->queues_list); - dqm->queue_count++; + if (q->properties.is_active) + dqm->queue_count++;
if (q->properties.type == KFD_QUEUE_TYPE_SDMA) dqm->sdma_queue_count++; @@ -313,7 +314,8 @@ static int destroy_queue_nocpsch(struct device_queue_manager *dqm, list_del(&q->list); if (list_empty(&qpd->queues_list)) deallocate_vmid(dqm, qpd, q); - dqm->queue_count--; + if (q->properties.is_active) + dqm->queue_count--;
/* * Unconditionally decrement this counter, regardless of the queue's @@ -1018,7 +1020,8 @@ static int destroy_queue_cpsch(struct device_queue_manager *dqm, dqm->sdma_queue_count--;
list_del(&q->list); - dqm->queue_count--; + if (q->properties.is_active) + dqm->queue_count--;
execute_queues_cpsch(dqm, false);
From: Jay Cornwall jay.cornwall@amd.com
CP microcode uses undocumented bits in this register to record queue state information. The KFD zeroes these bits in update_mqd, when invoked through the UPDATE_QUEUE ioctl, causing incoherent state when the ioctl is used to successively unmap and map a queue.
Since the queue type cannot be changed in this path, move the MQD write to init_mqd.
Signed-off-by: Jay Cornwall jay.cornwall@amd.com Reviewed-by: Ben Goz ben.goz@amd.com Signed-off-by: Oded Gabbay oded.gabbay@amd.com --- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c index a318743..a09e18a 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c @@ -94,6 +94,9 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, m->cp_hqd_pipe_priority = 1; m->cp_hqd_queue_priority = 15;
+ if (q->format == KFD_QUEUE_FORMAT_AQL) + m->cp_hqd_iq_rptr = AQL_ENABLE; + *mqd = m; if (gart_addr != NULL) *gart_addr = addr; @@ -187,7 +190,6 @@ static int update_mqd(struct mqd_manager *mm, void *mqd, m->cp_hqd_vmid = q->vmid;
if (q->format == KFD_QUEUE_FORMAT_AQL) { - m->cp_hqd_iq_rptr = AQL_ENABLE; m->cp_hqd_pq_control |= NO_UPDATE_RPTR; }
dri-devel@lists.freedesktop.org