summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 77578ecc6782..cab3196a87fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -503,6 +503,55 @@ void amdgpu_gfx_mqd_sw_fini(struct amdgpu_device *adev, int xcc_id)
&ring->mqd_ptr);
}
+void amdgpu_gfx_mqd_symmetrically_map_cu_mask(struct amdgpu_device *adev, const uint32_t *cu_mask,
+ uint32_t cu_mask_count, uint32_t *se_mask)
+{
+ struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
+ struct amdgpu_gfx_config *gfx_info = &adev->gfx.config;
+ uint32_t cu_per_sh[8][4] = {0};
+ int i, se, sh, cu, cu_bitmap_sh_mul;
+ int xcc_inst = ffs(adev->gfx.xcc_mask) - 1;
+ bool wgp_mode_req = amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(10, 0, 0);
+ int cu_inc = wgp_mode_req ? 2 : 1;
+ uint32_t en_mask = wgp_mode_req ? 0x3 : 0x1;
+ int num_xcc, inc, inst = 0;
+
+ if (xcc_inst < 0)
+ xcc_inst = 0;
+
+ num_xcc = hweight16(adev->gfx.xcc_mask);
+ if (!num_xcc)
+ num_xcc = 1;
+
+ inc = cu_inc * num_xcc;
+
+ cu_bitmap_sh_mul = 2;
+
+ for (se = 0; se < gfx_info->max_shader_engines; se++)
+ for (sh = 0; sh < gfx_info->max_sh_per_se; sh++)
+ cu_per_sh[se][sh] = hweight32(
+ cu_info->bitmap[xcc_inst][se % 4][sh + (se / 4) *
+ cu_bitmap_sh_mul]);
+
+ for (i = 0; i < gfx_info->max_shader_engines; i++)
+ se_mask[i] = 0;
+
+ i = inst;
+ for (cu = 0; cu < 16; cu += cu_inc) {
+ for (sh = 0; sh < gfx_info->max_sh_per_se; sh++) {
+ for (se = 0; se < gfx_info->max_shader_engines; se++) {
+ if (cu_per_sh[se][sh] > cu) {
+ if ((i / 32) < cu_mask_count && (cu_mask[i / 32] & (1 << (i % 32))))
+ se_mask[se] |= en_mask << (cu + sh * 16);
+ i += inc;
+ if (i >= cu_mask_count * 32)
+ return;
+ }
+ }
+ }
+ }
+}
+
int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
{
struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];