Skip to content

Basic system allocator support in xe driver

Oak Zeng intel-xe 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest31 patches 39 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/31drm/xe: Refactor vm_binddrivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/tests/xe_migrate.c drivers/gpu/drm/xe/xe_bo.c +29 more+2142 -17040 replies
2/31drm/xe/svm: Add SVM documentDocumentation/gpu/xe/index.rst Documentation/gpu/xe/xe_svm.rst drivers/gpu/drm/xe/xe_svm_doc.h+130 -00 replies
3/31drm/xe: Invalidate userptr VMA on page pin faultdrivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_trace.h drivers/gpu/drm/xe/xe_vm.c +1 more+18 -150 replies
4/31drm/xe: Drop unused arguments from vm_bind_ioctl_ops_parsedrivers/gpu/drm/xe/xe_vm.c+4 -50 replies
5/31drm/xe: Fix op->tile_mask for fault modedrivers/gpu/drm/xe/xe_vm.c+8 -00 replies
6/31drm/xe/uapi: Add DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR flagdrivers/gpu/drm/xe/xe_pt.c drivers/gpu/drm/xe/xe_vm.c drivers/gpu/drm/xe/xe_vm.h +2 more+161 -700 replies
7/31drm/xe: Create userptr if page fault occurs on system_allocator VMAdrivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_vm.c drivers/gpu/drm/xe/xe_vm.h +1 more+128 -50 replies
8/31drm/xe: Add faulted userptr VMA garbage collectordrivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_vm.c drivers/gpu/drm/xe/xe_vm.h +1 more+170 -00 replies
9/31drm/xe: Introduce helper to populate userptrdrivers/gpu/drm/xe/Kconfig drivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/xe_hmm.c +1 more+244 -00 replies
10/31drm/xe: Introduce a helper to free sg tabledrivers/gpu/drm/xe/xe_hmm.c drivers/gpu/drm/xe/xe_hmm.h+31 -00 replies
11/31drm/xe: Use hmm_range_fault to populate user pagesdrivers/gpu/drm/xe/xe_vm.c+12 -1100 replies
12/31drm/xe/svm: Remap and provide memmap backing for GPU vramdrivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/xe_device_types.h drivers/gpu/drm/xe/xe_mmio.c +3 more+123 -02 replies
13/31drm/xe/svm: Introduce DRM_XE_SVM kernel configdrivers/gpu/drm/xe/Kconfig drivers/gpu/drm/xe/xe_tile.c+26 -22 replies
14/31drm/xe: Introduce helper to get tile from memory regiondrivers/gpu/drm/xe/xe_device.h+8 -01 reply
15/31drm/xe: Introduce a helper to get dpa from pfndrivers/gpu/drm/xe/xe_svm.h+25 -21 reply
16/31drm/xe/svm: Get xe memory region from pagedrivers/gpu/drm/xe/xe_svm.h+11 -01 reply
17/31drm/xe: Get xe_vma from xe_userptrdrivers/gpu/drm/xe/xe_vm.h+14 -01 reply
18/31drm/xe/svm: Build userptr sg table for device pagesdrivers/gpu/drm/xe/xe_hmm.c drivers/gpu/drm/xe/xe_vm_types.h+100 -231 reply
19/31drm/xe/svm: Determine a vma is backed by device memorydrivers/gpu/drm/xe/xe_pt.c+12 -22 replies
20/31drm/xe: add xe lock documentDocumentation/gpu/xe/index.rst Documentation/gpu/xe/xe_lock.rst drivers/gpu/drm/xe/xe_lock_doc.h +1 more+123 -10 replies
21/31drm/xe/svm: Introduce svm migration functiondrivers/gpu/drm/xe/xe_migrate.c drivers/gpu/drm/xe/xe_migrate.h+224 -01 reply
22/31drm/xe/svm: implement functions to allocate and free device memorydrivers/gpu/drm/xe/xe_svm.h drivers/gpu/drm/xe/xe_svm_devmem.c+152 -28 replies
23/31drm/xe/svm: Trace buddy block allocation and freedrivers/gpu/drm/xe/xe_svm_devmem.c drivers/gpu/drm/xe/xe_trace.h+40 -10 replies
24/31drm/xe/svm: Create and destroy xe svmdrivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/xe_svm.c drivers/gpu/drm/xe/xe_svm.h+101 -01 reply
25/31drm/xe/svm: Add vm to xe_svm processdrivers/gpu/drm/xe/xe_svm.c drivers/gpu/drm/xe/xe_svm.h drivers/gpu/drm/xe/xe_vm.c +1 more+55 -00 replies
26/31drm/xe: Make function lookup_vma publicdrivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_vm.h+9 -21 reply
27/31drm/xe/svm: Handle CPU page faultdrivers/gpu/drm/xe/Makefile drivers/gpu/drm/xe/xe_svm.h drivers/gpu/drm/xe/xe_svm_devmem.c +1 more+230 -86 replies
28/31drm/xe/svm: Introduce helper to migrate vma to vramdrivers/gpu/drm/xe/xe_svm.h drivers/gpu/drm/xe/xe_svm_migrate.c+117 -06 replies
29/31drm/xe/svm: trace svm migrationdrivers/gpu/drm/xe/xe_svm_migrate.c drivers/gpu/drm/xe/xe_trace.h+15 -10 replies
30/31drm/xe/svm: Add a helper to determine a vma is fault userptrdrivers/gpu/drm/xe/xe_vm.h+5 -01 reply
31/31drm/xe/svm: Migration from sram to vram for system allocatordrivers/gpu/drm/xe/xe_gt_pagefault.c drivers/gpu/drm/xe/xe_vm.c+8 -54 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [v2 00/31] Basic system allocator support in xe driver

This is the v2 of basic system allocator support in xe kmd driver.
v1 is here: https://lore.kernel.org/dri-devel/[email protected]/

Significant design changes were made since v1, based on drm community review feedback:

1) Introduce vm_bind uAPI for system allocator. With this uAPI, user can optionally bind CPU virtual address range A..B to GPU virtual address range C..D. Right now we force A..B == C..D since we don't have a valid use case where A..B != C..D. But the interface is built so we can extend easily in the future if valid use case come out. See patch 3 to 8 for this work.

2) Unify system allocator and user ptr code. Now system allocator and userptr share the same codes for gpu page table programming, mmu interval notifier and vma invalidation, page fault handling and lock design. The codes are more unified.

This work is built on top of Matt Brost's huge vm_bind refactor series. The first patch is a squash of Matt's 30 patch series for reference purpose.

This work is still at its early stage. It is sent out so we can get some early eyes on it. We are open to any comments and suggestions.

The work that are planned in our bucket are:

*Virtual address range based memory attributes and hints: We plan to expose uAPI for user to set memory attributes such as preferred location or migration granularity etc to a virtual address range. This is important to tune SVM performance.

*GPU vram eviction: One key design choice of this series is, SVM layer allocate GPU memory directly from drm buddy allocator, instead of from xe vram manager. There is no BO (buffer object) concept in this implementation. The key benefit of this approach is we can migrate memory at page granularity easily. This also means SVM bypasses TTM's memory eviction logic. But we want the SVM memory and BO driver memory can mutually evicted each other. We have some prove of concept work to rework TTM resource manager for this purpose, see
https://lore.kernel.org/dri-devel/[email protected]/
We will continue work on that series then implement SVM's eviction function based on the concept of shared drm LRU list b/t SVM and TTM/BO driver.

* Try 1 vma with N PT_state for system allocator and userptr. One gigantic vma to hold address space initial default constant state and N PT_state to hold mutable page table state. Also try to register only one mmu interval notifier for the whole address range.

* Multiple GPU device support

Matthew Brost (7):
drm/xe: Refactor vm_bind
drm/xe: Invalidate userptr VMA on page pin fault
drm/xe: Drop unused arguments from vm_bind_ioctl_ops_parse drm/xe: Fix op->tile_mask for fault mode
drm/xe/uapi: Add DRM_XE_VM_BIND_FLAG_SYSTEM_ALLOCATOR flag drm/xe: Create userptr if page fault occurs on system_allocator VMA drm/xe: Add faulted userptr VMA garbage collector

Oak Zeng (24):
drm/xe/svm: Add SVM document
drm/xe: Introduce helper to populate userptr
drm/xe: Introduce a helper to free sg table
drm/xe: Use hmm_range_fault to populate user pages drm/xe/svm: Remap and provide memmap backing for GPU vram drm/xe/svm: Introduce DRM_XE_SVM kernel config
drm/xe: Introduce helper to get tile from memory region drm/xe: Introduce a helper to get dpa from pfn drm/xe/svm: Get xe memory region from page
drm/xe: Get xe_vma from xe_userptr
drm/xe/svm: Build userptr sg table for device pages drm/xe/svm: Determine a vma is backed by device memory drm/xe: add xe lock document
drm/xe/svm: Introduce svm migration function drm/xe/svm: implement functions to allocate and free device memory drm/xe/svm: Trace buddy block allocation and free drm/xe/svm: Create and destroy xe svm
drm/xe/svm: Add vm to xe_svm process
drm/xe: Make function lookup_vma public
drm/xe/svm: Handle CPU page fault
drm/xe/svm: Introduce helper to migrate vma to vram drm/xe/svm: trace svm migration
drm/xe/svm: Add a helper to determine a vma is fault userptr drm/xe/svm: Migration from sram to vram for system allocator

 Documentation/gpu/xe/index.rst              |    2 +
 Documentation/gpu/xe/xe_lock.rst            |    8 +
 Documentation/gpu/xe/xe_svm.rst             |    8 +
 drivers/gpu/drm/xe/Kconfig                  |   22 +
 drivers/gpu/drm/xe/Makefile                 |    6 +
 drivers/gpu/drm/xe/tests/xe_migrate.c       |   86 -
 drivers/gpu/drm/xe/xe_bo.c                  |    7 +-
 drivers/gpu/drm/xe/xe_bo.h                  |    4 +-
 drivers/gpu/drm/xe/xe_device.c              |   35 +
 drivers/gpu/drm/xe/xe_device.h              |   10 +
 drivers/gpu/drm/xe/xe_device_types.h        |   24 +
 drivers/gpu/drm/xe/xe_exec.c                |   41 +-
 drivers/gpu/drm/xe/xe_exec_queue.c          |  120 +-
 drivers/gpu/drm/xe/xe_exec_queue_types.h    |   20 +-
 drivers/gpu/drm/xe/xe_gt_pagefault.c        |   52 +-
 drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c |   59 +-
 drivers/gpu/drm/xe/xe_gt_tlb_invalidation.h |    3 +
 drivers/gpu/drm/xe/xe_guc_submit.c          |   22 +-
 drivers/gpu/drm/xe/xe_hmm.c                 |  329 ++++
 drivers/gpu/drm/xe/xe_hmm.h                 |   18 +
 drivers/gpu/drm/xe/xe_lock_doc.h            |  113 ++
 drivers/gpu/drm/xe/xe_migrate.c             |  602 ++++---
 drivers/gpu/drm/xe/xe_migrate.h             |   53 +-
 drivers/gpu/drm/xe/xe_mmio.c                |    6 +
 drivers/gpu/drm/xe/xe_pci.c                 |    1 +
 drivers/gpu/drm/xe/xe_pt.c                  | 1301 +++++++++-----
 drivers/gpu/drm/xe/xe_pt.h                  |   15 +-
 drivers/gpu/drm/xe/xe_pt_exec_queue.c       |  180 ++
 drivers/gpu/drm/xe/xe_pt_exec_queue.h       |   14 +
 drivers/gpu/drm/xe/xe_pt_types.h            |   53 +
 drivers/gpu/drm/xe/xe_sched_job.c           |   68 +-
 drivers/gpu/drm/xe/xe_sched_job_types.h     |   31 +-
 drivers/gpu/drm/xe/xe_svm.c                 |  122 ++
 drivers/gpu/drm/xe/xe_svm.h                 |   88 +
 drivers/gpu/drm/xe/xe_svm_devmem.c          |  231 +++
 drivers/gpu/drm/xe/xe_svm_doc.h             |  121 ++
 drivers/gpu/drm/xe/xe_svm_migrate.c         |  340 ++++
 drivers/gpu/drm/xe/xe_sync.c                |   15 +
 drivers/gpu/drm/xe/xe_sync.h                |    1 +
 drivers/gpu/drm/xe/xe_tile.c                |    7 +
 drivers/gpu/drm/xe/xe_trace.h               |   69 +-
 drivers/gpu/drm/xe/xe_uc_fw.c               |    1 +
 drivers/gpu/drm/xe/xe_vm.c                  | 1768 ++++++++++---------
 drivers/gpu/drm/xe/xe_vm.h                  |   40 +-
 drivers/gpu/drm/xe/xe_vm_types.h            |  229 ++-
 include/drm/xe_pciids.h                     |   16 +
 include/uapi/drm/xe_drm.h                   |   15 +-
 47 files changed, 4432 insertions(+), 1944 deletions(-)
 create mode 100644 Documentation/gpu/xe/xe_lock.rst
 create mode 100644 Documentation/gpu/xe/xe_svm.rst
 create mode 100644 drivers/gpu/drm/xe/xe_hmm.c
 create mode 100644 drivers/gpu/drm/xe/xe_hmm.h
 create mode 100644 drivers/gpu/drm/xe/xe_lock_doc.h
 create mode 100644 drivers/gpu/drm/xe/xe_pt_exec_queue.c
 create mode 100644 drivers/gpu/drm/xe/xe_pt_exec_queue.h
 create mode 100644 drivers/gpu/drm/xe/xe_svm.c
 create mode 100644 drivers/gpu/drm/xe/xe_svm.h
 create mode 100644 drivers/gpu/drm/xe/xe_svm_devmem.c
 create mode 100644 drivers/gpu/drm/xe/xe_svm_doc.h
 create mode 100644 drivers/gpu/drm/xe/xe_svm_migrate.c
Signature · 1 line
2.26.3