All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/15] Move LMEM (VRAM) management over to TTM
@ 2021-05-28 10:57 ` Thomas Hellström
  0 siblings, 0 replies; 39+ messages in thread
From: Thomas Hellström @ 2021-05-28 10:57 UTC (permalink / raw)
  To: intel-gfx, dri-devel; +Cc: Thomas Hellström, Christian König

This is an initial patch series to move discrete memory management over to
TTM. It will be followed up shortly with adding more functionality.

The buddy allocator is temporarily removed along with its selftests and
It is replaced with the TTM range manager and some selftests are adjusted
to account for introduced fragmentation. Work is ongoing to reintroduce the
buddy allocator as a TTM resource manager.

A new memcpy ttm move is introduced that uses kmap_local() functionality
rather than vmap(). Among other things stated in the patch commit message
it helps us deal with page-pased LMEM memory. It is generic enough to replace
the ttm memcpy move with some additional work if so desired. On x86 it also
enables prefetching reads from write-combined memory.

Finally the old i915 gem object LMEM backend is replaced with a
i915 gem object TTM backend and some additional i915 gem object ops are
introduced to support the added functionality.
Currently it is used only to support management and eviction of the LMEM
region, but work is underway to extend the support to system memory. In this
way we use TTM the way it was originally intended, having the GPU binding
taken care of by driver code.

Intention is to follow up with
- System memory support
- Pipelined accelerated moves / migration
- Re-added buddy allocator in the TTM framework

v2:
- Add patches to move pagefaulting over to TTM
- Break out TTM changes to separate patches
- Address various review comments as detailed in the affected patches

v3:
- Drop TTM pagefaulting patches for now due changing approach due to a NAK.
- Address feedback on TTM patches
- Move the new TTM memcpy functionality into TTM.
- Move fast WC memcpy to drm
- Various fixes all over the place as shown in patch commit messages.

v4:
- Re-add TTM pagefaulting patches.
- Addressed review feedback mainly from Matthew Auld
- Fixed the mock ttm device code that was using an incorrect approach.

v5:
- Cleanups in the TTM pagefaulting patches.
- Just add the WC memcpy to DRM without removing from i915
  (Suggested by Daniel Vetter).
- Various minor fixes as reported in patch log messages.
v6:
- Fix a merge conflict causing build error.

Cc: Christian König <christian.koenig@amd.com>

Maarten Lankhorst (3):
  drm/i915: Disable mmap ioctl for gen12+
  drm/vma: Add a driver_private member to vma_node.
  drm/i915: Use ttm mmap handling for ttm bo's.

Thomas Hellström (12):
  drm/i915: Untangle the vma pages_mutex
  drm/i915: Don't free shared locks while shared
  drm/i915: Fix i915_sg_page_sizes to record dma segments rather than
    physical pages
  drm/i915/ttm Initialize the ttm device and memory managers
  drm/i915/ttm: Embed a ttm buffer object in the i915 gem object
  drm/ttm: Add a generic TTM memcpy move for page-based iomem
  drm: Add a prefetching memcpy_from_wc
  drm/ttm: Use drm_memcpy_from_wc for TTM bo moves
  drm/ttm: Document and optimize ttm_bo_pipeline_gutting()
  drm/ttm, drm/amdgpu: Allow the driver some control over swapping
  drm/i915/ttm: Introduce a TTM i915 gem object backend
  drm/i915/lmem: Verify checks for lmem residency

 Documentation/gpu/drm-mm.rst                  |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |   4 +
 drivers/gpu/drm/drm_cache.c                   | 138 +++
 drivers/gpu/drm/drm_drv.c                     |   2 +
 drivers/gpu/drm/drm_gem.c                     |   9 -
 drivers/gpu/drm/i915/Kconfig                  |   1 +
 drivers/gpu/drm/i915/Makefile                 |   3 +-
 drivers/gpu/drm/i915/display/intel_display.c  |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_create.c    |   9 +-
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_lmem.c      |  71 +-
 drivers/gpu/drm/i915/gem/i915_gem_lmem.h      |   5 -
 drivers/gpu/drm/i915/gem/i915_gem_mman.c      |  90 +-
 drivers/gpu/drm/i915/gem/i915_gem_object.c    | 149 +++-
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  19 +-
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  52 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c     |   6 +-
 drivers/gpu/drm/i915/gem/i915_gem_phys.c      |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_region.c    | 126 +--
 drivers/gpu/drm/i915/gem/i915_gem_region.h    |   4 -
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c     |   4 +-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c    |  10 +-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.h    |   9 +-
 drivers/gpu/drm/i915/gem/i915_gem_ttm.c       | 647 ++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_ttm.h       |  48 ++
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c   |   2 +-
 .../drm/i915/gem/selftests/i915_gem_mman.c    |  90 +-
 drivers/gpu/drm/i915/gt/intel_ggtt.c          |  19 +-
 drivers/gpu/drm/i915/gt/intel_gt.c            |   2 -
 drivers/gpu/drm/i915/gt/intel_gtt.c           |  45 +-
 drivers/gpu/drm/i915/gt/intel_gtt.h           |  28 +-
 drivers/gpu/drm/i915/gt/intel_ppgtt.c         |   2 +-
 drivers/gpu/drm/i915/gt/intel_region_lmem.c   |  30 +-
 drivers/gpu/drm/i915/i915_buddy.c             | 435 ----------
 drivers/gpu/drm/i915/i915_buddy.h             | 131 ---
 drivers/gpu/drm/i915/i915_drv.c               |  13 +
 drivers/gpu/drm/i915/i915_drv.h               |   8 +-
 drivers/gpu/drm/i915/i915_gem.c               |   6 +-
 drivers/gpu/drm/i915/i915_globals.c           |   1 -
 drivers/gpu/drm/i915/i915_globals.h           |   1 -
 drivers/gpu/drm/i915/i915_scatterlist.c       |  70 ++
 drivers/gpu/drm/i915/i915_scatterlist.h       |  20 +-
 drivers/gpu/drm/i915/i915_vma.c               |  29 +-
 drivers/gpu/drm/i915/intel_memory_region.c    | 181 ++--
 drivers/gpu/drm/i915/intel_memory_region.h    |  45 +-
 drivers/gpu/drm/i915/intel_region_ttm.c       | 220 +++++
 drivers/gpu/drm/i915/intel_region_ttm.h       |  37 +
 drivers/gpu/drm/i915/selftests/i915_buddy.c   | 789 ------------------
 .../drm/i915/selftests/i915_mock_selftests.h  |   1 -
 drivers/gpu/drm/i915/selftests/igt_mmap.c     |  25 +-
 drivers/gpu/drm/i915/selftests/igt_mmap.h     |  12 +-
 .../drm/i915/selftests/intel_memory_region.c  | 133 +--
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  10 +
 drivers/gpu/drm/i915/selftests/mock_region.c  |  70 +-
 drivers/gpu/drm/ttm/ttm_bo.c                  |  63 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c             | 320 +++----
 drivers/gpu/drm/ttm/ttm_module.c              |  35 +
 drivers/gpu/drm/ttm/ttm_resource.c            | 193 +++++
 drivers/gpu/drm/ttm/ttm_tt.c                  |  42 +
 include/drm/drm_cache.h                       |   7 +
 include/drm/drm_vma_manager.h                 |   2 +-
 include/drm/ttm/ttm_bo_driver.h               |  28 +
 include/drm/ttm/ttm_caching.h                 |   2 +
 include/drm/ttm/ttm_kmap_iter.h               |  61 ++
 include/drm/ttm/ttm_resource.h                |  61 ++
 include/drm/ttm/ttm_tt.h                      |  29 +
 66 files changed, 2530 insertions(+), 2182 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_ttm.c
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_ttm.h
 delete mode 100644 drivers/gpu/drm/i915/i915_buddy.c
 delete mode 100644 drivers/gpu/drm/i915/i915_buddy.h
 create mode 100644 drivers/gpu/drm/i915/intel_region_ttm.c
 create mode 100644 drivers/gpu/drm/i915/intel_region_ttm.h
 delete mode 100644 drivers/gpu/drm/i915/selftests/i915_buddy.c
 create mode 100644 include/drm/ttm/ttm_kmap_iter.h

-- 
2.31.1


^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: [PATCH v6 15/15] drm/i915: Use ttm mmap handling for ttm bo's.
@ 2021-05-30  3:51 kernel test robot
  0 siblings, 0 replies; 39+ messages in thread
From: kernel test robot @ 2021-05-30  3:51 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4029 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210528105744.58271-16-thomas.hellstrom@linux.intel.com>
References: <20210528105744.58271-16-thomas.hellstrom@linux.intel.com>
TO: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>

Hi "Thomas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[cannot apply to drm-intel/for-linux-next drm-exynos/exynos-drm-next tegra-drm/drm/tegra/for-next linus/master drm/drm-next v5.13-rc3 next-20210528]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Thomas-Hellstr-m/Move-LMEM-VRAM-management-over-to-TTM/20210528-185923
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: x86_64-randconfig-b001-20210529 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project bc6799f2f79f0ae87e9f1ebf9d25ba799fbd25a9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # apt-get install iwyu # include-what-you-use
        # https://github.com/0day-ci/linux/commit/f16d9c3acbbd3132e66d59ab82b0efbc93c322d4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Thomas-Hellstr-m/Move-LMEM-VRAM-management-over-to-TTM/20210528-185923
        git checkout f16d9c3acbbd3132e66d59ab82b0efbc93c322d4
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross C=1 CHECK=iwyu ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


iwyu warnings: (new ones prefixed by >>)
   drivers/gpu/drm/i915/gem/i915_gem_mman.c:8:1: iwyu: warning: superfluous #include <linux/mman.h>
   drivers/gpu/drm/i915/gem/i915_gem_mman.c:9:1: iwyu: warning: superfluous #include <linux/pfn_t.h>
   drivers/gpu/drm/i915/gem/i915_gem_mman.c:12:1: iwyu: warning: superfluous #include "gt/intel_gt.h"
>> drivers/gpu/drm/i915/gem/i915_gem_mman.c:22:1: iwyu: warning: superfluous #include "i915_gem_ttm.h"
--
>> drivers/gpu/drm/i915/gem/i915_gem_ttm.c:16:1: iwyu: warning: superfluous #include "gem/i915_gem_mman.h"

vim +22 drivers/gpu/drm/i915/gem/i915_gem_mman.c

b414fcd5be0b00 Chris Wilson      2019-05-28  @8  #include <linux/mman.h>
cc662126b4134e Abdiel Janulgue   2019-12-04   9  #include <linux/pfn_t.h>
b414fcd5be0b00 Chris Wilson      2019-05-28  10  #include <linux/sizes.h>
b414fcd5be0b00 Chris Wilson      2019-05-28  11  
cb823ed9915b0d Chris Wilson      2019-07-12  12  #include "gt/intel_gt.h"
661019754202d6 Chris Wilson      2019-10-04  13  #include "gt/intel_gt_requests.h"
cb823ed9915b0d Chris Wilson      2019-07-12  14  
b414fcd5be0b00 Chris Wilson      2019-05-28  15  #include "i915_drv.h"
b414fcd5be0b00 Chris Wilson      2019-05-28  16  #include "i915_gem_gtt.h"
b414fcd5be0b00 Chris Wilson      2019-05-28  17  #include "i915_gem_ioctls.h"
b414fcd5be0b00 Chris Wilson      2019-05-28  18  #include "i915_gem_object.h"
cc662126b4134e Abdiel Janulgue   2019-12-04  19  #include "i915_gem_mman.h"
a09d9a8002368e Jani Nikula       2019-08-06  20  #include "i915_trace.h"
126d5de38542d4 Chris Wilson      2019-12-04  21  #include "i915_user_extensions.h"
f16d9c3acbbd31 Maarten Lankhorst 2021-05-28 @22  #include "i915_gem_ttm.h"
b414fcd5be0b00 Chris Wilson      2019-05-28  23  #include "i915_vma.h"
b414fcd5be0b00 Chris Wilson      2019-05-28  24  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37898 bytes --]

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2021-05-30  3:51 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 10:57 [PATCH v6 00/15] Move LMEM (VRAM) management over to TTM Thomas Hellström
2021-05-28 10:57 ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 01/15] drm/i915: Untangle the vma pages_mutex Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 02/15] drm/i915: Don't free shared locks while shared Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 03/15] drm/i915: Fix i915_sg_page_sizes to record dma segments rather than physical pages Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 04/15] drm/i915/ttm Initialize the ttm device and memory managers Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 05/15] drm/i915/ttm: Embed a ttm buffer object in the i915 gem object Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 06/15] drm/ttm: Add a generic TTM memcpy move for page-based iomem Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 07/15] drm: Add a prefetching memcpy_from_wc Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-29 19:49   ` kernel test robot
2021-05-29 21:54   ` kernel test robot
2021-05-28 10:57 ` [PATCH v6 08/15] drm/ttm: Use drm_memcpy_from_wc for TTM bo moves Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 09/15] drm/ttm: Document and optimize ttm_bo_pipeline_gutting() Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 10/15] drm/ttm, drm/amdgpu: Allow the driver some control over swapping Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 11/15] drm/i915/ttm: Introduce a TTM i915 gem object backend Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 12/15] drm/i915/lmem: Verify checks for lmem residency Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 13/15] drm/i915: Disable mmap ioctl for gen12+ Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 14/15] drm/vma: Add a driver_private member to vma_node Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 10:57 ` [PATCH v6 15/15] drm/i915: Use ttm mmap handling for ttm bo's Thomas Hellström
2021-05-28 10:57   ` [Intel-gfx] " Thomas Hellström
2021-05-28 17:10 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Move LMEM (VRAM) management over to TTM (rev2) Patchwork
2021-05-28 17:12 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-05-28 17:40 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-05-29  5:43 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-05-30  3:51 [PATCH v6 15/15] drm/i915: Use ttm mmap handling for ttm bo's kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.