1. 04 10月, 2019 4 次提交
    • C
      drm/i915: Coordinate i915_active with its own mutex · b1e3177b
      Chris Wilson 提交于
      Forgo the struct_mutex serialisation for i915_active, and interpose its
      own mutex handling for active/retire.
      
      This is a multi-layered sleight-of-hand. First, we had to ensure that no
      active/retire callbacks accidentally inverted the mutex ordering rules,
      nor assumed that they were themselves serialised by struct_mutex. More
      challenging though, is the rule over updating elements of the active
      rbtree. Instead of the whole i915_active now being serialised by
      struct_mutex, allocations/rotations of the tree are serialised by the
      i915_active.mutex and individual nodes are serialised by the caller
      using the i915_timeline.mutex (we need to use nested spinlocks to
      interact with the dma_fence callback lists).
      
      The pain point here is that instead of a single mutex around execbuf, we
      now have to take a mutex for active tracker (one for each vma, context,
      etc) and a couple of spinlocks for each fence update. The improvement in
      fine grained locking allowing for multiple concurrent clients
      (eventually!) should be worth it in typical loads.
      
      v2: Add some comments that barely elucidate anything :(
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-6-chris@chris-wilson.co.uk
      b1e3177b
    • C
      drm/i915: Pull i915_vma_pin under the vm->mutex · 2850748e
      Chris Wilson 提交于
      Replace the struct_mutex requirement for pinning the i915_vma with the
      local vm->mutex instead. Note that the vm->mutex is tainted by the
      shrinker (we require unbinding from inside fs-reclaim) and so we cannot
      allocate while holding that mutex. Instead we have to preallocate
      workers to do allocate and apply the PTE updates after we have we
      reserved their slot in the drm_mm (using fences to order the PTE writes
      with the GPU work and with later unbind).
      
      In adding the asynchronous vma binding, one subtle requirement is to
      avoid coupling the binding fence into the backing object->resv. That is
      the asynchronous binding only applies to the vma timeline itself and not
      to the pages as that is a more global timeline (the binding of one vma
      does not need to be ordered with another vma, nor does the implicit GEM
      fencing depend on a vma, only on writes to the backing store). Keeping
      the vma binding distinct from the backing store timelines is verified by
      a number of async gem_exec_fence and gem_exec_schedule tests. The way we
      do this is quite simple, we keep the fence for the vma binding separate
      and only wait on it as required, and never add it to the obj->resv
      itself.
      
      Another consequence in reducing the locking around the vma is the
      destruction of the vma is no longer globally serialised by struct_mutex.
      A natural solution would be to add a kref to i915_vma, but that requires
      decoupling the reference cycles, possibly by introducing a new
      i915_mm_pages object that is own by both obj->mm and vma->pages.
      However, we have not taken that route due to the overshadowing lmem/ttm
      discussions, and instead play a series of complicated games with
      trylocks to (hopefully) ensure that only one destruction path is called!
      
      v2: Add some commentary, and some helpers to reduce patch churn.
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-4-chris@chris-wilson.co.uk
      2850748e
    • C
      drm/i915: Mark up address spaces that may need to allocate · 11331125
      Chris Wilson 提交于
      Since we cannot allocate underneath the vm->mutex (it is used in the
      direct-reclaim paths), we need to shift the allocations off into a
      mutexless worker with fence recursion prevention. To know when we need
      this protection, we mark up the address spaces that do allocate before
      insertion. In the future, we may wish to extend the async bind scheme to
      more than just allocations.
      
      v2: s/vm->bind_alloc/vm->bind_async_flags/
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-3-chris@chris-wilson.co.uk
      11331125
    • C
      drm/i915: Only track bound elements of the GTT · 5e053450
      Chris Wilson 提交于
      The premise here is to simply avoiding having to acquire the vm->mutex
      inside vma create/destroy to update the vm->unbound_lists, to avoid some
      nasty lock recursions later.
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: NMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-2-chris@chris-wilson.co.uk
      5e053450
  2. 13 9月, 2019 1 次提交
  3. 11 9月, 2019 2 次提交
  4. 10 9月, 2019 2 次提交
  5. 03 9月, 2019 1 次提交
  6. 31 8月, 2019 1 次提交
  7. 30 8月, 2019 1 次提交
  8. 27 8月, 2019 1 次提交
  9. 24 8月, 2019 3 次提交
  10. 22 8月, 2019 1 次提交
  11. 21 8月, 2019 3 次提交
  12. 20 8月, 2019 3 次提交
  13. 17 8月, 2019 1 次提交
  14. 16 8月, 2019 1 次提交
  15. 15 8月, 2019 1 次提交
  16. 13 8月, 2019 1 次提交
  17. 10 8月, 2019 1 次提交
  18. 07 8月, 2019 2 次提交
  19. 30 7月, 2019 1 次提交
  20. 29 7月, 2019 3 次提交
    • C
      drm/i915: Flush the i915_vm_release before ggtt shutdown · 60a4233a
      Chris Wilson 提交于
      As the gen6_ppgtt may refer back to the GGTT for their page-directory
      slots, make sure those __i915_vm_release are completed prior to shutting
      down the GGTT.
      
      Fixes: b32fa811 ("drm/i915/gtt: Defer address space cleanup to an RCU worker")
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190729132412.23380-1-chris@chris-wilson.co.uk
      60a4233a
    • C
      drm/i915/gtt: Mark the freed page table entries with scratch · 5f4c82c8
      Chris Wilson 提交于
      On unwinding the allocation error path and having freed the page table
      entry, it is imperative that we mark it as scratch.
      
      <4> [416.075569] general protection fault: 0000 [#1] PREEMPT SMP PTI
      <4> [416.075801] CPU: 0 PID: 2385 Comm: kworker/u2:11 Tainted: G     U            5.2.0-rc7-CI-Patchwork_13534+ #1
      <4> [416.076162] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014
      <4> [416.076522] Workqueue: i915 __i915_vm_release [i915]
      <4> [416.076754] RIP: 0010:gen8_ppgtt_cleanup_3lvl+0x58/0xb0 [i915]
      <4> [416.077023] Code: 81 e2 04 fe ff ff 81 c2 ff 01 00 00 4c 8d 74 d6 58 4d 8b 65 00 4d 3b a7 28 02 00 00 74 40 49 8d 5c 24 50 49 81 c4 50 10 00 00 <48> 8b 2b 49 3b af 20 02 00 00 74 13 4c 89 ff 48 89 ee e8 01 fb ff
      <4> [416.077445] RSP: 0018:ffffc9000046bd98 EFLAGS: 00010206
      <4> [416.077625] RAX: 0001000000000000 RBX: 6b6b6b6b6b6b6bbb RCX: 8b4b56d500000000
      <4> [416.077838] RDX: 00000000000001ff RSI: ffff88805a578008 RDI: ffff88805bd0efc8
      <4> [416.078167] RBP: ffff88805bd0efc8 R08: 0000000004e42b93 R09: 0000000000000001
      <4> [416.078381] R10: 0000000000000000 R11: ffff888077a1b0b8 R12: 6b6b6b6b6b6b7bbb
      <4> [416.078594] R13: ffff88805a578058 R14: ffff88805a579058 R15: ffff88805bd0efc8
      <4> [416.078815] FS:  0000000000000000(0000) GS:ffff88807da00000(0000) knlGS:0000000000000000
      <4> [416.079395] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      <4> [416.079851] CR2: 000056160fec2b14 CR3: 0000000071bbc003 CR4: 00000000003606f0
      <4> [416.080388] Call Trace:
      <4> [416.080828]  gen8_ppgtt_cleanup+0x64/0x100 [i915]
      <4> [416.081399]  __i915_vm_release+0xfc/0x1d0 [i915]
      
      Fixes: 1d1b5490 ("drm/i915/gtt: Replace struct_mutex serialisation for allocation")
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Cc: Mika Kuoppala <mika.kuoppala@intel.com>
      Reviewed-by: NMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190704201656.15775-1-chris@chris-wilson.co.uk
      (cherry picked from commit e7539b79)
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      5f4c82c8
    • C
      drm/i915/gtt: Defer the free for alloc error paths · f691eaa4
      Chris Wilson 提交于
      If we hit an error while allocating the page tables, we have to unwind
      the incomplete updates, and wish to free the unused pd. However, we are
      not allowed to be hoding the spinlock at that point, and so must use the
      later free to defer it until after we drop the lock.
      
      <3> [414.363795] BUG: sleeping function called from invalid context at drivers/gpu/drm/i915/i915_gem_gtt.c:472
      <3> [414.364167] in_atomic(): 1, irqs_disabled(): 0, pid: 3905, name: i915_selftest
      <4> [414.364406] 3 locks held by i915_selftest/3905:
      <4> [414.364408]  #0: 0000000034fe8aa8 (&dev->mutex){....}, at: device_driver_attach+0x18/0x50
      <4> [414.364415]  #1: 000000006bd8a560 (&dev->struct_mutex){+.+.}, at: igt_ctx_exec+0xb7/0x410 [i915]
      <4> [414.364476]  #2: 000000003dfdc766 (&(&pd->lock)->rlock){+.+.}, at: gen8_ppgtt_alloc_pdp+0x448/0x540 [i915]
      <3> [414.364529] Preemption disabled at:
      <4> [414.364530] [<0000000000000000>] 0x0
      <4> [414.364696] CPU: 0 PID: 3905 Comm: i915_selftest Tainted: G     U            5.2.0-rc7-CI-CI_DRM_6403+ #1
      <4> [414.364698] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014
      <4> [414.364699] Call Trace:
      <4> [414.364704]  dump_stack+0x67/0x9b
      <4> [414.364708]  ___might_sleep+0x167/0x250
      <4> [414.364777]  vm_free_page+0x24/0xc0 [i915]
      <4> [414.364852]  free_pd+0xf/0x20 [i915]
      <4> [414.364897]  gen8_ppgtt_alloc_pdp+0x489/0x540 [i915]
      <4> [414.364946]  gen8_ppgtt_alloc_4lvl+0x8e/0x2e0 [i915]
      <4> [414.364992]  ppgtt_bind_vma+0x2e/0x60 [i915]
      <4> [414.365039]  i915_vma_bind+0xe8/0x2c0 [i915]
      <4> [414.365088]  __i915_vma_do_pin+0xa1/0xd20 [i915]
      
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111050
      Fixes: 1d1b5490 ("drm/i915/gtt: Replace struct_mutex serialisation for allocation")
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Cc: Mika Kuoppala <mika.kuoppala@intel.com>
      Reviewed-by: NMika Kuoppala <mika.kuoppala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190703171913.16585-3-chris@chris-wilson.co.uk
      (cherry picked from commit 06861089)
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      f691eaa4
  21. 23 7月, 2019 2 次提交
  22. 20 7月, 2019 2 次提交
  23. 16 7月, 2019 2 次提交