Skip to contentSkip to conversation

drm/i915: use consistent CPU mappings for pin_map users

PATCH In review Matthew Auld 5 participants 14 messages Jul 5, 2021 – Jul 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/5 drm/i915: use consistent CPU mappings for pin_map users

For discrete, users of pin_map() needs to obey the same rules at the TTM backend, where we map system only objects as WB, and everything else as WC. The simplest for now is to just force the correct mapping type as per the new rules for discrete.

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c | 34 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_object.h |  4 +++
 drivers/gpu/drm/i915/gem/i915_gem_pages.c  | 22 ++++++++++++--
 3 files changed, 58 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +34 -0
index 547cc9dad90d..9da7b288b7ed 100644
@@ -625,6 +625,40 @@ int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
 	return obj->ops->migrate(obj, mr);
 }
 
+/**
+ * i915_gem_object_placement_possible - Check whether the object can be
+ * placed at certain memory type
+ * @obj: Pointer to the object
+ * @type: The memory type to check
+ *
+ * Return: True if the object can be placed in @type. False otherwise.
+ */
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type)
+{
+	unsigned int i;
+
+	if (!obj->mm.n_placements) {
+		switch (type) {
+		case INTEL_MEMORY_LOCAL:
+			return i915_gem_object_has_iomem(obj);
+		case INTEL_MEMORY_SYSTEM:
+			return i915_gem_object_has_pages(obj);
+		default:
+			/* Ignore stolen for now */
+			GEM_BUG_ON(1);
+			return false;
+		}
+	}
+
+	for (i = 0; i < obj->mm.n_placements; i++) {
+		if (obj->mm.placements[i]->type == type)
+			return true;
+	}
+
+	return false;
+}
+
 void i915_gem_init__objects(struct drm_i915_private *i915)
 {
 	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
drivers/gpu/drm/i915/gem/i915_gem_object.h +4 -0
index d423d8cac4f2..8be4fadeee48 100644
@@ -12,6 +12,7 @@
 #include <drm/drm_device.h>
 
 #include "display/intel_frontbuffer.h"
+#include "intel_memory_region.h"
 #include "i915_gem_object_types.h"
 #include "i915_gem_gtt.h"
 #include "i915_gem_ww.h"
@@ -607,6 +608,9 @@ bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj,
 int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj,
 				   unsigned int flags);
 
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type);
+
 #ifdef CONFIG_MMU_NOTIFIER
 static inline bool
 i915_gem_object_is_userptr(struct drm_i915_gem_object *obj)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +20 -2
index f2f850e31b8e..810a157a18f8 100644
@@ -321,8 +321,7 @@ static void *i915_gem_object_map_pfn(struct drm_i915_gem_object *obj,
 	dma_addr_t addr;
 	void *vaddr;
 
-	if (type != I915_MAP_WC)
-		return ERR_PTR(-ENODEV);
+	GEM_BUG_ON(type != I915_MAP_WC);
 
 	if (n_pfn > ARRAY_SIZE(stack)) {
 		/* Too big for stack -- allocate temporary array instead */
@@ -374,6 +373,25 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 	}
 	GEM_BUG_ON(!i915_gem_object_has_pages(obj));
 
+	/*
+	 * For discrete our CPU mappings needs to be consistent in order to
+	 * function correctly on !x86. When mapping things through TTM, we use
+	 * the same rules to determine the caching type.
+	 *
+	 * Internal users of lmem are already expected to get this right, so no
+	 * fudging needed there.
+	 */
+	if (i915_gem_object_placement_possible(obj, INTEL_MEMORY_LOCAL)) {
+		if (type != I915_MAP_WC && !obj->mm.n_placements) {
+			ptr = ERR_PTR(-ENODEV);
+			goto err_unpin;
+		}
+
+		type = I915_MAP_WC;
+	} else if (IS_DGFX(to_i915(obj->base.dev))) {
+		type = I915_MAP_WB;
+	}
+
 	ptr = page_unpack_bits(obj->mm.mapping, &has_type);
 	if (ptr && has_type != type) {
 		if (pinned) {
Signature · 6 lines
2.26.3

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

PATCH v3 2/5 drm/i915/uapi: convert drm_i915_gem_caching to kernel doc

Convert all the drm_i915_gem_caching bits to proper kernel doc.

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 include/uapi/drm/i915_drm.h | 70 +++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 27 deletions(-)
include/uapi/drm/i915_drm.h +43 -27
index 2f70c48567c0..d13c6c5fad04 100644
@@ -1363,43 +1363,59 @@ struct drm_i915_gem_busy {
 };
 
 /**
- * I915_CACHING_NONE
+ * struct drm_i915_gem_caching - Set or get the caching for given object
+ * handle.
  *
- * GPU access is not coherent with cpu caches. Default for machines without an
- * LLC.
- */
-#define I915_CACHING_NONE		0
-/**
- * I915_CACHING_CACHED
+ * Allow userspace to control the GTT caching bits for a given object when the
+ * object is later mapped through the ppGTT(or GGTT on older platforms lacking
+ * ppGTT support, or if the object is used for scanout). Note that this might
+ * require unbinding the object from the GTT first, if its current caching value
+ * doesn't match.
  *
- * GPU access is coherent with cpu caches and furthermore the data is cached in
- * last-level caches shared between cpu cores and the gpu GT. Default on
- * machines with HAS_LLC.
- */
-#define I915_CACHING_CACHED		1
-/**
- * I915_CACHING_DISPLAY
  *
- * Special GPU caching mode which is coherent with the scanout engines.
- * Transparently falls back to I915_CACHING_NONE on platforms where no special
- * cache mode (like write-through or gfdt flushing) is available. The kernel
- * automatically sets this mode when using a buffer as a scanout target.
- * Userspace can manually set this mode to avoid a costly stall and clflush in
- * the hotpath of drawing the first frame.
  */
-#define I915_CACHING_DISPLAY		2
-
 struct drm_i915_gem_caching {
 	/**
-	 * Handle of the buffer to set/get the caching level of. */
+	 * @handle: Handle of the buffer to set/get the caching level.
+	 */
 	__u32 handle;
 
 	/**
-	 * Cacheing level to apply or return value
+	 * @caching: The GTT caching level to apply or possible return value.
+	 *
+	 * The supported @caching values:
 	 *
-	 * bits0-15 are for generic caching control (i.e. the above defined
-	 * values). bits16-31 are reserved for platform-specific variations
-	 * (e.g. l3$ caching on gen7). */
+	 * I915_CACHING_NONE:
+	 *
+	 * GPU access is not coherent with CPU caches.  Default for machines
+	 * without an LLC. This means we need to manually clflush, if we want
+	 * GPU access to be coherent.
+	 *
+	 * I915_CACHING_CACHED:
+	 *
+	 * GPU access is coherent with CPU caches and furthermore the data is
+	 * cached in last-level caches shared between CPU cores and the GPU GT.
+	 * Default on machines with HAS_LLC. In general the fast shared
+	 * last-level cache(HAS_LLC) is considered much faster then platforms
+	 * which only support snooping(HAS_SNOOP), hence by default
+	 *
+	 * I915_CACHING_DISPLAY:
+	 *
+	 * Special GPU caching mode which is coherent with the scanout engines.
+	 * Transparently falls back to I915_CACHING_NONE on platforms where no
+	 * special cache mode (like write-through or gfdt flushing) is
+	 * available. The kernel automatically sets this mode when using a
+	 * buffer as a scanout target.  Userspace can manually set this mode to
+	 * avoid a costly stall and clflush in the hotpath of drawing the first
+	 * frame.
+	 *
+	 * Side note: On gen8+ this no longer does much since we lost the GGTT
+	 * caching bits. Although setting this is harmless, since it still
+	 * effectively falls back to I915_CACHING_NONE.
+	 */
+#define I915_CACHING_NONE		0
+#define I915_CACHING_CACHED		1
+#define I915_CACHING_DISPLAY		2
 	__u32 caching;
 };
 
Signature · 1 line
2.26.3
Reviewed-by on v3 2/5
#2 lore raw

Re: [PATCH v3 2/5] drm/i915/uapi: convert drm_i915_gem_caching to kernel doc

Quoted 4 lines · Matthew Auld

Convert all the drm_i915_gem_caching bits to proper kernel doc.

LGTM.

Quoted 106 lines
Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 include/uapi/drm/i915_drm.h | 70 +++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 27 deletions(-)
include/uapi/drm/i915_drm.h +43 -27
index 2f70c48567c0..d13c6c5fad04 100644
@@ -1363,43 +1363,59 @@ struct drm_i915_gem_busy {
 };
 
 /**
- * I915_CACHING_NONE
+ * struct drm_i915_gem_caching - Set or get the caching for given object
+ * handle.
  *
- * GPU access is not coherent with cpu caches. Default for machines without an
- * LLC.
- */
-#define I915_CACHING_NONE		0
-/**
- * I915_CACHING_CACHED
+ * Allow userspace to control the GTT caching bits for a given object when the
+ * object is later mapped through the ppGTT(or GGTT on older platforms lacking
+ * ppGTT support, or if the object is used for scanout). Note that this might
+ * require unbinding the object from the GTT first, if its current caching value
+ * doesn't match.
  *
- * GPU access is coherent with cpu caches and furthermore the data is cached in
- * last-level caches shared between cpu cores and the gpu GT. Default on
- * machines with HAS_LLC.
- */
-#define I915_CACHING_CACHED		1
-/**
- * I915_CACHING_DISPLAY
  *
- * Special GPU caching mode which is coherent with the scanout engines.
- * Transparently falls back to I915_CACHING_NONE on platforms where no special
- * cache mode (like write-through or gfdt flushing) is available. The kernel
- * automatically sets this mode when using a buffer as a scanout target.
- * Userspace can manually set this mode to avoid a costly stall and clflush in
- * the hotpath of drawing the first frame.
  */
-#define I915_CACHING_DISPLAY		2
-
 struct drm_i915_gem_caching {
 	/**
-	 * Handle of the buffer to set/get the caching level of. */
+	 * @handle: Handle of the buffer to set/get the caching level.
+	 */
 	__u32 handle;
 
 	/**
-	 * Cacheing level to apply or return value
+	 * @caching: The GTT caching level to apply or possible return value.
+	 *
+	 * The supported @caching values:
 	 *
-	 * bits0-15 are for generic caching control (i.e. the above defined
-	 * values). bits16-31 are reserved for platform-specific variations
-	 * (e.g. l3$ caching on gen7). */
+	 * I915_CACHING_NONE:
+	 *
+	 * GPU access is not coherent with CPU caches.  Default for machines
+	 * without an LLC. This means we need to manually clflush, if we want
+	 * GPU access to be coherent.
+	 *
+	 * I915_CACHING_CACHED:
+	 *
+	 * GPU access is coherent with CPU caches and furthermore the data is
+	 * cached in last-level caches shared between CPU cores and the GPU GT.
+	 * Default on machines with HAS_LLC. In general the fast shared
+	 * last-level cache(HAS_LLC) is considered much faster then platforms
+	 * which only support snooping(HAS_SNOOP), hence by default
+	 *
+	 * I915_CACHING_DISPLAY:
+	 *
+	 * Special GPU caching mode which is coherent with the scanout engines.
+	 * Transparently falls back to I915_CACHING_NONE on platforms where no
+	 * special cache mode (like write-through or gfdt flushing) is
+	 * available. The kernel automatically sets this mode when using a
+	 * buffer as a scanout target.  Userspace can manually set this mode to
+	 * avoid a costly stall and clflush in the hotpath of drawing the first
+	 * frame.
+	 *
+	 * Side note: On gen8+ this no longer does much since we lost the GGTT
+	 * caching bits. Although setting this is harmless, since it still
+	 * effectively falls back to I915_CACHING_NONE.
+	 */
+#define I915_CACHING_NONE		0
+#define I915_CACHING_CACHED		1
+#define I915_CACHING_DISPLAY		2
 	__u32 caching;
 };
 
Signature · 1 line
2.26.3

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

#3 lore raw

PATCH v3 3/5 drm/i915/uapi: reject caching ioctls for discrete

In reply to Matthew Auld

It's a noop on DG1, and in the future when need to support other devices which let us control the coherency, then it should be an immutable creation time property for the BO. This will likely be controlled through a new gem_create_ext extension.

v2: add some kernel doc for the discrete changes, and document the
implicit rules

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c |  6 +++++
 include/uapi/drm/i915_drm.h                | 29 +++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +6 -0
index 7d1400b13429..43004bef55cb 100644
@@ -268,6 +268,9 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
 	struct drm_i915_gem_object *obj;
 	int err = 0;
 
+	if (IS_DGFX(to_i915(dev)))
+		return -ENODEV;
+
 	rcu_read_lock();
 	obj = i915_gem_object_lookup_rcu(file, args->handle);
 	if (!obj) {
@@ -303,6 +306,9 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
 	enum i915_cache_level level;
 	int ret = 0;
 
+	if (IS_DGFX(i915))
+		return -ENODEV;
+
 	switch (args->caching) {
 	case I915_CACHING_NONE:
 		level = I915_CACHE_NONE;
include/uapi/drm/i915_drm.h +28 -1
index d13c6c5fad04..a4faceeb8c32 100644
@@ -1372,7 +1372,34 @@ struct drm_i915_gem_busy {
  * require unbinding the object from the GTT first, if its current caching value
  * doesn't match.
  *
- *
+ * Note that this all changes on discrete platforms, starting from DG1, the
+ * set/get caching is no longer supported, and is now rejected.  Instead the CPU
+ * caching attributes(WB vs WC) will become an immutable creation time property
+ * for the object, along with the GTT caching level. For now we don't expose any
+ * new uAPI for this, instead on DG1 this is all implicit, although this largely
+ * shouldn't matter since DG1 is coherent by default(without any way of
+ * controlling it).
+ *
+ * Implicit caching rules, starting from DG1:
+ *
+ *     - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
+ *       contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
+ *       mapped as write-combined only.
+ *
+ *     - Everything else is always allocated and mapped as write-back, with the
+ *       guarantee that everything is also coherent with the GPU.
+ *
+ * Note that this is likely to change in the future again, where we might need
+ * more flexibility on future devices, so making this all explicit as part of a
+ * new &drm_i915_gem_create_ext extension is probable.
+ *
+ * Side note: Part of the reason for this is that changing the at-allocation-time CPU
+ * caching attributes for the pages might be required(and is expensive) if we
+ * need to then CPU map the pages later with different caching attributes. This
+ * inconsistent caching behaviour, while supported on x86, is not universally
+ * supported on other architectures. So for simplicity we opt for setting
+ * everything at creation time, whilst also making it immutable, on discrete
+ * platforms.
  */
 struct drm_i915_gem_caching {
 	/**
Signature · 1 line
2.26.3
Reviewed-by on v3 3/5
#4 lore raw

Re: [PATCH v3 3/5] drm/i915/uapi: reject caching ioctls for discrete

Quoted 7 lines · Matthew Auld

It's a noop on DG1, and in the future when need to support other devices which let us control the coherency, then it should be an immutable creation time property for the BO. This will likely be controlled through a new gem_create_ext extension.

v2: add some kernel doc for the discrete changes, and document the
implicit rules

LGTM

Quoted 83 lines
Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c |  6 +++++
 include/uapi/drm/i915_drm.h                | 29 +++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +6 -0
index 7d1400b13429..43004bef55cb 100644
@@ -268,6 +268,9 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
 	struct drm_i915_gem_object *obj;
 	int err = 0;
 
+	if (IS_DGFX(to_i915(dev)))
+		return -ENODEV;
+
 	rcu_read_lock();
 	obj = i915_gem_object_lookup_rcu(file, args->handle);
 	if (!obj) {
@@ -303,6 +306,9 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
 	enum i915_cache_level level;
 	int ret = 0;
 
+	if (IS_DGFX(i915))
+		return -ENODEV;
+
 	switch (args->caching) {
 	case I915_CACHING_NONE:
 		level = I915_CACHE_NONE;
include/uapi/drm/i915_drm.h +28 -1
index d13c6c5fad04..a4faceeb8c32 100644
@@ -1372,7 +1372,34 @@ struct drm_i915_gem_busy {
  * require unbinding the object from the GTT first, if its current caching value
  * doesn't match.
  *
- *
+ * Note that this all changes on discrete platforms, starting from DG1, the
+ * set/get caching is no longer supported, and is now rejected.  Instead the CPU
+ * caching attributes(WB vs WC) will become an immutable creation time property
+ * for the object, along with the GTT caching level. For now we don't expose any
+ * new uAPI for this, instead on DG1 this is all implicit, although this largely
+ * shouldn't matter since DG1 is coherent by default(without any way of
+ * controlling it).
+ *
+ * Implicit caching rules, starting from DG1:
+ *
+ *     - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
+ *       contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
+ *       mapped as write-combined only.
+ *
+ *     - Everything else is always allocated and mapped as write-back, with the
+ *       guarantee that everything is also coherent with the GPU.
+ *
+ * Note that this is likely to change in the future again, where we might need
+ * more flexibility on future devices, so making this all explicit as part of a
+ * new &drm_i915_gem_create_ext extension is probable.
+ *
+ * Side note: Part of the reason for this is that changing the at-allocation-time CPU
+ * caching attributes for the pages might be required(and is expensive) if we
+ * need to then CPU map the pages later with different caching attributes. This
+ * inconsistent caching behaviour, while supported on x86, is not universally
+ * supported on other architectures. So for simplicity we opt for setting
+ * everything at creation time, whilst also making it immutable, on discrete
+ * platforms.
  */
 struct drm_i915_gem_caching {
 	/**
Signature · 1 line
2.26.3

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

Reviewed-by on v3 3/5
#5 lore raw

Re: [PATCH v3 3/5] drm/i915/uapi: reject caching ioctls for discrete

In reply to Matthew Auld
Quoted 18 lines · PDT Matthew Auld

It's a noop on DG1, and in the future when need to support other devices which let us control the coherency, then it should be an immutable creation time property for the BO. This will likely be controlled through a new gem_create_ext extension.

v2: add some kernel doc for the discrete changes, and document the
implicit rules

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
Quoted 4 lines
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c |  6 +++++
 include/uapi/drm/i915_drm.h                | 29 +++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

This caching ioctl patch is:

#6 lore raw

PATCH v3 4/5 drm/i915/uapi: convert drm_i915_gem_set_domain to kernel doc

In reply to Matthew Auld

Convert all the drm_i915_gem_set_domain bits to proper kernel doc.

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 include/uapi/drm/i915_drm.h | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)
include/uapi/drm/i915_drm.h +31 -3
index a4faceeb8c32..6f94e5e7569a 100644
@@ -880,14 +880,42 @@ struct drm_i915_gem_mmap_offset {
 	__u64 extensions;
 };
 
+
+/**
+ * struct drm_i915_gem_set_domain - Adjust the objects write or read domain, in
+ * preparation for accessing the pages via some CPU domain.
+ *
+ * Specifying a new write or read domain will flush the object out of the
+ * previous domain(if required), before then updating the objects domain
+ * tracking with the new domain.
+ *
+ * Note this might involve waiting for the object first if it is still active on
+ * the GPU.
+ *
+ * Supported values for @read_domains and @write_domain:
+ *
+ *	- I915_GEM_DOMAIN_WC: Uncached write-combined domain
+ *	- I915_GEM_DOMAIN_CPU: CPU cache domain
+ *	- I915_GEM_DOMAIN_GTT: Mappable aperture domain
+ *
+ * All other domains are rejected.
+ *
+ */
 struct drm_i915_gem_set_domain {
-	/** Handle for the object */
+	/** @handle: Handle for the object. */
 	__u32 handle;
 
-	/** New read domains */
+	/**
+	 * @read_domains: New read domains.
+	 */
 	__u32 read_domains;
 
-	/** New write domain */
+	/**
+	 * @write_domain: New write domain.
+	 *
+	 * Note that having something in the write domain implies it's in the
+	 * read domain, and only that read domain.
+	 */
 	__u32 write_domain;
 };
 
Signature · 1 line
2.26.3
Reviewed-by on v3 4/5
#7 lore raw

Re: [PATCH v3 4/5] drm/i915/uapi: convert drm_i915_gem_set_domain to kernel doc

Quoted 1 line · Matthew Auld

Convert all the drm_i915_gem_set_domain bits to proper kernel doc.

LGTM.

Quoted 68 lines
Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 include/uapi/drm/i915_drm.h | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)
include/uapi/drm/i915_drm.h +31 -3
index a4faceeb8c32..6f94e5e7569a 100644
@@ -880,14 +880,42 @@ struct drm_i915_gem_mmap_offset {
 	__u64 extensions;
 };
 
+
+/**
+ * struct drm_i915_gem_set_domain - Adjust the objects write or read domain, in
+ * preparation for accessing the pages via some CPU domain.
+ *
+ * Specifying a new write or read domain will flush the object out of the
+ * previous domain(if required), before then updating the objects domain
+ * tracking with the new domain.
+ *
+ * Note this might involve waiting for the object first if it is still active on
+ * the GPU.
+ *
+ * Supported values for @read_domains and @write_domain:
+ *
+ *	- I915_GEM_DOMAIN_WC: Uncached write-combined domain
+ *	- I915_GEM_DOMAIN_CPU: CPU cache domain
+ *	- I915_GEM_DOMAIN_GTT: Mappable aperture domain
+ *
+ * All other domains are rejected.
+ *
+ */
 struct drm_i915_gem_set_domain {
-	/** Handle for the object */
+	/** @handle: Handle for the object. */
 	__u32 handle;
 
-	/** New read domains */
+	/**
+	 * @read_domains: New read domains.
+	 */
 	__u32 read_domains;
 
-	/** New write domain */
+	/**
+	 * @write_domain: New write domain.
+	 *
+	 * Note that having something in the write domain implies it's in the
+	 * read domain, and only that read domain.
+	 */
 	__u32 write_domain;
 };
 
Signature · 1 line
2.26.3
#8 lore raw

PATCH v3 5/5 drm/i915/uapi: reject set_domain for discrete

In reply to Matthew Auld

The CPU domain should be static for discrete, and on DG1 we don't need any flushing since everything is already coherent, so really all this does is an object wait, for which we have an ioctl. Longer term the desired caching should be an immutable creation time property for the BO, which can be set with something like gem_create_ext.

One other user is iris + userptr, which uses the set_domain to probe all the pages to check if the GUP succeeds, however keeping the set_domain around just for that seems rather scuffed. We could equally just submit a dummy batch, which should hopefully be good enough, otherwise adding a new creation time flag for userptr might be an option. Although longer term we will also have vm_bind, which should also be a nice fit for this, so adding a whole new flag is likely overkill.

v2: add some more kernel doc, also add the implicit rules with caching

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c |  3 +++
 include/uapi/drm/i915_drm.h                | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +3 -0
index 43004bef55cb..b684a62bf3b0 100644
@@ -490,6 +490,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 	u32 write_domain = args->write_domain;
 	int err;
 
+	if (IS_DGFX(to_i915(dev)))
+		return -ENODEV;
+
 	/* Only handle setting domains to types used by the CPU. */
 	if ((write_domain | read_domains) & I915_GEM_GPU_DOMAINS)
 		return -EINVAL;
include/uapi/drm/i915_drm.h +18 -0
index 6f94e5e7569a..fd1a9878730c 100644
@@ -900,6 +900,24 @@ struct drm_i915_gem_mmap_offset {
  *
  * All other domains are rejected.
  *
+ * Note that for discrete, starting from DG1, this is no longer supported, and
+ * is instead rejected. On such platforms the CPU domain is effectively static,
+ * where we also only support a single &drm_i915_gem_mmap_offset cache mode,
+ * which can't be set explicitly and instead depends on the object placements,
+ * as per the below.
+ *
+ * Implicit caching rules, starting from DG1:
+ *
+ *	- If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
+ *	  contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
+ *	  mapped as write-combined only.
+ *
+ *	- Everything else is always allocated and mapped as write-back, with the
+ *	  guarantee that everything is also coherent with the GPU.
+ *
+ * Note that this is likely to change in the future again, where we might need
+ * more flexibility on future devices, so making this all explicit as part of a
+ * new &drm_i915_gem_create_ext extension is probable.
  */
 struct drm_i915_gem_set_domain {
 	/** @handle: Handle for the object. */
Signature · 6 lines
2.26.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 5/5
#9 lore raw

Re: [PATCH v3 5/5] drm/i915/uapi: reject set_domain for discrete

Quoted 14 lines · Matthew Auld

The CPU domain should be static for discrete, and on DG1 we don't need any flushing since everything is already coherent, so really all this does is an object wait, for which we have an ioctl. Longer term the desired caching should be an immutable creation time property for the BO, which can be set with something like gem_create_ext.

One other user is iris + userptr, which uses the set_domain to probe all the pages to check if the GUP succeeds, however keeping the set_domain around just for that seems rather scuffed. We could equally just submit a dummy batch, which should hopefully be good enough, otherwise adding a new creation time flag for userptr might be an option. Although longer term we will also have vm_bind, which should also be a nice fit for this, so adding a whole new flag is likely overkill.

Quoted 1 line

v2: add some more kernel doc, also add the implicit rules with caching

LGTM

Quoted 62 lines
Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Jordan Justen <[email protected]>
Cc Kenneth Graunke <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_domain.c |  3 +++
 include/uapi/drm/i915_drm.h                | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_domain.c +3 -0
index 43004bef55cb..b684a62bf3b0 100644
@@ -490,6 +490,9 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 	u32 write_domain = args->write_domain;
 	int err;
 
+	if (IS_DGFX(to_i915(dev)))
+		return -ENODEV;
+
 	/* Only handle setting domains to types used by the CPU. */
 	if ((write_domain | read_domains) & I915_GEM_GPU_DOMAINS)
 		return -EINVAL;
include/uapi/drm/i915_drm.h +18 -0
index 6f94e5e7569a..fd1a9878730c 100644
@@ -900,6 +900,24 @@ struct drm_i915_gem_mmap_offset {
  *
  * All other domains are rejected.
  *
+ * Note that for discrete, starting from DG1, this is no longer supported, and
+ * is instead rejected. On such platforms the CPU domain is effectively static,
+ * where we also only support a single &drm_i915_gem_mmap_offset cache mode,
+ * which can't be set explicitly and instead depends on the object placements,
+ * as per the below.
+ *
+ * Implicit caching rules, starting from DG1:
+ *
+ *	- If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
+ *	  contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
+ *	  mapped as write-combined only.
+ *
+ *	- Everything else is always allocated and mapped as write-back, with the
+ *	  guarantee that everything is also coherent with the GPU.
+ *
+ * Note that this is likely to change in the future again, where we might need
+ * more flexibility on future devices, so making this all explicit as part of a
+ * new &drm_i915_gem_create_ext extension is probable.
  */
 struct drm_i915_gem_set_domain {
 	/** @handle: Handle for the object. */
Signature · 1 line
2.26.3

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

#10 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3,1/5] drm/i915: use consistent CPU mappings for pin_map users

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v3,1/5] drm/i915: use consistent CPU mappings for pin_map users
URL : https://patchwork.freedesktop.org/series/92209/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
a003ccd3dd56 drm/i915: use consistent CPU mappings for pin_map users
a6e0c6b9349a drm/i915/uapi: convert drm_i915_gem_caching to kernel doc
53317ac5ecc4 drm/i915/uapi: reject caching ioctls for discrete
ee22ceeab3ad drm/i915/uapi: convert drm_i915_gem_set_domain to kernel doc
-:30: CHECK:LINE_SPACING: Please don't use multiple blank lines
#30: FILE: include/uapi/drm/i915_drm.h:883:

+

total: 0 errors, 0 warnings, 1 checks, 45 lines checked d507ae4d5737 drm/i915/uapi: reject set_domain for discrete

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

#11 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v3,1/5] drm/i915: use consistent CPU mappings for pin_map users

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: series starting with [v3,1/5] drm/i915: use consistent CPU mappings for pin_map users
URL : https://patchwork.freedesktop.org/series/92209/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_10305 -> Patchwork_20531
====================================================

Summary
-------

**FAILURE**

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

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

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

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

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

### IGT changes ###

#### Possible regressions ####

* igt@gem_exec_parallel@engines@contexts:
- fi-ilk-650: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-ilk-650/igt@gem_exec_parallel@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-ilk-650/igt@gem_exec_parallel@[email protected]

* igt@gem_exec_parallel@engines@fds:
- fi-snb-2520m: [PASS][3] -> [DMESG-WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-snb-2520m/igt@gem_exec_parallel@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-snb-2520m/igt@gem_exec_parallel@[email protected]

* igt@kms_addfb_basic@bad-pitch-0:
- fi-bdw-5557u: NOTRUN -> [DMESG-WARN][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-bdw-5557u/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_basic@cs-gfx:
- fi-hsw-4770: NOTRUN -> [SKIP][6] ([fdo#109271] / [fdo#109315]) +17 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@amdgpu/[email protected]

* igt@amdgpu/amd_basic@memory-alloc:
- fi-cml-u2: NOTRUN -> [SKIP][7] ([fdo#109315]) +17 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@amdgpu/[email protected]

* igt@core_hotunplug@unbind-rebind:
- fi-hsw-4770: NOTRUN -> [WARN][8] ([i915#3718])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]

* igt@gem_exec_fence@basic-busy@bcs0:
- fi-apl-guc: NOTRUN -> [SKIP][9] ([fdo#109271]) +1 similar issue
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-apl-guc/igt@gem_exec_fence@[email protected]

* igt@gem_exec_gttfill@basic:
- fi-apl-guc: NOTRUN -> [INCOMPLETE][10] ([i915#2405])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-apl-guc/igt@[email protected]

* igt@gem_exec_parallel@engines@userptr:
- fi-bxt-dsi: [PASS][11] -> [DMESG-WARN][12] ([i915#1610])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-bxt-dsi/igt@gem_exec_parallel@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-bxt-dsi/igt@gem_exec_parallel@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-hsw-4770: NOTRUN -> [SKIP][13] ([fdo#109271]) +4 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]
- fi-glk-dsi: NOTRUN -> [SKIP][14] ([fdo#109271] / [i915#2190])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-glk-dsi/igt@[email protected]
- fi-kbl-8809g: NOTRUN -> [SKIP][15] ([fdo#109271] / [i915#2190])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-kbl-8809g/igt@[email protected]

* igt@i915_pm_backlight@basic-brightness:
- fi-hsw-4770: NOTRUN -> [SKIP][16] ([fdo#109271] / [i915#3012])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- fi-bdw-5557u: NOTRUN -> [SKIP][17] ([fdo#109271]) +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-bdw-5557u/igt@[email protected]

* igt@kms_chamelium@common-hpd-after-suspend:
- fi-hsw-4770: NOTRUN -> [SKIP][18] ([fdo#109271] / [fdo#111827]) +8 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]

* igt@kms_chamelium@dp-hpd-fast:
- fi-cml-u2: NOTRUN -> [SKIP][19] ([fdo#109284] / [fdo#111827]) +8 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@[email protected]

* igt@kms_chamelium@hdmi-edid-read:
- fi-kbl-8809g: NOTRUN -> [SKIP][20] ([fdo#109271] / [fdo#111827]) +8 similar issues
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-kbl-8809g/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-glk-dsi: NOTRUN -> [SKIP][21] ([fdo#109271] / [fdo#111827]) +8 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-glk-dsi/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- fi-cml-u2: NOTRUN -> [SKIP][22] ([fdo#109285])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@[email protected]

* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-hsw-4770: NOTRUN -> [SKIP][23] ([fdo#109271] / [i915#533])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]
- fi-cml-u2: NOTRUN -> [SKIP][24] ([fdo#109278] / [i915#533])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@[email protected]
- fi-glk-dsi: NOTRUN -> [SKIP][25] ([fdo#109271] / [i915#533])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-glk-dsi/igt@[email protected]
- fi-kbl-8809g: NOTRUN -> [SKIP][26] ([fdo#109271] / [i915#533])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-kbl-8809g/igt@[email protected]

* igt@kms_psr@cursor_plane_move:
- fi-kbl-8809g: NOTRUN -> [SKIP][27] ([fdo#109271]) +37 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-kbl-8809g/igt@kms_psr@cursor_plane_move.html

* igt@kms_psr@primary_mmap_gtt:
- fi-hsw-4770: NOTRUN -> [SKIP][28] ([fdo#109271] / [i915#1072]) +3 similar issues
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@kms_psr@primary_mmap_gtt.html

* igt@kms_psr@primary_page_flip:
- fi-glk-dsi: NOTRUN -> [SKIP][29] ([fdo#109271]) +25 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-glk-dsi/igt@kms_psr@primary_page_flip.html

* igt@prime_vgem@basic-userptr:
- fi-cml-u2: NOTRUN -> [SKIP][30] ([i915#3301])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@[email protected]

* igt@runner@aborted:
- fi-ilk-650: NOTRUN -> [FAIL][31] ([i915#2426])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-ilk-650/igt@[email protected]
- fi-apl-guc: NOTRUN -> [FAIL][32] ([i915#1186] / [i915#2426] / [i915#3363])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-apl-guc/igt@[email protected]
- fi-bxt-dsi: NOTRUN -> [FAIL][33] ([i915#2426] / [i915#3363] / [i915#3364])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-bxt-dsi/igt@[email protected]

#### Possible fixes ####

* igt@gem_exec_parallel@engines@basic:
- fi-glk-dsi: [DMESG-WARN][34] ([i915#1610]) -> [PASS][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-glk-dsi/igt@gem_exec_parallel@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-glk-dsi/igt@gem_exec_parallel@[email protected]

* igt@gem_exec_parallel@engines@contexts:
- fi-snb-2520m: [DMESG-WARN][36] -> [PASS][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-snb-2520m/igt@gem_exec_parallel@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-snb-2520m/igt@gem_exec_parallel@[email protected]

* igt@gem_exec_suspend@basic-s3:
- fi-hsw-4770: [DMESG-WARN][38] -> [PASS][39]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-hsw-4770/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-hsw-4770/igt@[email protected]

* igt@gem_sync@basic-each:
- fi-cml-u2: [DMESG-WARN][40] ([i915#1610]) -> [PASS][41]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-cml-u2/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-cml-u2/igt@[email protected]

* igt@kms_flip@basic-flip-vs-dpms@b-dp3:
- {fi-tgl-1115g4}: [DMESG-WARN][42] -> [PASS][43]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10305/fi-tgl-1115g4/igt@kms_flip@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20531/fi-tgl-1115g4/igt@kms_flip@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#1186]: https://gitlab.freedesktop.org/drm/intel/issues/1186
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#1610]: https://gitlab.freedesktop.org/drm/intel/issues/1610
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2405]: https://gitlab.freedesktop.org/drm/intel/issues/2405
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2927]: https://gitlab.freedesktop.org/drm/intel/issues/2927
[i915#2966]: https://gitlab.freedesktop.org/drm/intel/issues/2966
[i915#3012]: https://gitlab.freedesktop.org/drm/intel/issues/3012
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3364]: https://gitlab.freedesktop.org/drm/intel/issues/3364
[i915#3690]: https://gitlab.freedesktop.org/drm/intel/issues/3690
[i915#3718]: https://gitlab.freedesktop.org/drm/intel/issues/3718
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533

Participating hosts (32 -> 26)
------------------------------

Additional (1): fi-apl-guc
Missing (7): fi-kbl-soraka fi-hsw-4200u fi-cfl-guc fi-kbl-7500u fi-dg1-1 fi-cfl-8109u fi-bdw-samus

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

* Linux: CI_DRM_10305 -> Patchwork_20531

CI-20190529: 20190529
CI_DRM_10305: fd899b57cb480c98e60ee842671bddd4759dfca3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6128: b24e5949af7e51f0af484d2ce4cb4c5a41ac5358 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20531: d507ae4d5737096c9a688db042e3d52e74ff57f3 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

d507ae4d5737 drm/i915/uapi: reject set_domain for discrete ee22ceeab3ad drm/i915/uapi: convert drm_i915_gem_set_domain to kernel doc 53317ac5ecc4 drm/i915/uapi: reject caching ioctls for discrete a6e0c6b9349a drm/i915/uapi: convert drm_i915_gem_caching to kernel doc a003ccd3dd56 drm/i915: use consistent CPU mappings for pin_map users

== Logs ==

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

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

Reviewed-by on v3 1/5
#12 lore raw
In reply to Matthew Auld
Quoted 110 lines · Matthew Auld

For discrete, users of pin_map() needs to obey the same rules at the TTM backend, where we map system only objects as WB, and everything else as WC. The simplest for now is to just force the correct mapping type as per the new rules for discrete.

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c | 34 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_object.h |  4 +++
 drivers/gpu/drm/i915/gem/i915_gem_pages.c  | 22 ++++++++++++--
 3 files changed, 58 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +34 -0
index 547cc9dad90d..9da7b288b7ed 100644
@@ -625,6 +625,40 @@ int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
 	return obj->ops->migrate(obj, mr);
 }
 
+/**
+ * i915_gem_object_placement_possible - Check whether the object can be
+ * placed at certain memory type
+ * @obj: Pointer to the object
+ * @type: The memory type to check
+ *
+ * Return: True if the object can be placed in @type. False otherwise.
+ */
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type)
+{
+	unsigned int i;
+
+	if (!obj->mm.n_placements) {
+		switch (type) {
+		case INTEL_MEMORY_LOCAL:
+			return i915_gem_object_has_iomem(obj);
+		case INTEL_MEMORY_SYSTEM:
+			return i915_gem_object_has_pages(obj);
+		default:
+			/* Ignore stolen for now */
+			GEM_BUG_ON(1);
+			return false;
+		}
+	}
+
+	for (i = 0; i < obj->mm.n_placements; i++) {
+		if (obj->mm.placements[i]->type == type)
+			return true;
+	}
+
+	return false;
+}
+
 void i915_gem_init__objects(struct drm_i915_private *i915)
 {
 	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
drivers/gpu/drm/i915/gem/i915_gem_object.h +4 -0
index d423d8cac4f2..8be4fadeee48 100644
@@ -12,6 +12,7 @@
 #include <drm/drm_device.h>
 
 #include "display/intel_frontbuffer.h"
+#include "intel_memory_region.h"
 #include "i915_gem_object_types.h"
 #include "i915_gem_gtt.h"
 #include "i915_gem_ww.h"
@@ -607,6 +608,9 @@ bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj,
 int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj,
 				   unsigned int flags);
 
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type);
+
 #ifdef CONFIG_MMU_NOTIFIER
 static inline bool
 i915_gem_object_is_userptr(struct drm_i915_gem_object *obj)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +9 -2
index f2f850e31b8e..810a157a18f8 100644
@@ -321,8 +321,7 @@ static void *i915_gem_object_map_pfn(struct drm_i915_gem_object *obj,
 	dma_addr_t addr;
 	void *vaddr;
 
-	if (type != I915_MAP_WC)
-		return ERR_PTR(-ENODEV);
+	GEM_BUG_ON(type != I915_MAP_WC);
 
 	if (n_pfn > ARRAY_SIZE(stack)) {
 		/* Too big for stack -- allocate temporary array instead */
@@ -374,6 +373,25 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 	}
 	GEM_BUG_ON(!i915_gem_object_has_pages(obj));
 
+	/*
+	 * For discrete our CPU mappings needs to be consistent in order to
+	 * function correctly on !x86. When mapping things through TTM, we use
+	 * the same rules to determine the caching type.
+	 *
+	 * Internal users of lmem are already expected to get this right, so no
+	 * fudging needed there.
+	 */

drivers/gpu/drm/i915/gem/i915_gem_pages.c void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj, · line 393

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_pages.c +10 -0
+	if (i915_gem_object_placement_possible(obj, INTEL_MEMORY_LOCAL)) {
+		if (type != I915_MAP_WC && !obj->mm.n_placements) {
+			ptr = ERR_PTR(-ENODEV);
+			goto err_unpin;
+		}
+
+		type = I915_MAP_WC;
+	} else if (IS_DGFX(to_i915(obj->base.dev))) {
+		type = I915_MAP_WB;
+	}

Looks good to me.

Quoted 7 lines
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -0
+
 	ptr = page_unpack_bits(obj->mm.mapping, &has_type);
 	if (ptr && has_type != type) {
 		if (pinned) {
Signature · 1 line
2.26.3

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

#13 lore raw
In reply to Matthew Auld
Quoted 11 lines · Matthew Auld

For discrete, users of pin_map() needs to obey the same rules at the TTM backend, where we map system only objects as WB, and everything else as WC. The simplest for now is to just force the correct mapping type as per the new rules for discrete.

Cc Thomas Hellström <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Ramalingam C <[email protected]>

Huge thanks for doing all the kerneldoc work for uapi you're doing in this series, this should help a lot with umd conversions since we can just point them at the docs and tell them to pls update code.

Yes I know there's no kerneldoc here, but I didn't see the cover letter :-)

Cheers, Daniel

Quoted 116 lines
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c | 34 ++++++++++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_object.h |  4 +++
 drivers/gpu/drm/i915/gem/i915_gem_pages.c  | 22 ++++++++++++--
 3 files changed, 58 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +34 -0
index 547cc9dad90d..9da7b288b7ed 100644
@@ -625,6 +625,40 @@ int i915_gem_object_migrate(struct drm_i915_gem_object *obj,
 	return obj->ops->migrate(obj, mr);
 }
 
+/**
+ * i915_gem_object_placement_possible - Check whether the object can be
+ * placed at certain memory type
+ * @obj: Pointer to the object
+ * @type: The memory type to check
+ *
+ * Return: True if the object can be placed in @type. False otherwise.
+ */
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type)
+{
+	unsigned int i;
+
+	if (!obj->mm.n_placements) {
+		switch (type) {
+		case INTEL_MEMORY_LOCAL:
+			return i915_gem_object_has_iomem(obj);
+		case INTEL_MEMORY_SYSTEM:
+			return i915_gem_object_has_pages(obj);
+		default:
+			/* Ignore stolen for now */
+			GEM_BUG_ON(1);
+			return false;
+		}
+	}
+
+	for (i = 0; i < obj->mm.n_placements; i++) {
+		if (obj->mm.placements[i]->type == type)
+			return true;
+	}
+
+	return false;
+}
+
 void i915_gem_init__objects(struct drm_i915_private *i915)
 {
 	INIT_WORK(&i915->mm.free_work, __i915_gem_free_work);
drivers/gpu/drm/i915/gem/i915_gem_object.h +4 -0
index d423d8cac4f2..8be4fadeee48 100644
@@ -12,6 +12,7 @@
 #include <drm/drm_device.h>
 
 #include "display/intel_frontbuffer.h"
+#include "intel_memory_region.h"
 #include "i915_gem_object_types.h"
 #include "i915_gem_gtt.h"
 #include "i915_gem_ww.h"
@@ -607,6 +608,9 @@ bool i915_gem_object_can_migrate(struct drm_i915_gem_object *obj,
 int i915_gem_object_wait_migration(struct drm_i915_gem_object *obj,
 				   unsigned int flags);
 
+bool i915_gem_object_placement_possible(struct drm_i915_gem_object *obj,
+					enum intel_memory_type type);
+
 #ifdef CONFIG_MMU_NOTIFIER
 static inline bool
 i915_gem_object_is_userptr(struct drm_i915_gem_object *obj)
drivers/gpu/drm/i915/gem/i915_gem_pages.c +20 -2
index f2f850e31b8e..810a157a18f8 100644
@@ -321,8 +321,7 @@ static void *i915_gem_object_map_pfn(struct drm_i915_gem_object *obj,
 	dma_addr_t addr;
 	void *vaddr;
 
-	if (type != I915_MAP_WC)
-		return ERR_PTR(-ENODEV);
+	GEM_BUG_ON(type != I915_MAP_WC);
 
 	if (n_pfn > ARRAY_SIZE(stack)) {
 		/* Too big for stack -- allocate temporary array instead */
@@ -374,6 +373,25 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 	}
 	GEM_BUG_ON(!i915_gem_object_has_pages(obj));
 
+	/*
+	 * For discrete our CPU mappings needs to be consistent in order to
+	 * function correctly on !x86. When mapping things through TTM, we use
+	 * the same rules to determine the caching type.
+	 *
+	 * Internal users of lmem are already expected to get this right, so no
+	 * fudging needed there.
+	 */
+	if (i915_gem_object_placement_possible(obj, INTEL_MEMORY_LOCAL)) {
+		if (type != I915_MAP_WC && !obj->mm.n_placements) {
+			ptr = ERR_PTR(-ENODEV);
+			goto err_unpin;
+		}
+
+		type = I915_MAP_WC;
+	} else if (IS_DGFX(to_i915(obj->base.dev))) {
+		type = I915_MAP_WB;
+	}
+
 	ptr = page_unpack_bits(obj->mm.mapping, &has_type);
 	if (ptr && has_type != type) {
 		if (pinned) {
Signature · 1 line
2.26.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch