drm/amdgpu: simplify hw status clear/set logic
authorJiawei <Jiawei.Gu@amd.com>
Thu, 27 Aug 2020 02:07:52 +0000 (10:07 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Aug 2020 14:09:07 +0000 (10:09 -0400)
Optimize code to iterate less loops in
amdgpu_device_ip_reinit_early_sriov()

Signed-off-by: Jiawei <Jiawei.Gu@amd.com>
Reviewed-by: Emily.Deng <Emily.Deng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 8f37f9f..696a61c 100644 (file)
@@ -2598,17 +2598,16 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
                AMD_IP_BLOCK_TYPE_IH,
        };
 
-       for (i = 0; i < adev->num_ip_blocks; i++)
-               adev->ip_blocks[i].status.hw = false;
-
-       for (i = 0; i < ARRAY_SIZE(ip_order); i++) {
+       for (i = 0; i < adev->num_ip_blocks; i++) {
                int j;
                struct amdgpu_ip_block *block;
 
-               for (j = 0; j < adev->num_ip_blocks; j++) {
-                       block = &adev->ip_blocks[j];
+               block = &adev->ip_blocks[i];
+               block->status.hw = false;
 
-                       if (block->version->type != ip_order[i] ||
+               for (j = 0; j < ARRAY_SIZE(ip_order); j++) {
+
+                       if (block->version->type != ip_order[j] ||
                                !block->status.valid)
                                continue;