Commit 88e5c8f8 authored by Ma Jun's avatar Ma Jun Committed by Alex Deucher

drm/amd/pm: only check sriov vf flag once when creating hwmon sysfs

The current code checks sriov vf flag multiple times when creating
hwmon sysfs. So fix it.
Signed-off-by: default avatarMa Jun <Jun.Ma2@amd.com>
Reviewed-by: default avatarYang Wang <kevinyang.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0e2e7c5b
...@@ -3288,10 +3288,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, ...@@ -3288,10 +3288,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
uint32_t gc_ver = amdgpu_ip_version(adev, GC_HWIP, 0); uint32_t gc_ver = amdgpu_ip_version(adev, GC_HWIP, 0);
uint32_t tmp; uint32_t tmp;
/* under multi-vf mode, the hwmon attributes are all not supported */
if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
return 0;
/* under pp one vf mode manage of hwmon attributes is not supported */ /* under pp one vf mode manage of hwmon attributes is not supported */
if (amdgpu_sriov_is_pp_one_vf(adev)) if (amdgpu_sriov_is_pp_one_vf(adev))
effective_mode &= ~S_IWUSR; effective_mode &= ~S_IWUSR;
...@@ -4162,6 +4158,7 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev) ...@@ -4162,6 +4158,7 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
{ {
enum amdgpu_sriov_vf_mode mode;
uint32_t mask = 0; uint32_t mask = 0;
int ret; int ret;
...@@ -4173,17 +4170,21 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) ...@@ -4173,17 +4170,21 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
if (adev->pm.dpm_enabled == 0) if (adev->pm.dpm_enabled == 0)
return 0; return 0;
adev->pm.int_hwmon_dev = hwmon_device_register_with_groups(adev->dev, mode = amdgpu_virt_get_sriov_vf_mode(adev);
DRIVER_NAME, adev,
hwmon_groups); /* under multi-vf mode, the hwmon attributes are all not supported */
if (IS_ERR(adev->pm.int_hwmon_dev)) { if (mode != SRIOV_VF_MODE_MULTI_VF) {
ret = PTR_ERR(adev->pm.int_hwmon_dev); adev->pm.int_hwmon_dev = hwmon_device_register_with_groups(adev->dev,
dev_err(adev->dev, DRIVER_NAME, adev,
"Unable to register hwmon device: %d\n", ret); hwmon_groups);
return ret; if (IS_ERR(adev->pm.int_hwmon_dev)) {
ret = PTR_ERR(adev->pm.int_hwmon_dev);
dev_err(adev->dev, "Unable to register hwmon device: %d\n", ret);
return ret;
}
} }
switch (amdgpu_virt_get_sriov_vf_mode(adev)) { switch (mode) {
case SRIOV_VF_MODE_ONE_VF: case SRIOV_VF_MODE_ONE_VF:
mask = ATTR_FLAG_ONEVF; mask = ATTR_FLAG_ONEVF;
break; break;
......
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