]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amdgpu: Check if SW SMU is supported before accessing funcs
authorLeo Li <sunpeng.li@amd.com>
Thu, 18 Apr 2019 15:53:58 +0000 (11:53 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Apr 2019 22:27:25 +0000 (17:27 -0500)
smu.ppt_funcs is only initialized for ASICs supporting SW SMU.

On a Hawaii ASIC, attempting to access the udev attribute
ATTRS{power_dpm_state} will cause a null pointer deref in
amdgpu_get_dpm_state() because of this.

Fix by checking if SW SMU is supported first.

Signed-off-by: Leo Li <sunpeng.li@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c

index 4b7a076eea9cd5f59dbd25d9713f35d06376b56a..95144e49c7f9df9e914b3e37421d4f60913070fd 100644 (file)
@@ -144,7 +144,7 @@ static ssize_t amdgpu_get_dpm_state(struct device *dev,
        struct amdgpu_device *adev = ddev->dev_private;
        enum amd_pm_state_type pm;
 
-       if (adev->smu.ppt_funcs->get_current_power_state)
+       if (is_support_sw_smu(adev) && adev->smu.ppt_funcs->get_current_power_state)
                pm = amdgpu_smu_get_current_power_state(adev);
        else if (adev->powerplay.pp_funcs->get_current_power_state)
                pm = amdgpu_dpm_get_current_power_state(adev);