]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915/gem/ttm: Only call __i915_gem_object_set_pages if needed
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 23 Jul 2021 17:21:39 +0000 (12:21 -0500)
committerMatthew Auld <matthew.auld@intel.com>
Mon, 26 Jul 2021 15:37:34 +0000 (16:37 +0100)
commit4a1b3154294b55e95f3ff56f36ecee06fdf5eaf7
tree6307e71fcfc8b318cf1ef9115906e2c96baf8464
parent71c662173f8d5596e7069f5bd7d0cc57e750f164
drm/i915/gem/ttm: Only call __i915_gem_object_set_pages if needed

__i915_ttm_get_pages does two things.  First, it calls ttm_bo_validate()
to check the given placement and migrate the BO if needed.  Then, it
updates the GEM object to match, in case the object was migrated.  If
no migration occured, however, we might still have pages on the GEM
object in which case we don't need to fetch them from TTM and call
__i915_gem_object_set_pages.  This hasn't been a problem before because
the primary user of __i915_ttm_get_pages is __i915_gem_object_get_pages
which only calls it if the GEM object doesn't have pages.

However, i915_ttm_migrate also uses __i915_ttm_get_pages to do the
migration so this meant it was unsafe to call on an already populated
object.  This patch checks i915_gem_object_has_pages() before trying to
__i915_gem_object_set_pages so i915_ttm_migrate is safe to call, even on
populated objects.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210723172142.3273510-6-jason@jlekstrand.net
drivers/gpu/drm/i915/gem/i915_gem_ttm.c