Skip to content

Commit

Permalink
drm/amdgpu/userq: prevent runtime pm when userqs are active
Browse files Browse the repository at this point in the history
Similar to KFD, prevent runtime pm while user queues are active.

Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Alex Deucher committed Apr 8, 2025
1 parent 4ce60db commit cf97de5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,29 @@ static int amdgpu_runtime_idle_check_display(struct device *dev)
return 0;
}

static int amdgpu_runtime_idle_check_userq(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev);
struct amdgpu_device *adev = drm_to_adev(drm_dev);
struct amdgpu_usermode_queue *queue;
struct amdgpu_userq_mgr *uqm, *tmp;
int queue_id;
int ret = 0;

mutex_lock(&adev->userq_mutex);
list_for_each_entry_safe(uqm, tmp, &adev->userq_mgr_list, list) {
idr_for_each_entry(&uqm->userq_idr, queue, queue_id) {
ret = -EBUSY;
goto done;
}
}
done:
mutex_unlock(&adev->userq_mutex);

return ret;
}

static int amdgpu_pmops_runtime_suspend(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
Expand All @@ -2723,6 +2746,9 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
}

ret = amdgpu_runtime_idle_check_display(dev);
if (ret)
return ret;
ret = amdgpu_runtime_idle_check_userq(dev);
if (ret)
return ret;

Expand Down Expand Up @@ -2846,7 +2872,11 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)
}

ret = amdgpu_runtime_idle_check_display(dev);
if (ret)
goto done;

ret = amdgpu_runtime_idle_check_userq(dev);
done:
pm_runtime_mark_last_busy(dev);
pm_runtime_autosuspend(dev);
return ret;
Expand Down

0 comments on commit cf97de5

Please sign in to comment.