aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
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_vm.h
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_vm.h')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h84
1 files changed, 59 insertions, 25 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 9fa9df0c5e7f..2a8898d19c8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -29,6 +29,8 @@
29#include <linux/rbtree.h> 29#include <linux/rbtree.h>
30#include <drm/gpu_scheduler.h> 30#include <drm/gpu_scheduler.h>
31#include <drm/drm_file.h> 31#include <drm/drm_file.h>
32#include <drm/ttm/ttm_bo_driver.h>
33#include <linux/chash.h>
32 34
33#include "amdgpu_sync.h" 35#include "amdgpu_sync.h"
34#include "amdgpu_ring.h" 36#include "amdgpu_ring.h"
@@ -48,9 +50,6 @@ struct amdgpu_bo_list_entry;
48/* number of entries in page table */ 50/* number of entries in page table */
49#define AMDGPU_VM_PTE_COUNT(adev) (1 << (adev)->vm_manager.block_size) 51#define AMDGPU_VM_PTE_COUNT(adev) (1 << (adev)->vm_manager.block_size)
50 52
51/* PTBs (Page Table Blocks) need to be aligned to 32K */
52#define AMDGPU_VM_PTB_ALIGN_SIZE 32768
53
54#define AMDGPU_PTE_VALID (1ULL << 0) 53#define AMDGPU_PTE_VALID (1ULL << 0)
55#define AMDGPU_PTE_SYSTEM (1ULL << 1) 54#define AMDGPU_PTE_SYSTEM (1ULL << 1)
56#define AMDGPU_PTE_SNOOPED (1ULL << 2) 55#define AMDGPU_PTE_SNOOPED (1ULL << 2)
@@ -103,19 +102,6 @@ struct amdgpu_bo_list_entry;
103/* hardcode that limit for now */ 102/* hardcode that limit for now */
104#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20) 103#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20)
105 104
106/* VA hole for 48bit addresses on Vega10 */
107#define AMDGPU_VA_HOLE_START 0x0000800000000000ULL
108#define AMDGPU_VA_HOLE_END 0xffff800000000000ULL
109
110/*
111 * Hardware is programmed as if the hole doesn't exists with start and end
112 * address values.
113 *
114 * This mask is used to remove the upper 16bits of the VA and so come up with
115 * the linear addr value.
116 */
117#define AMDGPU_VA_HOLE_MASK 0x0000ffffffffffffULL
118
119/* max vmids dedicated for process */ 105/* max vmids dedicated for process */
120#define AMDGPU_VM_MAX_RESERVED_VMID 1 106#define AMDGPU_VM_MAX_RESERVED_VMID 1
121 107
@@ -143,7 +129,7 @@ struct amdgpu_vm_bo_base {
143 struct amdgpu_bo *bo; 129 struct amdgpu_bo *bo;
144 130
145 /* protected by bo being reserved */ 131 /* protected by bo being reserved */
146 struct list_head bo_list; 132 struct amdgpu_vm_bo_base *next;
147 133
148 /* protected by spinlock */ 134 /* protected by spinlock */
149 struct list_head vm_status; 135 struct list_head vm_status;
@@ -160,6 +146,27 @@ struct amdgpu_vm_pt {
160 struct amdgpu_vm_pt *entries; 146 struct amdgpu_vm_pt *entries;
161}; 147};
162 148
149/* provided by hw blocks that can write ptes, e.g., sdma */
150struct amdgpu_vm_pte_funcs {
151 /* number of dw to reserve per operation */
152 unsigned copy_pte_num_dw;
153
154 /* copy pte entries from GART */
155 void (*copy_pte)(struct amdgpu_ib *ib,
156 uint64_t pe, uint64_t src,
157 unsigned count);
158
159 /* write pte one entry at a time with addr mapping */
160 void (*write_pte)(struct amdgpu_ib *ib, uint64_t pe,
161 uint64_t value, unsigned count,
162 uint32_t incr);
163 /* for linear pte/pde updates without addr mapping */
164 void (*set_pte_pde)(struct amdgpu_ib *ib,
165 uint64_t pe,
166 uint64_t addr, unsigned count,
167 uint32_t incr, uint64_t flags);
168};
169
163#define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr)) 170#define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr))
164#define AMDGPU_VM_FAULT_PASID(fault) ((u64)(fault) >> 48) 171#define AMDGPU_VM_FAULT_PASID(fault) ((u64)(fault) >> 48)
165#define AMDGPU_VM_FAULT_ADDR(fault) ((u64)(fault) & 0xfffffffff000ULL) 172#define AMDGPU_VM_FAULT_ADDR(fault) ((u64)(fault) & 0xfffffffff000ULL)
@@ -172,6 +179,13 @@ struct amdgpu_task_info {
172 pid_t tgid; 179 pid_t tgid;
173}; 180};
174 181
182#define AMDGPU_PAGEFAULT_HASH_BITS 8
183struct amdgpu_retryfault_hashtable {
184 DECLARE_CHASH_TABLE(hash, AMDGPU_PAGEFAULT_HASH_BITS, 8, 0);
185 spinlock_t lock;
186 int count;
187};
188
175struct amdgpu_vm { 189struct amdgpu_vm {
176 /* tree of virtual addresses mapped */ 190 /* tree of virtual addresses mapped */
177 struct rb_root_cached va; 191 struct rb_root_cached va;
@@ -182,13 +196,16 @@ struct amdgpu_vm {
182 /* PT BOs which relocated and their parent need an update */ 196 /* PT BOs which relocated and their parent need an update */
183 struct list_head relocated; 197 struct list_head relocated;
184 198
185 /* BOs moved, but not yet updated in the PT */ 199 /* per VM BOs moved, but not yet updated in the PT */
186 struct list_head moved; 200 struct list_head moved;
187 spinlock_t moved_lock;
188 201
189 /* All BOs of this VM not currently in the state machine */ 202 /* All BOs of this VM not currently in the state machine */
190 struct list_head idle; 203 struct list_head idle;
191 204
205 /* regular invalidated BOs, but not yet updated in the PT */
206 struct list_head invalidated;
207 spinlock_t invalidated_lock;
208
192 /* BO mappings freed, but not yet updated in the PT */ 209 /* BO mappings freed, but not yet updated in the PT */
193 struct list_head freed; 210 struct list_head freed;
194 211
@@ -226,6 +243,12 @@ struct amdgpu_vm {
226 243
227 /* Some basic info about the task */ 244 /* Some basic info about the task */
228 struct amdgpu_task_info task_info; 245 struct amdgpu_task_info task_info;
246
247 /* Store positions of group of BOs */
248 struct ttm_lru_bulk_move lru_bulk_move;
249 /* mark whether can do the bulk move */
250 bool bulk_moveable;
251 struct amdgpu_retryfault_hashtable *fault_hash;
229}; 252};
230 253
231struct amdgpu_vm_manager { 254struct amdgpu_vm_manager {
@@ -244,10 +267,9 @@ struct amdgpu_vm_manager {
244 /* vram base address for page table entry */ 267 /* vram base address for page table entry */
245 u64 vram_base_offset; 268 u64 vram_base_offset;
246 /* vm pte handling */ 269 /* vm pte handling */
247 const struct amdgpu_vm_pte_funcs *vm_pte_funcs; 270 const struct amdgpu_vm_pte_funcs *vm_pte_funcs;
248 struct amdgpu_ring *vm_pte_rings[AMDGPU_MAX_RINGS]; 271 struct drm_sched_rq *vm_pte_rqs[AMDGPU_MAX_RINGS];
249 unsigned vm_pte_num_rings; 272 unsigned vm_pte_num_rqs;
250 atomic_t vm_pte_next_ring;
251 273
252 /* partial resident texture handling */ 274 /* partial resident texture handling */
253 spinlock_t prt_lock; 275 spinlock_t prt_lock;
@@ -266,11 +288,16 @@ struct amdgpu_vm_manager {
266 spinlock_t pasid_lock; 288 spinlock_t pasid_lock;
267}; 289};
268 290
291#define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
292#define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
293#define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
294
269void amdgpu_vm_manager_init(struct amdgpu_device *adev); 295void amdgpu_vm_manager_init(struct amdgpu_device *adev);
270void amdgpu_vm_manager_fini(struct amdgpu_device *adev); 296void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
271int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, 297int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
272 int vm_context, unsigned int pasid);