drm/amdgpu: skip invalid ip blocks in ip helpers
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 23 Jun 2016 15:53:12 +0000 (11:53 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 7 Jul 2016 19:02:04 +0000 (15:02 -0400)
Skip IP blocks that are not enabled.

Reviewed-by: Chunming zhou <david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index e3cfee18fa68a4e509041cb7916d8d53b239c369..a1364778bd3be4fb6c52b4b4d0b8e1896b94c7d7 100644 (file)
@@ -1075,6 +1075,8 @@ int amdgpu_set_clockgating_state(struct amdgpu_device *adev,
        int i, r = 0;
 
        for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_block_status[i].valid)
+                       continue;
                if (adev->ip_blocks[i].type == block_type) {
                        r = adev->ip_blocks[i].funcs->set_clockgating_state((void *)adev,
                                                                            state);
@@ -1093,6 +1095,8 @@ int amdgpu_set_powergating_state(struct amdgpu_device *adev,
        int i, r = 0;
 
        for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_block_status[i].valid)
+                       continue;
                if (adev->ip_blocks[i].type == block_type) {
                        r = adev->ip_blocks[i].funcs->set_powergating_state((void *)adev,
                                                                            state);
@@ -1110,6 +1114,8 @@ int amdgpu_wait_for_idle(struct amdgpu_device *adev,
        int i, r;
 
        for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_block_status[i].valid)
+                       continue;
                if (adev->ip_blocks[i].type == block_type) {
                        r = adev->ip_blocks[i].funcs->wait_for_idle((void *)adev);
                        if (r)
@@ -1127,6 +1133,8 @@ bool amdgpu_is_idle(struct amdgpu_device *adev,
        int i;
 
        for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_block_status[i].valid)
+                       continue;
                if (adev->ip_blocks[i].type == block_type)
                        return adev->ip_blocks[i].funcs->is_idle((void *)adev);
        }