aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-10-28 20:49:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-28 20:49:53 -0400
commit53b3b6bbfde6aae8d1ededc86ad4e0e1e00eb5f8 (patch)
treeb29473f21270aefd113b298c9402be8b4b3c91b4 /drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
parent746bb4ed6d626f3f9e431a7f9b20504538e62ded (diff)
parentf2bfc71aee75feff33ca659322b72ffeed5a243d (diff)
Merge tag 'drm-next-2018-10-24' of git://anongit.freedesktop.org/drm/drm
Pull drm updates from Dave Airlie: "This is going to rebuild more than drm as it adds a new helper to list.h for doing bulk updates. Seemed like a reasonable addition to me. Otherwise the usual merge window stuff lots of i915 and amdgpu, not so much nouveau, and piles of everything else. Core: - Adds a new list.h helper for doing bulk list updates for TTM. - Don't leak fb address in smem_start to userspace (comes with EXPORT workaround for people using mali out of tree hacks) - udmabuf device to turn memfd regions into dma-buf - Per-plane blend mode property - ref/unref replacements with get/put - fbdev conflicting framebuffers code cleaned up - host-endian format variants - panel orientation quirk for Acer One 10 bridge: - TI SN65DSI86 chip support vkms: - GEM support. - Cursor support amdgpu: - Merge amdkfd and amdgpu into one module - CEC over DP AUX support - Picasso APU support + VCN dynamic powergating - Raven2 APU support - Vega20 enablement + kfd support - ACP powergating improvements - ABGR/XBGR display support - VCN jpeg support - xGMI support - DC i2c/aux cleanup - Ycbcr 4:2:0 support - GPUVM improvements - Powerplay and powerplay endian fixes - Display underflow fixes vmwgfx: - Move vmwgfx specific TTM code to vmwgfx - Split out vmwgfx buffer/resource validation code - Atomic operation rework bochs: - use more helpers - format/byteorder improvements qxl: - use more helpers i915: - GGTT coherency getparam - Turn off resource streamer API - More Icelake enablement + DMC firmware - Full PPGTT for Ivybridge, Haswell and Valleyview - DDB distribution based on resolution - Limited range DP display support nouveau: - CEC over DP AUX support - Initial HDMI 2.0 support virtio-gpu: - vmap support for PRIME objects tegra: - Initial Tegra194 support - DMA/IOMMU integration fixes msm: - a6xx perf improvements + clock prefix - GPU preemption optimisations - a6xx devfreq support - cursor support rockchip: - PX30 support - rgb output interface support mediatek: - HDMI output support on mt2701 and mt7623 rcar-du: - Interlaced modes on Gen3 - LVDS on R8A77980 - D3 and E3 SoC support hisilicon: - misc fixes mxsfb: - runtime pm support sun4i: - R40 TCON support - Allwinner A64 support - R40 HDMI support omapdrm: - Driver rework changing display pipeline ordering to use common code - DMM memory barrier and irq fixes - Errata workarounds exynos: - out-bridge support for LVDS bridge driver - Samsung 16x16 tiled format support - Plane alpha and pixel blend mode support tilcdc: - suspend/resume update mali-dp: - misc updates" * tag 'drm-next-2018-10-24' of git://anongit.freedesktop.org/drm/drm: (1382 commits) firmware/dmc/icl: Add missing MODULE_FIRMWARE() for Icelake. drm/i915/icl: Fix signal_levels drm/i915/icl: Fix DDI/TC port clk_off bits drm/i915/icl: create function to identify combophy port drm/i915/gen9+: Fix initial readout for Y tiled framebuffers drm/i915: Large page offsets for pread/pwrite drm/i915/selftests: Disable shrinker across mmap-exhaustion drm/i915/dp: Link train Fallback on eDP only if fallback link BW can fit panel's native mode drm/i915: Fix intel_dp_mst_best_encoder() drm/i915: Skip vcpi allocation for MSTB ports that are gone drm/i915: Don't unset intel_connector->mst_port drm/i915: Only reset seqno if actually idle drm/i915: Use the correct crtc when sanitizing plane mapping drm/i915: Restore vblank interrupts earlier drm/i915: Check fb stride against plane max stride drm/amdgpu/vcn:Fix uninitialized symbol error drm: panel-orientation-quirks: Add quirk for Acer One 10 (S1003) drm/amd/amdgpu: Fix debugfs error handling drm/amdgpu: Update gc_9_0 golden settings. drm/amd/powerplay: update PPtable with DC BTC and Tvr SocLimit fields ...
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c224
1 files changed, 133 insertions, 91 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fcf421263fd9..a44fc12ae1f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -47,6 +47,7 @@
47#include "amdgpu_object.h" 47#include "amdgpu_object.h"
48#include "amdgpu_trace.h" 48#include "amdgpu_trace.h"
49#include "amdgpu_amdkfd.h" 49#include "amdgpu_amdkfd.h"
50#include "amdgpu_sdma.h"
50#include "bif/bif_4_1_d.h" 51#include "bif/bif_4_1_d.h"
51 52
52#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) 53#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
@@ -255,6 +256,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
255 256
256 abo = ttm_to_amdgpu_bo(bo); 257 abo = ttm_to_amdgpu_bo(bo);
257 switch (bo->mem.mem_type) { 258 switch (bo->mem.mem_type) {
259 case AMDGPU_PL_GDS:
260 case AMDGPU_PL_GWS:
261 case AMDGPU_PL_OA:
262 placement->num_placement = 0;
263 placement->num_busy_placement = 0;
264 return;
265
258 case TTM_PL_VRAM: 266 case TTM_PL_VRAM:
259 if (!adev->mman.buffer_funcs_enabled) { 267 if (!adev->mman.buffer_funcs_enabled) {
260 /* Move to system memory */ 268 /* Move to system memory */
@@ -282,6 +290,7 @@ static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
282 case TTM_PL_TT: 290 case TTM_PL_TT:
283 default: 291 default:
284 amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU); 292 amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);
293 break;
285 } 294 }
286 *placement = abo->placement; 295 *placement = abo->placement;
287} 296}
@@ -344,7 +353,7 @@ static uint64_t amdgpu_mm_node_addr(struct ttm_buffer_object *bo,
344{ 353{
345 uint64_t addr = 0; 354 uint64_t addr = 0;
346 355
347 if (mem->mem_type != TTM_PL_TT || amdgpu_gtt_mgr_has_gart_addr(mem)) { 356 if (mm_node->start != AMDGPU_BO_INVALID_OFFSET) {
348 addr = mm_node->start << PAGE_SHIFT; 357 addr = mm_node->start << PAGE_SHIFT;
349 addr += bo->bdev->man[mem->mem_type].gpu_offset; 358 addr += bo->bdev->man[mem->mem_type].gpu_offset;
350 } 359 }
@@ -432,8 +441,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
432 /* Map only what needs to be accessed. Map src to window 0 and 441 /* Map only what needs to be accessed. Map src to window 0 and
433 * dst to window 1 442 * dst to window 1
434 */ 443 */
435 if (src->mem->mem_type == TTM_PL_TT && 444 if (src->mem->start == AMDGPU_BO_INVALID_OFFSET) {
436 !amdgpu_gtt_mgr_has_gart_addr(src->mem)) {
437 r = amdgpu_map_buffer(src->bo, src->mem, 445 r = amdgpu_map_buffer(src->bo, src->mem,
438 PFN_UP(cur_size + src_page_offset), 446 PFN_UP(cur_size + src_page_offset),
439 src_node_start, 0, ring, 447 src_node_start, 0, ring,
@@ -446,8 +454,7 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
446 from += src_page_offset; 454 from += src_page_offset;
447 } 455 }
448 456
449 if (dst->mem->mem_type == TTM_PL_TT && 457 if (dst->mem->start == AMDGPU_BO_INVALID_OFFSET) {
450 !amdgpu_gtt_mgr_has_gart_addr(dst->mem)) {
451 r = amdgpu_map_buffer(dst->bo, dst->mem, 458 r = amdgpu_map_buffer(dst->bo, dst->mem,
452 PFN_UP(cur_size + dst_page_offset), 459 PFN_UP(cur_size + dst_page_offset),
453 dst_node_start, 1, ring, 460 dst_node_start, 1, ring,
@@ -525,7 +532,11 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
525 if (r) 532 if (r)
526 goto error; 533 goto error;
527 534
528 r = ttm_bo_pipeline_move(bo, fence, evict, new_mem); 535 /* Always block for VM page tables before committing the new location */
536 if (bo->type == ttm_bo_type_kernel)
537 r = ttm_bo_move_accel_cleanup(bo, fence, true, new_mem);
538 else
539 r = ttm_bo_pipeline_move(bo, fence, evict, new_mem);
529 dma_fence_put(fence); 540 dma_fence_put(fence);
530 return r; 541 return r;
531 542
@@ -676,6 +687,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
676 amdgpu_move_null(bo, new_mem); 687 amdgpu_move_null(bo, new_mem);
677 return 0; 688 return 0;
678 } 689 }
690 if (old_mem->mem_type == AMDGPU_PL_GDS ||
691 old_mem->mem_type == AMDGPU_PL_GWS ||
692 old_mem->mem_type == AMDGPU_PL_OA ||
693 new_mem->mem_type == AMDGPU_PL_GDS ||
694 new_mem->mem_type == AMDGPU_PL_GWS ||
695 new_mem->mem_type == AMDGPU_PL_OA) {
696 /* Nothing to save here */
697 amdgpu_move_null(bo, new_mem);
698 return 0;
699 }
679 700
680 if (!adev->mman.buffer_funcs_enabled) 701 if (!adev->mman.buffer_funcs_enabled)
681 goto memcpy; 702 goto memcpy;
@@ -1082,42 +1103,48 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
1082 struct ttm_mem_reg tmp; 1103 struct ttm_mem_reg tmp;
1083 struct ttm_placement placement; 1104 struct ttm_placement placement;
1084 struct ttm_place placements; 1105 struct ttm_place placements;
1085 uint64_t flags; 1106 uint64_t addr, flags;
1086 int r; 1107 int r;
1087 1108
1088 if (bo->mem.mem_type != TTM_PL_TT || 1109 if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
1089 amdgpu_gtt_mgr_has_gart_addr(&bo->mem))
1090 return 0; 1110 return 0;
1091 1111
1092 /* allocate GTT space */ 1112 addr = amdgpu_gmc_agp_addr(bo);
1093 tmp = bo->mem; 1113 if (addr != AMDGPU_BO_INVALID_OFFSET) {
1094 tmp.mm_node = NULL; 1114 bo->mem.start = addr >> PAGE_SHIFT;
1095 placement.num_placement = 1; 1115 } else {
1096 placement.placement = &placements;
1097 placement.num_busy_placement = 1;
1098 placement.busy_placement = &placements;
1099 placements.fpfn = 0;
1100 placements.lpfn = adev->gmc.gart_size >> PAGE_SHIFT;
1101 placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM) |
1102 TTM_PL_FLAG_TT;
1103 1116
1104 r = ttm_bo_mem_space(bo, &placement, &tmp, &ctx); 1117 /* allocate GART space */
1105 if (unlikely(r)) 1118 tmp = bo->mem;
1106 return r; 1119 tmp.mm_node = NULL;
1120 placement.num_placement = 1;
1121 placement.placement = &placements;
1122 placement.num_busy_placement = 1;
1123 placement.busy_placement = &placements;
1124 placements.fpfn = 0;
1125 placements.lpfn = adev->gmc.gart_size >> PAGE_SHIFT;
1126 placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM) |
1127 TTM_PL_FLAG_TT;
1128
1129 r = ttm_bo_mem_space(bo, &placement, &tmp, &ctx);
1130 if (unlikely(r))
1131 return r;
1107 1132
1108 /* compute PTE flags for this buffer object */ 1133 /* compute PTE flags for this buffer object */
1109 flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp); 1134 flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp);
1110 1135
1111 /* Bind pages */ 1136 /* Bind pages */
1112 gtt->offset = (u64)tmp.start << PAGE_SHIFT; 1137 gtt->offset = (u64)tmp.start << PAGE_SHIFT;
1113 r = amdgpu_ttm_gart_bind(adev, bo, flags); 1138 r = amdgpu_ttm_gart_bind(adev, bo, flags);
1114 if (unlikely(r)) { 1139 if (unlikely(r)) {
1115 ttm_bo_mem_put(bo, &tmp); 1140 ttm_bo_mem_put(bo, &tmp);
1116<