aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunwei Zhang <Jerry.Zhang@amd.com>2016-03-10 01:20:39 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:53:34 -0400
commit8fe733289bc00914e9ace101088857cda20a1c51 (patch)
treea0a11011cf3694ebea7805e19bb4d95593fb70fb
parent04e30c9c8667494847f3876fe3e6c8b39fa6fd1b (diff)
drm/amdgpu: init aperture definitions (v2)
v2: agd: move apertures to mc structure Signed-off-by: Flora Cui <Flora.Cui@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@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/amdgpu.h5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c17
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c8
5 files changed, 55 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 946ef0c6c75d..d5eed6b86314 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -570,6 +570,11 @@ struct amdgpu_mc {
570 uint32_t srbm_soft_reset; 570 uint32_t srbm_soft_reset;
571 struct amdgpu_mode_mc_save save; 571 struct amdgpu_mode_mc_save save;
572 bool prt_warning; 572 bool prt_warning;
573 /* apertures */
574 u64 shared_aperture_start;
575 u64 shared_aperture_end;
576 u64 private_aperture_start;
577 u64 private_aperture_end;
573}; 578};
574 579
575/* 580/*
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index e471c08dd249..1b8b4941dcf3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -1889,7 +1889,8 @@ static void gfx_v7_0_config_init(struct amdgpu_device *adev)
1889 */ 1889 */
1890static void gfx_v7_0_gpu_init(struct amdgpu_device *adev) 1890static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
1891{ 1891{
1892 u32 tmp, sh_mem_cfg; 1892 u32 sh_mem_cfg, sh_static_mem_cfg, sh_mem_base;
1893 u32 tmp;
1893 int i; 1894 int i;
1894 1895
1895 WREG32(mmGRBM_CNTL, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT)); 1896 WREG32(mmGRBM_CNTL, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT));
@@ -1920,15 +1921,32 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
1920 /* where to put LDS, scratch, GPUVM in FSA64 space */ 1921 /* where to put LDS, scratch, GPUVM in FSA64 space */
1921 sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, 1922 sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE,
1922 SH_MEM_ALIGNMENT_MODE_UNALIGNED); 1923 SH_MEM_ALIGNMENT_MODE_UNALIGNED);
1924 sh_mem_cfg = REG_SET_FIELD(sh_mem_cfg, SH_MEM_CONFIG, DEFAULT_MTYPE,
1925 MTYPE_NC);
1926 sh_mem_cfg = REG_SET_FIELD(sh_mem_cfg, SH_MEM_CONFIG, APE1_MTYPE,
1927 MTYPE_UC);
1928 sh_mem_cfg = REG_SET_FIELD(sh_mem_cfg, SH_MEM_CONFIG, PRIVATE_ATC, 0);
1929
1930 sh_static_mem_cfg = REG_SET_FIELD(0, SH_STATIC_MEM_CONFIG,
1931 SWIZZLE_ENABLE, 1);
1932 sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
1933 ELEMENT_SIZE, 1);
1934 sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
1935 INDEX_STRIDE, 3);
1923 1936
1924 mutex_lock(&adev->srbm_mutex); 1937 mutex_lock(&adev->srbm_mutex);
1925 for (i = 0; i < 16; i++) { 1938 for (i = 0; i < adev->vm_manager.num_ids; i++) {
1939 if (i == 0)
1940 sh_mem_base = 0;
1941 else
1942 sh_mem_base = adev->mc.shared_aperture_start >> 48;
1926 cik_srbm_select(adev, 0, 0, 0, i); 1943 cik_srbm_select(adev, 0, 0, 0, i);
1927 /* CP and shaders */ 1944 /* CP and shaders */
1928 WREG32(mmSH_MEM_CONFIG, sh_mem_cfg); 1945 WREG32(mmSH_MEM_CONFIG, sh_mem_cfg);
1929 WREG32(mmSH_MEM_APE1_BASE, 1); 1946 WREG32(mmSH_MEM_APE1_BASE, 1);
1930 WREG32(mmSH_MEM_APE1_LIMIT, 0); 1947 WREG32(mmSH_MEM_APE1_LIMIT, 0);
1931 WREG32(mmSH_MEM_BASES, 0); 1948 WREG32(mmSH_MEM_BASES, sh_mem_base);
1949 WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
1932 } 1950 }
1933 cik_srbm_select(adev, 0, 0, 0, 0); 1951 cik_srbm_select(adev, 0, 0, 0, 0);
1934 mutex_unlock(&adev->srbm_mutex); 1952 mutex_unlock(&adev->srbm_mutex);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 5dcf8dbdd5b3..fefec6e6379b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -3859,7 +3859,7 @@ static void gfx_v8_0_config_init(struct amdgpu_device *adev)
3859 3859
3860static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) 3860static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
3861{ 3861{
3862 u32 tmp; 3862 u32 tmp, sh_static_mem_cfg;
3863 int i; 3863 int i;
3864 3864
3865 WREG32_FIELD(GRBM_CNTL, READ_TIMEOUT, 0xFF); 3865 WREG32_FIELD(GRBM_CNTL, READ_TIMEOUT, 0xFF);
@@ -3874,8 +3874,14 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
3874 3874
3875 /* XXX SH_MEM regs */ 3875 /* XXX SH_MEM regs */
3876 /* where to put LDS, scratch, GPUVM in FSA64 space */ 3876 /* where to put LDS, scratch, GPUVM in FSA64 space */
3877 sh_static_mem_cfg = REG_SET_FIELD(0, SH_STATIC_MEM_CONFIG,
3878 SWIZZLE_ENABLE, 1);
3879 sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
3880 ELEMENT_SIZE, 1);
3881 sh_static_mem_cfg = REG_SET_FIELD(sh_static_mem_cfg, SH_STATIC_MEM_CONFIG,
3882 INDEX_STRIDE, 3);
3877 mutex_lock(&adev->srbm_mutex); 3883 mutex_lock(&adev->srbm_mutex);
3878 for (i = 0; i < 16; i++) { 3884 for (i = 0; i < adev->vm_manager.num_ids; i++) {
3879 vi_srbm_select(adev, 0, 0, 0, i); 3885 vi_srbm_select(adev, 0, 0, 0, i);
3880 /* CP and shaders */ 3886 /* CP and shaders */
3881 if (i == 0) { 3887 if (i == 0) {
@@ -3884,17 +3890,20 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
3884 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE, 3890 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE,
3885 SH_MEM_ALIGNMENT_MODE_UNALIGNED); 3891 SH_MEM_ALIGNMENT_MODE_UNALIGNED);
3886 WREG32(mmSH_MEM_CONFIG, tmp); 3892 WREG32(mmSH_MEM_CONFIG, tmp);
3893 WREG32(mmSH_MEM_BASES, 0);
3887 } else { 3894 } else {
3888 tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_NC); 3895 tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_NC);
3889 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_NC); 3896 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_UC);
3890 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE, 3897 tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE,
3891 SH_MEM_ALIGNMENT_MODE_UNALIGNED); 3898 SH_MEM_ALIGNMENT_MODE_UNALIGNED);
3892 WREG32(mmSH_MEM_CONFIG, tmp); 3899 WREG32(mmSH_MEM_CONFIG, tmp);
3900 tmp = adev->mc.shared_aperture_start >> 48;
3901 WREG32(mmSH_MEM_BASES, tmp);
3893 } 3902 }
3894 3903
3895 WREG32(mmSH_MEM_APE1_BASE, 1); 3904 WREG32(mmSH_MEM_APE1_BASE, 1);
3896 WREG32(mmSH_MEM_APE1_LIMIT, 0); 3905 WREG32(mmSH_MEM_APE1_LIMIT, 0);
3897 WREG32(mmSH_MEM_BASES, 0); 3906 WREG32(mmSH_STATIC_MEM_CONFIG, sh_static_mem_cfg);
3898 } 3907 }
3899 vi_srbm_select(adev, 0, 0, 0, 0); 3908 vi_srbm_select(adev, 0, 0, 0, 0);
3900 mutex_unlock(&adev->srbm_mutex); 3909 mutex_unlock(&adev->srbm_mutex);
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index 552bf6b7851c..13efb679dfa1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -934,6 +934,14 @@ static int gmc_v7_0_early_init(void *handle)
934 gmc_v7_0_set_gart_funcs(adev); 934 gmc_v7_0_set_gart_funcs(adev);
935 gmc_v7_0_set_irq_funcs(adev); 935 gmc_v7_0_set_irq_funcs(adev);
936 936
937 adev->mc.shared_aperture_start = 0x2000000000000000ULL;
938 adev->mc.shared_aperture_end =
939 adev->mc.shared_aperture_start + (4ULL << 30) - 1;
940 adev->mc.private_aperture_start =
941 adev->mc.shared_aperture_end + 1;
942 adev->mc.private_aperture_end =
943 adev->mc.private_aperture_start + (4ULL << 30) - 1;
944
937 return 0; 945 return 0;
938} 946}
939 947
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index f2bd0164bdfd..952ba1e02a77 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -939,6 +939,14 @@ static int gmc_v8_0_early_init(void *handle)
939 gmc_v8_0_set_gart_funcs(adev); 939 gmc_v8_0_set_gart_funcs(adev);
940 gmc_v8_0_set_irq_funcs(adev); 940 gmc_v8_0_set_irq_funcs(adev);
941 941
942 adev->mc.shared_aperture_start = 0x2000000000000000ULL;
943 adev->mc.shared_aperture_end =
944 adev->mc.shared_aperture_start + (4ULL << 30) - 1;
945 adev->mc.private_aperture_start =
946 adev->mc.shared_aperture_end + 1;
947 adev->mc.private_aperture_end =
948 adev->mc.private_aperture_start + (4ULL << 30) - 1;
949
942 return 0; 950 return 0;
943} 951}
944 952