drm/amdgpu:fix get wrong gfx always on cu masks.
authorRex Zhu <Rex.Zhu@amd.com>
Wed, 26 Apr 2017 08:32:22 +0000 (16:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 May 2017 21:40:05 +0000 (17:40 -0400)
Bug: SWDEV-117987: Always on CU mask broken for gfx7+

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

index a125f9d44577ed4bb86d01516c7594977def46a7..5d9e95bcd0112fb8adac55c1e7b5d8783bdbb598 100644 (file)
@@ -3719,6 +3719,12 @@ static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev)
        u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
        struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
        unsigned disable_masks[4 * 2];
+       u32 ao_cu_num;
+
+       if (adev->flags & AMD_IS_APU)
+               ao_cu_num = 2;
+       else
+               ao_cu_num = adev->gfx.config.max_cu_per_sh;
 
        memset(cu_info, 0, sizeof(*cu_info));
 
@@ -3737,9 +3743,9 @@ static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev)
                        bitmap = gfx_v6_0_get_cu_enabled(adev);
                        cu_info->bitmap[i][j] = bitmap;
 
-                       for (k = 0; k < 16; k++) {
+                       for (k = 0; k < adev->gfx.config.max_cu_per_sh; k++) {
                                if (bitmap & mask) {
-                                       if (counter < 2)
+                                       if (counter < ao_cu_num)
                                                ao_bitmap |= mask;
                                        counter ++;
                                }
index 29d0df2b55d9d78e80508e49b3a8dca61b089ab8..e27262bc0fd1eb7bff0e27ad9d437d0eb6b7de61 100644 (file)
@@ -5339,6 +5339,12 @@ static void gfx_v7_0_get_cu_info(struct amdgpu_device *adev)
        u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
        struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
        unsigned disable_masks[4 * 2];
+       u32 ao_cu_num;
+
+       if (adev->flags & AMD_IS_APU)
+               ao_cu_num = 2;
+       else
+               ao_cu_num = adev->gfx.config.max_cu_per_sh;
 
        memset(cu_info, 0, sizeof(*cu_info));
 
@@ -5357,9 +5363,9 @@ static void gfx_v7_0_get_cu_info(struct amdgpu_device *adev)
                        bitmap = gfx_v7_0_get_cu_active_bitmap(adev);
                        cu_info->bitmap[i][j] = bitmap;
 
-                       for (k = 0; k < 16; k ++) {
+                       for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
                                if (bitmap & mask) {
-                                       if (counter < 2)
+                                       if (counter < ao_cu_num)
                                                ao_bitmap |= mask;
                                        counter ++;
                                }
index 8da7ecc8a8c8871dd150a2360611c4bc97d5e46a..ffe3ac20f2907e2f2308685737c706a984eff915 100644 (file)
@@ -7109,9 +7109,15 @@ static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev)
        u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
        struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
        unsigned disable_masks[4 * 2];
+       u32 ao_cu_num;
 
        memset(cu_info, 0, sizeof(*cu_info));
 
+       if (adev->flags & AMD_IS_APU)
+               ao_cu_num = 2;
+       else
+               ao_cu_num = adev->gfx.config.max_cu_per_sh;
+
        amdgpu_gfx_parse_disable_cu(disable_masks, 4, 2);
 
        mutex_lock(&adev->grbm_idx_mutex);
@@ -7127,9 +7133,9 @@ static void gfx_v8_0_get_cu_info(struct amdgpu_device *adev)
                        bitmap = gfx_v8_0_get_cu_active_bitmap(adev);
                        cu_info->bitmap[i][j] = bitmap;
 
-                       for (k = 0; k < 16; k ++) {
+                       for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
                                if (bitmap & mask) {
-                                       if (counter < 2)
+                                       if (counter < ao_cu_num)
                                                ao_bitmap |= mask;
                                        counter ++;
                                }
index 3f5ba3fd08b7d0c36760581445e619dd9c5e4ac9..9788417920019d3cd94021904638a18f7febac5c 100644 (file)
@@ -3666,9 +3666,9 @@ static int gfx_v9_0_get_cu_info(struct amdgpu_device *adev,
                        bitmap = gfx_v9_0_get_cu_active_bitmap(adev);
                        cu_info->bitmap[i][j] = bitmap;
 
-                       for (k = 0; k < 16; k ++) {
+                       for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
                                if (bitmap & mask) {
-                                       if (counter < 2)
+                                       if (counter < adev->gfx.config.max_cu_per_sh)
                                                ao_bitmap |= mask;
                                        counter ++;
                                }