OSDN Git Service

drm/i915/ttm: Failsafe migration blits
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 4 Nov 2021 11:07:18 +0000 (12:07 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Fri, 5 Nov 2021 08:05:32 +0000 (09:05 +0100)
commit2b0a750caf332a24f62f6960820d24d885f2efc2
treebb1a143f99e2191c60e8d0388a31ea28e5798d7e
parent3589fdbd3b2085e273b6ea1e9f27a211e0ef74f8
drm/i915/ttm: Failsafe migration blits

If the initial fill blit or copy blit of an object fails, the old
content of the data might be exposed and read as soon as either CPU- or
GPU PTEs are set up to point at the pages.

Intercept the blit fence with an async callback that checks the
blit fence for errors and if there are errors performs an async cpu blit
instead. If there is a failure to allocate the async dma_fence_work,
allocate it on the stack and sync wait for the blit to complete.

Add selftests that simulate gpu blit failures and failure to allocate
the async dma_fence_work.

A previous version of this pach used dma_fence_work, now that's
opencoded which adds more code but might lower the latency
somewhat in the common non-error case.

v3:
- Style fixes (Matthew Auld)
v4:
- Use "#if IS_ENABLED()" instead of #ifdef (Matthew Auld)
v5:
- Fix an issue where we, if the dependency was already signaled, might
  end up waiting for a memcpy fence that would never signal.
v6:
- Add a missing i915_ttm_memcpy_release() (Matthew Auld)

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211104110718.688420-3-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c
drivers/gpu/drm/i915/gem/i915_gem_ttm_move.h
drivers/gpu/drm/i915/gem/selftests/i915_gem_migrate.c