summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
authorshaoyunl <shaoyun.liu@amd.com>2019-02-21 16:30:25 -0500
committerAlex Deucher <alexander.deucher@amd.com>2019-03-19 15:36:48 -0500
commit9b638f9751308ae3ae8f28e0c6e9decffd97f5f9 (patch)
treef64c4de40d4e49ea3f11ba79dbc3e65bd514c2fa /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
parenta690aa0f459eba3e768257a655c82b24d14dcc88 (diff)
drm/amdgpu: XGMI pstate switch initial support
Driver vote low to high pstate switch whenever there is an outstanding XGMI mapping request. Driver vote high to low pstate when all the outstanding XGMI mapping is terminated. Signed-off-by: shaoyunl <shaoyun.liu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 67d638fef1fb..52db19e88ab5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -34,6 +34,7 @@
#include "amdgpu_trace.h"
#include "amdgpu_amdkfd.h"
#include "amdgpu_gmc.h"
+#include "amdgpu_xgmi.h"
/**
* DOC: GPUVM
@@ -2013,8 +2014,9 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
struct ttm_mem_reg *mem;
struct drm_mm_node *nodes;
struct dma_fence *exclusive, **last_update;
- uint64_t flags;
struct amdgpu_device *bo_adev = adev;
+ bool is_xgmi = false;
+ uint64_t flags;
int r;
if (clear || !bo) {
@@ -2036,6 +2038,10 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
if (bo) {
flags = amdgpu_ttm_tt_pte_flags(adev, bo->tbo.ttm, mem);
bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
+ if (adev != bo_adev &&
+ adev->gmc.xgmi.hive_id &&
+ adev->gmc.xgmi.hive_id == bo_adev->gmc.xgmi.hive_id)
+ is_xgmi = true;
} else {
flags = 0x0;
}
@@ -2054,6 +2060,19 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
}
list_for_each_entry(mapping, &bo_va->invalids, list) {
+ if (mapping->is_xgmi != is_xgmi) {
+ if (is_xgmi) {
+ /* Adding an XGMI mapping to the PT */
+ if (atomic_inc_return(&adev->xgmi_map_counter) == 1)
+ amdgpu_xgmi_set_pstate(adev, 1);
+ } else {
+ /* Removing an XGMI mapping from the PT */
+ if (atomic_dec_return(&adev->xgmi_map_counter) == 0)
+ amdgpu_xgmi_set_pstate(adev, 0);
+ }
+ mapping->is_xgmi = is_xgmi;
+ }
+
r = amdgpu_vm_bo_split_mapping(adev, exclusive, pages_addr, vm,
mapping, flags, bo_adev, nodes,
last_update);
@@ -2271,6 +2290,13 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,
mapping->start, mapping->last,
init_pte_value, 0, &f);
+
+ if (mapping->is_xgmi) {
+ /* Removing an XGMI mapping from the PT */
+ if (atomic_dec_return(&adev->xgmi_map_counter) == 0)
+ amdgpu_xgmi_set_pstate(adev, 0);
+ }
+
amdgpu_vm_free_mapping(adev, vm, mapping, f);
if (r) {
dma_fence_put(f);
@@ -2467,6 +2493,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
mapping->last = eaddr;
mapping->offset = offset;
mapping->flags = flags;
+ mapping->is_xgmi = false;
amdgpu_vm_bo_insert_map(adev, bo_va, mapping);