OSDN Git Service

drm/amdgpu/gfx10: set SH_MEM_CONFIG.INITIAL_INST_PREFETCH
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 16 Jul 2019 18:11:22 +0000 (13:11 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 16 Jul 2019 19:49:57 +0000 (14:49 -0500)
Prefetch mode 0 is not supported and can lead to hangs with certain very
specific code patterns. Set a sound prefetch mode for all VMIDs rather
than forcing all shaders to set the prefetch mode at the beginning.

Reduce code duplication a bit while we're at it. Note that the 64-bit
address mode enum and the retry all enum are both 0, so the only
functional change is in the INITIAL_INST_PREFETCH field.

Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

index 4356789..1675d58 100644 (file)
@@ -109,6 +109,13 @@ static const struct soc15_reg_golden golden_settings_gc_10_0_nv10[] =
        /* Pending on emulation bring up */
 };
 
+#define DEFAULT_SH_MEM_CONFIG \
+       ((SH_MEM_ADDRESS_MODE_64 << SH_MEM_CONFIG__ADDRESS_MODE__SHIFT) | \
+        (SH_MEM_ALIGNMENT_MODE_UNALIGNED << SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT) | \
+        (SH_MEM_RETRY_MODE_ALL << SH_MEM_CONFIG__RETRY_MODE__SHIFT) | \
+        (3 << SH_MEM_CONFIG__INITIAL_INST_PREFETCH__SHIFT))
+
+
 static void gfx_v10_0_set_ring_funcs(struct amdgpu_device *adev);
 static void gfx_v10_0_set_irq_funcs(struct amdgpu_device *adev);
 static void gfx_v10_0_set_gds_init(struct amdgpu_device *adev);
@@ -1415,7 +1422,6 @@ static u32 gfx_v10_0_init_pa_sc_tile_steering_override(struct amdgpu_device *ade
 static void gfx_v10_0_init_compute_vmid(struct amdgpu_device *adev)
 {
        int i;
-       uint32_t sh_mem_config;
        uint32_t sh_mem_bases;
 
        /*
@@ -1426,15 +1432,11 @@ static void gfx_v10_0_init_compute_vmid(struct amdgpu_device *adev)
         */
        sh_mem_bases = DEFAULT_SH_MEM_BASES | (DEFAULT_SH_MEM_BASES << 16);
 
-       sh_mem_config = SH_MEM_ADDRESS_MODE_64 |
-                       SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
-                       SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT;
-
        mutex_lock(&adev->srbm_mutex);
        for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) {
                nv_grbm_select(adev, 0, 0, 0, i);
                /* CP and shaders */
-               WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, sh_mem_config);
+               WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, DEFAULT_SH_MEM_CONFIG);
                WREG32_SOC15(GC, 0, mmSH_MEM_BASES, sh_mem_bases);
        }
        nv_grbm_select(adev, 0, 0, 0, 0);
@@ -1527,17 +1529,8 @@ static void gfx_v10_0_constants_init(struct amdgpu_device *adev)
        for (i = 0; i < adev->vm_manager.id_mgr[AMDGPU_GFXHUB].num_ids; i++) {
                nv_grbm_select(adev, 0, 0, 0, i);
                /* CP and shaders */
-               if (i == 0) {
-                       tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
-                                           SH_MEM_ALIGNMENT_MODE_UNALIGNED);
-                       tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, RETRY_MODE, 0);
-                       WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
-                       WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0);
-               } else {
-                       tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
-                                           SH_MEM_ALIGNMENT_MODE_UNALIGNED);
-                       tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, RETRY_MODE, 0);
-                       WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp);
+               WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, DEFAULT_SH_MEM_CONFIG);
+               if (i != 0) {
                        tmp = REG_SET_FIELD(0, SH_MEM_BASES, PRIVATE_BASE,
                                (adev->gmc.private_aperture_start >> 48));
                        tmp = REG_SET_FIELD(tmp, SH_MEM_BASES, SHARED_BASE,