mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
drm/amd: Reduce code duplication in runtime PM
[Why] amdgpu_pmops_runtime_suspend() runs almost the same code that amdgpu_pmops_runtime_idle() runs. That is there is pointless code duplication. [How] Move amdgpu_pmops_runtime_idle() up, extract common code and then call from both functions. No intended functional changes. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
bfe9a7545b
commit
bdb423fd39
|
|
@ -2810,12 +2810,11 @@ static int amdgpu_runtime_idle_check_userq(struct device *dev)
|
|||
return xa_empty(&adev->userq_doorbell_xa) ? 0 : -EBUSY;
|
||||
}
|
||||
|
||||
static int amdgpu_pmops_runtime_suspend(struct device *dev)
|
||||
static int amdgpu_pmops_runtime_checks(struct device *dev)
|
||||
{
|
||||
struct pci_dev *pdev = to_pci_dev(dev);
|
||||
struct drm_device *drm_dev = pci_get_drvdata(pdev);
|
||||
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
||||
struct amdgpu_device *adev = drm_to_adev(drm_dev);
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
if (adev->pm.rpm_mode == AMDGPU_RUNPM_NONE) {
|
||||
pm_runtime_forbid(dev);
|
||||
|
|
@ -2825,7 +2824,27 @@ 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);
|
||||
|
||||
return amdgpu_runtime_idle_check_userq(dev);
|
||||
}
|
||||
|
||||
static int amdgpu_pmops_runtime_idle(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = amdgpu_pmops_runtime_checks(dev);
|
||||
pm_runtime_autosuspend(dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int amdgpu_pmops_runtime_suspend(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);
|
||||
int ret, i;
|
||||
|
||||
ret = amdgpu_pmops_runtime_checks(dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -2937,27 +2956,6 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int amdgpu_pmops_runtime_idle(struct device *dev)
|
||||
{
|
||||
struct drm_device *drm_dev = dev_get_drvdata(dev);
|
||||
struct amdgpu_device *adev = drm_to_adev(drm_dev);
|
||||
int ret;
|
||||
|
||||
if (adev->pm.rpm_mode == AMDGPU_RUNPM_NONE) {
|
||||
pm_runtime_forbid(dev);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
ret = amdgpu_runtime_idle_check_display(dev);
|
||||
if (ret)
|
||||
goto done;
|
||||
|
||||
ret = amdgpu_runtime_idle_check_userq(dev);
|
||||
done:
|
||||
pm_runtime_autosuspend(dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int amdgpu_drm_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
struct drm_file *file_priv = filp->private_data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user