diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-22 06:22:14 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 12:11:19 -0400 |
commit | 11c3a249ff7a1c710011bd06a451956f2a40c30c (patch) | |
tree | 5bebe0cee82cb0e67c1303d399cf8f83853f6619 /drivers/gpu | |
parent | 4e830fb1b5f589352e711fc0df515c34e978e1a0 (diff) |
drm/amdgpu: add amdgpu_gmc_pd_addr helper
Add a helper to get the root PD address and remove the workarounds from
the GMC9 code for that.
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/Makefile | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 47 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 7 |
9 files changed, 56 insertions, 23 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 860cb8731c7c..d2bafabe585d 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -51,7 +51,8 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ | |||
51 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ | 51 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
52 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ | 52 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
53 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ | 53 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ |
54 | amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o | 54 | amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \ |
55 | amdgpu_gmc.o | ||
55 | 56 | ||
56 | # add asic specific block | 57 | # add asic specific block |
57 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | 58 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index f92597c292fe..2ef6e8557b65 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | |||
@@ -364,7 +364,6 @@ static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm) | |||
364 | struct amdgpu_bo *pd = vm->root.base.bo; | 364 | struct amdgpu_bo *pd = vm->root.base.bo; |
365 | struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev); | 365 | struct amdgpu_device *adev = amdgpu_ttm_adev(pd->tbo.bdev); |
366 | struct amdgpu_vm_parser param; | 366 | struct amdgpu_vm_parser param; |
367 | uint64_t addr, flags = AMDGPU_PTE_VALID; | ||
368 | int ret; | 367 | int ret; |
369 | 368 | ||
370 | param.domain = AMDGPU_GEM_DOMAIN_VRAM; | 369 | param.domain = AMDGPU_GEM_DOMAIN_VRAM; |
@@ -383,9 +382,7 @@ static int vm_validate_pt_pd_bos(struct amdgpu_vm *vm) | |||
383 | return ret; | 382 | return ret; |
384 | } | 383 | } |
385 | 384 | ||
386 | addr = amdgpu_bo_gpu_offset(vm->root.base.bo); | 385 | vm->pd_phys_addr = amdgpu_gmc_pd_addr(vm->root.base.bo); |
387 | amdgpu_gmc_get_vm_pde(adev, -1, &addr, &flags); | ||
388 | vm->pd_phys_addr = addr; | ||
389 | 386 | ||
390 | if (vm->use_cpu_for_update) { | 387 | if (vm->use_cpu_for_update) { |
391 | ret = amdgpu_bo_kmap(pd, NULL); | 388 | ret = amdgpu_bo_kmap(pd, NULL); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 5b70a30967ec..fd3902983195 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -946,7 +946,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p) | |||
946 | if (r) | 946 | if (r) |
947 | return r; | 947 | return r; |
948 | 948 | ||
949 | p->job->vm_pd_addr = amdgpu_bo_gpu_offset(vm->root.base.bo); | 949 | p->job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.base.bo); |
950 | 950 | ||
951 | if (amdgpu_vm_debug) { | 951 | if (amdgpu_vm_debug) { |
952 | /* Invalidate all BOs to test for userspace bugs */ | 952 | /* Invalidate all BOs to test for userspace bugs */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c new file mode 100644 index 000000000000..36058feac64f --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Copyright 2018 Advanced Micro Devices, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
6 | * copy of this software and associated documentation files (the | ||
7 | * "Software"), to deal in the Software without restriction, including | ||
8 | * without limitation the rights to use, copy, modify, merge, publish, | ||
9 | * distribute, sub license, and/or sell copies of the Software, and to | ||
10 | * permit persons to whom the Software is furnished to do so, subject to | ||
11 | * the following conditions: | ||
12 | * | ||
13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
16 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
17 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
18 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
19 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
20 | * | ||
21 | * The above copyright notice and this permission notice (including the | ||
22 | * next paragraph) shall be included in all copies or substantial portions | ||
23 | * of the Software. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #include "amdgpu.h" | ||
28 | |||
29 | /** | ||
30 | * amdgpu_gmc_pd_addr - return the address of the root directory | ||
31 | * | ||
32 | */ | ||
33 | uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo) | ||
34 | { | ||
35 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | ||
36 | uint64_t pd_addr; | ||
37 | |||
38 | pd_addr = amdgpu_bo_gpu_offset(bo); | ||
39 | /* TODO: move that into ASIC specific code */ | ||
40 | if (adev->asic_type >= CHIP_VEGA10) { | ||
41 | uint64_t flags = AMDGPU_PTE_VALID; | ||
42 | |||
43 | amdgpu_gmc_get_vm_pde(adev, -1, &pd_addr, &flags); | ||
44 | pd_addr |= flags; | ||
45 | } | ||
46 | return pd_addr; | ||
47 | } | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h index 64391d811a82..1c6974a33467 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | |||
@@ -133,4 +133,6 @@ static inline bool amdgpu_gmc_vram_full_visible(struct amdgpu_gmc *gmc) | |||
133 | return (gmc->real_vram_size == gmc->visible_vram_size); | 133 | return (gmc->real_vram_size == gmc->visible_vram_size); |
134 | } | 134 | } |
135 | 135 | ||
136 | uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo); | ||
137 | |||
136 | #endif | 138 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index e7f73deed975..eb08a03b82a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -2049,7 +2049,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset, | |||
2049 | return r; | 2049 | return r; |
2050 | 2050 | ||
2051 | if (vm_needs_flush) { | 2051 | if (vm_needs_flush) { |
2052 | job->vm_pd_addr = amdgpu_bo_gpu_offset(adev->gart.bo); | 2052 | job->vm_pd_addr = amdgpu_gmc_pd_addr(adev->gart.bo); |
2053 | job->vm_needs_flush = true; | 2053 | job->vm_needs_flush = true; |
2054 | } | 2054 | } |
2055 | if (resv) { | 2055 | if (resv) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c index 2baab7e69ef5..3403ded39d13 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | |||
@@ -37,12 +37,7 @@ u64 gfxhub_v1_0_get_mc_fb_offset(struct amdgpu_device *adev) | |||
37 | 37 | ||
38 | static void gfxhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev) | 38 | static void gfxhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev) |
39 | { | 39 | { |
40 | uint64_t value = amdgpu_bo_gpu_offset(adev->gart.bo); | 40 | uint64_t value = amdgpu_gmc_pd_addr(adev->gart.bo); |
41 | |||
42 | BUG_ON(value & (~0x0000FFFFFFFFF000ULL)); | ||
43 | value -= adev->gmc.vram_start + adev->vm_manager.vram_base_offset; | ||
44 | value &= 0x0000FFFFFFFFF000ULL; | ||
45 | value |= 0x1; /*valid bit*/ | ||
46 | 41 | ||
47 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32, | 42 | WREG32_SOC15(GC, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32, |
48 | lower_32_bits(value)); | 43 | lower_32_bits(value)); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index dc48e19d01f8..a82b3eb429e8 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
@@ -429,12 +429,8 @@ static uint64_t gmc_v9_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring, | |||
429 | struct amdgpu_device *adev = ring->adev; | 429 | struct amdgpu_device *adev = ring->adev; |
430 | struct amdgpu_vmhub *hub = &adev->vmhub[ring->funcs->vmhub]; | 430 | struct amdgpu_vmhub *hub = &adev->vmhub[ring->funcs->vmhub]; |
431 | uint32_t req = gmc_v9_0_get_invalidate_req(vmid); | 431 | uint32_t req = gmc_v9_0_get_invalidate_req(vmid); |
432 | uint64_t flags = AMDGPU_PTE_VALID; | ||
433 | unsigned eng = ring->vm_inv_eng; | 432 | unsigned eng = ring->vm_inv_eng; |
434 | 433 | ||
435 | amdgpu_gmc_get_vm_pde(adev, -1, &pd_addr, &flags); | ||
436 | pd_addr |= flags; | ||
437 | |||
438 | amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid), | 434 | amdgpu_ring_emit_wreg(ring, hub->ctx0_ptb_addr_lo32 + (2 * vmid), |
439 | lower_32_bits(pd_addr)); | 435 | lower_32_bits(pd_addr)); |
440 | 436 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c index 800ec4687f13..5f6a9c85488f 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | |||
@@ -47,12 +47,7 @@ u64 mmhub_v1_0_get_fb_location(struct amdgpu_device *adev) | |||
47 | 47 | ||
48 | static void mmhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev) | 48 | static void mmhub_v1_0_init_gart_pt_regs(struct amdgpu_device *adev) |
49 | { | 49 | { |
50 | uint64_t value = amdgpu_bo_gpu_offset(adev->gart.bo); | 50 | uint64_t value = amdgpu_gmc_pd_addr(adev->gart.bo); |
51 | |||
52 | BUG_ON(value & (~0x0000FFFFFFFFF000ULL)); | ||
53 | value -= adev->gmc.vram_start + adev->vm_manager.vram_base_offset; | ||
54 | value &= 0x0000FFFFFFFFF000ULL; | ||
55 | value |= 0x1; /* valid bit */ | ||
56 | 51 | ||
57 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32, | 52 | WREG32_SOC15(MMHUB, 0, mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32, |
58 | lower_32_bits(value)); | 53 | lower_32_bits(value)); |