diff options
author | Ben Goz <ben.goz@amd.com> | 2015-06-24 15:39:21 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-06-29 11:21:39 -0400 |
commit | cd06bf687b89f7532d19b0e4484299372e1bf70c (patch) | |
tree | 56fa750cb71c56a87cec48babad8b28d7db19134 | |
parent | 69ee2410238e6ea6fd5d0a91b04510bba8abc7b5 (diff) |
drm/amdgpu: Initialize compute sdma and memory from kgd
v2: add missing MTYPE_NONCACHED enum
Signed-off-by: Ben Goz <ben.goz@amd.com>
Acked-by: Oded Gabbay <oded.gabbay@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/cikd.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 42 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 47 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 28 |
4 files changed, 123 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/cikd.h b/drivers/gpu/drm/amd/amdgpu/cikd.h index 220865a44814..d19085a97064 100644 --- a/drivers/gpu/drm/amd/amdgpu/cikd.h +++ b/drivers/gpu/drm/amd/amdgpu/cikd.h | |||
@@ -552,4 +552,10 @@ | |||
552 | #define VCE_CMD_IB_AUTO 0x00000005 | 552 | #define VCE_CMD_IB_AUTO 0x00000005 |
553 | #define VCE_CMD_SEMAPHORE 0x00000006 | 553 | #define VCE_CMD_SEMAPHORE 0x00000006 |
554 | 554 | ||
555 | /* valid for both DEFAULT_MTYPE and APE1_MTYPE */ | ||
556 | enum { | ||
557 | MTYPE_CACHED = 0, | ||
558 | MTYPE_NONCACHED = 3 | ||
559 | }; | ||
560 | |||
555 | #endif | 561 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c index cb7907447b81..2c188fb9fd22 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | |||
@@ -2010,6 +2010,46 @@ static void gfx_v7_0_setup_rb(struct amdgpu_device *adev, | |||
2010 | } | 2010 | } |
2011 | 2011 | ||
2012 | /** | 2012 | /** |
2013 | * gmc_v7_0_init_compute_vmid - gart enable | ||
2014 | * | ||
2015 | * @rdev: amdgpu_device pointer | ||
2016 | * | ||
2017 | * Initialize compute vmid sh_mem registers | ||
2018 | * | ||
2019 | */ | ||
2020 | #define DEFAULT_SH_MEM_BASES (0x6000) | ||
2021 | #define FIRST_COMPUTE_VMID (8) | ||
2022 | #define LAST_COMPUTE_VMID (16) | ||
2023 | static void gmc_v7_0_init_compute_vmid(struct amdgpu_device *adev) | ||
2024 | { | ||
2025 | int i; | ||
2026 | uint32_t sh_mem_config; | ||
2027 | uint32_t sh_mem_bases; | ||
2028 | |||
2029 | /* | ||
2030 | * Configure apertures: | ||
2031 | * LDS: 0x60000000'00000000 - 0x60000001'00000000 (4GB) | ||
2032 | * Scratch: 0x60000001'00000000 - 0x60000002'00000000 (4GB) | ||
2033 | * GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB) | ||
2034 | */ | ||
2035 | sh_mem_bases = DEFAULT_SH_MEM_BASES | (DEFAULT_SH_MEM_BASES << 16); | ||
2036 | sh_mem_config = SH_MEM_ALIGNMENT_MODE_UNALIGNED << | ||
2037 | SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT; | ||
2038 | sh_mem_config |= MTYPE_NONCACHED << SH_MEM_CONFIG__DEFAULT_MTYPE__SHIFT; | ||
2039 | mutex_lock(&adev->srbm_mutex); | ||
2040 | for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) { | ||
2041 | cik_srbm_select(adev, 0, 0, 0, i); | ||
2042 | /* CP and shaders */ | ||
2043 | WREG32(mmSH_MEM_CONFIG, sh_mem_config); | ||
2044 | WREG32(mmSH_MEM_APE1_BASE, 1); | ||
2045 | WREG32(mmSH_MEM_APE1_LIMIT, 0); | ||
2046 | WREG32(mmSH_MEM_BASES, sh_mem_bases); | ||
2047 | } | ||
2048 | cik_srbm_select(adev, 0, 0, 0, 0); | ||
2049 | mutex_unlock(&adev->srbm_mutex); | ||
2050 | } | ||
2051 | |||
2052 | /** | ||
2013 | * gfx_v7_0_gpu_init - setup the 3D engine | 2053 | * gfx_v7_0_gpu_init - setup the 3D engine |
2014 | * | 2054 | * |
2015 | * @adev: amdgpu_device pointer | 2055 | * @adev: amdgpu_device pointer |
@@ -2230,6 +2270,8 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev) | |||
2230 | cik_srbm_select(adev, 0, 0, 0, 0); | 2270 | cik_srbm_select(adev, 0, 0, 0, 0); |
2231 | mutex_unlock(&adev->srbm_mutex); | 2271 | mutex_unlock(&adev->srbm_mutex); |
2232 | 2272 | ||
2273 | gmc_v7_0_init_compute_vmid(adev); | ||
2274 | |||
2233 | WREG32(mmSX_DEBUG_1, 0x20); | 2275 | WREG32(mmSX_DEBUG_1, 0x20); |
2234 | 2276 | ||
2235 | WREG32(mmTA_CNTL_AUX, 0x00010000); | 2277 | WREG32(mmTA_CNTL_AUX, 0x00010000); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 14242bd33363..e4aeb74d2599 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -1894,6 +1894,51 @@ static void gfx_v8_0_setup_rb(struct amdgpu_device *adev, | |||
1894 | mutex_unlock(&adev->grbm_idx_mutex); | 1894 | mutex_unlock(&adev->grbm_idx_mutex); |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | /** | ||
1898 | * gmc_v8_0_init_compute_vmid - gart enable | ||
1899 | * | ||
1900 | * @rdev: amdgpu_device pointer | ||
1901 | * | ||
1902 | * Initialize compute vmid sh_mem registers | ||
1903 | * | ||
1904 | */ | ||
1905 | #define DEFAULT_SH_MEM_BASES (0x6000) | ||
1906 | #define FIRST_COMPUTE_VMID (8) | ||
1907 | #define LAST_COMPUTE_VMID (16) | ||
1908 | static void gmc_v8_0_init_compute_vmid(struct amdgpu_device *adev) | ||
1909 | { | ||
1910 | int i; | ||
1911 | uint32_t sh_mem_config; | ||
1912 | uint32_t sh_mem_bases; | ||
1913 | |||
1914 | /* | ||
1915 | * Configure apertures: | ||
1916 | * LDS: 0x60000000'00000000 - 0x60000001'00000000 (4GB) | ||
1917 | * Scratch: 0x60000001'00000000 - 0x60000002'00000000 (4GB) | ||
1918 | * GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB) | ||
1919 | */ | ||
1920 | sh_mem_bases = DEFAULT_SH_MEM_BASES | (DEFAULT_SH_MEM_BASES << 16); | ||
1921 | |||
1922 | sh_mem_config = SH_MEM_ADDRESS_MODE_HSA64 << | ||
1923 | SH_MEM_CONFIG__ADDRESS_MODE__SHIFT | | ||
1924 | SH_MEM_ALIGNMENT_MODE_UNALIGNED << | ||
1925 | SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT | | ||
1926 | MTYPE_CC << SH_MEM_CONFIG__DEFAULT_MTYPE__SHIFT | | ||
1927 | SH_MEM_CONFIG__PRIVATE_ATC_MASK; | ||
1928 | |||
1929 | mutex_lock(&adev->srbm_mutex); | ||
1930 | for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) { | ||
1931 | vi_srbm_select(adev, 0, 0, 0, i); | ||
1932 | /* CP and shaders */ | ||
1933 | WREG32(mmSH_MEM_CONFIG, sh_mem_config); | ||
1934 | WREG32(mmSH_MEM_APE1_BASE, 1); | ||
1935 | WREG32(mmSH_MEM_APE1_LIMIT, 0); | ||
1936 | WREG32(mmSH_MEM_BASES, sh_mem_bases); | ||
1937 | } | ||
1938 | vi_srbm_select(adev, 0, 0, 0, 0); | ||
1939 | mutex_unlock(&adev->srbm_mutex); | ||
1940 | } | ||
1941 | |||
1897 | static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) | 1942 | static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) |
1898 | { | 1943 | { |
1899 | u32 gb_addr_config; | 1944 | u32 gb_addr_config; |
@@ -2113,6 +2158,8 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) | |||
2113 | vi_srbm_select(adev, 0, 0, 0, 0); | 2158 | vi_srbm_select(adev, 0, 0, 0, 0); |
2114 | mutex_unlock(&adev->srbm_mutex); | 2159 | mutex_unlock(&adev->srbm_mutex); |
2115 | 2160 | ||
2161 | gmc_v8_0_init_compute_vmid(adev); | ||
2162 | |||
2116 | mutex_lock(&adev->grbm_idx_mutex); | 2163 | mutex_lock(&adev->grbm_idx_mutex); |
2117 | /* | 2164 | /* |
2118 | * making sure that the following register writes will be broadcasted | 2165 | * making sure that the following register writes will be broadcasted |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index e3c1fde75363..7bb37b93993f 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -439,6 +439,31 @@ static void sdma_v3_0_rlc_stop(struct amdgpu_device *adev) | |||
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * sdma_v3_0_ctx_switch_enable - stop the async dma engines context switch | ||
443 | * | ||
444 | * @adev: amdgpu_device pointer | ||
445 | * @enable: enable/disable the DMA MEs context switch. | ||
446 | * | ||
447 | * Halt or unhalt the async dma engines context switch (VI). | ||
448 | */ | ||
449 | static void sdma_v3_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) | ||
450 | { | ||
451 | u32 f32_cntl; | ||
452 | int i; | ||
453 | |||
454 | for (i = 0; i < SDMA_MAX_INSTANCE; i++) { | ||
455 | f32_cntl = RREG32(mmSDMA0_CNTL + sdma_offsets[i]); | ||
456 | if (enable) | ||
457 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | ||
458 | AUTO_CTXSW_ENABLE, 1); | ||
459 | else | ||
460 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | ||
461 | AUTO_CTXSW_ENABLE, 0); | ||
462 | WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | /** | ||
442 | * sdma_v3_0_enable - stop the async dma engines | 467 | * sdma_v3_0_enable - stop the async dma engines |
443 | * | 468 | * |
444 | * @adev: amdgpu_device pointer | 469 | * @adev: amdgpu_device pointer |
@@ -648,6 +673,8 @@ static int sdma_v3_0_start(struct amdgpu_device *adev) | |||
648 | 673 | ||
649 | /* unhalt the MEs */ | 674 | /* unhalt the MEs */ |
650 | sdma_v3_0_enable(adev, true); | 675 | sdma_v3_0_enable(adev, true); |
676 | /* enable sdma ring preemption */ | ||
677 | sdma_v3_0_ctx_switch_enable(adev, true); | ||
651 | 678 | ||
652 | /* start the gfx rings and rlc compute queues */ | 679 | /* start the gfx rings and rlc compute queues */ |
653 | r = sdma_v3_0_gfx_resume(adev); | 680 | r = sdma_v3_0_gfx_resume(adev); |
@@ -1079,6 +1106,7 @@ static int sdma_v3_0_hw_fini(void *handle) | |||
1079 | { | 1106 | { |
1080 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1107 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1081 | 1108 | ||
1109 | sdma_v3_0_ctx_switch_enable(adev, false); | ||
1082 | sdma_v3_0_enable(adev, false); | 1110 | sdma_v3_0_enable(adev, false); |
1083 | 1111 | ||
1084 | return 0; | 1112 | return 0; |