Skip to content

Dynamic page table alloc, 64b, and GPU/CPU mirror

Ben Widawsky intel-gfx 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest56 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/56drm/i915: Fix flush before context switch commentdrivers/gpu/drm/i915/i915_gem_context.c+1 -30 replies
2/56Revert "drm/i915: Drop I915_PARAM_HAS_FULL_PPGTT again"drivers/gpu/drm/i915/i915_dma.c include/uapi/drm/i915_drm.h+5 -10 replies
3/56drm/i915: Prevent signals from interrupting close()drivers/gpu/drm/i915/i915_dma.c+9 -00 replies
4/56drm/i915: Wrap VMA bindingdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem.c drivers/gpu/drm/i915/i915_gem_context.c +2 more+25 -100 replies
5/56drm/i915: Make pin global flags explicitdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem.c drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 more+47 -120 replies
6/56drm/i915: Split out aliasing bindsdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem.c drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 more+11 -50 replies
7/56drm/i915: fix gtt_total_entries()drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+7 -40 replies
8/56drm/i915: Rename to GEN8_LEGACY_PDPESdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+6 -60 replies
9/56drm/i915: Split out verbose PPGTT dumpingdrivers/gpu/drm/i915/i915_debugfs.c+30 -190 replies
10/56drm/i915: s/pd/pdpe, s/pt/pdedrivers/gpu/drm/i915/i915_gem_gtt.c+7 -70 replies
11/56drm/i915: rename map/unmap to dma_map/unmapdrivers/gpu/drm/i915/i915_gem_gtt.c+6 -60 replies
12/56drm/i915: Setup less PPGTT on failed pagedirdrivers/gpu/drm/i915/i915_gem_gtt.c+4 -10 replies
13/56drm/i915: clean up PPGTT init error pathdrivers/gpu/drm/i915/i915_gem_gtt.c+9 -130 replies
14/56drm/i915: Un-hardcode number of page directoriesdrivers/gpu/drm/i915/i915_gem_gtt.h+1 -10 replies
15/56drm/i915: Make gen6_write_pdes gen6_map_page_tablesdrivers/gpu/drm/i915/i915_gem_gtt.c+23 -160 replies
16/56drm/i915: Range clearing is PPGTT agnosticdrivers/gpu/drm/i915/i915_gem_gtt.c+1 -40 replies
17/56drm/i915: Page table helpers, and define renamesdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+156 -550 replies
18/56drm/i915: construct page table abstractionsdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+104 -950 replies
19/56drm/i915: Complete page table structuresdrivers/gpu/drm/i915/i915_debugfs.c drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h +1 more+38 -650 replies
20/56drm/i915: Create page table allocatorsdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+147 -830 replies
21/56drm/i915: Generalize GEN6 mappingdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+34 -290 replies
22/56drm/i915: Clean up pagetable DMA map & unmapdrivers/gpu/drm/i915/i915_gem_gtt.c+85 -620 replies
23/56drm/i915: Always dma map page table allocationsdrivers/gpu/drm/i915/i915_gem_gtt.c+17 -610 replies
24/56drm/i915: Consolidate dma mappingsdrivers/gpu/drm/i915/i915_gem_gtt.c+18 -380 replies
25/56drm/i915: Always dma map page directory allocationsdrivers/gpu/drm/i915/i915_gem_gtt.c+19 -600 replies
26/56drm/i915: Track GEN6 page table usagedrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+231 -890 replies
27/56drm/i915: Extract context switch skip logicdrivers/gpu/drm/i915/i915_gem_context.c+11 -10 replies
28/56drm/i915: Force pd restore when PDEs change, gen6-7drivers/gpu/drm/i915/i915_gem_context.c drivers/gpu/drm/i915/i915_gem_execbuffer.c drivers/gpu/drm/i915/i915_gem_gtt.c +1 more+35 -40 replies
29/56drm/i915: Finish gen6/7 dynamic page table allocationdrivers/gpu/drm/i915/i915_debugfs.c drivers/gpu/drm/i915/i915_gem_context.c drivers/gpu/drm/i915/i915_gem_gtt.c +2 more+238 -110 replies
30/56drm/i915/bdw: Use dynamic allocation idioms on freedrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+55 -160 replies
31/56drm/i915/bdw: pagedirs rework allocationdrivers/gpu/drm/i915/i915_gem_gtt.c+31 -120 replies
32/56drm/i915/bdw: pagetable allocation reworkdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+39 -250 replies
33/56drm/i915/bdw: Make the pdp switch a bit less hackydrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+24 -130 replies
34/56drm/i915: num_pd_pages/num_pd_entries isn't usefuldrivers/gpu/drm/i915/i915_debugfs.c drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+21 -420 replies
35/56drm/i915: Extract PPGTT param from pagedir allocdrivers/gpu/drm/i915/i915_gem_gtt.c+7 -80 replies
36/56drm/i915/bdw: Split out mappingsdrivers/gpu/drm/i915/i915_gem_gtt.c+52 -420 replies
37/56drm/i915/bdw: begin bitmap trackingdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+99 -140 replies
38/56drm/i915/bdw: Dynamic page table allocationsdrivers/gpu/drm/i915/i915_gem_gtt.c+216 -450 replies
39/56drm/i915/bdw: Scratch unused pagesdrivers/gpu/drm/i915/i915_gem_gtt.c+23 -20 replies
40/56drm/i915/bdw: Add ppgtt info for dynamic pagesdrivers/gpu/drm/i915/i915_debugfs.c drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+85 -150 replies
41/56drm/i915/bdw: Optimize PDP loadsdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+21 -00 replies
42/56TESTME: Either drop the last patch or fix it.drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+0 -210 replies
43/56drm/i915/bdw: Add dynamic page trace eventsdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_trace.h+47 -100 replies
44/56drm/i915/bdw: Make pdp allocation more dynamicdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h +1 more+151 -320 replies
45/56drm/i915/bdw: Abstract PDP usagedrivers/gpu/drm/i915/i915_gem_gtt.c+85 -440 replies
46/56drm/i915/bdw: implement alloc/teardown for 4lvldrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+163 -190 replies
47/56drm/i915/bdw: 4 level pages tablesdrivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h drivers/gpu/drm/i915/i915_reg.h+52 -60 replies
48/56drm/i915: Restructure map vs. insert entriesdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem_gtt.c drivers/gpu/drm/i915/i915_gem_gtt.h+126 -1220 replies
49/56drm/i915/bdw: make aliasing PPGTT dynamicdrivers/gpu/drm/i915/i915_gem_gtt.c+153 -1280 replies
50/56drm/i915: Expand error state's address width to 64bdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gpu_error.c+12 -100 replies
51/56drm/i915/bdw: Flip the 48b switchdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem_gtt.c+1 -40 replies
52/56TESTME: GFX_TLB_INVALIDATE_EXPLICITdrivers/gpu/drm/i915/intel_ringbuffer.c+1 -10 replies
53/56TESTME: Always force invalidatedrivers/gpu/drm/i915/i915_gem_context.c+1 -10 replies
54/56drm/i915: Introduce mapping of user pages into video memory (userptr) ioctldrivers/gpu/drm/i915/Kconfig drivers/gpu/drm/i915/Makefile drivers/gpu/drm/i915/i915_dma.c +6 more+754 -10 replies
55/56drm/i915: Track userptr VMAsdrivers/gpu/drm/i915/i915_drv.h drivers/gpu/drm/i915/i915_gem.c drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 more+27 -30 replies
56/56drm/i915/userptr: Mirror GPU addr at ioctl (HACK/POC)drivers/gpu/drm/i915/i915_gem_userptr.c include/uapi/drm/i915_drm.h+98 -290 replies

Reviews trailers per patch

2 of 56 patches have a Reviewed-by or Acked-by.

PatchBen WidawskyTvrtko Ursulin
1/56
2/56
3/56R-b
4/56
5/56
6/56
7/56
8/56
9/56
10/56
11/56
12/56
13/56
14/56
15/56
16/56
17/56
18/56
19/56
20/56
21/56
22/56
23/56
24/56
25/56
26/56
27/56
28/56
29/56
30/56
31/56
32/56
33/56
34/56
35/56
36/56
37/56
38/56
39/56
40/56
41/56
42/56
43/56
44/56
45/56
46/56
47/56
48/56
49/56
50/56
51/56
52/56
53/56
54/56R-b
55/56
56/56

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/56] [RFCish] Dynamic page table alloc, 64b, and GPU/CPU mirror

Just as before, these patches are living based off of my Broadwell branch, here:
http://cgit.freedesktop.org/~bwidawsk/drm-intel/log/?h=gpu_mirror

This is the follow-on patches for [1]

This patch series brings 3 things:
1. Dynamic page table allocation for gen6-8
2. 64b (48b canonical) graphics virtual address space for Broadwell
3. An interface to specify a specific offset for a BO.

It's taken way longer than I thought to get this work done, and given the current state of our driver, I fear I may not have time to see this through to the end before I am pulled onto other things. If people want to send me smallish bugfixes, I will gladly do my best to fix them quickly. If there are more substantial change requests wrt design or patch reorganization, I will not be able to accommodate. Someone else must take over this patch series at that point if they want these features. I do believe that everything up until the userptr patch is in decent shape though, so we'll see, I guess. (if you are qualified to take this over, and have interest, please let me know).

The patch series is highly volatile and not manicured. I've run exactly 1 test on the GPU mirror (see below for what that means), though many more on the prior stuff. The series depends on full PPGTT, which is not yet enabled by default, and has a few outstanding issues. It also has been developed exclusively on pre-production hardware. I am only sending out now because I will be on vacation for the next 10 days, and I know there are people that can benefit from this code before I return. With that, I got the last parts of this working very recently, and they're very hackish. The reason for this lack of refinement is I expect the interfaces for letting userspace dictate things to change (more on this later), and the other part is I just ran out of time before my vacation. Throughout development, I've been hitting issues which I am not yet sure if they are bugs in my code, bugs in full PPGTT, bugs in userptr, or generally flakiness. There are a few patches in here which say TESTME reflecting upon this. Also, if you want to run this, I highly recommend turning off semaphores, and rc6. (To be honest, I've not tried it recently). You also need to turn on PPGTT since it is disabled by default.

modprobe i915 enable_ppgtt=2 semaphores=0 enable_rc6=0

What you get in this series is what I'm going to coin, GPU mirror. This patch series allows one to allocate an arbitrary address for your GPU buffer object, and map it to a specific space within the GPUs address space. This is only possible because on Broadwell we get a 64b canonical GPU address space, and this allows us to map any CPU address as a GPU address. The obvious usage here is malloc(). malloc() returns a pointer that is valid on the CPU. Now that address can be identical on the GPU.

The interface provided is identical to the userptr interface previously posted by Chris Wilson. I've added a flag to that interface that indicates this new functionality. This is not necessarily the final version, and it's arguably not the best idea either. The reason for this choice is we had users of userptr that wanted to try out this concept and not have to do much porting.

To get to the userptr interface, I had to make a few things happen first. I needed to get dynamic page table allocation and teardown working. This was posted previously for gen6-7 [1] (with very rough code for gen8). I've now added more robust support for gen8 dynamic page table allocations. Doing the allocations dynamically was important because preallocating all 4 levels of page tables is not feasible in a real system. 4 level page tables are required in order to be able to support the 64b canonical address space.

With that all done, I was able to make a few minor hacks to userptr, take the intel-gpu-tools test from Tvrtko, and see at least one pass. FWIW, I am currently running,
./tests/gem_userptr_blits --run-subtest coherency-unsync

Since I feel the interface will likely change, I do not feel compelled to post either my libdrm, not my IGT changes. If you want the modified test, let me know, as I don't think it's really relevant here.

One last thing. Intel GPU tools, as it stands today, makes a lot of assumptions about using an address space > 32b. I have not had time to fix this. It is something which needs fixing before this series could even be considered testable.

[1] http://lists.freedesktop.org/archives/intel-gfx/2014-March/041814.html

Ben Widawsky (54):
drm/i915: Fix flush before context switch comment Revert "drm/i915: Drop I915_PARAM_HAS_FULL_PPGTT again" drm/i915: Wrap VMA binding
drm/i915: Make pin global flags explicit drm/i915: Split out aliasing binds
drm/i915: fix gtt_total_entries()
drm/i915: Rename to GEN8_LEGACY_PDPES drm/i915: Split out verbose PPGTT dumping drm/i915: s/pd/pdpe, s/pt/pde
drm/i915: rename map/unmap to dma_map/unmap drm/i915: Setup less PPGTT on failed pagedir drm/i915: clean up PPGTT init error path drm/i915: Un-hardcode number of page directories drm/i915: Make gen6_write_pdes gen6_map_page_tables drm/i915: Range clearing is PPGTT agnostic drm/i915: Page table helpers, and define renames drm/i915: construct page table abstractions drm/i915: Complete page table structures drm/i915: Create page table allocators drm/i915: Generalize GEN6 mapping
drm/i915: Clean up pagetable DMA map & unmap drm/i915: Always dma map page table allocations drm/i915: Consolidate dma mappings
drm/i915: Always dma map page directory allocations drm/i915: Track GEN6 page table usage drm/i915: Extract context switch skip logic drm/i915: Force pd restore when PDEs change, gen6-7 drm/i915: Finish gen6/7 dynamic page table allocation drm/i915/bdw: Use dynamic allocation idioms on free drm/i915/bdw: pagedirs rework allocation drm/i915/bdw: pagetable allocation rework drm/i915/bdw: Make the pdp switch a bit less hacky drm/i915: num_pd_pages/num_pd_entries isn't useful drm/i915: Extract PPGTT param from pagedir alloc drm/i915/bdw: Split out mappings
drm/i915/bdw: begin bitmap tracking drm/i915/bdw: Dynamic page table allocations drm/i915/bdw: Scratch unused pages drm/i915/bdw: Add ppgtt info for dynamic pages drm/i915/bdw: Optimize PDP loads
TESTME: Either drop the last patch or fix it. drm/i915/bdw: Add dynamic page trace events drm/i915/bdw: Make pdp allocation more dynamic drm/i915/bdw: Abstract PDP usage
drm/i915/bdw: implement alloc/teardown for 4lvl drm/i915/bdw: 4 level pages tables
drm/i915: Restructure map vs. insert entries drm/i915/bdw: make aliasing PPGTT dynamic drm/i915: Expand error state's address width to 64b drm/i915/bdw: Flip the 48b switch
TESTME: GFX_TLB_INVALIDATE_EXPLICIT
TESTME: Always force invalidate
drm/i915: Track userptr VMAs
drm/i915/userptr: Mirror GPU addr at ioctl (HACK/POC)

Chris Wilson (2):
drm/i915: Prevent signals from interrupting close() drm/i915: Introduce mapping of user pages into video memory (userptr)
ioctl

 drivers/gpu/drm/i915/Kconfig               |    1 +
 drivers/gpu/drm/i915/Makefile              |    1 +
 drivers/gpu/drm/i915/i915_debugfs.c        |  112 +-
 drivers/gpu/drm/i915/i915_dma.c            |   15 +-
 drivers/gpu/drm/i915/i915_drv.h            |   40 +-
 drivers/gpu/drm/i915/i915_gem.c            |   61 +-
 drivers/gpu/drm/i915/i915_gem_context.c    |   31 +-
 drivers/gpu/drm/i915/i915_gem_dmabuf.c     |    5 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   22 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c        | 1810 +++++++++++++++++++++-------
 drivers/gpu/drm/i915/i915_gem_gtt.h        |  354 +++++-
 drivers/gpu/drm/i915/i915_gem_userptr.c    |  767 ++++++++++++
 drivers/gpu/drm/i915/i915_gpu_error.c      |   21 +-
 drivers/gpu/drm/i915/i915_reg.h            |    1 +
 drivers/gpu/drm/i915/i915_trace.h          |  140 +++
 drivers/gpu/drm/i915/intel_ringbuffer.c    |    2 +-
 include/uapi/drm/i915_drm.h                |   20 +
 17 files changed, 2823 insertions(+), 580 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/i915_gem_userptr.c
Signature · 1 line
1.9.2