Skip to content

Commit 59dd13a

Browse files
icklerodrigovivi
authored andcommitted
drm/i915/gem: Flush coherency domains on first set-domain-ioctl
Avoid skipping what appears to be a no-op set-domain-ioctl if the cache coherency state is inconsistent with our target domain. This also has the utility of using the population of the pages to validate the backing store. The danger in skipping the first set-domain is leaving the cache inconsistent and submitting stale data, or worse leaving the clean data in the cache and not flushing it to the GPU. The impact should be small as it requires a no-op set-domain as the very first ioctl in a particular sequence not found in typical userspace. Reported-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Fixes: 754a254 ("drm/i915: Skip object locking around a no-op set-domain ioctl") Testcase: igt/gem_mmap_offset/blt-coherency Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Matthew Auld <matthew.william.auld@gmail.com> Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: <stable@vger.kernel.org> # v5.2+ Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20201019203825.10966-1-chris@chris-wilson.co.uk (cherry picked from commit 44c2200) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 0dccdba commit 59dd13a

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

drivers/gpu/drm/i915/gem/i915_gem_domain.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -508,21 +508,6 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
508508
if (!obj)
509509
return -ENOENT;
510510

511-
/*
512-
* Already in the desired write domain? Nothing for us to do!
513-
*
514-
* We apply a little bit of cunning here to catch a broader set of
515-
* no-ops. If obj->write_domain is set, we must be in the same
516-
* obj->read_domains, and only that domain. Therefore, if that
517-
* obj->write_domain matches the request read_domains, we are
518-
* already in the same read/write domain and can skip the operation,
519-
* without having to further check the requested write_domain.
520-
*/
521-
if (READ_ONCE(obj->write_domain) == read_domains) {
522-
err = 0;
523-
goto out;
524-
}
525-
526511
/*
527512
* Try to flush the object off the GPU without holding the lock.
528513
* We will repeat the flush holding the lock in the normal manner
@@ -560,6 +545,19 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
560545
if (err)
561546
goto out;
562547

548+
/*
549+
* Already in the desired write domain? Nothing for us to do!
550+
*
551+
* We apply a little bit of cunning here to catch a broader set of
552+
* no-ops. If obj->write_domain is set, we must be in the same
553+
* obj->read_domains, and only that domain. Therefore, if that
554+
* obj->write_domain matches the request read_domains, we are
555+
* already in the same read/write domain and can skip the operation,
556+
* without having to further check the requested write_domain.
557+
*/
558+
if (READ_ONCE(obj->write_domain) == read_domains)
559+
goto out_unpin;
560+
563561
err = i915_gem_object_lock_interruptible(obj, NULL);
564562
if (err)
565563
goto out_unpin;

0 commit comments

Comments
 (0)