Skip to content

Commit 88e5c8f

Browse files
Ma Junalexdeucher
authored andcommitted
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: Ma Jun <[email protected]> Reviewed-by: Yang Wang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 0e2e7c5 commit 88e5c8f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

drivers/gpu/drm/amd/pm/amdgpu_pm.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,10 +3288,6 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
32883288
uint32_t gc_ver = amdgpu_ip_version(adev, GC_HWIP, 0);
32893289
uint32_t tmp;
32903290

3291-
/* under multi-vf mode, the hwmon attributes are all not supported */
3292-
if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))
3293-
return 0;
3294-
32953291
/* under pp one vf mode manage of hwmon attributes is not supported */
32963292
if (amdgpu_sriov_is_pp_one_vf(adev))
32973293
effective_mode &= ~S_IWUSR;
@@ -4162,6 +4158,7 @@ static int amdgpu_od_set_init(struct amdgpu_device *adev)
41624158

41634159
int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
41644160
{
4161+
enum amdgpu_sriov_vf_mode mode;
41654162
uint32_t mask = 0;
41664163
int ret;
41674164

@@ -4173,17 +4170,21 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
41734170
if (adev->pm.dpm_enabled == 0)
41744171
return 0;
41754172

4176-
adev->pm.int_hwmon_dev = hwmon_device_register_with_groups(adev->dev,
4177-
DRIVER_NAME, adev,
4178-
hwmon_groups);
4179-
if (IS_ERR(adev->pm.int_hwmon_dev)) {
4180-
ret = PTR_ERR(adev->pm.int_hwmon_dev);
4181-
dev_err(adev->dev,
4182-
"Unable to register hwmon device: %d\n", ret);
4183-
return ret;
4173+
mode = amdgpu_virt_get_sriov_vf_mode(adev);
4174+
4175+
/* under multi-vf mode, the hwmon attributes are all not supported */
4176+
if (mode != SRIOV_VF_MODE_MULTI_VF) {
4177+
adev->pm.int_hwmon_dev = hwmon_device_register_with_groups(adev->dev,
4178+
DRIVER_NAME, adev,
4179+
hwmon_groups);
4180+
if (IS_ERR(adev->pm.int_hwmon_dev)) {
4181+
ret = PTR_ERR(adev->pm.int_hwmon_dev);
4182+
dev_err(adev->dev, "Unable to register hwmon device: %d\n", ret);
4183+
return ret;
4184+
}
41844185
}
41854186

4186-
switch (amdgpu_virt_get_sriov_vf_mode(adev)) {
4187+
switch (mode) {
41874188
case SRIOV_VF_MODE_ONE_VF:
41884189
mask = ATTR_FLAG_ONEVF;
41894190
break;

0 commit comments

Comments
 (0)