Skip to contentSkip to conversation

drm/i915: document caching related bits

PATCH Superseded Matthew Auld 4 participants 8 messages Jul 21, 2021 – Aug 2, 2021

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 drm/i915: document caching related bits

Try to document the object caching related bits, like cache_coherent and cache_dirty.

v2(Ville):
- As pointed out by Ville, fix the completely incorrect assumptions about the "partial" coherency on shared LLC platforms.

---
 .../gpu/drm/i915/gem/i915_gem_object_types.h  | 173 +++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.h               |   9 -
 2 files changed, 169 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +169 -4
index ef3de2ae9723..a809424bc8c1 100644
@@ -92,6 +92,76 @@ struct drm_i915_gem_object_ops {
 	const char *name; /* friendly name for debug, e.g. lockdep classes */
 };
 
+/**
+ * enum i915_cache_level - The supported GTT caching values for system memory
+ * pages.
+ *
+ * These translate to some special GTT PTE bits when binding pages into some
+ * address space. It also determines whether an object, or rather its pages are
+ * coherent with the GPU, when also reading or writing through the CPU cache
+ * with those pages.
+ *
+ * Userspace can also control this through struct drm_i915_gem_caching.
+ */
+enum i915_cache_level {
+	/**
+	 * @I915_CACHE_NONE:
+	 *
+	 * Not coherent with the CPU cache. If the cache is dirty and we need
+	 * the underlying pages to be coherent with some later GPU access then
+	 * we need to manually flush the pages.
+	 *
+	 * Note that on shared LLC platforms reads and writes through the CPU
+	 * cache are still coherent even with this setting. See also
+	 * &drm_i915_gem_object.cache_coherent for more details.
+	 *
+	 * Note that on platforms with a shared LLC this should ideally only be
+	 * used for scanout surfaces, otherwise we end up over-flushing in some
+	 * places.
+	 */
+	I915_CACHE_NONE = 0,
+	/**
+	 * @I915_CACHE_LLC:
+	 *
+	 * Coherent with the CPU cache. If the cache is dirty, then the GPU will
+	 * ensure that access remains coherent, when both reading and writing
+	 * through the CPU cache.
+	 *
+	 * Not used for scanout surfaces.
+	 *
+	 * Applies to both platforms with shared LLC(HAS_LLC), and snooping
+	 * based platforms(HAS_SNOOP).
+	 *
+	 * This should be the default for platforms which share the LLC with the
+	 * CPU. The only exception is scanout objects, where the display engine
+	 * is not coherent with the LLC. For such objects I915_CACHE_NONE or
+	 * I915_CACHE_WT should be used.
+	 */
+	I915_CACHE_LLC,
+	/**
+	 * @I915_CACHE_L3_LLC:
+	 *
+	 * Explicitly enable the Gfx L3 cache, with snooped LLC.
+	 *
+	 * The Gfx L3 sits between the domain specific caches, e.g
+	 * sampler/render caches, and the larger LLC. LLC is coherent with the
+	 * GPU, but L3 is only visible to the GPU, so likely needs to be flushed
+	 * when the workload completes.
+	 *
+	 * Not used for scanout surfaces.
+	 *
+	 * Only exposed on some gen7 + GGTT. More recent hardware has dropped
+	 * this.
+	 */
+	I915_CACHE_L3_LLC,
+	/**
+	 * @I915_CACHE_WT:
+	 *
+	 * hsw:gt3e Write-through for scanout buffers.
+	 */
+	I915_CACHE_WT,
+};
+
 enum i915_map_type {
 	I915_MAP_WB = 0,
 	I915_MAP_WC,
@@ -228,14 +298,109 @@ struct drm_i915_gem_object {
 	unsigned int mem_flags;
 #define I915_BO_FLAG_STRUCT_PAGE BIT(0) /* Object backed by struct pages */
 #define I915_BO_FLAG_IOMEM       BIT(1) /* Object backed by IO memory */
-	/*
-	 * Is the object to be mapped as read-only to the GPU
-	 * Only honoured if hardware has relevant pte bit
+	/**
+	 * @cache_level: The desired GTT caching level.
+	 *
+	 * See enum i915_cache_level for possible values, along with what
+	 * each does.
 	 */
 	unsigned int cache_level:3;
-	unsigned int cache_coherent:2;
+	/**
+	 * @cache_coherent:
+	 *
+	 * Track whether the pages are coherent with the GPU if reading or
+	 * writing through the CPU caches. The largely depends on the
+	 * @cache_level setting.
+	 *
+	 * On platforms which don't have the shared LLC(HAS_SNOOP), like on Atom
+	 * platforms, coherency must be explicitly requested with some special
+	 * GTT caching bits(see enum i915_cache_level). When enabling coherency
+	 * it does come at a performance and power cost on such platforms. On
+	 * the flip side the kernel does need to manually flush any buffers
+	 * which need to be coherent with the GPU, if the object is not
+	 * coherent i.e @cache_coherent is zero.
+	 *
+	 * On platforms that share the LLC with the CPU(HAS_LLC), all GT memory
+	 * access will automatically snoop the CPU caches(even with CACHE_NONE).
+	 * The one exception is when dealing with the display engine, like with
+	 * scanout surfaces. To handle this the kernel will always flush the
+	 * surface out of the CPU caches when preparing it for scanout.  Also
+	 * note that since scanout surfaces are only ever read by the display
+	 * engine we only need to care about flushing any writes through the CPU
+	 * cache, reads on the other hand will always be coherent.
+	 *
+	 * Something strange here is why @cache_coherent is not a simple
+	 * boolean, i.e coherent vs non-coherent. The reasoning for this is back
+	 * to the display engine not being fully coherent. As a result scanout
+	 * surfaces will either be marked as I915_CACHE_NONE or I915_CACHE_WT.
+	 * In the case of seeing I915_CACHE_NONE the kernel makes the assumption
+	 * that this is likely a scanout surface, and will set @cache_coherent
+	 * as only I915_BO_CACHE_COHERENT_FOR_READ, on platforms with the shared
+	 * LLC. The kernel uses this to avoid flushing reads, while then also
+	 * applying some optimisations to always flush writes through the CPU
+	 * cache as early as possible, where it can, in effect keeping
+	 * @cache_dirty clean, so we can potentially avoid stalling when
+	 * flushing the surface just before doing the scanout.  This does mean
+	 * we might unnecessarily flush non-scanout objects in some places, but
+	 * the default assumption is that all normal objects should be using
+	 * I915_CACHE_LLC, at least on platforms with the shared LLC.
+	 *
+	 * I915_BO_CACHE_COHERENT_FOR_READ:
+	 *
+	 * When reading through the CPU cache, the GPU is still coherent. Reads
+	 * through the CPU cache only become a concern when writes can bypass
+	 * the CPU cache.
+	 *
+	 * As an example, if some object is mapped on the CPU with write-back
+	 * caching, and we read some page, then the cache likely now contains
+	 * the data from that read. At this point the cache and main memory
+	 * match up, so all good. But next the GPU needs to write some data to
+	 * that same page. Now if the @cache_level is I915_CACHE_NONE and the
+	 * the platform doesn't have the shared LLC, then the GPU will
+	 * effectively skip invalidating the cache(or however that works
+	 * internally) when writing the new value.  This is really bad since the
+	 * GPU has just written some new data to main memory, but the CPU cache
+	 * is still valid and now contains stale data. As a result the next time
+	 * we do a cached read with the CPU, we are rewarded with stale data.
+	 * Likewise if the cache is later flushed, we might be rewarded with
+	 * overwriting main memory with stale data.
+	 *
+	 * I915_BO_CACHE_COHERENT_FOR_WRITE:
+	 *
+	 * When writing through the CPU cache, the GPU is still coherent. Note
+	 * that this also implies I915_BO_CACHE_COHERENT_FOR_READ.
+	 */
 #define I915_BO_CACHE_COHERENT_FOR_READ BIT(0)
 #define I915_BO_CACHE_COHERENT_FOR_WRITE BIT(1)
+	unsigned int cache_coherent:2;
+
+	/**
+	 * @cache_dirty:
+	 *
+	 * Track if we are we dirty with writes through the CPU cache for this
+	 * object. As a result reading directly from main memory might yield
+	 * stale data.
+	 *
+	 * This also ties into whether the kernel is tracking the object as
+	 * coherent with the GPU, as per @cache_coherent, as it determines if
+	 * flushing might be needed at various points.
+	 *
+	 * Another part of @cache_dirty is managing flushing when first
+	 * acquiring the pages for system memory, at this point the pages are
+	 * considered foreign, so the default assumption is that the cache is
+	 * dirty, for example the page zeroing done by the kernel might leave
+	 * writes though the CPU cache, or swapping-in, while the actual data in
+	 * main memory is potentially stale.  Note that this is a potential
+	 * security issue when dealing with userspace objects and zeroing. Now,
+	 * whether we actually need apply the big sledgehammer of flushing all
+	 * the pages on acquire depends on if @cache_coherent is marked as
+	 * I915_BO_CACHE_COHERENT_FOR_WRITE, i.e that the GPU will be coherent
+	 * for both reads and writes though the CPU cache.
+	 *
+	 * Note that on shared LLC platforms we still apply the heavy flush for
+	 * I915_CACHE_NONE objects, under the assumption that this is going to
+	 * be used for scanout.
+	 */
 	unsigned int cache_dirty:1;
 
 	/**
drivers/gpu/drm/i915/i915_drv.h +0 -9
index f99b6c0dd068..ac144d0c69a5 100644
@@ -394,15 +394,6 @@ struct drm_i915_display_funcs {
 	void (*read_luts)(struct intel_crtc_state *crtc_state);
 };
 
-enum i915_cache_level {
-	I915_CACHE_NONE = 0,
-	I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */
-	I915_CACHE_L3_LLC, /* gen7+, L3 sits between the domain specifc
-			      caches, eg sampler/render caches, and the
-			      large Last-Level-Cache. LLC is coherent with
-			      the CPU, but L3 is only visible to the GPU. */
-	I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
-};
 
 #define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
 
Signature · 6 lines
2.26.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 2/2 drm/i915/ehl: unconditionally flush the pages on acquire

EHL and JSL add the 'Bypass LLC' MOCS entry, which should make it possible for userspace to bypass the GTT caching bits set by the kernel, as per the given object cache_level. This is troublesome since the heavy flush we apply when first acquiring the pages is skipped if the kernel thinks the object is coherent with the GPU. As a result it might be possible to bypass the cache and read the contents of the page directly, which could be stale data. If it's just a case of userspace shooting themselves in the foot then so be it, but since i915 takes the stance of always zeroing memory before handing it to userspace, we need to prevent this.

v2: this time actually set cache_dirty in put_pages()
v3: move to get_pages() which looks simpler

BSpec: 34007
References: 046091758b50 ("Revert "drm/i915/ehl: Update MOCS table for EHL"")

Cc Tejas Upadhyay <[email protected]>
Cc Francisco Jerez <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Jon Bloomfield <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Matt Roper <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 .../gpu/drm/i915/gem/i915_gem_object_types.h   |  6 ++++++
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c      | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +6 -0
index a809424bc8c1..dfcfe9a14423 100644
@@ -400,6 +400,12 @@ struct drm_i915_gem_object {
 	 * Note that on shared LLC platforms we still apply the heavy flush for
 	 * I915_CACHE_NONE objects, under the assumption that this is going to
 	 * be used for scanout.
+	 *
+	 * Update: Some bonkers hardware decided to add the 'Bypass LLC' MOCS
+	 * entry, which defeats our @cache_coherent tracking, since userspace
+	 * can freely bypass the CPU cache when touching the pages with the GPU,
+	 * where the kernel is completely unaware. On such platform we need
+	 * apply the sledgehammer-on-acquire regardless of the @cache_coherent.
 	 */
 	unsigned int cache_dirty:1;
 
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +18 -0
index 6a04cce188fc..11f072193f3b 100644
@@ -182,6 +182,24 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
 	if (i915_gem_object_needs_bit17_swizzle(obj))
 		i915_gem_object_do_bit_17_swizzle(obj, st);
 
+	/*
+	 * EHL and JSL add the 'Bypass LLC' MOCS entry, which should make it
+	 * possible for userspace to bypass the GTT caching bits set by the
+	 * kernel, as per the given object cache_level. This is troublesome
+	 * since the heavy flush we apply when first gathering the pages is
+	 * skipped if the kernel thinks the object is coherent with the GPU. As
+	 * a result it might be possible to bypass the cache and read the
+	 * contents of the page directly, which could be stale data. If it's
+	 * just a case of userspace shooting themselves in the foot then so be
+	 * it, but since i915 takes the stance of always zeroing memory before
+	 * handing it to userspace, we need to prevent this.
+	 *
+	 * By setting cache_dirty here we make the clflush in set_pages
+	 * unconditional on such platforms.
+	 */
+	if (IS_JSL_EHL(i915) && obj->flags & I915_BO_ALLOC_USER)
+		obj->cache_dirty = true;
+
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
 	return 0;
Signature · 6 lines
2.26.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2,1/2] drm/i915: document caching related bits

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/2] drm/i915: document caching related bits
URL : https://patchwork.freedesktop.org/series/92817/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
430032dadde2 drm/i915: document caching related bits
-:168: WARNING:REPEATED_WORD: Possible repeated word: 'the'
#168: FILE: drivers/gpu/drm/i915/gem/i915_gem_object_types.h:359:
+	 * that same page. Now if the @cache_level is I915_CACHE_NONE and the
+	 * the platform doesn't have the shared LLC, then the GPU will

total: 0 errors, 1 warnings, 0 checks, 204 lines checked
c03ee0e0e858 drm/i915/ehl: unconditionally flush the pages on acquire
-:21: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #21:
References: 046091758b50 ("Revert "drm/i915/ehl: Update MOCS table for EHL"")

-:21: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 046091758b50 ("Revert "drm/i915/ehl: Update MOCS table for EHL"")' #21:
References: 046091758b50 ("Revert "drm/i915/ehl: Update MOCS table for EHL"")

total: 1 errors, 1 warnings, 0 checks, 36 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

[Intel-gfx] ✗ Fi.CI.DOCS: warning for series starting with [v2,1/2] drm/i915: document caching related bits

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/2] drm/i915: document caching related bits
URL : https://patchwork.freedesktop.org/series/92817/
State : warning

== Summary ==

$ make htmldocs 2>&1 > /dev/null | grep i915
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'jump_whitelist' description in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'shadow_map' description in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'batch_map' description in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Function parameter or member 'trampoline' not described in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'jump_whitelist' description in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'shadow_map' description in 'intel_engine_cmd_parser'
./drivers/gpu/drm/i915/i915_cmd_parser.c:1436: warning: Excess function parameter 'batch_map' description in 'intel_engine_cmd_parser'

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Matthew Auld
Quoted 162 lines · Matthew Auld

Try to document the object caching related bits, like cache_coherent and cache_dirty.

v2(Ville):
- As pointed out by Ville, fix the completely incorrect assumptions about the "partial" coherency on shared LLC platforms.

---
 .../gpu/drm/i915/gem/i915_gem_object_types.h  | 173 +++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.h               |   9 -
 2 files changed, 169 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +124 -4
index ef3de2ae9723..a809424bc8c1 100644
@@ -92,6 +92,76 @@ struct drm_i915_gem_object_ops {
        const char *name; /* friendly name for debug, e.g. lockdep classes */
 };
 
+/**
+ * enum i915_cache_level - The supported GTT caching values for system memory
+ * pages.
+ *
+ * These translate to some special GTT PTE bits when binding pages into some
+ * address space. It also determines whether an object, or rather its pages are
+ * coherent with the GPU, when also reading or writing through the CPU cache
+ * with those pages.
+ *
+ * Userspace can also control this through struct drm_i915_gem_caching.
+ */
+enum i915_cache_level {
+       /**
+        * @I915_CACHE_NONE:
+        *
+        * Not coherent with the CPU cache. If the cache is dirty and we need
+        * the underlying pages to be coherent with some later GPU access then
+        * we need to manually flush the pages.
+        *
+        * Note that on shared LLC platforms reads and writes through the CPU
+        * cache are still coherent even with this setting. See also
+        * &drm_i915_gem_object.cache_coherent for more details.
+        *
+        * Note that on platforms with a shared LLC this should ideally only be
+        * used for scanout surfaces, otherwise we end up over-flushing in some
+        * places.
+        */
+       I915_CACHE_NONE = 0,
+       /**
+        * @I915_CACHE_LLC:
+        *
+        * Coherent with the CPU cache. If the cache is dirty, then the GPU will
+        * ensure that access remains coherent, when both reading and writing
+        * through the CPU cache.
+        *
+        * Not used for scanout surfaces.
+        *
+        * Applies to both platforms with shared LLC(HAS_LLC), and snooping
+        * based platforms(HAS_SNOOP).
+        *
+        * This should be the default for platforms which share the LLC with the
+        * CPU. The only exception is scanout objects, where the display engine
+        * is not coherent with the LLC. For such objects I915_CACHE_NONE or
+        * I915_CACHE_WT should be used.
+        */
+       I915_CACHE_LLC,
+       /**
+        * @I915_CACHE_L3_LLC:
+        *
+        * Explicitly enable the Gfx L3 cache, with snooped LLC.
+        *
+        * The Gfx L3 sits between the domain specific caches, e.g
+        * sampler/render caches, and the larger LLC. LLC is coherent with the
+        * GPU, but L3 is only visible to the GPU, so likely needs to be flushed
+        * when the workload completes.
+        *
+        * Not used for scanout surfaces.
+        *
+        * Only exposed on some gen7 + GGTT. More recent hardware has dropped
+        * this.
+        */
+       I915_CACHE_L3_LLC,
+       /**
+        * @I915_CACHE_WT:
+        *
+        * hsw:gt3e Write-through for scanout buffers.
+        */
+       I915_CACHE_WT,
+};
+
 enum i915_map_type {
        I915_MAP_WB = 0,
        I915_MAP_WC,
@@ -228,14 +298,109 @@ struct drm_i915_gem_object {
        unsigned int mem_flags;
 #define I915_BO_FLAG_STRUCT_PAGE BIT(0) /* Object backed by struct pages */
 #define I915_BO_FLAG_IOMEM       BIT(1) /* Object backed by IO memory */
-       /*
-        * Is the object to be mapped as read-only to the GPU
-        * Only honoured if hardware has relevant pte bit
+       /**
+        * @cache_level: The desired GTT caching level.
+        *
+        * See enum i915_cache_level for possible values, along with what
+        * each does.
         */
        unsigned int cache_level:3;
-       unsigned int cache_coherent:2;
+       /**
+        * @cache_coherent:
+        *
+        * Track whether the pages are coherent with the GPU if reading or
+        * writing through the CPU caches. The largely depends on the
+        * @cache_level setting.
+        *
+        * On platforms which don't have the shared LLC(HAS_SNOOP), like on Atom
+        * platforms, coherency must be explicitly requested with some special
+        * GTT caching bits(see enum i915_cache_level). When enabling coherency
+        * it does come at a performance and power cost on such platforms. On
+        * the flip side the kernel does need to manually flush any buffers
+        * which need to be coherent with the GPU, if the object is not
+        * coherent i.e @cache_coherent is zero.
+        *
+        * On platforms that share the LLC with the CPU(HAS_LLC), all GT memory
+        * access will automatically snoop the CPU caches(even with CACHE_NONE).
+        * The one exception is when dealing with the display engine, like with
+        * scanout surfaces. To handle this the kernel will always flush the
+        * surface out of the CPU caches when preparing it for scanout.  Also
+        * note that since scanout surfaces are only ever read by the display
+        * engine we only need to care about flushing any writes through the CPU
+        * cache, reads on the other hand will always be coherent.
+        *
+        * Something strange here is why @cache_coherent is not a simple
+        * boolean, i.e coherent vs non-coherent. The reasoning for this is back
+        * to the display engine not being fully coherent. As a result scanout
+        * surfaces will either be marked as I915_CACHE_NONE or I915_CACHE_WT.
+        * In the case of seeing I915_CACHE_NONE the kernel makes the assumption
+        * that this is likely a scanout surface, and will set @cache_coherent
+        * as only I915_BO_CACHE_COHERENT_FOR_READ, on platforms with the shared
+        * LLC. The kernel uses this to avoid flushing reads, while then also
+        * applying some optimisations to always flush writes through the CPU
+        * cache as early as possible, where it can, in effect keeping
+        * @cache_dirty clean, so we can potentially avoid stalling when
+        * flushing the surface just before doing the scanout.  This does mean
+        * we might unnecessarily flush non-scanout objects in some places, but
+        * the default assumption is that all normal objects should be using
+        * I915_CACHE_LLC, at least on platforms with the shared LLC.
+        *
+        * I915_BO_CACHE_COHERENT_FOR_READ:
+        *
+        * When reading through the CPU cache, the GPU is still coherent. Reads
+        * through the CPU cache only become a concern when writes can bypass
+        * the CPU cache.
+        *
+        * As an example, if some object is mapped on the CPU with write-back
+        * caching, and we read some page, then the cache likely now contains
+        * the data from that read. At this point the cache and main memory

drivers/gpu/drm/i915/gem/i915_gem_object_types.h struct drm_i915_gem_object { · line 366

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +10 -0
+        * match up, so all good. But next the GPU needs to write some data to
+        * that same page. Now if the @cache_level is I915_CACHE_NONE and the
+        * the platform doesn't have the shared LLC, then the GPU will
+        * effectively skip invalidating the cache(or however that works
+        * internally) when writing the new value.  This is really bad since the
+        * GPU has just written some new data to main memory, but the CPU cache
+        * is still valid and now contains stale data. As a result the next time
+        * we do a cached read with the CPU, we are rewarded with stale data.
+        * Likewise if the cache is later flushed, we might be rewarded with
+        * overwriting main memory with stale data.

This cannot happen.

If it does our entire clflush scheme would fall apart. We rely on an IA guarantee that clean cachelines are dropped, never written back.

Also I'm honeslty wondering why we're storing this in the object and not computing from cache_level and the platform? Or is this indeed set anytime later on?

Quoted 26 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +24 -0
+        *
+        * I915_BO_CACHE_COHERENT_FOR_WRITE:
+        *
+        * When writing through the CPU cache, the GPU is still coherent. Note
+        * that this also implies I915_BO_CACHE_COHERENT_FOR_READ.
+        */
 #define I915_BO_CACHE_COHERENT_FOR_READ BIT(0)
 #define I915_BO_CACHE_COHERENT_FOR_WRITE BIT(1)
+       unsigned int cache_coherent:2;
+
+       /**
+        * @cache_dirty:
+        *
+        * Track if we are we dirty with writes through the CPU cache for this
+        * object. As a result reading directly from main memory might yield
+        * stale data.
+        *
+        * This also ties into whether the kernel is tracking the object as
+        * coherent with the GPU, as per @cache_coherent, as it determines if
+        * flushing might be needed at various points.
+        *
+        * Another part of @cache_dirty is managing flushing when first
+        * acquiring the pages for system memory, at this point the pages are
+        * considered foreign, so the default assumption is that the cache is
+        * dirty, for example the page zeroing done by the kernel might leave
+        * writes though the CPU cache, or swapping-in, while the actual data in

drivers/gpu/drm/i915/gem/i915_gem_object_types.h struct drm_i915_gem_object { · line 402

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +10 -0
+        * main memory is potentially stale.  Note that this is a potential
+        * security issue when dealing with userspace objects and zeroing. Now,
+        * whether we actually need apply the big sledgehammer of flushing all
+        * the pages on acquire depends on if @cache_coherent is marked as
+        * I915_BO_CACHE_COHERENT_FOR_WRITE, i.e that the GPU will be coherent
+        * for both reads and writes though the CPU cache.
+        *
+        * Note that on shared LLC platforms we still apply the heavy flush for
+        * I915_CACHE_NONE objects, under the assumption that this is going to
+        * be used for scanout.

Uh, this makes me feel like the ehl w/a is extremely fragile.

Essentially what we're exploiting is the fact that on LLC the gpu cannot ever do a non-coherent write, it's always coherent with cpu caches. And so all this does is make sure we keep flushing for display reads, which also happens to be good enough for other reads that bypass the coherence with the new MOCS setting.

I feel like Ville's take of making this explicit about "needs invalidate" and "needs flush" (which is what this stuff was all called way back), maybe as functions even instead of bits we set that might go out of sync, would be a lot clearer?

And then that function could have lots of comments about why we needs flushes/invalidates in certain cases and why not in others.

Anyway that would be future work I guess, for now lets try to just document this as correctly as we can.
-Daniel

Quoted 27 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +1 -0
+        */
        unsigned int cache_dirty:1;
 
        /**
drivers/gpu/drm/i915/i915_drv.h +0 -10
index f99b6c0dd068..ac144d0c69a5 100644
@@ -394,15 +394,6 @@ struct drm_i915_display_funcs {
        void (*read_luts)(struct intel_crtc_state *crtc_state);
 };
 
-enum i915_cache_level {
-       I915_CACHE_NONE = 0,
-       I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */
-       I915_CACHE_L3_LLC, /* gen7+, L3 sits between the domain specifc
-                             caches, eg sampler/render caches, and the
-                             large Last-Level-Cache. LLC is coherent with
-                             the CPU, but L3 is only visible to the GPU. */
-       I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
-};
 
 #define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
 
--

2.26.3

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#5 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: document caching related bits

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/2] drm/i915: document caching related bits
URL : https://patchwork.freedesktop.org/series/92817/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10364 -> Patchwork_20662
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/index.html

New tests
---------

New tests have been introduced between CI_DRM_10364 and Patchwork_20662:

### New IGT tests (1) ###

* igt@gem_huc_copy@huc-copy:
- Statuses : 32 skip(s)
- Exec time: [0.0] s

Known issues
------------

Here are the changes found in Patchwork_20662 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-kbl-7500u: [PASS][1] -> [SKIP][2] ([fdo#109271]) +1 similar issue
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/fi-kbl-7500u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/fi-kbl-7500u/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- fi-kbl-7500u: [PASS][3] -> [FAIL][4] ([i915#579])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/fi-kbl-7500u/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/fi-kbl-7500u/igt@[email protected]

* igt@i915_selftest@live@execlists:
- fi-bsw-nick: [PASS][5] -> [INCOMPLETE][6] ([i915#2782] / [i915#2940])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/fi-bsw-nick/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/fi-bsw-nick/igt@i915_selftest@[email protected]

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7500u: [PASS][7] -> [DMESG-FAIL][8] ([i915#165])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/fi-kbl-7500u/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/fi-kbl-7500u/igt@[email protected]

* igt@runner@aborted:
- fi-bsw-nick: NOTRUN -> [FAIL][9] ([fdo#109271] / [i915#1436])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/fi-bsw-nick/igt@[email protected]

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#165]: https://gitlab.freedesktop.org/drm/intel/issues/165
[i915#2782]: https://gitlab.freedesktop.org/drm/intel/issues/2782
[i915#2940]: https://gitlab.freedesktop.org/drm/intel/issues/2940
[i915#579]: https://gitlab.freedesktop.org/drm/intel/issues/579

Participating hosts (38 -> 35)
------------------------------

Missing (3): fi-ilk-m540 fi-bdw-samus fi-hsw-4200u

Build changes
-------------

* Linux: CI_DRM_10364 -> Patchwork_20662

CI-20190529: 20190529
CI_DRM_10364: 8164e3f91057cf9b7d25255c184f3be6b3a6aa06 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6146: 6caef22e4aafed275771f564d4ea4cab09896ebc @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20662: c03ee0e0e85819e916ba52ac5e9429c53c6a3504 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

c03ee0e0e858 drm/i915/ehl: unconditionally flush the pages on acquire 430032dadde2 drm/i915: document caching related bits

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

[Intel-gfx] ✗ Fi.CI.IGT: failure for series starting with [v2,1/2] drm/i915: document caching related bits

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v2,1/2] drm/i915: document caching related bits
URL : https://patchwork.freedesktop.org/series/92817/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10364_full -> Patchwork_20662_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_20662_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_20662_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_20662_full:

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_dc@dc9-dpms:
- shard-skl: NOTRUN -> [FAIL][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_pm_rpm@gem-execbuf-stress:
- {shard-rkl}: [PASS][2] -> [SKIP][3] +1 similar issue
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rpm@gem-mmap-type:
- {shard-rkl}: NOTRUN -> [SKIP][4]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rpm@i2c:
- {shard-rkl}: [SKIP][5] ([fdo#109308]) -> [SKIP][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rpm@modeset-lpsp:
- {shard-rkl}: [SKIP][7] ([i915#1397]) -> [SKIP][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@i915_pm_rpm@system-suspend:
- {shard-rkl}: [FAIL][9] ([fdo#103375]) -> [SKIP][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@sysfs_heartbeat_interval@precise@bcs0:
- {shard-rkl}: [PASS][11] -> [FAIL][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-1/igt@sysfs_heartbeat_interval@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-2/igt@sysfs_heartbeat_interval@[email protected]

Known issues
------------

Here are the changes found in Patchwork_20662_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@feature_discovery@display-4x:
- shard-tglb: NOTRUN -> [SKIP][13] ([i915#1839])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb5/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][14] ([i915#1839])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb5/igt@[email protected]

* igt@gem_ctx_isolation@preservation-s3@bcs0:
- shard-apl: NOTRUN -> [DMESG-WARN][15] ([i915#180]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl3/igt@gem_ctx_isolation@[email protected]

* igt@gem_ctx_persistence@legacy-engines-hostile-preempt:
- shard-snb: NOTRUN -> [SKIP][16] ([fdo#109271] / [i915#1099]) +4 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-snb5/igt@[email protected]

* igt@gem_exec_fair@basic-flow@rcs0:
- shard-skl: NOTRUN -> [SKIP][17] ([fdo#109271]) +72 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none-rrul@rcs0:
- shard-kbl: [PASS][18] -> [FAIL][19] ([i915#2842])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-kbl4/igt@gem_exec_fair@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-kbl2/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@vecs0:
- shard-kbl: [PASS][20] -> [SKIP][21] ([fdo#109271])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-kbl7/igt@gem_exec_fair@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-kbl1/igt@gem_exec_fair@[email protected]
- shard-tglb: [PASS][22] -> [FAIL][23] ([i915#2842])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-tglb7/igt@gem_exec_fair@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb3/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-throttle@rcs0:
- shard-glk: [PASS][24] -> [FAIL][25] ([i915#2842]) +1 similar issue
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk1/igt@gem_exec_fair@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk8/igt@gem_exec_fair@[email protected]

* igt@gem_exec_schedule@smoketest-all:
- shard-glk: [PASS][26] -> [DMESG-WARN][27] ([i915#118] / [i915#95]) +1 similar issue
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk6/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk7/igt@[email protected]

* igt@gem_pread@exhaustion:
- shard-skl: NOTRUN -> [WARN][28] ([i915#2658])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl10/igt@[email protected]

* igt@gem_render_copy@y-tiled-to-vebox-linear:
- shard-iclb: NOTRUN -> [SKIP][29] ([i915#768])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@[email protected]

* igt@gem_userptr_blits@dmabuf-sync:
- shard-skl: NOTRUN -> [SKIP][30] ([fdo#109271] / [i915#3323])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@[email protected]

* igt@gem_userptr_blits@dmabuf-unsync:
- shard-iclb: NOTRUN -> [SKIP][31] ([i915#3297])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@[email protected]

* igt@gem_userptr_blits@input-checking:
- shard-apl: NOTRUN -> [DMESG-WARN][32] ([i915#3002]) +1 similar issue
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl3/igt@[email protected]

* igt@gem_userptr_blits@vma-merge:
- shard-snb: NOTRUN -> [FAIL][33] ([i915#2724])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-snb2/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- shard-skl: NOTRUN -> [FAIL][34] ([i915#579])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl10/igt@[email protected]

* igt@i915_pm_rpm@dpms-mode-unset-lpsp:
- shard-tglb: NOTRUN -> [SKIP][35] ([i915#579])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb7/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][36] ([i915#579])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@[email protected]

* igt@kms_big_fb@linear-32bpp-rotate-0:
- shard-glk: NOTRUN -> [DMESG-WARN][37] ([i915#118] / [i915#95])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk2/igt@[email protected]

* igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-0-hflip:
- shard-skl: NOTRUN -> [SKIP][38] ([fdo#109271] / [i915#3777])
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@[email protected]

* igt@kms_big_fb@yf-tiled-max-hw-stride-32bpp-rotate-0-hflip:
- shard-apl: NOTRUN -> [SKIP][39] ([fdo#109271] / [i915#3777]) +2 similar issues
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

* igt@kms_big_fb@yf-tiled-max-hw-stride-64bpp-rotate-0:
- shard-iclb: NOTRUN -> [SKIP][40] ([fdo#110723])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@[email protected]

* igt@kms_ccs@pipe-d-crc-primary-rotation-180-y_tiled_gen12_mc_ccs:
- shard-glk: NOTRUN -> [SKIP][41] ([fdo#109271]) +20 similar issues
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk2/igt@kms_ccs@pipe-d-crc-primary-rotation-180-y_tiled_gen12_mc_ccs.html

* igt@kms_chamelium@hdmi-edid-change-during-suspend:
- shard-apl: NOTRUN -> [SKIP][42] ([fdo#109271] / [fdo#111827]) +19 similar issues
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl7/igt@[email protected]

* igt@kms_chamelium@vga-hpd-after-suspend:
- shard-skl: NOTRUN -> [SKIP][43] ([fdo#109271] / [fdo#111827]) +4 similar issues
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl10/igt@[email protected]

* igt@kms_color_chamelium@pipe-a-ctm-0-25:
- shard-snb: NOTRUN -> [SKIP][44] ([fdo#109271] / [fdo#111827]) +22 similar issues
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-snb5/igt@[email protected]

* igt@kms_color_chamelium@pipe-a-ctm-0-5:
- shard-iclb: NOTRUN -> [SKIP][45] ([fdo#109284] / [fdo#111827]) +1 similar issue
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@[email protected]

* igt@kms_color_chamelium@pipe-d-ctm-0-25:
- shard-tglb: NOTRUN -> [SKIP][46] ([fdo#109284] / [fdo#111827])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb5/igt@[email protected]
- shard-iclb: NOTRUN -> [SKIP][47] ([fdo#109278] / [fdo#109284] / [fdo#111827]) +1 similar issue
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb5/igt@[email protected]

* igt@kms_color_chamelium@pipe-d-ctm-0-75:
- shard-glk: NOTRUN -> [SKIP][48] ([fdo#109271] / [fdo#111827]) +3 similar issues
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk2/igt@[email protected]

* igt@kms_content_protection@atomic-dpms:
- shard-apl: NOTRUN -> [TIMEOUT][49] ([i915#1319]) +2 similar issues
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

* igt@kms_cursor_crc@pipe-a-cursor-32x10-sliding:
- shard-tglb: NOTRUN -> [SKIP][50] ([i915#3359])
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb7/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-apl: [PASS][51] -> [DMESG-WARN][52] ([i915#180]) +1 similar issue
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-apl8/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl6/igt@[email protected]

* igt@kms_cursor_edge_walk@pipe-a-64x64-bottom-edge:
- shard-snb: [PASS][53] -> [SKIP][54] ([fdo#109271]) +3 similar issues
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-snb7/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-snb2/igt@[email protected]

* igt@kms_cursor_edge_walk@pipe-d-128x128-right-edge:
- shard-snb: NOTRUN -> [SKIP][55] ([fdo#109271]) +450 similar issues
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-snb2/igt@[email protected]

* igt@kms_cursor_legacy@2x-long-nonblocking-modeset-vs-cursor-atomic:
- shard-iclb: NOTRUN -> [SKIP][56] ([fdo#109274] / [fdo#109278])
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@kms_cursor_legacy@2x-long-nonblocking-modeset-vs-cursor-atomic.html

* igt@kms_dither@fb-8bpc-vs-panel-8bpc@edp-1-pipe-a:
- shard-iclb: [PASS][57] -> [SKIP][58] ([i915#3788])
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-iclb4/igt@kms_dither@[email protected]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@kms_dither@[email protected]

* igt@kms_flip@2x-absolute-wf_vblank:
- shard-kbl: NOTRUN -> [SKIP][59] ([fdo#109271]) +2 similar issues
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-kbl2/igt@kms_flip@2x-absolute-wf_vblank.html

* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2:
- shard-glk: [PASS][60] -> [FAIL][61] ([i915#2122])
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk4/igt@kms_flip@[email protected]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk5/igt@kms_flip@[email protected]

* igt@kms_flip@2x-flip-vs-modeset-vs-hang:
- shard-iclb: NOTRUN -> [SKIP][62] ([fdo#109274])
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank-interruptible@c-edp1:
- shard-skl: [PASS][63] -> [FAIL][64] ([i915#79])
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl5/igt@kms_flip@[email protected]
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl2/igt@kms_flip@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible@b-dp1:
- shard-kbl: [PASS][65] -> [DMESG-WARN][66] ([i915#180])
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-kbl1/igt@kms_flip@[email protected]
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-kbl3/igt@kms_flip@[email protected]

* igt@kms_flip@plain-flip-fb-recreate@b-edp1:
- shard-skl: [PASS][67] -> [FAIL][68] ([i915#2122]) +2 similar issues
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl8/igt@kms_flip@[email protected]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@kms_flip@[email protected]

* igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs:
- shard-skl: NOTRUN -> [SKIP][69] ([fdo#109271] / [i915#2672])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@kms_flip_scaled_crc@flip-32bpp-ytile-to-32bpp-ytilegen12rcccs.html

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-move:
- shard-iclb: NOTRUN -> [SKIP][70] ([fdo#109280]) +2 similar issues
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-2p-scndscrn-cur-indfb-move:
- shard-tglb: NOTRUN -> [SKIP][71] ([fdo#111825]) +2 similar issues
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb7/igt@[email protected]

* igt@kms_hdr@bpc-switch-dpms:
- shard-skl: [PASS][72] -> [FAIL][73] ([i915#1188])
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl5/igt@[email protected]
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl2/igt@[email protected]

* igt@kms_pipe_b_c_ivb@from-pipe-c-to-b-with-3-lanes:
- shard-iclb: NOTRUN -> [SKIP][74] ([fdo#109289])
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d:
- shard-apl: NOTRUN -> [SKIP][75] ([fdo#109271] / [i915#533]) +4 similar issues
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-alpha-transparent-fb:
- shard-skl: NOTRUN -> [FAIL][76] ([i915#265])
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-max:
- shard-apl: NOTRUN -> [FAIL][77] ([fdo#108145] / [i915#265]) +1 similar issue
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [PASS][78] -> [FAIL][79] ([fdo#108145] / [i915#265]) +1 similar issue
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl10/igt@[email protected]
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl9/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-d-coverage-vs-premult-vs-constant:
- shard-iclb: NOTRUN -> [SKIP][80] ([fdo#109278]) +6 similar issues
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@kms_plane_alpha_blend@pipe-d-coverage-vs-premult-vs-constant.html

* igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping:
- shard-apl: NOTRUN -> [SKIP][81] ([fdo#109271] / [i915#2733])
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@kms_plane_scaling@scaler-with-clipping-clamping@pipe-c-scaler-with-clipping-clamping.html

* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-2:
- shard-apl: NOTRUN -> [SKIP][82] ([fdo#109271] / [i915#658]) +4 similar issues
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl2/igt@[email protected]

* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area-3:
- shard-glk: NOTRUN -> [SKIP][83] ([fdo#109271] / [i915#658])
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk2/igt@[email protected]

* igt@kms_psr2_sf@plane-move-sf-dmg-area-2:
- shard-skl: NOTRUN -> [SKIP][84] ([fdo#109271] / [i915#658])
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl1/igt@[email protected]

* igt@kms_psr@psr2_sprite_blt:
- shard-iclb: [PASS][85] -> [SKIP][86] ([fdo#109441])
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-iclb2/igt@kms_psr@psr2_sprite_blt.html
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@kms_psr@psr2_sprite_blt.html

* igt@kms_vblank@pipe-d-ts-continuation-idle:
- shard-apl: NOTRUN -> [SKIP][87] ([fdo#109271]) +283 similar issues
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

* igt@perf@polling-parameterized:
- shard-skl: [PASS][88] -> [FAIL][89] ([i915#1542])
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl1/igt@[email protected]
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl8/igt@[email protected]

* igt@perf_pmu@rc6-runtime-pm:
- shard-tglb: NOTRUN -> [SKIP][90] ([fdo#111719])
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-tglb2/igt@[email protected]

* igt@prime_nv_pcopy@test3_3:
- shard-iclb: NOTRUN -> [SKIP][91] ([fdo#109291]) +1 similar issue
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb2/igt@prime_nv_pcopy@test3_3.html

* igt@sysfs_clients@sema-10:
- shard-skl: NOTRUN -> [SKIP][92] ([fdo#109271] / [i915#2994]) +2 similar issues
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl10/igt@[email protected]

* igt@sysfs_clients@sema-50:
- shard-apl: NOTRUN -> [SKIP][93] ([fdo#109271] / [i915#2994]) +4 similar issues
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl8/igt@[email protected]

#### Possible fixes ####

* igt@gem_ctx_persistence@legacy-engines-hang@render:
- {shard-rkl}: [FAIL][94] ([i915#2410]) -> [PASS][95] +1 similar issue
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-6/igt@gem_ctx_persistence@[email protected]
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-1/igt@gem_ctx_persistence@[email protected]

* igt@gem_exec_fair@basic-none-share@rcs0:
- {shard-rkl}: [FAIL][96] ([i915#2842]) -> [PASS][97]
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-6/igt@gem_exec_fair@[email protected]
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-5/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vcs0:
- shard-kbl: [FAIL][98] ([i915#2842]) -> [PASS][99] +1 similar issue
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-kbl2/igt@gem_exec_fair@[email protected]
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-kbl1/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vecs0:
- shard-apl: [FAIL][100] ([i915#2842] / [i915#3468]) -> [PASS][101]
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-apl1/igt@gem_exec_fair@[email protected]
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl7/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace-solo@rcs0:
- shard-glk: [FAIL][102] ([i915#2842]) -> [PASS][103] +1 similar issue
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk8/igt@gem_exec_fair@[email protected]
[103]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk9/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace@vcs0:
- shard-iclb: [FAIL][104] ([i915#2842]) -> [PASS][105] +4 similar issues
[104]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-iclb1/igt@gem_exec_fair@[email protected]
[105]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb7/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-throttle@rcs0:
- shard-iclb: [FAIL][106] ([i915#2849]) -> [PASS][107]
[106]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-iclb4/igt@gem_exec_fair@[email protected]
[107]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-iclb8/igt@gem_exec_fair@[email protected]

* igt@gem_exec_flush@basic-uc-ro-default:
- shard-glk: [INCOMPLETE][108] ([i915#2944]) -> [PASS][109]
[108]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk2/igt@[email protected]
[109]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk2/igt@[email protected]

* igt@gem_exec_suspend@basic-s4-devices:
- {shard-rkl}: [INCOMPLETE][110] ([i915#3810]) -> [PASS][111]
[110]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-2/igt@[email protected]
[111]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-1/igt@[email protected]

* igt@gem_exec_whisper@basic-fds-priority:
- shard-glk: [DMESG-WARN][112] ([i915#118] / [i915#95]) -> [PASS][113]
[112]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk5/igt@[email protected]
[113]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk3/igt@[email protected]

* igt@gem_mmap_gtt@cpuset-big-copy-odd:
- {shard-rkl}: [FAIL][114] ([i915#2428]) -> [PASS][115]
[114]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[115]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@gem_mmap_gtt@cpuset-big-copy-xy:
- {shard-rkl}: [FAIL][116] ([i915#307]) -> [PASS][117]
[116]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-2/igt@[email protected]
[117]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@gem_workarounds@suspend-resume-context:
- shard-apl: [DMESG-WARN][118] ([i915#180]) -> [PASS][119] +5 similar issues
[118]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-apl8/igt@[email protected]
[119]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-apl7/igt@[email protected]

* igt@i915_pm_backlight@bad-brightness:
- {shard-rkl}: [SKIP][120] ([i915#3012]) -> [PASS][121] +1 similar issue
[120]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[121]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@linear-8bpp-rotate-180:
- {shard-rkl}: [SKIP][122] ([i915#3638]) -> [PASS][123] +1 similar issue
[122]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[123]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@linear-max-hw-stride-32bpp-rotate-0:
- {shard-rkl}: [SKIP][124] ([i915#3721]) -> [PASS][125] +4 similar issues
[124]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-2/igt@[email protected]
[125]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@y-tiled-32bpp-rotate-270:
- {shard-rkl}: [SKIP][126] ([fdo#111614]) -> [PASS][127]
[126]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[127]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@y-tiled-8bpp-rotate-180:
- shard-skl: [DMESG-WARN][128] ([i915#1982]) -> [PASS][129] +1 similar issue
[128]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl8/igt@[email protected]
[129]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl5/igt@[email protected]

* igt@kms_ccs@pipe-c-crc-sprite-planes-basic-y_tiled_gen12_rc_ccs_cc:
- {shard-rkl}: [FAIL][130] ([i915#3678]) -> [PASS][131] +9 similar issues
[130]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@kms_ccs@pipe-c-crc-sprite-planes-basic-y_tiled_gen12_rc_ccs_cc.html
[131]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@kms_ccs@pipe-c-crc-sprite-planes-basic-y_tiled_gen12_rc_ccs_cc.html

* igt@kms_color@pipe-a-ctm-blue-to-red:
- {shard-rkl}: [SKIP][132] ([i915#1149] / [i915#1849]) -> [PASS][133] +2 similar issues
[132]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[133]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_cursor_crc@pipe-a-cursor-256x256-rapid-movement:
- {shard-rkl}: [SKIP][134] ([fdo#112022]) -> [PASS][135] +12 similar issues
[134]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-rkl-5/igt@[email protected]
[135]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-rkl-6/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic:
- shard-glk: [FAIL][136] ([i915#2346]) -> [PASS][137]
[136]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-glk8/igt@[email protected]
[137]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-glk9/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
- shard-skl: [FAIL][138] ([i915#2346] / [i915#533]) -> [PASS][139]
[138]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10364/shard-skl2/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
[139]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/shard-skl6/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

* igt@kms_cursor_legacy@flip-vs-cursor-varying-size:
- {shard-rk

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20662/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
In reply to Matthew Auld
Quoted 75 lines · Matthew Auld

Try to document the object caching related bits, like cache_coherent and cache_dirty.

v2(Ville):
- As pointed out by Ville, fix the completely incorrect assumptions about the "partial" coherency on shared LLC platforms.

---
 .../gpu/drm/i915/gem/i915_gem_object_types.h  | 173 +++++++++++++++++-
 drivers/gpu/drm/i915/i915_drv.h               |   9 -
 2 files changed, 169 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +51 -0
index ef3de2ae9723..a809424bc8c1 100644
@@ -92,6 +92,76 @@ struct drm_i915_gem_object_ops {
 	const char *name; /* friendly name for debug, e.g. lockdep classes */
 };
 
+/**
+ * enum i915_cache_level - The supported GTT caching values for system memory
+ * pages.
+ *
+ * These translate to some special GTT PTE bits when binding pages into some
+ * address space. It also determines whether an object, or rather its pages are
+ * coherent with the GPU, when also reading or writing through the CPU cache
+ * with those pages.
+ *
+ * Userspace can also control this through struct drm_i915_gem_caching.
+ */
+enum i915_cache_level {
+	/**
+	 * @I915_CACHE_NONE:
+	 *
+	 * Not coherent with the CPU cache. If the cache is dirty and we need
+	 * the underlying pages to be coherent with some later GPU access then
+	 * we need to manually flush the pages.
+	 *
+	 * Note that on shared LLC platforms reads and writes through the CPU
+	 * cache are still coherent even with this setting. See also
+	 * &drm_i915_gem_object.cache_coherent for more details.
+	 *
+	 * Note that on platforms with a shared LLC this should ideally only be
+	 * used for scanout surfaces, otherwise we end up over-flushing in some
+	 * places.
+	 */
+	I915_CACHE_NONE = 0,
+	/**
+	 * @I915_CACHE_LLC:
+	 *
+	 * Coherent with the CPU cache. If the cache is dirty, then the GPU will
+	 * ensure that access remains coherent, when both reading and writing
+	 * through the CPU cache.
+	 *
+	 * Not used for scanout surfaces.
+	 *
+	 * Applies to both platforms with shared LLC(HAS_LLC), and snooping
+	 * based platforms(HAS_SNOOP).
+	 *
+	 * This should be the default for platforms which share the LLC with the
+	 * CPU. The only exception is scanout objects, where the display engine
+	 * is not coherent with the LLC. For such objects I915_CACHE_NONE or
+	 * I915_CACHE_WT should be used.
+	 */
+	I915_CACHE_LLC,
+	/**
+	 * @I915_CACHE_L3_LLC:
+	 *
+	 * Explicitly enable the Gfx L3 cache, with snooped LLC.
+	 *

drivers/gpu/drm/i915/gem/i915_gem_object_types.h struct drm_i915_gem_object_ops { · line 155

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +10 -0
+	 * The Gfx L3 sits between the domain specific caches, e.g
+	 * sampler/render caches, and the larger LLC. LLC is coherent with the
+	 * GPU, but L3 is only visible to the GPU, so likely needs to be flushed
+	 * when the workload completes.
+	 *
+	 * Not used for scanout surfaces.
+	 *
+	 * Only exposed on some gen7 + GGTT. More recent hardware has dropped
+	 * this.
+	 */

This is stellar. Thanks!
-Mika

Quoted 148 lines
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +108 -4
+	I915_CACHE_L3_LLC,
+	/**
+	 * @I915_CACHE_WT:
+	 *
+	 * hsw:gt3e Write-through for scanout buffers.
+	 */
+	I915_CACHE_WT,
+};
+
 enum i915_map_type {
 	I915_MAP_WB = 0,
 	I915_MAP_WC,
@@ -228,14 +298,109 @@ struct drm_i915_gem_object {
 	unsigned int mem_flags;
 #define I915_BO_FLAG_STRUCT_PAGE BIT(0) /* Object backed by struct pages */
 #define I915_BO_FLAG_IOMEM       BIT(1) /* Object backed by IO memory */
-	/*
-	 * Is the object to be mapped as read-only to the GPU
-	 * Only honoured if hardware has relevant pte bit
+	/**
+	 * @cache_level: The desired GTT caching level.
+	 *
+	 * See enum i915_cache_level for possible values, along with what
+	 * each does.
 	 */
 	unsigned int cache_level:3;
-	unsigned int cache_coherent:2;
+	/**
+	 * @cache_coherent:
+	 *
+	 * Track whether the pages are coherent with the GPU if reading or
+	 * writing through the CPU caches. The largely depends on the
+	 * @cache_level setting.
+	 *
+	 * On platforms which don't have the shared LLC(HAS_SNOOP), like on Atom
+	 * platforms, coherency must be explicitly requested with some special
+	 * GTT caching bits(see enum i915_cache_level). When enabling coherency
+	 * it does come at a performance and power cost on such platforms. On
+	 * the flip side the kernel does need to manually flush any buffers
+	 * which need to be coherent with the GPU, if the object is not
+	 * coherent i.e @cache_coherent is zero.
+	 *
+	 * On platforms that share the LLC with the CPU(HAS_LLC), all GT memory
+	 * access will automatically snoop the CPU caches(even with CACHE_NONE).
+	 * The one exception is when dealing with the display engine, like with
+	 * scanout surfaces. To handle this the kernel will always flush the
+	 * surface out of the CPU caches when preparing it for scanout.  Also
+	 * note that since scanout surfaces are only ever read by the display
+	 * engine we only need to care about flushing any writes through the CPU
+	 * cache, reads on the other hand will always be coherent.
+	 *
+	 * Something strange here is why @cache_coherent is not a simple
+	 * boolean, i.e coherent vs non-coherent. The reasoning for this is back
+	 * to the display engine not being fully coherent. As a result scanout
+	 * surfaces will either be marked as I915_CACHE_NONE or I915_CACHE_WT.
+	 * In the case of seeing I915_CACHE_NONE the kernel makes the assumption
+	 * that this is likely a scanout surface, and will set @cache_coherent
+	 * as only I915_BO_CACHE_COHERENT_FOR_READ, on platforms with the shared
+	 * LLC. The kernel uses this to avoid flushing reads, while then also
+	 * applying some optimisations to always flush writes through the CPU
+	 * cache as early as possible, where it can, in effect keeping
+	 * @cache_dirty clean, so we can potentially avoid stalling when
+	 * flushing the surface just before doing the scanout.  This does mean
+	 * we might unnecessarily flush non-scanout objects in some places, but
+	 * the default assumption is that all normal objects should be using
+	 * I915_CACHE_LLC, at least on platforms with the shared LLC.
+	 *
+	 * I915_BO_CACHE_COHERENT_FOR_READ:
+	 *
+	 * When reading through the CPU cache, the GPU is still coherent. Reads
+	 * through the CPU cache only become a concern when writes can bypass
+	 * the CPU cache.
+	 *
+	 * As an example, if some object is mapped on the CPU with write-back
+	 * caching, and we read some page, then the cache likely now contains
+	 * the data from that read. At this point the cache and main memory
+	 * match up, so all good. But next the GPU needs to write some data to
+	 * that same page. Now if the @cache_level is I915_CACHE_NONE and the
+	 * the platform doesn't have the shared LLC, then the GPU will
+	 * effectively skip invalidating the cache(or however that works
+	 * internally) when writing the new value.  This is really bad since the
+	 * GPU has just written some new data to main memory, but the CPU cache
+	 * is still valid and now contains stale data. As a result the next time
+	 * we do a cached read with the CPU, we are rewarded with stale data.
+	 * Likewise if the cache is later flushed, we might be rewarded with
+	 * overwriting main memory with stale data.
+	 *
+	 * I915_BO_CACHE_COHERENT_FOR_WRITE:
+	 *
+	 * When writing through the CPU cache, the GPU is still coherent. Note
+	 * that this also implies I915_BO_CACHE_COHERENT_FOR_READ.
+	 */
 #define I915_BO_CACHE_COHERENT_FOR_READ BIT(0)
 #define I915_BO_CACHE_COHERENT_FOR_WRITE BIT(1)
+	unsigned int cache_coherent:2;
+
+	/**
+	 * @cache_dirty:
+	 *
+	 * Track if we are we dirty with writes through the CPU cache for this
+	 * object. As a result reading directly from main memory might yield
+	 * stale data.
+	 *
+	 * This also ties into whether the kernel is tracking the object as
+	 * coherent with the GPU, as per @cache_coherent, as it determines if
+	 * flushing might be needed at various points.
+	 *
+	 * Another part of @cache_dirty is managing flushing when first
+	 * acquiring the pages for system memory, at this point the pages are
+	 * considered foreign, so the default assumption is that the cache is
+	 * dirty, for example the page zeroing done by the kernel might leave
+	 * writes though the CPU cache, or swapping-in, while the actual data in
+	 * main memory is potentially stale.  Note that this is a potential
+	 * security issue when dealing with userspace objects and zeroing. Now,
+	 * whether we actually need apply the big sledgehammer of flushing all
+	 * the pages on acquire depends on if @cache_coherent is marked as
+	 * I915_BO_CACHE_COHERENT_FOR_WRITE, i.e that the GPU will be coherent
+	 * for both reads and writes though the CPU cache.
+	 *
+	 * Note that on shared LLC platforms we still apply the heavy flush for
+	 * I915_CACHE_NONE objects, under the assumption that this is going to
+	 * be used for scanout.
+	 */
 	unsigned int cache_dirty:1;
 
 	/**
drivers/gpu/drm/i915/i915_drv.h +0 -9
index f99b6c0dd068..ac144d0c69a5 100644
@@ -394,15 +394,6 @@ struct drm_i915_display_funcs {
 	void (*read_luts)(struct intel_crtc_state *crtc_state);
 };
 
-enum i915_cache_level {
-	I915_CACHE_NONE = 0,
-	I915_CACHE_LLC, /* also used for snoopable memory on non-LLC */
-	I915_CACHE_L3_LLC, /* gen7+, L3 sits between the domain specifc
-			      caches, eg sampler/render caches, and the
-			      large Last-Level-Cache. LLC is coherent with
-			      the CPU, but L3 is only visible to the GPU. */
-	I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
-};
 
 #define I915_COLOR_UNEVICTABLE (-1) /* a non-vma sharing the address space */
 
Signature · 1 line
2.26.3