drm/amdkfd: Fix compute profile switching
Fix compute profile switching on process termination. Add a dedicated reference counter to keep track of entry/exit to/from compute profile. This enables switching compute profiles for other reasons than process creation or termination. Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com> Signed-off-by: Eric Huang <JinhuiEric.Huang@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
057f91645c
commit
43d8107f0b
|
@ -463,6 +463,7 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
|
|||
kfd->pdev = pdev;
|
||||
kfd->init_complete = false;
|
||||
kfd->kfd2kgd = f2g;
|
||||
atomic_set(&kfd->compute_profile, 0);
|
||||
|
||||
mutex_init(&kfd->doorbell_mutex);
|
||||
memset(&kfd->doorbell_available_index, 0,
|
||||
|
@ -1037,6 +1038,21 @@ void kgd2kfd_set_sram_ecc_flag(struct kfd_dev *kfd)
|
|||
atomic_inc(&kfd->sram_ecc_flag);
|
||||
}
|
||||
|
||||
void kfd_inc_compute_active(struct kfd_dev *kfd)
|
||||
{
|
||||
if (atomic_inc_return(&kfd->compute_profile) == 1)
|
||||
amdgpu_amdkfd_set_compute_idle(kfd->kgd, false);
|
||||
}
|
||||
|
||||
void kfd_dec_compute_active(struct kfd_dev *kfd)
|
||||
{
|
||||
int count = atomic_dec_return(&kfd->compute_profile);
|
||||
|
||||
if (count == 0)
|
||||
amdgpu_amdkfd_set_compute_idle(kfd->kgd, true);
|
||||
WARN_ONCE(count < 0, "Compute profile ref. count error");
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
|
||||
/* This function will send a package to HIQ to hang the HWS
|
||||
|
|
|
@ -811,8 +811,8 @@ static int register_process(struct device_queue_manager *dqm,
|
|||
|
||||
retval = dqm->asic_ops.update_qpd(dqm, qpd);
|
||||
|
||||
if (dqm->processes_count++ == 0)
|
||||
amdgpu_amdkfd_set_compute_idle(dqm->dev->kgd, false);
|
||||
dqm->processes_count++;
|
||||
kfd_inc_compute_active(dqm->dev);
|
||||
|
||||
dqm_unlock(dqm);
|
||||
|
||||
|
@ -835,9 +835,8 @@ static int unregister_process(struct device_queue_manager *dqm,
|
|||
if (qpd == cur->qpd) {
|
||||
list_del(&cur->list);
|
||||
kfree(cur);
|
||||
if (--dqm->processes_count == 0)
|
||||
amdgpu_amdkfd_set_compute_idle(
|
||||
dqm->dev->kgd, true);
|
||||
dqm->processes_count--;
|
||||
kfd_dec_compute_active(dqm->dev);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -1539,6 +1538,7 @@ static int process_termination_nocpsch(struct device_queue_manager *dqm,
|
|||
list_del(&cur->list);
|
||||
kfree(cur);
|
||||
dqm->processes_count--;
|
||||
kfd_dec_compute_active(dqm->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1626,6 +1626,7 @@ static int process_termination_cpsch(struct device_queue_manager *dqm,
|
|||
list_del(&cur->list);
|
||||
kfree(cur);
|
||||
dqm->processes_count--;
|
||||
kfd_dec_compute_active(dqm->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,6 +279,9 @@ struct kfd_dev {
|
|||
|
||||
/* SRAM ECC flag */
|
||||
atomic_t sram_ecc_flag;
|
||||
|
||||
/* Compute Profile ref. count */
|
||||
atomic_t compute_profile;
|
||||
};
|
||||
|
||||
enum kfd_mempool {
|
||||
|
@ -978,6 +981,10 @@ int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p);
|
|||
|
||||
bool kfd_is_locked(void);
|
||||
|
||||
/* Compute profile */
|
||||
void kfd_inc_compute_active(struct kfd_dev *dev);
|
||||
void kfd_dec_compute_active(struct kfd_dev *dev);
|
||||
|
||||
/* Debugfs */
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
|
||||
|
|
Loading…
Reference in New Issue