Commit d2f52ac8 authored by Rex Zhu's avatar Rex Zhu Committed by Alex Deucher

drm/amdgpu: move common pm sysfs code to amdgpu_device.c

Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c98171cc
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "amdgpu_vf_error.h" #include "amdgpu_vf_error.h"
#include "amdgpu_amdkfd.h" #include "amdgpu_amdkfd.h"
#include "amdgpu_pm.h"
MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin");
...@@ -2216,6 +2217,10 @@ int amdgpu_device_init(struct amdgpu_device *adev, ...@@ -2216,6 +2217,10 @@ int amdgpu_device_init(struct amdgpu_device *adev,
amdgpu_fbdev_init(adev); amdgpu_fbdev_init(adev);
r = amdgpu_pm_sysfs_init(adev);
if (r)
DRM_ERROR("registering pm debugfs failed (%d).\n", r);
r = amdgpu_gem_debugfs_init(adev); r = amdgpu_gem_debugfs_init(adev);
if (r) if (r)
DRM_ERROR("registering gem debugfs failed (%d).\n", r); DRM_ERROR("registering gem debugfs failed (%d).\n", r);
...@@ -2312,6 +2317,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) ...@@ -2312,6 +2317,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
iounmap(adev->rmmio); iounmap(adev->rmmio);
adev->rmmio = NULL; adev->rmmio = NULL;
amdgpu_doorbell_fini(adev); amdgpu_doorbell_fini(adev);
amdgpu_pm_sysfs_fini(adev);
amdgpu_debugfs_regs_cleanup(adev); amdgpu_debugfs_regs_cleanup(adev);
} }
......
...@@ -1317,6 +1317,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) ...@@ -1317,6 +1317,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
if (adev->pm.sysfs_initialized) if (adev->pm.sysfs_initialized)
return 0; return 0;
if (adev->pm.dpm_enabled == 0)
return 0;
if (adev->powerplay.pp_funcs->get_temperature == NULL) if (adev->powerplay.pp_funcs->get_temperature == NULL)
return 0; return 0;
...@@ -1417,6 +1420,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) ...@@ -1417,6 +1420,9 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
{ {
if (adev->pm.dpm_enabled == 0)
return;
if (adev->pm.int_hwmon_dev) if (adev->pm.int_hwmon_dev)
hwmon_device_unregister(adev->pm.int_hwmon_dev); hwmon_device_unregister(adev->pm.int_hwmon_dev);
device_remove_file(adev->dev, &dev_attr_power_dpm_state); device_remove_file(adev->dev, &dev_attr_power_dpm_state);
......
...@@ -137,10 +137,8 @@ static int amdgpu_pp_late_init(void *handle) ...@@ -137,10 +137,8 @@ static int amdgpu_pp_late_init(void *handle)
ret = adev->powerplay.ip_funcs->late_init( ret = adev->powerplay.ip_funcs->late_init(
adev->powerplay.pp_handle); adev->powerplay.pp_handle);
if (adev->pp_enabled && adev->pm.dpm_enabled) { if (adev->pp_enabled && adev->pm.dpm_enabled)
amdgpu_pm_sysfs_init(adev);
amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_COMPLETE_INIT, NULL, NULL); amdgpu_dpm_dispatch_task(adev, AMD_PP_TASK_COMPLETE_INIT, NULL, NULL);
}
return ret; return ret;
} }
...@@ -199,9 +197,6 @@ static int amdgpu_pp_hw_fini(void *handle) ...@@ -199,9 +197,6 @@ static int amdgpu_pp_hw_fini(void *handle)
int ret = 0; int ret = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
if (adev->pp_enabled && adev->pm.dpm_enabled)
amdgpu_pm_sysfs_fini(adev);
if (adev->powerplay.ip_funcs->hw_fini) if (adev->powerplay.ip_funcs->hw_fini)
ret = adev->powerplay.ip_funcs->hw_fini( ret = adev->powerplay.ip_funcs->hw_fini(
adev->powerplay.pp_handle); adev->powerplay.pp_handle);
......
...@@ -6365,7 +6365,6 @@ static int ci_dpm_sw_fini(void *handle) ...@@ -6365,7 +6365,6 @@ static int ci_dpm_sw_fini(void *handle)
flush_work(&adev->pm.dpm.thermal.work); flush_work(&adev->pm.dpm.thermal.work);
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
amdgpu_pm_sysfs_fini(adev);
ci_dpm_fini(adev); ci_dpm_fini(adev);
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
......
...@@ -2969,16 +2969,10 @@ static int kv_dpm_late_init(void *handle) ...@@ -2969,16 +2969,10 @@ static int kv_dpm_late_init(void *handle)
{ {
/* powerdown unused blocks for now */ /* powerdown unused blocks for now */
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int ret;
if (!amdgpu_dpm) if (!amdgpu_dpm)
return 0; return 0;
/* init the sysfs and debugfs files late */
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
return ret;
kv_dpm_powergate_acp(adev, true); kv_dpm_powergate_acp(adev, true);
kv_dpm_powergate_samu(adev, true); kv_dpm_powergate_samu(adev, true);
...@@ -3040,7 +3034,6 @@ static int kv_dpm_sw_fini(void *handle) ...@@ -3040,7 +3034,6 @@ static int kv_dpm_sw_fini(void *handle)
flush_work(&adev->pm.dpm.thermal.work); flush_work(&adev->pm.dpm.thermal.work);
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
amdgpu_pm_sysfs_fini(adev);
kv_dpm_fini(adev); kv_dpm_fini(adev);
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
......
...@@ -7604,11 +7604,6 @@ static int si_dpm_late_init(void *handle) ...@@ -7604,11 +7604,6 @@ static int si_dpm_late_init(void *handle)
if (!amdgpu_dpm) if (!amdgpu_dpm)
return 0; return 0;
/* init the sysfs and debugfs files late */
ret = amdgpu_pm_sysfs_init(adev);
if (ret)
return ret;
ret = si_set_temperature_range(adev); ret = si_set_temperature_range(adev);
if (ret) if (ret)
return ret; return ret;
...@@ -7764,7 +7759,6 @@ static int si_dpm_sw_fini(void *handle) ...@@ -7764,7 +7759,6 @@ static int si_dpm_sw_fini(void *handle)
flush_work(&adev->pm.dpm.thermal.work); flush_work(&adev->pm.dpm.thermal.work);
mutex_lock(&adev->pm.mutex); mutex_lock(&adev->pm.mutex);
amdgpu_pm_sysfs_fini(adev);
si_dpm_fini(adev); si_dpm_fini(adev);
mutex_unlock(&adev->pm.mutex); mutex_unlock(&adev->pm.mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment