Skip to contentSkip to conversation

LMEM basics

PATCH In review Matthew Auld 3 participants 34 messages Oct 4, 2019 – Oct 8, 2019

Subsystems (5)
DRM drivers x86 Intel i915 PCI +1 more subsystems
lore
Share & tools
lore
#0 lore raw

v3 cover LMEM basics

The basic LMEM bits, minus the uAPI, pruning, etc. The goal is to support basic LMEM object creation within the kernel. From there we can start with the dumb buffer support, and then the other display related bits.

Quick respin with a bunch of minor tweaks + rebasing on the now merged struct_mutex removal patches.

Abdiel Janulgue (4):
drm/i915: Add memory region information to device_info drm/i915: setup io-mapping for LMEM drm/i915/lmem: support kernel mapping drm/i915: enumerate and init each supported region

CQ Tang (1):
drm/i915/stolen: make the object creation interface consistent

Daniele Ceraolo Spurio (4):
drm/i915: define i915_ggtt_has_aperture drm/i915: do not map aperture if it is not available. drm/i915: set num_fence_regs to 0 if there is no aperture drm/i915: error capture with no ggtt slot

Matthew Auld (11):
drm/i915: introduce intel_memory_region drm/i915/region: support contiguous allocations drm/i915/region: support volatile objects
drm/i915: support creating LMEM objects drm/i915/selftests: add write-dword test for LMEM drm/i915/selftests: extend coverage to include LMEM huge-pages drm/i915: treat shmem as a region
drm/i915: treat stolen as a region
drm/i915: don't allocate the ring in stolen if we lack aperture drm/i915/selftests: check for missing aperture
HAX drm/i915: add the fake lmem region

Michal Wajdeczko (1):
drm/i915: Don't try to place HWS in non-existing mappable region

 arch/x86/kernel/early-quirks.c                |  26 +
 drivers/gpu/drm/i915/Makefile                 |   4 +
 drivers/gpu/drm/i915/display/intel_display.c  |   2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c    |   4 +-
 drivers/gpu/drm/i915/display/intel_overlay.c  |   2 +-
 drivers/gpu/drm/i915/gem/i915_gem_internal.c  |  17 +-
 drivers/gpu/drm/i915/gem/i915_gem_lmem.c      |  68 ++
 drivers/gpu/drm/i915/gem/i915_gem_lmem.h      |  31 +
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |  18 +
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |  29 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c     |  28 +-
 drivers/gpu/drm/i915/gem/i915_gem_phys.c      |   5 +-
 drivers/gpu/drm/i915/gem/i915_gem_region.c    | 168 +++++
 drivers/gpu/drm/i915/gem/i915_gem_region.h    |  29 +
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c     |  74 ++-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c    |  99 ++-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.h    |   3 +-
 .../gpu/drm/i915/gem/selftests/huge_pages.c   | 218 ++++++-
 .../i915/gem/selftests/i915_gem_coherency.c   |   5 +-
 .../drm/i915/gem/selftests/i915_gem_mman.c    |   6 +
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     |   3 +-
 drivers/gpu/drm/i915/gt/intel_gt.c            |   2 +-
 drivers/gpu/drm/i915/gt/intel_rc6.c           |   8 +-
 drivers/gpu/drm/i915/gt/intel_ringbuffer.c    |   6 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |  14 +-
 drivers/gpu/drm/i915/i915_drv.c               |   8 +
 drivers/gpu/drm/i915/i915_drv.h               |  13 +
 drivers/gpu/drm/i915/i915_gem.c               |   9 -
 drivers/gpu/drm/i915/i915_gem_fence_reg.c     |   6 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c           | 117 +++-
 drivers/gpu/drm/i915/i915_gem_gtt.h           |   5 +
 drivers/gpu/drm/i915/i915_gpu_error.c         |  66 +-
 drivers/gpu/drm/i915/i915_pci.c               |  29 +-
 drivers/gpu/drm/i915/intel_device_info.h      |   2 +
 drivers/gpu/drm/i915/intel_memory_region.c    | 212 ++++++
 drivers/gpu/drm/i915/intel_memory_region.h    | 125 ++++
 drivers/gpu/drm/i915/intel_region_lmem.c      | 157 +++++
 drivers/gpu/drm/i915/intel_region_lmem.h      |  16 +
 drivers/gpu/drm/i915/selftests/i915_gem.c     |   4 +
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c |   8 +-
 .../drm/i915/selftests/i915_live_selftests.h  |   1 +
 .../drm/i915/selftests/i915_mock_selftests.h  |   1 +
 .../drm/i915/selftests/intel_memory_region.c  | 602 ++++++++++++++++++
 .../gpu/drm/i915/selftests/mock_gem_device.c  |   9 +-
 drivers/gpu/drm/i915/selftests/mock_region.c  |  59 ++
 drivers/gpu/drm/i915/selftests/mock_region.h  |  16 +
 include/drm/i915_drm.h                        |   3 +
 47 files changed, 2186 insertions(+), 151 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_lmem.c
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_lmem.h
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_region.c
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_region.h
 create mode 100644 drivers/gpu/drm/i915/intel_memory_region.c
 create mode 100644 drivers/gpu/drm/i915/intel_memory_region.h
 create mode 100644 drivers/gpu/drm/i915/intel_region_lmem.c
 create mode 100644 drivers/gpu/drm/i915/intel_region_lmem.h
 create mode 100644 drivers/gpu/drm/i915/selftests/intel_memory_region.c
 create mode 100644 drivers/gpu/drm/i915/selftests/mock_region.c
 create mode 100644 drivers/gpu/drm/i915/selftests/mock_region.h
Signature · 6 lines
2.20.1

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

PATCH v3 1/21 drm/i915/stolen: make the object creation interface consistent

From: CQ Tang <[email protected]>

Our other backends return an actual error value upon failure. Do the same for stolen objects, which currently just return NULL on failure.

---
 drivers/gpu/drm/i915/display/intel_display.c |  2 +-
 drivers/gpu/drm/i915/display/intel_fbdev.c   |  4 +--
 drivers/gpu/drm/i915/display/intel_overlay.c |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c   | 36 +++++++++++---------
 drivers/gpu/drm/i915/gt/intel_gt.c           |  2 +-
 drivers/gpu/drm/i915/gt/intel_rc6.c          |  8 ++---
 drivers/gpu/drm/i915/gt/intel_ringbuffer.c   |  2 +-
 7 files changed, 30 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +1 -1
index 5acc39f32d0c..c15975a410bc 100644
@@ -3066,7 +3066,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 							     base_aligned,
 							     base_aligned,
 							     size_aligned);
-	if (!obj)
+	if (IS_ERR(obj))
 		return false;
 
 	switch (plane_config->tiling) {
drivers/gpu/drm/i915/display/intel_fbdev.c +2 -2
index 97cde017670a..3d1061470e76 100644
@@ -141,10 +141,10 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
 	/* If the FB is too big, just don't use it since fbdev is not very
 	 * important and we should probably use that space with FBC or other
 	 * features. */
-	obj = NULL;
+	obj = ERR_PTR(-ENODEV);
 	if (size * 2 < dev_priv->stolen_usable_size)
 		obj = i915_gem_object_create_stolen(dev_priv, size);
-	if (obj == NULL)
+	if (IS_ERR(obj))
 		obj = i915_gem_object_create_shmem(dev_priv, size);
 	if (IS_ERR(obj)) {
 		DRM_ERROR("failed to allocate framebuffer\n");
drivers/gpu/drm/i915/display/intel_overlay.c +1 -1
index daea112cbb87..2360f19f9694 100644
@@ -1291,7 +1291,7 @@ static int get_registers(struct intel_overlay *overlay, bool use_phys)
 	int err;
 
 	obj = i915_gem_object_create_stolen(i915, PAGE_SIZE);
-	if (obj == NULL)
+	if (IS_ERR(obj))
 		obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
drivers/gpu/drm/i915/gem/i915_gem_stolen.c +20 -16
index fad98a921cde..2a34355b738f 100644
@@ -585,28 +585,32 @@ i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 	int ret;
 
 	if (!drm_mm_initialized(&dev_priv->mm.stolen))
-		return NULL;
+		return ERR_PTR(-ENODEV);
 
 	if (size == 0)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);
 	if (!stolen)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	ret = i915_gem_stolen_insert_node(dev_priv, stolen, size, 4096);
-	if (ret) {
-		kfree(stolen);
-		return NULL;
-	}
+	if (ret)
+		goto err_free;
 
 	obj = _i915_gem_object_create_stolen(dev_priv, stolen);
-	if (obj)
-		return obj;
+	if (obj == NULL) {
+		ret = -ENOMEM;
+		goto err_remove;
+	}
 
+	return obj;
+
+err_remove:
 	i915_gem_stolen_remove_node(dev_priv, stolen);
+err_free:
 	kfree(stolen);
-	return NULL;
+	return ERR_PTR(ret);
 }
 
 struct drm_i915_gem_object *
@@ -622,7 +626,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 	int ret;
 
 	if (!drm_mm_initialized(&dev_priv->mm.stolen))
-		return NULL;
+		return ERR_PTR(-ENODEV);
 
 	DRM_DEBUG_DRIVER("creating preallocated stolen object: stolen_offset=%pa, gtt_offset=%pa, size=%pa\n",
 			 &stolen_offset, &gtt_offset, &size);
@@ -631,11 +635,11 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 	if (WARN_ON(size == 0) ||
 	    WARN_ON(!IS_ALIGNED(size, I915_GTT_PAGE_SIZE)) ||
 	    WARN_ON(!IS_ALIGNED(stolen_offset, I915_GTT_MIN_ALIGNMENT)))
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);
 	if (!stolen)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	stolen->start = stolen_offset;
 	stolen->size = size;
@@ -645,7 +649,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 	if (ret) {
 		DRM_DEBUG_DRIVER("failed to allocate stolen space\n");
 		kfree(stolen);
-		return NULL;
+		return ERR_PTR(ret);
 	}
 
 	obj = _i915_gem_object_create_stolen(dev_priv, stolen);
@@ -653,7 +657,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 		DRM_DEBUG_DRIVER("failed to allocate stolen object\n");
 		i915_gem_stolen_remove_node(dev_priv, stolen);
 		kfree(stolen);
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	}
 
 	/* Some objects just need physical mem from stolen space */
@@ -706,5 +710,5 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 	i915_gem_object_unpin_pages(obj);
 err:
 	i915_gem_object_put(obj);
-	return NULL;
+	return ERR_PTR(ret);
 }
drivers/gpu/drm/i915/gt/intel_gt.c +1 -1
index 53220741e49e..8f44cf8c79b2 100644
@@ -334,7 +334,7 @@ static int intel_gt_init_scratch(struct intel_gt *gt, unsigned int size)
 	int ret;
 
 	obj = i915_gem_object_create_stolen(i915, size);
-	if (!obj)
+	if (IS_ERR(obj))
 		obj = i915_gem_object_create_internal(i915, size);
 	if (IS_ERR(obj)) {
 		DRM_ERROR("Failed to allocate scratch page\n");
drivers/gpu/drm/i915/gt/intel_rc6.c +4 -4
index d6167dd592e9..71184aa72896 100644
@@ -299,8 +299,8 @@ static int vlv_rc6_init(struct intel_rc6 *rc6)
 								      pcbr_offset,
 								      I915_GTT_OFFSET_NONE,
 								      pctx_size);
-		if (!pctx)
-			return -ENOMEM;
+		if (IS_ERR(pctx))
+			return PTR_ERR(pctx);
 
 		goto out;
 	}
@@ -316,9 +316,9 @@ static int vlv_rc6_init(struct intel_rc6 *rc6)
 	 * memory, or any other relevant ranges.
 	 */
 	pctx = i915_gem_object_create_stolen(i915, pctx_size);
-	if (!pctx) {
+	if (IS_ERR(pctx)) {
 		DRM_DEBUG("not enough stolen space for PCTX, disabling\n");
-		return -ENOMEM;
+		return PTR_ERR(pctx);
 	}
 
 	GEM_BUG_ON(range_overflows_t(u64,
drivers/gpu/drm/i915/gt/intel_ringbuffer.c +1 -1
index ec32996254c0..311fdc0a21bc 100644
@@ -1274,7 +1274,7 @@ static struct i915_vma *create_ring_vma(struct i915_ggtt *ggtt, int size)
 	struct i915_vma *vma;
 
 	obj = i915_gem_object_create_stolen(i915, size);
-	if (!obj)
+	if (IS_ERR(obj))
 		obj = i915_gem_object_create_internal(i915, size);
 	if (IS_ERR(obj))
 		return ERR_CAST(obj);
Signature · 6 lines
2.20.1

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

PATCH v3 2/21 drm/i915: introduce intel_memory_region

In reply to Matthew Auld

Support memory regions, as defined by a given (start, end), and allow creating GEM objects which are backed by said region. The immediate goal here is to have something to represent our device memory, but later on we also want to represent every memory domain with a region, so stolen, shmem, and of course device. At some point we are probably going to want use a common struct here, such that we are better aligned with say TTM.

---
 drivers/gpu/drm/i915/Makefile                 |   2 +
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   9 +
 drivers/gpu/drm/i915/gem/i915_gem_region.c    | 134 ++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_region.h    |  28 +++
 .../gpu/drm/i915/gem/selftests/huge_pages.c   |  78 +++++++
 drivers/gpu/drm/i915/i915_drv.h               |   1 +
 drivers/gpu/drm/i915/intel_memory_region.c    | 191 ++++++++++++++++++
 drivers/gpu/drm/i915/intel_memory_region.h    |  83 ++++++++
 .../drm/i915/selftests/i915_mock_selftests.h  |   1 +
 .../drm/i915/selftests/intel_memory_region.c  | 115 +++++++++++
 .../gpu/drm/i915/selftests/mock_gem_device.c  |   1 +
 drivers/gpu/drm/i915/selftests/mock_region.c  |  59 ++++++
 drivers/gpu/drm/i915/selftests/mock_region.h  |  16 ++
 13 files changed, 718 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_region.c
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_region.h
 create mode 100644 drivers/gpu/drm/i915/intel_memory_region.c
 create mode 100644 drivers/gpu/drm/i915/intel_memory_region.h
 create mode 100644 drivers/gpu/drm/i915/selftests/intel_memory_region.c
 create mode 100644 drivers/gpu/drm/i915/selftests/mock_region.c
 create mode 100644 drivers/gpu/drm/i915/selftests/mock_region.h
drivers/gpu/drm/i915/Makefile +2 -0
index 06e1876d0250..6f0817bcc688 100644
@@ -50,6 +50,7 @@ i915-y += i915_drv.o \
 	  i915_utils.o \
 	  intel_csr.o \
 	  intel_device_info.o \
+	  intel_memory_region.o \
 	  intel_pch.o \
 	  intel_pm.o \
 	  intel_runtime_pm.o \
@@ -120,6 +121,7 @@ gem-y += \
 	gem/i915_gem_pages.o \
 	gem/i915_gem_phys.o \
 	gem/i915_gem_pm.o \
+	gem/i915_gem_region.o \
 	gem/i915_gem_shmem.o \
 	gem/i915_gem_shrinker.o \
 	gem/i915_gem_stolen.o \
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +9 -0
index c00b4f077f9e..11390586cfe1 100644
@@ -160,6 +160,15 @@ struct drm_i915_gem_object {
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
+		/**
+		 * Memory region for this object.
+		 */
+		struct intel_memory_region *region;
+		/**
+		 * List of memory region blocks allocated for this object.
+		 */
+		struct list_head blocks;
+
 		struct sg_table *pages;
 		void *mapping;
 
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +134 -0

134 lines not on this page · raw message

drivers/gpu/drm/i915/gem/i915_gem_region.h new file +28 -0
new file mode 100644
index 000000000000..ebddc86d78f7
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_GEM_REGION_H__
+#define __I915_GEM_REGION_H__
+
+#include <linux/types.h>
+
+struct intel_memory_region;
+struct drm_i915_gem_object;
+struct sg_table;
+
+int i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj);
+void i915_gem_object_put_pages_buddy(struct drm_i915_gem_object *obj,
+				     struct sg_table *pages);
+
+void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
+					struct intel_memory_region *mem);
+void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj);
+
+struct drm_i915_gem_object *
+i915_gem_object_create_region(struct intel_memory_region *mem,
+			      resource_size_t size,
+			      unsigned int flags);
+
+#endif
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +78 -0

102 lines not on this page · raw message

drivers/gpu/drm/i915/i915_drv.h +1 -0
index cde4c7fb5570..dcbc6e6394fc 100644
@@ -85,6 +85,7 @@
 #include "intel_device_info.h"
 #include "intel_pch.h"
 #include "intel_runtime_pm.h"
+#include "intel_memory_region.h"
 #include "intel_uncore.h"
 #include "intel_wakeref.h"
 #include "intel_wopcm.h"
drivers/gpu/drm/i915/intel_memory_region.c new file +191 -0

191 lines not on this page · raw message

drivers/gpu/drm/i915/intel_memory_region.h new file +83 -0

83 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/i915_mock_selftests.h +1 -0
index b88084fe3269..aa5a0e7f5d9e 100644
@@ -26,3 +26,4 @@ selftest(gtt, i915_gem_gtt_mock_selftests)
 selftest(hugepages, i915_gem_huge_page_mock_selftests)
 selftest(contexts, i915_gem_context_mock_selftests)
 selftest(buddy, i915_buddy_mock_selftests)
+selftest(memory_region, intel_memory_region_mock_selftests)
drivers/gpu/drm/i915/selftests/intel_memory_region.c new file +115 -0

115 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/mock_gem_device.c +1 -0
index 70a7026db08d..8264d38fa690 100644
@@ -33,6 +33,7 @@
 #include "mock_gem_device.h"
 #include "mock_gtt.h"
 #include "mock_uncore.h"
+#include "mock_region.h"
 
 #include "gem/selftests/mock_context.h"
 #include "gem/selftests/mock_gem_object.h"
drivers/gpu/drm/i915/selftests/mock_region.c new file +59 -0

59 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/mock_region.h new file +16 -0
new file mode 100644
index 000000000000..24608089d833
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __MOCK_REGION_H
+#define __MOCK_REGION_H
+
+struct intel_memory_region *
+mock_region_create(struct drm_i915_private *i915,
+		   resource_size_t start,
+		   resource_size_t size,
+		   resource_size_t min_page_size,
+		   resource_size_t io_start);
+
+#endif /* !__MOCK_REGION_H */
Signature · 6 lines
2.20.1

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

PATCH v3 3/21 drm/i915/region: support contiguous allocations

In reply to Matthew Auld

Some kernel internal objects may need to be allocated as a contiguous block, also thinking ahead the various kernel io_mapping interfaces seem to expect it, although this is purely a limitation in the kernel API...so perhaps something to be improved.

Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
Cc Michael J Ruhl <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.h    |   6 +
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   4 +
 drivers/gpu/drm/i915/gem/i915_gem_region.c    |  15 +-
 drivers/gpu/drm/i915/gem/i915_gem_region.h    |   3 +-
 .../gpu/drm/i915/gem/selftests/huge_pages.c   |  71 ++++----
 drivers/gpu/drm/i915/intel_memory_region.c    |   9 +-
 drivers/gpu/drm/i915/intel_memory_region.h    |   3 +-
 .../drm/i915/selftests/intel_memory_region.c  | 165 ++++++++++++++++++
 drivers/gpu/drm/i915/selftests/mock_region.c  |   2 +-
 9 files changed, 239 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -0
index 086a9bf5adcc..dfd16d65630f 100644
@@ -139,6 +139,12 @@ i915_gem_object_is_readonly(const struct drm_i915_gem_object *obj)
 	return obj->base.vma_node.readonly;
 }
 
+static inline bool
+i915_gem_object_is_contiguous(const struct drm_i915_gem_object *obj)
+{
+	return obj->flags & I915_BO_ALLOC_CONTIGUOUS;
+}
+
 static inline bool
 i915_gem_object_type_has(const struct drm_i915_gem_object *obj,
 			 unsigned long flags)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +4 -0
index 11390586cfe1..c6a712cf7d7a 100644
@@ -119,6 +119,10 @@ struct drm_i915_gem_object {
 
 	I915_SELFTEST_DECLARE(struct list_head st_link);
 
+	unsigned long flags;
+#define I915_BO_ALLOC_CONTIGUOUS BIT(0)
+#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS)
+
 	/*
 	 * Is the object to be mapped as read-only to the GPU
 	 * Only honoured if hardware has relevant pte bit
drivers/gpu/drm/i915/gem/i915_gem_region.c +12 -3
index 5fc6e4540f82..04cb9f72945e 100644
@@ -23,10 +23,10 @@ i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
 {
 	struct intel_memory_region *mem = obj->mm.region;
 	struct list_head *blocks = &obj->mm.blocks;
-	unsigned int flags = I915_ALLOC_MIN_PAGE_SIZE;
 	resource_size_t size = obj->base.size;
 	resource_size_t prev_end;
 	struct i915_buddy_block *block;
+	unsigned int flags;
 	struct sg_table *st;
 	struct scatterlist *sg;
 	unsigned int sg_page_sizes;
@@ -42,6 +42,10 @@ i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
 		return -ENOMEM;
 	}
 
+	flags = I915_ALLOC_MIN_PAGE_SIZE;
+	if (obj->flags & I915_BO_ALLOC_CONTIGUOUS)
+		flags |= I915_ALLOC_CONTIGUOUS;
+
 	ret = __intel_memory_region_get_pages_buddy(mem, size, flags, blocks);
 	if (ret)
 		goto err_free_sg;
@@ -56,7 +60,8 @@ i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
 	list_for_each_entry(block, blocks, link) {
 		u64 block_size, offset;
 
-		block_size = i915_buddy_block_size(&mem->mm, block);
+		block_size = min_t(u64, size,
+				   i915_buddy_block_size(&mem->mm, block));
 		offset = i915_buddy_block_offset(block);
 
 		GEM_BUG_ON(overflows_type(block_size, sg->length));
@@ -98,10 +103,12 @@ i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
 }
 
 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
-					struct intel_memory_region *mem)
+					struct intel_memory_region *mem,
+					unsigned long flags)
 {
 	INIT_LIST_HEAD(&obj->mm.blocks);
 	obj->mm.region = intel_memory_region_get(mem);
+	obj->flags = flags;
 }
 
 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj)
@@ -116,6 +123,8 @@ i915_gem_object_create_region(struct intel_memory_region *mem,
 {
 	struct drm_i915_gem_object *obj;
 
+	GEM_BUG_ON(flags & ~I915_BO_ALLOC_FLAGS);
+
 	if (!mem)
 		return ERR_PTR(-ENODEV);
 
drivers/gpu/drm/i915/gem/i915_gem_region.h +2 -1
index ebddc86d78f7..f2ff6f8bff74 100644
@@ -17,7 +17,8 @@ void i915_gem_object_put_pages_buddy(struct drm_i915_gem_object *obj,
 				     struct sg_table *pages);
 
 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
-					struct intel_memory_region *mem);
+					struct intel_memory_region *mem,
+					unsigned long flags);
 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj);
 
 struct drm_i915_gem_object *
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +39 -32

91 lines not on this page · raw message

drivers/gpu/drm/i915/intel_memory_region.c +8 -1
index 2ef67c397fca..98006618e871 100644
@@ -47,8 +47,8 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem,
 				      unsigned int flags,
 				      struct list_head *blocks)
 {
-	unsigned long n_pages = size >> ilog2(mem->mm.chunk_size);
 	unsigned int min_order = 0;
+	unsigned long n_pages;
 
 	GEM_BUG_ON(!IS_ALIGNED(size, mem->mm.chunk_size));
 	GEM_BUG_ON(!list_empty(blocks));
@@ -58,6 +58,13 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem,
 			    ilog2(mem->mm.chunk_size);
 	}
 
+	if (flags & I915_ALLOC_CONTIGUOUS) {
+		size = roundup_pow_of_two(size);
+		min_order = ilog2(size) - ilog2(mem->mm.chunk_size);
+	}
+
+	n_pages = size >> ilog2(mem->mm.chunk_size);
+
 	mutex_lock(&mem->mm_lock);
 
 	do {
drivers/gpu/drm/i915/intel_memory_region.h +2 -1
index 2ea17d6c31ed..29b86ca17dd9 100644
@@ -18,7 +18,8 @@ struct drm_i915_gem_object;
 struct intel_memory_region;
 struct sg_table;
 
-#define I915_ALLOC_MIN_PAGE_SIZE   BIT(0)
+#define I915_ALLOC_MIN_PAGE_SIZE  BIT(0)
+#define I915_ALLOC_CONTIGUOUS     BIT(1)
 
 struct intel_memory_region_ops {
 	unsigned int flags;
drivers/gpu/drm/i915/selftests/intel_memory_region.c +165 -0

181 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/mock_region.c +1 -1
index 0e9a575ede3b..7b0c99ddc2d5 100644
@@ -36,7 +36,7 @@ mock_object_create(struct intel_memory_region *mem,
 
 	i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
 
-	i915_gem_object_init_memory_region(obj, mem);
+	i915_gem_object_init_memory_region(obj, mem, flags);
 
 	return obj;
 }
Signature · 6 lines
2.20.1

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

PATCH v3 4/21 drm/i915/region: support volatile objects

In reply to Matthew Auld

Volatile objects are marked as DONTNEED while pinned, therefore once unpinned the backing store can be discarded. This is limited to kernel internal objects.

Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_internal.c    | 17 +++++++++--------
 drivers/gpu/drm/i915/gem/i915_gem_object.h      | 12 ++++++++++++
 .../gpu/drm/i915/gem/i915_gem_object_types.h    |  9 ++++++++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  6 ++++++
 drivers/gpu/drm/i915/gem/i915_gem_region.c      | 13 +++++++++++++
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 12 ++++--------
 drivers/gpu/drm/i915/intel_memory_region.c      |  4 ++++
 drivers/gpu/drm/i915/intel_memory_region.h      |  5 +++++
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c   |  5 ++---
 9 files changed, 63 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_internal.c +9 -8
index 0c41e04ab8fa..5ae694c24df4 100644
@@ -117,13 +117,6 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)
 		goto err;
 	}
 
-	/* Mark the pages as dontneed whilst they are still pinned. As soon
-	 * as they are unpinned they are allowed to be reaped by the shrinker,
-	 * and the caller is expected to repopulate - the contents of this
-	 * object are only valid whilst active and pinned.
-	 */
-	obj->mm.madv = I915_MADV_DONTNEED;
-
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
 	return 0;
@@ -143,7 +136,6 @@ static void i915_gem_object_put_pages_internal(struct drm_i915_gem_object *obj,
 	internal_free_pages(pages);
 
 	obj->mm.dirty = false;
-	obj->mm.madv = I915_MADV_WILLNEED;
 }
 
 static const struct drm_i915_gem_object_ops i915_gem_object_internal_ops = {
@@ -188,6 +180,15 @@ i915_gem_object_create_internal(struct drm_i915_private *i915,
 	drm_gem_private_object_init(&i915->drm, &obj->base, size);
 	i915_gem_object_init(obj, &i915_gem_object_internal_ops);
 
+	/*
+	 * Mark the object as volatile, such that the pages are marked as
+	 * dontneed whilst they are still pinned. As soon as they are unpinned
+	 * they are allowed to be reaped by the shrinker, and the caller is
+	 * expected to repopulate - the contents of this object are only valid
+	 * whilst active and pinned.
+	 */
+	i915_gem_object_set_volatile(obj);
+
 	obj->read_domains = I915_GEM_DOMAIN_CPU;
 	obj->write_domain = I915_GEM_DOMAIN_CPU;
 
drivers/gpu/drm/i915/gem/i915_gem_object.h +12 -0
index dfd16d65630f..c5e14c9c805c 100644
@@ -145,6 +145,18 @@ i915_gem_object_is_contiguous(const struct drm_i915_gem_object *obj)
 	return obj->flags & I915_BO_ALLOC_CONTIGUOUS;
 }
 
+static inline bool
+i915_gem_object_is_volatile(const struct drm_i915_gem_object *obj)
+{
+	return obj->flags & I915_BO_ALLOC_VOLATILE;
+}
+
+static inline void
+i915_gem_object_set_volatile(struct drm_i915_gem_object *obj)
+{
+	obj->flags |= I915_BO_ALLOC_VOLATILE;
+}
+
 static inline bool
 i915_gem_object_type_has(const struct drm_i915_gem_object *obj,
 			 unsigned long flags)
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +8 -1
index c6a712cf7d7a..a387e3ee728b 100644
@@ -121,7 +121,8 @@ struct drm_i915_gem_object {
 
 	unsigned long flags;
 #define I915_BO_ALLOC_CONTIGUOUS BIT(0)
-#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS)
+#define I915_BO_ALLOC_VOLATILE   BIT(1)
+#define I915_BO_ALLOC_FLAGS (I915_BO_ALLOC_CONTIGUOUS | I915_BO_ALLOC_VOLATILE)
 
 	/*
 	 * Is the object to be mapped as read-only to the GPU
@@ -172,6 +173,12 @@ struct drm_i915_gem_object {
 		 * List of memory region blocks allocated for this object.
 		 */
 		struct list_head blocks;
+		/**
+		 * Element within memory_region->objects or region->purgeable
+		 * if the object is marked as DONTNEED. Access is protected by
+		 * region->obj_lock.
+		 */
+		struct list_head region_link;
 
 		struct sg_table *pages;
 		void *mapping;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +6 -0
index 2e941f093a20..b0ec0959c13f 100644
@@ -18,6 +18,9 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 
 	lockdep_assert_held(&obj->mm.lock);
 
+	if (i915_gem_object_is_volatile(obj))
+		obj->mm.madv = I915_MADV_DONTNEED;
+
 	/* Make the pages coherent with the GPU (flushing any swapin). */
 	if (obj->cache_dirty) {
 		obj->write_domain = 0;
@@ -160,6 +163,9 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 	if (IS_ERR_OR_NULL(pages))
 		return pages;
 
+	if (i915_gem_object_is_volatile(obj))
+		obj->mm.madv = I915_MADV_WILLNEED;
+
 	i915_gem_object_make_unshrinkable(obj);
 
 	if (obj->mm.mapping) {
drivers/gpu/drm/i915/gem/i915_gem_region.c +13 -0
index 04cb9f72945e..663254b3da21 100644
@@ -109,10 +109,23 @@ void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
 	INIT_LIST_HEAD(&obj->mm.blocks);
 	obj->mm.region = intel_memory_region_get(mem);
 	obj->flags = flags;
+
+	mutex_lock(&mem->obj_lock);
+
+	if (obj->flags & I915_BO_ALLOC_VOLATILE)
+		list_add(&obj->mm.region_link, &mem->purgeable);
+	else
+		list_add(&obj->mm.region_link, &mem->objects);
+
+	mutex_unlock(&mem->obj_lock);
 }
 
 void i915_gem_object_release_memory_region(struct drm_i915_gem_object *obj)
 {
+	mutex_lock(&obj->mm.region->obj_lock);
+	list_del(&obj->mm.region_link);
+	mutex_unlock(&obj->mm.region->obj_lock);
+
 	intel_memory_region_put(obj->mm.region);
 }
 
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +4 -8
index 63a4743e5f54..f27772f6779a 100644
@@ -115,8 +115,6 @@ static int get_huge_pages(struct drm_i915_gem_object *obj)
 	if (i915_gem_gtt_prepare_pages(obj, st))
 		goto err;
 
-	obj->mm.madv = I915_MADV_DONTNEED;
-
 	GEM_BUG_ON(sg_page_sizes != obj->mm.page_mask);
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
@@ -137,7 +135,6 @@ static void put_huge_pages(struct drm_i915_gem_object *obj,
 	huge_pages_free_pages(pages);
 
 	obj->mm.dirty = false;
-	obj->mm.madv = I915_MADV_WILLNEED;
 }
 
 static const struct drm_i915_gem_object_ops huge_page_ops = {
@@ -170,6 +167,8 @@ huge_pages_object(struct drm_i915_private *i915,
 	drm_gem_private_object_init(&i915->drm, &obj->base, size);
 	i915_gem_object_init(obj, &huge_page_ops);
 
+	i915_gem_object_set_volatile(obj);
+
 	obj->write_domain = I915_GEM_DOMAIN_CPU;
 	obj->read_domains = I915_GEM_DOMAIN_CPU;
 	obj->cache_level = I915_CACHE_NONE;
@@ -229,8 +228,6 @@ static int fake_get_huge_pages(struct drm_i915_gem_object *obj)
 
 	i915_sg_trim(st);
 
-	obj->mm.madv = I915_MADV_DONTNEED;
-
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
 	return 0;
@@ -263,8 +260,6 @@ static int fake_get_huge_pages_single(struct drm_i915_gem_object *obj)
 	sg_dma_len(sg) = obj->base.size;
 	sg_dma_address(sg) = page_size;
 
-	obj->mm.madv = I915_MADV_DONTNEED;
-
 	__i915_gem_object_set_pages(obj, st, sg->length);
 
 	return 0;
@@ -283,7 +278,6 @@ static void fake_put_huge_pages(struct drm_i915_gem_object *obj,
 {
 	fake_free_huge_pages(obj, pages);
 	obj->mm.dirty = false;
-	obj->mm.madv = I915_MADV_WILLNEED;
 }
 
 static const struct drm_i915_gem_object_ops fake_ops = {
@@ -323,6 +317,8 @@ fake_huge_pages_object(struct drm_i915_private *i915, u64 size, bool single)
 	else
 		i915_gem_object_init(obj, &fake_ops);
 
+	i915_gem_object_set_volatile(obj);
+
 	obj->write_domain = I915_GEM_DOMAIN_CPU;
 	obj->read_domains = I915_GEM_DOMAIN_CPU;
 	obj->cache_level = I915_CACHE_NONE;
drivers/gpu/drm/i915/intel_memory_region.c +4 -0
index 98006618e871..fe808899cbf8 100644
@@ -152,6 +152,10 @@ intel_memory_region_create(struct drm_i915_private *i915,
 	mem->min_page_size = min_page_size;
 	mem->ops = ops;
 
+	mutex_init(&mem->obj_lock);
+	INIT_LIST_HEAD(&mem->objects);
+	INIT_LIST_HEAD(&mem->purgeable);
+
 	mutex_init(&mem->mm_lock);
 
 	if (ops->init) {
drivers/gpu/drm/i915/intel_memory_region.h +5 -0
index 29b86ca17dd9..323270a1ef67 100644
@@ -52,6 +52,11 @@ struct intel_memory_region {
 	unsigned int type;
 	unsigned int instance;
 	unsigned int id;
+
+	/* Protects access to objects and purgeable */
+	struct mutex obj_lock;
+	struct list_head objects;
+	struct list_head purgeable;
 };
 
 int intel_memory_region_init_buddy(struct intel_memory_region *mem);
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +2 -3
index 165b3a7f9744..ebe735df6504 100644
@@ -82,8 +82,6 @@ static int fake_get_pages(struct drm_i915_gem_object *obj)
 	}
 	GEM_BUG_ON(rem);
 
-	obj->mm.madv = I915_MADV_DONTNEED;
-
 	__i915_gem_object_set_pages(obj, pages, sg_page_sizes);
 
 	return 0;
@@ -95,7 +93,6 @@ static void fake_put_pages(struct drm_i915_gem_object *obj,
 {
 	fake_free_pages(obj, pages);
 	obj->mm.dirty = false;
-	obj->mm.madv = I915_MADV_WILLNEED;
 }
 
 static const struct drm_i915_gem_object_ops fake_ops = {
@@ -122,6 +119,8 @@ fake_dma_object(struct drm_i915_private *i915, u64 size)
 	drm_gem_private_object_init(&i915->drm, &obj->base, size);
 	i915_gem_object_init(obj, &fake_ops);
 
+	i915_gem_object_set_volatile(obj);
+
 	obj->write_domain = I915_GEM_DOMAIN_CPU;
 	obj->read_domains = I915_GEM_DOMAIN_CPU;
 	obj->cache_level = I915_CACHE_NONE;
Signature · 6 lines
2.20.1

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

PATCH v3 5/21 drm/i915: Add memory region information to device_info

In reply to Matthew Auld

From: Abdiel Janulgue <[email protected]>

Exposes available regions for the platform. Shared memory will always be available.

---
 drivers/gpu/drm/i915/i915_drv.h          | 2 ++
 drivers/gpu/drm/i915/intel_device_info.h | 2 ++
 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index dcbc6e6394fc..b7be46faef2d 100644
@@ -2129,6 +2129,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
 
 #define HAS_IPC(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ipc)
 
+#define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i))
+
 #define HAS_GT_UC(dev_priv)	(INTEL_INFO(dev_priv)->has_gt_uc)
 
 /* Having GuC is not the same as using GuC */
drivers/gpu/drm/i915/intel_device_info.h +2 -0
index 0cdc2465534b..e9940f932d26 100644
@@ -160,6 +160,8 @@ struct intel_device_info {
 
 	unsigned int page_sizes; /* page sizes supported by the HW */
 
+	u32 memory_regions; /* regions supported by the HW */
+
 	u32 display_mmio_offset;
 
 	u8 pipe_mask;
Signature · 6 lines
2.20.1

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

PATCH v3 6/21 drm/i915: support creating LMEM objects

In reply to Matthew Auld

We currently define LMEM, or local memory, as just another memory region, like system memory or stolen, which we can expose to userspace and can be mapped to the CPU via some BAR.

Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
---
 drivers/gpu/drm/i915/Makefile                 |  2 +
 drivers/gpu/drm/i915/gem/i915_gem_lmem.c      | 29 +++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_lmem.h      | 23 ++++++++++
 drivers/gpu/drm/i915/i915_drv.h               |  5 +++
 drivers/gpu/drm/i915/intel_memory_region.c    | 10 +++++
 drivers/gpu/drm/i915/intel_memory_region.h    | 30 +++++++++++++
 drivers/gpu/drm/i915/intel_region_lmem.c      | 43 +++++++++++++++++++
 drivers/gpu/drm/i915/intel_region_lmem.h      | 11 +++++
 .../drm/i915/selftests/i915_live_selftests.h  |  1 +
 .../drm/i915/selftests/intel_memory_region.c  | 40 +++++++++++++++++
 10 files changed, 194 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_lmem.c
 create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_lmem.h
 create mode 100644 drivers/gpu/drm/i915/intel_region_lmem.c
 create mode 100644 drivers/gpu/drm/i915/intel_region_lmem.h
drivers/gpu/drm/i915/Makefile +2 -0
index 6f0817bcc688..3154874e32b0 100644
@@ -117,6 +117,7 @@ gem-y += \
 	gem/i915_gem_internal.o \
 	gem/i915_gem_object.o \
 	gem/i915_gem_object_blt.o \
+	gem/i915_gem_lmem.o \
 	gem/i915_gem_mman.o \
 	gem/i915_gem_pages.o \
 	gem/i915_gem_phys.o \
@@ -145,6 +146,7 @@ i915-y += \
 	  i915_scheduler.o \
 	  i915_trace_points.o \
 	  i915_vma.o \
+	  intel_region_lmem.o \
 	  intel_wopcm.o
 
 # general-purpose microcontroller (GuC) support
drivers/gpu/drm/i915/gem/i915_gem_lmem.c new file +29 -0
new file mode 100644
index 000000000000..aadd5d5a69da
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "intel_memory_region.h"
+#include "gem/i915_gem_region.h"
+#include "gem/i915_gem_lmem.h"
+#include "i915_drv.h"
+
+const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
+	.get_pages = i915_gem_object_get_pages_buddy,
+	.put_pages = i915_gem_object_put_pages_buddy,
+	.release = i915_gem_object_release_memory_region,
+};
+
+bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
+{
+	return obj->ops == &i915_gem_lmem_obj_ops;
+}
+
+struct drm_i915_gem_object *
+i915_gem_object_create_lmem(struct drm_i915_private *i915,
+			    resource_size_t size,
+			    unsigned int flags)
+{
+	return i915_gem_object_create_region(i915->mm.regions[INTEL_MEMORY_LMEM],
+					     size, flags);
+}
drivers/gpu/drm/i915/gem/i915_gem_lmem.h new file +23 -0
new file mode 100644
index 000000000000..ebc15fe24f58
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_GEM_LMEM_H
+#define __I915_GEM_LMEM_H
+
+#include <linux/types.h>
+
+struct drm_i915_private;
+struct drm_i915_gem_object;
+
+extern const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops;
+
+bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj);
+
+struct drm_i915_gem_object *
+i915_gem_object_create_lmem(struct drm_i915_private *i915,
+			    resource_size_t size,
+			    unsigned int flags);
+
+#endif /* !__I915_GEM_LMEM_H */
drivers/gpu/drm/i915/i915_drv.h +5 -0
index b7be46faef2d..ff8e21e585a3 100644
@@ -100,6 +100,8 @@
 #include "i915_vma.h"
 #include "i915_irq.h"
 
+#include "intel_region_lmem.h"
+
 #include "intel_gvt.h"
 
 /* General customization:
@@ -679,6 +681,8 @@ struct i915_gem_mm {
 	 */
 	struct vfsmount *gemfs;
 
+	struct intel_memory_region *regions[INTEL_MEMORY_UNKNOWN];
+
 	struct notifier_block oom_notifier;
 	struct notifier_block vmap_notifier;
 	struct shrinker shrinker;
@@ -2130,6 +2134,7 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
 #define HAS_IPC(dev_priv)		 (INTEL_INFO(dev_priv)->display.has_ipc)
 
 #define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i))
+#define HAS_LMEM(i915) HAS_REGION(i915, REGION_LMEM)
 
 #define HAS_GT_UC(dev_priv)	(INTEL_INFO(dev_priv)->has_gt_uc)
 
drivers/gpu/drm/i915/intel_memory_region.c +10 -0
index fe808899cbf8..920f9590f410 100644
@@ -6,6 +6,16 @@
 #include "intel_memory_region.h"
 #include "i915_drv.h"
 
+/* XXX: Hysterical raisins. BIT(inst) needs to just be (inst) at some point. */
+#define REGION_MAP(type, inst) \
+	BIT((type) + INTEL_MEMORY_TYPE_SHIFT) | BIT(inst)
+
+const u32 intel_region_map[] = {
+	[INTEL_MEMORY_SMEM] = REGION_MAP(INTEL_SMEM, 0),
+	[INTEL_MEMORY_LMEM] = REGION_MAP(INTEL_LMEM, 0),
+	[INTEL_MEMORY_STOLEN] = REGION_MAP(INTEL_STOLEN, 0),
+};
+
 static u64
 intel_memory_region_free_pages(struct intel_memory_region *mem,
 			       struct list_head *blocks)
drivers/gpu/drm/i915/intel_memory_region.h +30 -0
index 323270a1ef67..39d2c4ec3302 100644
@@ -18,9 +18,39 @@ struct drm_i915_gem_object;
 struct intel_memory_region;
 struct sg_table;
 
+/**
+ *  Base memory type
+ */
+enum intel_memory_type {
+	INTEL_SMEM = 0,
+	INTEL_LMEM,
+	INTEL_STOLEN,
+};
+
+enum intel_region_id {
+	INTEL_MEMORY_SMEM = 0,
+	INTEL_MEMORY_LMEM,
+	INTEL_MEMORY_STOLEN,
+	INTEL_MEMORY_UNKNOWN, /* Should be last */
+};
+
+#define REGION_SMEM     BIT(INTEL_MEMORY_SMEM)
+#define REGION_LMEM     BIT(INTEL_MEMORY_LMEM)
+#define REGION_STOLEN   BIT(INTEL_MEMORY_STOLEN)
+
+#define INTEL_MEMORY_TYPE_SHIFT 16
+
+#define MEMORY_TYPE_FROM_REGION(r) (ilog2((r) >> INTEL_MEMORY_TYPE_SHIFT))
+#define MEMORY_INSTANCE_FROM_REGION(r) (ilog2((r) & 0xffff))
+
 #define I915_ALLOC_MIN_PAGE_SIZE  BIT(0)
 #define I915_ALLOC_CONTIGUOUS     BIT(1)
 
+/**
+ * Memory regions encoded as type | instance
+ */
+extern const u32 intel_region_map[];
+
 struct intel_memory_region_ops {
 	unsigned int flags;
 
drivers/gpu/drm/i915/intel_region_lmem.c new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/i915/intel_region_lmem.h new file +11 -0
new file mode 100644
index 000000000000..ed2a3bab6443
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __INTEL_REGION_LMEM_H
+#define __INTEL_REGION_LMEM_H
+
+extern const struct intel_memory_region_ops intel_region_lmem_ops;
+
+#endif /* !__INTEL_REGION_LMEM_H */
drivers/gpu/drm/i915/selftests/i915_live_selftests.h +1 -0
index 6713efea350b..d00c198ba1a2 100644
@@ -32,6 +32,7 @@ selftest(gem_contexts, i915_gem_context_live_selftests)
 selftest(blt, i915_gem_object_blt_live_selftests)
 selftest(client, i915_gem_client_blt_live_selftests)
 selftest(reset, intel_reset_live_selftests)
+selftest(memory_region, intel_memory_region_live_selftests)
 selftest(hangcheck, intel_hangcheck_live_selftests)
 selftest(execlists, intel_execlists_live_selftests)
 selftest(guc, intel_guc_live_selftest)
drivers/gpu/drm/i915/selftests/intel_memory_region.c +40 -0
index 913fb9d6b05b..f54eccffaa01 100644
@@ -11,8 +11,10 @@
 #include "mock_gem_device.h"
 #include "mock_region.h"
 
+#include "gem/i915_gem_lmem.h"
 #include "gem/i915_gem_region.h"
 #include "gem/selftests/mock_context.h"
+#include "gt/intel_gt.h"
 #include "selftests/i915_random.h"
 
 static void close_objects(struct intel_memory_region *mem,
@@ -250,6 +252,27 @@ static int igt_mock_contiguous(void *arg)
 	return err;
 }
 
+static int igt_lmem_create(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	struct drm_i915_gem_object *obj;
+	int err = 0;
+
+	obj = i915_gem_object_create_lmem(i915, PAGE_SIZE, 0);
+	if (IS_ERR(obj))
+		return PTR_ERR(obj);
+
+	err = i915_gem_object_pin_pages(obj);
+	if (err)
+		goto out_put;
+
+	i915_gem_object_unpin_pages(obj);
+out_put:
+	i915_gem_object_put(obj);
+
+	return err;
+}
+
 int intel_memory_region_mock_selftests(void)
 {
 	static const struct i915_subtest tests[] = {
@@ -278,3 +301,20 @@ int intel_memory_region_mock_selftests(void)
 	drm_dev_put(&i915->drm);
 	return err;
 }
+
+int intel_memory_region_live_selftests(struct drm_i915_private *i915)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(igt_lmem_create),
+	};
+
+	if (!HAS_LMEM(i915)) {
+		pr_info("device lacks LMEM support, skipping\n");
+		return 0;
+	}
+
+	if (intel_gt_is_wedged(&i915->gt))
+		return 0;
+
+	return i915_live_subtests(tests, i915);
+}
Signature · 6 lines
2.20.1

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

PATCH v3 7/21 drm/i915: setup io-mapping for LMEM

In reply to Matthew Auld

From: Abdiel Janulgue <[email protected]>

---
 drivers/gpu/drm/i915/intel_region_lmem.c | 28 ++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_region_lmem.c +26 -2
index 7a3f96e1f766..051069664074 100644
@@ -36,8 +36,32 @@ lmem_create_object(struct intel_memory_region *mem,
 	return obj;
 }
 
+static void
+region_lmem_release(struct intel_memory_region *mem)
+{
+	io_mapping_fini(&mem->iomap);
+	intel_memory_region_release_buddy(mem);
+}
+
+static int
+region_lmem_init(struct intel_memory_region *mem)
+{
+	int ret;
+
+	if (!io_mapping_init_wc(&mem->iomap,
+				mem->io_start,
+				resource_size(&mem->region)))
+		return -EIO;
+
+	ret = intel_memory_region_init_buddy(mem);
+	if (ret)
+		io_mapping_fini(&mem->iomap);
+
+	return ret;
+}
+
 const struct intel_memory_region_ops intel_region_lmem_ops = {
-	.init = intel_memory_region_init_buddy,
-	.release = intel_memory_region_release_buddy,
+	.init = region_lmem_init,
+	.release = region_lmem_release,
 	.create_object = lmem_create_object,
 };
Signature · 6 lines
2.20.1

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

PATCH v3 8/21 drm/i915/lmem: support kernel mapping

In reply to Matthew Auld

From: Abdiel Janulgue <[email protected]>

We can create LMEM objects, but we also need to support mapping them into kernel space for internal use.

---
 drivers/gpu/drm/i915/gem/i915_gem_lmem.c      |  36 ++++++
 drivers/gpu/drm/i915/gem/i915_gem_lmem.h      |   8 ++
 .../gpu/drm/i915/gem/i915_gem_object_types.h  |   9 +-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c     |  22 +++-
 .../drm/i915/selftests/intel_memory_region.c  | 115 ++++++++++++++++++
 5 files changed, 182 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_lmem.c +36 -0
index aadd5d5a69da..fd8b63dd154d 100644
@@ -9,11 +9,47 @@
 #include "i915_drv.h"
 
 const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
+	.flags = I915_GEM_OBJECT_HAS_IOMEM,
+
 	.get_pages = i915_gem_object_get_pages_buddy,
 	.put_pages = i915_gem_object_put_pages_buddy,
 	.release = i915_gem_object_release_memory_region,
 };
 
+/* XXX: Time to vfunc your life up? */
+void __iomem *i915_gem_object_lmem_io_map_page(struct drm_i915_gem_object *obj,
+					       unsigned long n)
+{
+	resource_size_t offset;
+
+	offset = i915_gem_object_get_dma_address(obj, n);
+
+	return io_mapping_map_wc(&obj->mm.region->iomap, offset, PAGE_SIZE);
+}
+
+void __iomem *i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj,
+						      unsigned long n)
+{
+	resource_size_t offset;
+
+	offset = i915_gem_object_get_dma_address(obj, n);
+
+	return io_mapping_map_atomic_wc(&obj->mm.region->iomap, offset);
+}
+
+void __iomem *i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
+					  unsigned long n,
+					  unsigned long size)
+{
+	resource_size_t offset;
+
+	GEM_BUG_ON(!i915_gem_object_is_contiguous(obj));
+
+	offset = i915_gem_object_get_dma_address(obj, n);
+
+	return io_mapping_map_wc(&obj->mm.region->iomap, offset, size);
+}
+
 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
 {
 	return obj->ops == &i915_gem_lmem_obj_ops;
drivers/gpu/drm/i915/gem/i915_gem_lmem.h +8 -0
index ebc15fe24f58..31a6462bdbb6 100644
@@ -13,6 +13,14 @@ struct drm_i915_gem_object;
 
 extern const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops;
 
+void __iomem *i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
+					  unsigned long n, unsigned long size);
+void __iomem *i915_gem_object_lmem_io_map_page(struct drm_i915_gem_object *obj,
+					       unsigned long n);
+void __iomem *
+i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj,
+					unsigned long n);
+
 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj);
 
 struct drm_i915_gem_object *
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -4
index a387e3ee728b..96008374a412 100644
@@ -31,10 +31,11 @@ struct i915_lut_handle {
 struct drm_i915_gem_object_ops {
 	unsigned int flags;
 #define I915_GEM_OBJECT_HAS_STRUCT_PAGE	BIT(0)
-#define I915_GEM_OBJECT_IS_SHRINKABLE	BIT(1)
-#define I915_GEM_OBJECT_IS_PROXY	BIT(2)
-#define I915_GEM_OBJECT_NO_GGTT		BIT(3)
-#define I915_GEM_OBJECT_ASYNC_CANCEL	BIT(4)
+#define I915_GEM_OBJECT_HAS_IOMEM	BIT(1)
+#define I915_GEM_OBJECT_IS_SHRINKABLE	BIT(2)
+#define I915_GEM_OBJECT_IS_PROXY	BIT(3)
+#define I915_GEM_OBJECT_NO_GGTT		BIT(4)
+#define I915_GEM_OBJECT_ASYNC_CANCEL	BIT(5)
 
 	/* Interface between the GEM object and its backing storage.
 	 * get_pages() is called once prior to the use of the associated set
drivers/gpu/drm/i915/gem/i915_gem_pages.c +18 -4
index b0ec0959c13f..cf7f5a3cb210 100644
@@ -7,6 +7,7 @@
 #include "i915_drv.h"
 #include "i915_gem_object.h"
 #include "i915_scatterlist.h"
+#include "i915_gem_lmem.h"
 
 void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 				 struct sg_table *pages,
@@ -172,7 +173,9 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 		void *ptr;
 
 		ptr = page_mask_bits(obj->mm.mapping);
-		if (is_vmalloc_addr(ptr))
+		if (i915_gem_object_is_lmem(obj))
+			io_mapping_unmap(ptr);
+		else if (is_vmalloc_addr(ptr))
 			vunmap(ptr);
 		else
 			kunmap(kmap_to_page(ptr));
@@ -231,7 +234,7 @@ int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
 }
 
 /* The 'mapping' part of i915_gem_object_pin_map() below */
-static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
+static void *i915_gem_object_map(struct drm_i915_gem_object *obj,
 				 enum i915_map_type type)
 {
 	unsigned long n_pages = obj->base.size >> PAGE_SHIFT;
@@ -244,6 +247,13 @@ static void *i915_gem_object_map(const struct drm_i915_gem_object *obj,
 	pgprot_t pgprot;
 	void *addr;
 
+	if (i915_gem_object_is_lmem(obj)) {
+		if (type != I915_MAP_WC)
+			return NULL;
+
+		return i915_gem_object_lmem_io_map(obj, 0, obj->base.size);
+	}
+
 	/* A single page can always be kmapped */
 	if (n_pages == 1 && type == I915_MAP_WB)
 		return kmap(sg_page(sgt->sgl));
@@ -285,11 +295,13 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 			      enum i915_map_type type)
 {
 	enum i915_map_type has_type;
+	unsigned int flags;
 	bool pinned;
 	void *ptr;
 	int err;
 
-	if (unlikely(!i915_gem_object_has_struct_page(obj)))
+	flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE | I915_GEM_OBJECT_HAS_IOMEM;
+	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
 	err = mutex_lock_interruptible(&obj->mm.lock);
@@ -321,7 +333,9 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 			goto err_unpin;
 		}
 
-		if (is_vmalloc_addr(ptr))
+		if (i915_gem_object_is_lmem(obj))
+			io_mapping_unmap(ptr);
+		else if (is_vmalloc_addr(ptr))
 			vunmap(ptr);
 		else
 			kunmap(kmap_to_page(ptr));
drivers/gpu/drm/i915/selftests/intel_memory_region.c +115 -0

135 lines not on this page · raw message

Signature · 6 lines
2.20.1

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

PATCH v3 9/21 drm/i915/selftests: add write-dword test for LMEM

In reply to Matthew Auld

Simple test writing to dwords across an object, using various engines in a randomized order, checking that our writes land from the cpu.

---
 .../drm/i915/selftests/intel_memory_region.c  | 167 ++++++++++++++++++
 1 file changed, 167 insertions(+)
drivers/gpu/drm/i915/selftests/intel_memory_region.c +167 -0
index 48244d885521..76c0ab0aa78c 100644
@@ -7,13 +7,16 @@
 
 #include "../i915_selftest.h"
 
+
 #include "mock_drm.h"
 #include "mock_gem_device.h"
 #include "mock_region.h"
 
+#include "gem/i915_gem_context.h"
 #include "gem/i915_gem_lmem.h"
 #include "gem/i915_gem_region.h"
 #include "gem/i915_gem_object_blt.h"
+#include "gem/selftests/igt_gem_utils.h"
 #include "gem/selftests/mock_context.h"
 #include "gt/intel_gt.h"
 #include "selftests/igt_flush_test.h"
@@ -254,6 +257,125 @@ static int igt_mock_contiguous(void *arg)
 	return err;
 }
 
+static int igt_gpu_write_dw(struct intel_context *ce,
+			    struct i915_vma *vma,
+			    u32 dword,
+			    u32 value)
+{
+	return igt_gpu_fill_dw(ce, vma, dword * sizeof(u32),
+			       vma->size >> PAGE_SHIFT, value);
+}
+
+static int igt_cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val)
+{
+	unsigned long n;
+	int err;
+
+	i915_gem_object_lock(obj);
+	err = i915_gem_object_set_to_wc_domain(obj, false);
+	i915_gem_object_unlock(obj);
+	if (err)
+		return err;
+
+	err = i915_gem_object_pin_pages(obj);
+	if (err)
+		return err;
+
+	for (n = 0; n < obj->base.size >> PAGE_SHIFT; ++n) {
+		u32 __iomem *base;
+		u32 read_val;
+
+		base = i915_gem_object_lmem_io_map_page_atomic(obj, n);
+
+		read_val = ioread32(base + dword);
+		io_mapping_unmap_atomic(base);
+		if (read_val != val) {
+			pr_err("n=%lu base[%u]=%u, val=%u\n",
+			       n, dword, read_val, val);
+			err = -EINVAL;
+			break;
+		}
+	}
+
+	i915_gem_object_unpin_pages(obj);
+	return err;
+}
+
+static int igt_gpu_write(struct i915_gem_context *ctx,
+			 struct drm_i915_gem_object *obj)
+{
+	struct drm_i915_private *i915 = ctx->i915;
+	struct i915_address_space *vm = ctx->vm ?: &i915->ggtt.vm;
+	struct i915_gem_engines *engines;
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
+	I915_RND_STATE(prng);
+	IGT_TIMEOUT(end_time);
+	unsigned int count;
+	struct i915_vma *vma;
+	int *order;
+	int i, n;
+	int err = 0;
+
+	GEM_BUG_ON(!i915_gem_object_has_pinned_pages(obj));
+
+	n = 0;
+	count = 0;
+	for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
+		count++;
+		if (!intel_engine_can_store_dword(ce->engine))
+			continue;
+
+		n++;
+	}
+	i915_gem_context_unlock_engines(ctx);
+	if (!n)
+		return 0;
+
+	order = i915_random_order(count * count, &prng);
+	if (!order)
+		return -ENOMEM;
+
+	vma = i915_vma_instance(obj, vm, NULL);
+	if (IS_ERR(vma)) {
+		err = PTR_ERR(vma);
+		goto out_free;
+	}
+
+	err = i915_vma_pin(vma, 0, 0, PIN_USER);
+	if (err)
+		goto out_free;
+
+	i = 0;
+	engines = i915_gem_context_lock_engines(ctx);
+	do {
+		u32 rng = prandom_u32_state(&prng);
+		u32 dword = offset_in_page(rng) / 4;
+
+		ce = engines->engines[order[i] % engines->num_engines];
+		i = (i + 1) % (count * count);
+		if (!ce || !intel_engine_can_store_dword(ce->engine))
+			continue;
+
+		err = igt_gpu_write_dw(ce, vma, dword, rng);
+		if (err)
+			break;
+
+		err = igt_cpu_check(obj, dword, rng);
+		if (err)
+			break;
+	} while (!__igt_timeout(end_time, NULL));
+	i915_gem_context_unlock_engines(ctx);
+
+out_free:
+	kfree(order);
+
+	if (err == -ENOMEM)
+		err = 0;
+
+	return err;
+}
+
 static int igt_lmem_create(void *arg)
 {
 	struct drm_i915_private *i915 = arg;
@@ -275,6 +397,50 @@ static int igt_lmem_create(void *arg)
 	return err;
 }
 
+static int igt_lmem_write_gpu(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	struct drm_i915_gem_object *obj;
+	struct i915_gem_context *ctx;
+	struct drm_file *file;
+	I915_RND_STATE(prng);
+	u32 sz;
+	int err;
+
+	file = mock_file(i915);
+	if (IS_ERR(file))
+		return PTR_ERR(file);
+
+	ctx = live_context(i915, file);
+	if (IS_ERR(ctx)) {
+		err = PTR_ERR(ctx);
+		goto out_file;
+	}
+
+	sz = round_up(prandom_u32_state(&prng) % SZ_32M, PAGE_SIZE);
+
+	obj = i915_gem_object_create_lmem(i915, sz, 0);
+	if (IS_ERR(obj)) {
+		err = PTR_ERR(obj);
+		goto out_file;
+	}
+
+	err = i915_gem_object_pin_pages(obj);
+	if (err)
+		goto out_put;
+
+	err = igt_gpu_write(ctx, obj);
+	if (err)
+		pr_err("igt_gpu_write failed(%d)\n", err);
+
+	i915_gem_object_unpin_pages(obj);
+out_put:
+	i915_gem_object_put(obj);
+out_file:
+	mock_file_free(i915, file);
+	return err;
+}
+
 static int igt_lmem_write_cpu(void *arg)
 {
 	struct drm_i915_private *i915 = arg;
@@ -421,6 +587,7 @@ int intel_memory_region_live_selftests(struct drm_i915_private *i915)
 	static const struct i915_subtest tests[] = {
 		SUBTEST(igt_lmem_create),
 		SUBTEST(igt_lmem_write_cpu),
+		SUBTEST(igt_lmem_write_gpu),
 	};
 
 	if (!HAS_LMEM(i915)) {
Signature · 6 lines
2.20.1

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

PATCH v3 10/21 drm/i915/selftests: extend coverage to include LMEM huge-pages

In reply to Matthew Auld
---
 .../gpu/drm/i915/gem/selftests/huge_pages.c   | 121 +++++++++++++++++-
 1 file changed, 120 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +120 -1
index f27772f6779a..d4892769b739 100644
@@ -9,6 +9,7 @@
 #include "i915_selftest.h"
 
 #include "gem/i915_gem_region.h"
+#include "gem/i915_gem_lmem.h"
 #include "gem/i915_gem_pm.h"
 
 #include "gt/intel_gt.h"
@@ -981,7 +982,7 @@ static int gpu_write(struct intel_context *ce,
 			       vma->size >> PAGE_SHIFT, val);
 }
 
-static int cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val)
+static int __cpu_check_shmem(struct drm_i915_gem_object *obj, u32 dword, u32 val)
 {
 	unsigned int needs_flush;
 	unsigned long n;
@@ -1013,6 +1014,51 @@ static int cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val)
 	return err;
 }
 
+static int __cpu_check_lmem(struct drm_i915_gem_object *obj, u32 dword, u32 val)
+{
+	unsigned long n;
+	int err;
+
+	i915_gem_object_lock(obj);
+	err = i915_gem_object_set_to_wc_domain(obj, false);
+	i915_gem_object_unlock(obj);
+	if (err)
+		return err;
+
+	err = i915_gem_object_pin_pages(obj);
+	if (err)
+		return err;
+
+	for (n = 0; n < obj->base.size >> PAGE_SHIFT; ++n) {
+		u32 __iomem *base;
+		u32 read_val;
+
+		base = i915_gem_object_lmem_io_map_page_atomic(obj, n);
+
+		read_val = ioread32(base + dword);
+		io_mapping_unmap_atomic(base);
+		if (read_val != val) {
+			pr_err("n=%lu base[%u]=%u, val=%u\n",
+			       n, dword, read_val, val);
+			err = -EINVAL;
+			break;
+		}
+	}
+
+	i915_gem_object_unpin_pages(obj);
+	return err;
+}
+
+static int cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val)
+{
+	if (i915_gem_object_has_struct_page(obj))
+		return __cpu_check_shmem(obj, dword, val);
+	else if (i915_gem_object_is_lmem(obj))
+		return __cpu_check_lmem(obj, dword, val);
+
+	return -ENODEV;
+}
+
 static int __igt_write_huge(struct intel_context *ce,
 			    struct drm_i915_gem_object *obj,
 			    u64 size, u64 offset,
@@ -1397,6 +1443,78 @@ static int igt_ppgtt_gemfs_huge(void *arg)
 	return err;
 }
 
+static int igt_ppgtt_lmem_huge(void *arg)
+{
+	struct i915_gem_context *ctx = arg;
+	struct drm_i915_private *i915 = ctx->i915;
+	struct drm_i915_gem_object *obj;
+	static const unsigned int sizes[] = {
+		SZ_64K,
+		SZ_512K,
+		SZ_1M,
+		SZ_2M,
+	};
+	int i;
+	int err;
+
+	if (!HAS_LMEM(i915)) {
+		pr_info("device lacks LMEM support, skipping\n");
+		return 0;
+	}
+
+	/*
+	 * Sanity check that the HW uses huge pages correctly through LMEM
+	 * -- ensure that our writes land in the right place.
+	 */
+
+	for (i = 0; i < ARRAY_SIZE(sizes); ++i) {
+		unsigned int size = sizes[i];
+
+		obj = i915_gem_object_create_lmem(i915, size, I915_BO_ALLOC_CONTIGUOUS);
+		if (IS_ERR(obj)) {
+			err = PTR_ERR(obj);
+			if (err == -E2BIG) {
+				pr_info("object too big for region!\n");
+				return 0;
+			}
+
+			return err;
+		}
+
+		err = i915_gem_object_pin_pages(obj);
+		if (err)
+			goto out_put;
+
+		if (obj->mm.page_sizes.phys < I915_GTT_PAGE_SIZE_64K) {
+			pr_info("LMEM unable to allocate huge-page(s) with size=%u\n",
+				size);
+			goto out_unpin;
+		}
+
+		err = igt_write_huge(ctx, obj);
+		if (err) {
+			pr_err("LMEM write-huge failed with size=%u\n", size);
+			goto out_unpin;
+		}
+
+		i915_gem_object_unpin_pages(obj);
+		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		i915_gem_object_put(obj);
+	}
+
+	return 0;
+
+out_unpin:
+	i915_gem_object_unpin_pages(obj);
+out_put:
+	i915_gem_object_put(obj);
+
+	if (err == -ENOMEM)
+		err = 0;
+
+	return err;
+}
+
 static int igt_ppgtt_pin_update(void *arg)
 {
 	struct i915_gem_context *ctx = arg;
@@ -1758,6 +1876,7 @@ int i915_gem_huge_page_live_selftests(struct drm_i915_private *i915)
 		SUBTEST(igt_ppgtt_exhaust_huge),
 		SUBTEST(igt_ppgtt_gemfs_huge),
 		SUBTEST(igt_ppgtt_internal_huge),
+		SUBTEST(igt_ppgtt_lmem_huge),
 	};
 	struct drm_file *file;
 	struct i915_gem_context *ctx;
Signature · 6 lines
2.20.1

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

PATCH v3 11/21 drm/i915: enumerate and init each supported region

In reply to Matthew Auld

From: Abdiel Janulgue <[email protected]>

Nothing to enumerate yet...

---
 drivers/gpu/drm/i915/i915_drv.h               |  3 +
 drivers/gpu/drm/i915/i915_gem_gtt.c           | 70 +++++++++++++++++--
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  6 ++
 3 files changed, 72 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index ff8e21e585a3..0233265405b4 100644
@@ -2351,6 +2351,9 @@ int __must_check i915_gem_evict_for_node(struct i915_address_space *vm,
 					 unsigned int flags);
 int i915_gem_evict_vm(struct i915_address_space *vm);
 
+void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915);
+int i915_gem_init_memory_regions(struct drm_i915_private *i915);
+
 /* i915_gem_internal.c */
 struct drm_i915_gem_object *
 i915_gem_object_create_internal(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/i915_gem_gtt.c +63 -7

94 lines not on this page · raw message

drivers/gpu/drm/i915/selftests/mock_gem_device.c +6 -0
index 8264d38fa690..6d47f0aeac0c 100644
@@ -74,6 +74,8 @@ static void mock_device_release(struct drm_device *dev)
 
 	i915_gemfs_fini(i915);
 
+	i915_gem_cleanup_memory_regions(i915);
+
 	drm_mode_config_cleanup(&i915->drm);
 
 	drm_dev_fini(&i915->drm);
@@ -196,6 +198,10 @@ struct drm_i915_private *mock_gem_device(void)
 
 	WARN_ON(i915_gemfs_init(i915));
 
+	err = i915_gem_init_memory_regions(i915);
+	if (err)
+		goto err_context;
+
 	return i915;
 
 err_context:
Signature · 6 lines
2.20.1

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

PATCH v3 12/21 drm/i915: treat shmem as a region

In reply to Matthew Auld
Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_phys.c      |  5 +-
 drivers/gpu/drm/i915/gem/i915_gem_region.c    | 14 +++-
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c     | 74 ++++++++++++++-----
 drivers/gpu/drm/i915/i915_drv.h               |  2 +
 drivers/gpu/drm/i915/i915_gem.c               |  9 ---
 drivers/gpu/drm/i915/i915_gem_gtt.c           |  3 +-
 drivers/gpu/drm/i915/i915_pci.c               | 29 ++++++--
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  6 +-
 8 files changed, 99 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_phys.c +4 -1
index 768356908160..8043ff63d73f 100644
@@ -16,6 +16,7 @@
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
 #include "i915_gem_object.h"
+#include "i915_gem_region.h"
 #include "i915_scatterlist.h"
 
 static int i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj)
@@ -191,8 +192,10 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
 	/* Perma-pin (until release) the physical set of pages */
 	__i915_gem_object_pin_pages(obj);
 
-	if (!IS_ERR_OR_NULL(pages))
+	if (!IS_ERR_OR_NULL(pages)) {
 		i915_gem_shmem_ops.put_pages(obj, pages);
+		i915_gem_object_release_memory_region(obj);
+	}
 	mutex_unlock(&obj->mm.lock);
 	return 0;
 
drivers/gpu/drm/i915/gem/i915_gem_region.c +13 -1
index 663254b3da21..0c03c2c40dbc 100644
@@ -6,6 +6,7 @@
 #include "intel_memory_region.h"
 #include "i915_gem_region.h"
 #include "i915_drv.h"
+#include "i915_trace.h"
 
 void
 i915_gem_object_put_pages_buddy(struct drm_i915_gem_object *obj,
@@ -146,11 +147,22 @@ i915_gem_object_create_region(struct intel_memory_region *mem,
 	GEM_BUG_ON(!size);
 	GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_MIN_ALIGNMENT));
 
+	/*
+	 * There is a prevalence of the assumption that we fit the object's
+	 * page count inside a 32bit _signed_ variable. Let's document this and
+	 * catch if we ever need to fix it. In the meantime, if you do spot
+	 * such a local variable, please consider fixing!
+	 */
+
 	if (size >> PAGE_SHIFT > INT_MAX)
 		return ERR_PTR(-E2BIG);
 
 	if (overflows_type(size, obj->base.size))
 		return ERR_PTR(-E2BIG);
 
-	return mem->ops->create_object(mem, size, flags);
+	obj = mem->ops->create_object(mem, size, flags);
+	if (!IS_ERR(obj))
+		trace_i915_gem_object_create(obj);
+
+	return obj;
 }
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +55 -19

137 lines not on this page · raw message

drivers/gpu/drm/i915/i915_drv.h +2 -0
index 0233265405b4..3f7f407c4ca4 100644
@@ -2222,6 +2222,8 @@ void i915_gem_cleanup_early(struct drm_i915_private *dev_priv);
 int i915_gem_freeze(struct drm_i915_private *dev_priv);
 int i915_gem_freeze_late(struct drm_i915_private *dev_priv);
 
+struct intel_memory_region *i915_gem_shmem_setup(struct drm_i915_private *i915);
+
 static inline void i915_gem_drain_freed_objects(struct drm_i915_private *i915)
 {
 	/*
drivers/gpu/drm/i915/i915_gem.c +0 -9
index 0ddbd3a5fb8d..9cc5ee3b7f2f 100644
@@ -45,7 +45,6 @@
 #include "gem/i915_gem_context.h"
 #include "gem/i915_gem_ioctls.h"
 #include "gem/i915_gem_pm.h"
-#include "gem/i915_gemfs.h"
 #include "gt/intel_engine_user.h"
 #include "gt/intel_gt.h"
 #include "gt/intel_gt_pm.h"
@@ -1441,16 +1440,10 @@ static void i915_gem_init__mm(struct drm_i915_private *i915)
 
 void i915_gem_init_early(struct drm_i915_private *dev_priv)
 {
-	int err;
-
 	i915_gem_init__mm(dev_priv);
 	i915_gem_init__pm(dev_priv);
 
 	spin_lock_init(&dev_priv->fb_tracking.lock);
-
-	err = i915_gemfs_init(dev_priv);
-	if (err)
-		DRM_NOTE("Unable to create a private tmpfs mount, hugepage support will be disabled(%d).\n", err);
 }
 
 void i915_gem_cleanup_early(struct drm_i915_private *dev_priv)
@@ -1459,8 +1452,6 @@ void i915_gem_cleanup_early(struct drm_i915_private *dev_priv)
 	GEM_BUG_ON(!llist_empty(&dev_priv->mm.free_list));
 	GEM_BUG_ON(atomic_read(&dev_priv->mm.free_count));
 	WARN_ON(dev_priv->mm.shrink_count);
-
-	i915_gemfs_fini(dev_priv);
 }
 
 int i915_gem_freeze(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
index 450ec8779252..32ee220d2837 100644
@@ -2780,7 +2780,8 @@ int i915_gem_init_memory_regions(struct drm_i915_private *i915)
 
 		type = MEMORY_TYPE_FROM_REGION(intel_region_map[i]);
 		switch (type) {
-		default:
+		case INTEL_SMEM:
+			mem = i915_gem_shmem_setup(i915);
 			break;
 		}
 
drivers/gpu/drm/i915/i915_pci.c +21 -8
index 1cbf3998b361..e55ab2724996 100644
@@ -151,6 +151,9 @@
 #define GEN_DEFAULT_PAGE_SIZES \
 	.page_sizes = I915_GTT_PAGE_SIZE_4K
 
+#define GEN_DEFAULT_REGIONS \
+	.memory_regions = REGION_SMEM
+
 #define I830_FEATURES \
 	GEN(2), \
 	.is_mobile = 1, \
@@ -168,7 +171,8 @@
 	I9XX_PIPE_OFFSETS, \
 	I9XX_CURSOR_OFFSETS, \
 	I9XX_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 #define I845_FEATURES \
 	GEN(2), \
@@ -185,7 +189,8 @@
 	I845_PIPE_OFFSETS, \
 	I845_CURSOR_OFFSETS, \
 	I9XX_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 static const struct intel_device_info intel_i830_info = {
 	I830_FEATURES,
@@ -219,7 +224,8 @@ static const struct intel_device_info intel_i865g_info = {
 	I9XX_PIPE_OFFSETS, \
 	I9XX_CURSOR_OFFSETS, \
 	I9XX_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 static const struct intel_device_info intel_i915g_info = {
 	GEN3_FEATURES,
@@ -304,7 +310,8 @@ static const struct intel_device_info intel_pineview_m_info = {
 	I9XX_PIPE_OFFSETS, \
 	I9XX_CURSOR_OFFSETS, \
 	I965_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 static const struct intel_device_info intel_i965g_info = {
 	GEN4_FEATURES,
@@ -354,7 +361,8 @@ static const struct intel_device_info intel_gm45_info = {
 	I9XX_PIPE_OFFSETS, \
 	I9XX_CURSOR_OFFSETS, \
 	ILK_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 static const struct intel_device_info intel_ironlake_d_info = {
 	GEN5_FEATURES,
@@ -384,7 +392,8 @@ static const struct intel_device_info intel_ironlake_m_info = {
 	I9XX_PIPE_OFFSETS, \
 	I9XX_CURSOR_OFFSETS, \
 	ILK_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 #define SNB_D_PLATFORM \
 	GEN6_FEATURES, \
@@ -432,7 +441,8 @@ static const struct intel_device_info intel_sandybridge_m_gt2_info = {
 	IVB_PIPE_OFFSETS, \
 	IVB_CURSOR_OFFSETS, \
 	IVB_COLORS, \
-	GEN_DEFAULT_PAGE_SIZES
+	GEN_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 #define IVB_D_PLATFORM \
 	GEN7_FEATURES, \
@@ -493,6 +503,7 @@ static const struct intel_device_info intel_valleyview_info = {
 	I9XX_CURSOR_OFFSETS,
 	I965_COLORS,
 	GEN_DEFAULT_PAGE_SIZES,
+	GEN_DEFAULT_REGIONS,
 };
 
 #define G75_FEATURES  \
@@ -587,6 +598,7 @@ static const struct intel_device_info intel_cherryview_info = {
 	CHV_CURSOR_OFFSETS,
 	CHV_COLORS,
 	GEN_DEFAULT_PAGE_SIZES,
+	GEN_DEFAULT_REGIONS,
 };
 
 #define GEN9_DEFAULT_PAGE_SIZES \
@@ -661,7 +673,8 @@ static const struct intel_device_info intel_skylake_gt4_info = {
 	HSW_PIPE_OFFSETS, \
 	IVB_CURSOR_OFFSETS, \
 	IVB_COLORS, \
-	GEN9_DEFAULT_PAGE_SIZES
+	GEN9_DEFAULT_PAGE_SIZES, \
+	GEN_DEFAULT_REGIONS
 
 static const struct intel_device_info intel_broxton_info = {
 	GEN9_LP_FEATURES,
drivers/gpu/drm/i915/selftests/mock_gem_device.c +2 -4
index 6d47f0aeac0c..c50234f938a4 100644
@@ -72,8 +72,6 @@ static void mock_device_release(struct drm_device *dev)
 	mock_fini_ggtt(&i915->ggtt);
 	destroy_workqueue(i915->wq);
 
-	i915_gemfs_fini(i915);
-
 	i915_gem_cleanup_memory_regions(i915);
 
 	drm_mode_config_cleanup(&i915->drm);
@@ -165,6 +163,8 @@ struct drm_i915_private *mock_gem_device(void)
 		I915_GTT_PAGE_SIZE_64K |
 		I915_GTT_PAGE_SIZE_2M;
 
+	mkwrite_device_info(i915)->memory_regions = REGION_SMEM;
+
 	mock_uncore_init(&i915->uncore);
 	i915_gem_init__mm(i915);
 	intel_gt_init_early(&i915->gt, i915);
@@ -196,8 +196,6 @@ struct drm_i915_private *mock_gem_device(void)
 
 	intel_engines_driver_register(i915);
 
-	WARN_ON(i915_gemfs_init(i915));
-
 	err = i915_gem_init_memory_regions(i915);
 	if (err)
 		goto err_context;
Signature · 6 lines
2.20.1

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

PATCH v3 13/21 drm/i915: treat stolen as a region

In reply to Matthew Auld

Convert stolen memory over to a region object. Still leaves open the question with what to do with pre-allocated objects...

Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 65 +++++++++++++++++++---
 drivers/gpu/drm/i915/gem/i915_gem_stolen.h |  3 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c        | 14 +----
 drivers/gpu/drm/i915/i915_pci.c            |  2 +-
 4 files changed, 61 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_stolen.c +56 -9
index 2a34355b738f..a452f992e71c 100644
@@ -10,6 +10,7 @@
 #include <drm/drm_mm.h>
 #include <drm/i915_drm.h>
 
+#include "gem/i915_gem_region.h"
 #include "i915_drv.h"
 #include "i915_gem_stolen.h"
 
@@ -150,7 +151,7 @@ static int i915_adjust_stolen(struct drm_i915_private *dev_priv,
 	return 0;
 }
 
-void i915_gem_cleanup_stolen(struct drm_i915_private *dev_priv)
+static void i915_gem_cleanup_stolen(struct drm_i915_private *dev_priv)
 {
 	if (!drm_mm_initialized(&dev_priv->mm.stolen))
 		return;
@@ -355,7 +356,7 @@ static void icl_get_stolen_reserved(struct drm_i915_private *i915,
 	}
 }
 
-int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
+static int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
 {
 	resource_size_t reserved_base, stolen_top;
 	resource_size_t reserved_total, reserved_size;
@@ -539,6 +540,9 @@ i915_gem_object_release_stolen(struct drm_i915_gem_object *obj)
 
 	i915_gem_stolen_remove_node(dev_priv, stolen);
 	kfree(stolen);
+
+	if (obj->mm.region)
+		i915_gem_object_release_memory_region(obj);
 }
 
 static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
@@ -548,8 +552,9 @@ static const struct drm_i915_gem_object_ops i915_gem_object_stolen_ops = {
 };
 
 static struct drm_i915_gem_object *
-_i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
-			       struct drm_mm_node *stolen)
+__i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
+				struct drm_mm_node *stolen,
+				struct intel_memory_region *mem)
 {
 	struct drm_i915_gem_object *obj;
 	unsigned int cache_level;
@@ -566,6 +571,9 @@ _i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 	cache_level = HAS_LLC(dev_priv) ? I915_CACHE_LLC : I915_CACHE_NONE;
 	i915_gem_object_set_cache_coherency(obj, cache_level);
 
+	if (mem)
+		i915_gem_object_init_memory_region(obj, mem, 0);
+
 	if (i915_gem_object_pin_pages(obj))
 		goto cleanup;
 
@@ -576,10 +584,12 @@ _i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 	return NULL;
 }
 
-struct drm_i915_gem_object *
-i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
-			      resource_size_t size)
+static struct drm_i915_gem_object *
+_i915_gem_object_create_stolen(struct intel_memory_region *mem,
+			       resource_size_t size,
+			       unsigned int flags)
 {
+	struct drm_i915_private *dev_priv = mem->i915;
 	struct drm_i915_gem_object *obj;
 	struct drm_mm_node *stolen;
 	int ret;
@@ -598,7 +608,7 @@ i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 	if (ret)
 		goto err_free;
 
-	obj = _i915_gem_object_create_stolen(dev_priv, stolen);
+	obj = __i915_gem_object_create_stolen(dev_priv, stolen, mem);
 	if (obj == NULL) {
 		ret = -ENOMEM;
 		goto err_remove;
@@ -613,6 +623,43 @@ i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 	return ERR_PTR(ret);
 }
 
+struct drm_i915_gem_object *
+i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
+			      resource_size_t size)
+{
+	return i915_gem_object_create_region(dev_priv->mm.regions[INTEL_MEMORY_STOLEN],
+					     size, I915_BO_ALLOC_CONTIGUOUS);
+}
+
+static int init_stolen(struct intel_memory_region *mem)
+{
+	/*
+	 * Initialise stolen early so that we may reserve preallocated
+	 * objects for the BIOS to KMS transition.
+	 */
+	return i915_gem_init_stolen(mem->i915);
+}
+
+static void release_stolen(struct intel_memory_region *mem)
+{
+	i915_gem_cleanup_stolen(mem->i915);
+}
+
+static const struct intel_memory_region_ops i915_region_stolen_ops = {
+	.init = init_stolen,
+	.release = release_stolen,
+	.create_object = _i915_gem_object_create_stolen,
+};
+
+struct intel_memory_region *i915_gem_stolen_setup(struct drm_i915_private *i915)
+{
+	return intel_memory_region_create(i915,
+					  intel_graphics_stolen_res.start,
+					  resource_size(&intel_graphics_stolen_res),
+					  I915_GTT_PAGE_SIZE_4K, 0,
+					  &i915_region_stolen_ops);
+}
+
 struct drm_i915_gem_object *
 i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv,
 					       resource_size_t stolen_offset,
@@ -652,7 +699,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
 		return ERR_PTR(ret);
 	}
 
-	obj = _i915_gem_object_create_stolen(dev_priv, stolen);
+	obj = __i915_gem_object_create_stolen(dev_priv, stolen, NULL);
 	if (obj == NULL) {
 		DRM_DEBUG_DRIVER("failed to allocate stolen object\n");
 		i915_gem_stolen_remove_node(dev_priv, stolen);
drivers/gpu/drm/i915/gem/i915_gem_stolen.h +1 -2
index 2289644d8604..c1040627fbf3 100644
@@ -21,8 +21,7 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv,
 					 u64 end);
 void i915_gem_stolen_remove_node(struct drm_i915_private *dev_priv,
 				 struct drm_mm_node *node);
-int i915_gem_init_stolen(struct drm_i915_private *dev_priv);
-void i915_gem_cleanup_stolen(struct drm_i915_private *dev_priv);
+struct intel_memory_region *i915_gem_stolen_setup(struct drm_i915_private *i915);
 struct drm_i915_gem_object *
 i915_gem_object_create_stolen(struct drm_i915_private *dev_priv,
 			      resource_size_t size);
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -11
index 32ee220d2837..44900596fec6 100644
@@ -2748,8 +2748,6 @@ void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915)
 {
 	int i;
 
-	i915_gem_cleanup_stolen(i915);
-
 	for (i = 0; i < ARRAY_SIZE(i915->mm.regions); i++) {
 		struct intel_memory_region *region = i915->mm.regions[i];
 
@@ -2762,15 +2760,6 @@ int i915_gem_init_memory_regions(struct drm_i915_private *i915)
 {
 	int err, i;
 
-	/*
-	 * Initialise stolen early so that we may reserve preallocated
-	 * objects for the BIOS to KMS transition.
-	 */
-	/* XXX: stolen will become a region at some point */
-	err = i915_gem_init_stolen(i915);
-	if (err)
-		return err;
-
 	for (i = 0; i < ARRAY_SIZE(i915->mm.regions); i++) {
 		struct intel_memory_region *mem = NULL;
 		u32 type;
@@ -2783,6 +2772,9 @@ int i915_gem_init_memory_regions(struct drm_i915_private *i915)
 		case INTEL_SMEM:
 			mem = i915_gem_shmem_setup(i915);
 			break;
+		case INTEL_STOLEN:
+			mem = i915_gem_stolen_setup(i915);
+			break;
 		}
 
 		if (IS_ERR(mem)) {
drivers/gpu/drm/i915/i915_pci.c +1 -1
index e55ab2724996..f9a3bfe68689 100644
@@ -152,7 +152,7 @@
 	.page_sizes = I915_GTT_PAGE_SIZE_4K
 
 #define GEN_DEFAULT_REGIONS \
-	.memory_regions = REGION_SMEM
+	.memory_regions = REGION_SMEM | REGION_STOLEN
 
 #define I830_FEATURES \
 	GEN(2), \
Signature · 6 lines
2.20.1

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

PATCH v3 14/21 drm/i915: define i915_ggtt_has_aperture

In reply to Matthew Auld

From: Daniele Ceraolo Spurio <[email protected]>

The following patches in the series will use it to avoid certain operations when the mappable aperture is not available in HW.

---
 drivers/gpu/drm/i915/i915_gem_gtt.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.h +5 -0
index 0a18fdfe63ff..62b586c4cf71 100644
@@ -570,6 +570,11 @@ void i915_ggtt_disable_guc(struct i915_ggtt *ggtt);
 int i915_init_ggtt(struct drm_i915_private *dev_priv);
 void i915_ggtt_driver_release(struct drm_i915_private *dev_priv);
 
+static inline bool i915_ggtt_has_aperture(struct i915_ggtt *ggtt)
+{
+	return ggtt->mappable_end > 0;
+}
+
 int i915_ppgtt_init_hw(struct intel_gt *gt);
 
 struct i915_ppgtt *i915_ppgtt_create(struct drm_i915_private *dev_priv);
Signature · 6 lines
2.20.1

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

PATCH v3 15/21 drm/i915: do not map aperture if it is not available.

In reply to Matthew Auld

From: Daniele Ceraolo Spurio <[email protected]>

Skip both setup and cleanup of the aperture mapping if the HW doesn't have an aperture bar.

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 32 ++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +20 -12
index 44900596fec6..ad123b84880d 100644
@@ -2823,7 +2823,9 @@ static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
 	i915_address_space_fini(&ggtt->vm);
 
 	arch_phys_wc_del(ggtt->mtrr);
-	io_mapping_fini(&ggtt->iomap);
+
+	if (ggtt->iomap.size)
+		io_mapping_fini(&ggtt->iomap);
 }
 
 /**
@@ -3034,10 +3036,13 @@ static int gen8_gmch_probe(struct i915_ggtt *ggtt)
 	int err;
 
 	/* TODO: We're not aware of mappable constraints on gen8 yet */
-	ggtt->gmadr =
-		(struct resource) DEFINE_RES_MEM(pci_resource_start(pdev, 2),
-						 pci_resource_len(pdev, 2));
-	ggtt->mappable_end = resource_size(&ggtt->gmadr);
+	/* FIXME: We probably need to add do device_info or runtime_info */
+	if (!HAS_LMEM(dev_priv)) {
+		ggtt->gmadr =
+			(struct resource) DEFINE_RES_MEM(pci_resource_start(pdev, 2),
+							 pci_resource_len(pdev, 2));
+		ggtt->mappable_end = resource_size(&ggtt->gmadr);
+	}
 
 	err = pci_set_dma_mask(pdev, DMA_BIT_MASK(39));
 	if (!err)
@@ -3260,14 +3265,17 @@ static int ggtt_init_hw(struct i915_ggtt *ggtt)
 	if (!HAS_LLC(i915) && !HAS_PPGTT(i915))
 		ggtt->vm.mm.color_adjust = i915_ggtt_color_adjust;
 
-	if (!io_mapping_init_wc(&ggtt->iomap,
-				ggtt->gmadr.start,
-				ggtt->mappable_end)) {
-		ggtt->vm.cleanup(&ggtt->vm);
-		return -EIO;
-	}
+	if (ggtt->mappable_end) {
+		if (!io_mapping_init_wc(&ggtt->iomap,
+					ggtt->gmadr.start,
+					ggtt->mappable_end)) {
+			ggtt->vm.cleanup(&ggtt->vm);
+			return -EIO;
+		}
 
-	ggtt->mtrr = arch_phys_wc_add(ggtt->gmadr.start, ggtt->mappable_end);
+		ggtt->mtrr = arch_phys_wc_add(ggtt->gmadr.start,
+					      ggtt->mappable_end);
+	}
 
 	i915_ggtt_init_fences(ggtt);
 
Signature · 6 lines
2.20.1

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

PATCH v3 16/21 drm/i915: set num_fence_regs to 0 if there is no aperture

In reply to Matthew Auld

From: Daniele Ceraolo Spurio <[email protected]>

We can't fence anything without aperture.

---
 drivers/gpu/drm/i915/i915_gem_fence_reg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_fence_reg.c +4 -2
index 487b7261f7ed..911aab45fce3 100644
@@ -831,8 +831,10 @@ void i915_ggtt_init_fences(struct i915_ggtt *ggtt)
 
 	detect_bit_6_swizzle(i915);
 
-	if (INTEL_GEN(i915) >= 7 &&
-	    !(IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)))
+	if (!i915_ggtt_has_aperture(ggtt))
+		num_fences = 0;
+	else if (INTEL_GEN(i915) >= 7 &&
+		 !(IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)))
 		num_fences = 32;
 	else if (INTEL_GEN(i915) >= 4 ||
 		 IS_I945G(i915) || IS_I945GM(i915) ||
Signature · 6 lines
2.20.1

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

PATCH v3 17/21 drm/i915: error capture with no ggtt slot

In reply to Matthew Auld

From: Daniele Ceraolo Spurio <[email protected]>

If the aperture is not available in HW we can't use a ggtt slot and wc copy, so fall back to regular kmap.

---
 drivers/gpu/drm/i915/i915_gem_gtt.c   | 19 ++++----
 drivers/gpu/drm/i915/i915_gpu_error.c | 66 ++++++++++++++++++++++-----
 2 files changed, 65 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +11 -8
index ad123b84880d..235028ad684f 100644
@@ -2661,7 +2661,8 @@ static void ggtt_release_guc_top(struct i915_ggtt *ggtt)
 static void cleanup_init_ggtt(struct i915_ggtt *ggtt)
 {
 	ggtt_release_guc_top(ggtt);
-	drm_mm_remove_node(&ggtt->error_capture);
+	if (drm_mm_node_allocated(&ggtt->error_capture))
+		drm_mm_remove_node(&ggtt->error_capture);
 }
 
 static int init_ggtt(struct i915_ggtt *ggtt)
@@ -2692,13 +2693,15 @@ static int init_ggtt(struct i915_ggtt *ggtt)
 	if (ret)
 		return ret;
 
-	/* Reserve a mappable slot for our lockless error capture */
-	ret = drm_mm_insert_node_in_range(&ggtt->vm.mm, &ggtt->error_capture,
-					  PAGE_SIZE, 0, I915_COLOR_UNEVICTABLE,
-					  0, ggtt->mappable_end,
-					  DRM_MM_INSERT_LOW);
-	if (ret)
-		return ret;
+	if (ggtt->mappable_end) {
+		/* Reserve a mappable slot for our lockless error capture */
+		ret = drm_mm_insert_node_in_range(&ggtt->vm.mm, &ggtt->error_capture,
+						  PAGE_SIZE, 0, I915_COLOR_UNEVICTABLE,
+						  0, ggtt->mappable_end,
+						  DRM_MM_INSERT_LOW);
+		if (ret)
+			return ret;
+	}
 
 	/*
 	 * The upper portion of the GuC address space has a sizeable hole
drivers/gpu/drm/i915/i915_gpu_error.c +54 -12

119 lines not on this page · raw message

Signature · 6 lines
2.20.1

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

PATCH v3 18/21 drm/i915: Don't try to place HWS in non-existing mappable region

In reply to Matthew Auld

From: Michal Wajdeczko <[email protected]>

HWS placement restrictions can't just rely on HAS_LLC flag.

---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -1
index 80fd072ac719..f6799ef9915a 100644
@@ -513,7 +513,8 @@ static int pin_ggtt_status_page(struct intel_engine_cs *engine,
 	unsigned int flags;
 
 	flags = PIN_GLOBAL;
-	if (!HAS_LLC(engine->i915))
+	if (!HAS_LLC(engine->i915) &&
+	    i915_ggtt_has_aperture(&engine->i915->ggtt))
 		/*
 		 * On g33, we cannot place HWS above 256MiB, so
 		 * restrict its pinning to the low mappable arena.
Signature · 6 lines
2.20.1

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

PATCH v3 19/21 drm/i915: don't allocate the ring in stolen if we lack aperture

In reply to Matthew Auld

Since we have no way access it from the CPU. For such cases just fallback to internal objects.

---
 drivers/gpu/drm/i915/gt/intel_ringbuffer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_ringbuffer.c +3 -1
index 311fdc0a21bc..9ed6f52d178f 100644
@@ -1273,7 +1273,9 @@ static struct i915_vma *create_ring_vma(struct i915_ggtt *ggtt, int size)
 	struct drm_i915_gem_object *obj;
 	struct i915_vma *vma;
 
-	obj = i915_gem_object_create_stolen(i915, size);
+	obj = ERR_PTR(-ENODEV);
+	if (i915_ggtt_has_aperture(ggtt))
+		obj = i915_gem_object_create_stolen(i915, size);
 	if (IS_ERR(obj))
 		obj = i915_gem_object_create_internal(i915, size);
 	if (IS_ERR(obj))
Signature · 6 lines
2.20.1

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

PATCH v3 20/21 drm/i915/selftests: check for missing aperture

In reply to Matthew Auld

We may be missing support for the mappable aperture on some platforms.

Cc Daniele Ceraolo Spurio <[email protected]>
---
 .../drm/i915/gem/selftests/i915_gem_coherency.c    |  5 ++++-
 drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c |  6 ++++++
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c       | 14 ++++++++++----
 drivers/gpu/drm/i915/selftests/i915_gem.c          |  4 ++++
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c      |  3 +++
 5 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c +4 -1
index 549810f70aeb..e82255526782 100644
@@ -259,7 +259,10 @@ static bool always_valid(struct drm_i915_private *i915)
 
 static bool needs_fence_registers(struct drm_i915_private *i915)
 {
-	return !intel_gt_is_wedged(&i915->gt);
+	if (intel_gt_is_wedged(&i915->gt))
+		return false;
+
+	return i915->ggtt.num_fences;
 }
 
 static bool needs_mi_store_dword(struct drm_i915_private *i915)
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c +6 -0
index cfa52c525691..468603fa6218 100644
@@ -301,6 +301,9 @@ static int igt_partial_tiling(void *arg)
 	int tiling;
 	int err;
 
+	if (!i915_ggtt_has_aperture(&i915->ggtt))
+		return 0;
+
 	/* We want to check the page mapping and fencing of a large object
 	 * mmapped through the GTT. The object we create is larger than can
 	 * possibly be mmaped as a whole, and so we must use partial GGTT vma.
@@ -431,6 +434,9 @@ static int igt_smoke_tiling(void *arg)
 	IGT_TIMEOUT(end);
 	int err;
 
+	if (!i915_ggtt_has_aperture(&i915->ggtt))
+		return 0;
+
 	/*
 	 * igt_partial_tiling() does an exhastive check of partial tiling
 	 * chunking, but will undoubtably run out of time. Here, we do a
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +10 -4
index e8a40df79bd0..c7896d4bf7ae 100644
@@ -1149,8 +1149,12 @@ static int __igt_reset_evict_vma(struct intel_gt *gt,
 	struct i915_request *rq;
 	struct evict_vma arg;
 	struct hang h;
+	unsigned int pin_flags;
 	int err;
 
+	if (!gt->ggtt->num_fences && flags & EXEC_OBJECT_NEEDS_FENCE)
+		return 0;
+
 	if (!engine || !intel_engine_can_store_dword(engine))
 		return 0;
 
@@ -1186,10 +1190,12 @@ static int __igt_reset_evict_vma(struct intel_gt *gt,
 		goto out_obj;
 	}
 
-	err = i915_vma_pin(arg.vma, 0, 0,
-			   i915_vma_is_ggtt(arg.vma) ?
-			   PIN_GLOBAL | PIN_MAPPABLE :
-			   PIN_USER);
+	pin_flags = i915_vma_is_ggtt(arg.vma) ? PIN_GLOBAL : PIN_USER;
+
+	if (flags & EXEC_OBJECT_NEEDS_FENCE)
+		pin_flags |= PIN_MAPPABLE;
+
+	err = i915_vma_pin(arg.vma, 0, 0, pin_flags);
 	if (err) {
 		i915_request_add(rq);
 		goto out_obj;
drivers/gpu/drm/i915/selftests/i915_gem.c +4 -0
index bfa40a5b6d98..6f80a92c967b 100644
@@ -42,6 +42,10 @@ static void trash_stolen(struct drm_i915_private *i915)
 	unsigned long page;
 	u32 prng = 0x12345678;
 
+	/* XXX: fsck. needs some more thought... */
+	if (!i915_ggtt_has_aperture(ggtt))
+		return;
+
 	for (page = 0; page < size; page += PAGE_SIZE) {
 		const dma_addr_t dma = i915->dsm.start + page;
 		u32 __iomem *s;
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +3 -0
index ebe735df6504..4037e2cdca43 100644
@@ -1148,6 +1148,9 @@ static int igt_ggtt_page(void *arg)
 	unsigned int *order, n;
 	int err;
 
+	if (!i915_ggtt_has_aperture(ggtt))
+		return 0;
+
 	obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
Signature · 6 lines
2.20.1

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

PATCH v3 21/21 HAX drm/i915: add the fake lmem region

In reply to Matthew Auld

Intended for upstream testing so that we can still exercise the LMEM plumbing and !HAS_MAPPABLE_APERTURE paths. Smoke tested on Skull Canyon device. This works by allocating an intel_memory_region for a reserved portion of system memory, which we treat like LMEM. For the LMEMBAR we steal the aperture and 1:1 it map to the stolen region.

To enable simply set i915_fake_lmem_start= on the kernel cmdline with the start of reserved region(see memmap=). The size of the region we can use is determined by the size of the mappable aperture, so the size of reserved region should be >= mappable_end.

eg. memmap=2G$16G i915_fake_lmem_start=0x400000000

Cc Joonas Lahtinen <[email protected]>
Cc Abdiel Janulgue <[email protected]>
---
 arch/x86/kernel/early-quirks.c             | 26 +++++++
 drivers/gpu/drm/i915/gem/i915_gem_lmem.c   |  3 +
 drivers/gpu/drm/i915/i915_drv.c            |  8 ++
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  3 +
 drivers/gpu/drm/i915/intel_memory_region.h |  6 ++
 drivers/gpu/drm/i915/intel_region_lmem.c   | 90 ++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_region_lmem.h   |  5 ++
 include/drm/i915_drm.h                     |  3 +
 8 files changed, 144 insertions(+)
arch/x86/kernel/early-quirks.c +26 -0
index 6f6b1d04dadf..9b04655e3926 100644
@@ -603,6 +603,32 @@ static void __init intel_graphics_quirks(int num, int slot, int func)
 	}
 }
 
+struct resource intel_graphics_fake_lmem_res __ro_after_init = DEFINE_RES_MEM(0, 0);
+EXPORT_SYMBOL(intel_graphics_fake_lmem_res);
+
+static int __init early_i915_fake_lmem_init(char *s)
+{
+	u64 start;
+	int ret;
+
+	if (*s == '=')
+		s++;
+
+	ret = kstrtoull(s, 16, &start);
+	if (ret)
+		return ret;
+
+	intel_graphics_fake_lmem_res.start = start;
+	intel_graphics_fake_lmem_res.end = SZ_2G; /* Placeholder; depends on aperture size */
+
+	printk(KERN_INFO "Intel graphics fake LMEM starts at %pa\n",
+	       &intel_graphics_fake_lmem_res.start);
+
+	return 0;
+}
+
+early_param("i915_fake_lmem_start", early_i915_fake_lmem_init);
+
 static void __init force_disable_hpet(int num, int slot, int func)
 {
 #ifdef CONFIG_HPET_TIMER
drivers/gpu/drm/i915/gem/i915_gem_lmem.c +3 -0
index fd8b63dd154d..b48f95ba336f 100644
@@ -23,6 +23,7 @@ void __iomem *i915_gem_object_lmem_io_map_page(struct drm_i915_gem_object *obj,
 	resource_size_t offset;
 
 	offset = i915_gem_object_get_dma_address(obj, n);
+	offset -= obj->mm.region->region.start;
 
 	return io_mapping_map_wc(&obj->mm.region->iomap, offset, PAGE_SIZE);
 }
@@ -33,6 +34,7 @@ void __iomem *i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object
 	resource_size_t offset;
 
 	offset = i915_gem_object_get_dma_address(obj, n);
+	offset -= obj->mm.region->region.start;
 
 	return io_mapping_map_atomic_wc(&obj->mm.region->iomap, offset);
 }
@@ -46,6 +48,7 @@ void __iomem *i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
 	GEM_BUG_ON(!i915_gem_object_is_contiguous(obj));
 
 	offset = i915_gem_object_get_dma_address(obj, n);
+	offset -= obj->mm.region->region.start;
 
 	return io_mapping_map_wc(&obj->mm.region->iomap, offset, size);
 }
drivers/gpu/drm/i915/i915_drv.c +8 -0
index 024da582ba0f..fdd548299156 100644
@@ -1526,6 +1526,14 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (!i915_modparams.nuclear_pageflip && match_info->gen < 5)
 		dev_priv->drm.driver_features &= ~DRIVER_ATOMIC;
 
+	/* Check if we support fake LMEM -- enable for live selftests */
+	if (INTEL_GEN(dev_priv) >= 9 && i915_selftest.live &&
+	    intel_graphics_fake_lmem_res.start) {
+		mkwrite_device_info(dev_priv)->memory_regions =
+			REGION_SMEM | REGION_LMEM | REGION_STOLEN;
+		GEM_BUG_ON(!HAS_LMEM(dev_priv));
+	}
+
 	ret = pci_enable_device(pdev);
 	if (ret)
 		goto out_fini;
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -0
index 235028ad684f..146b2c0573e8 100644
@@ -2778,6 +2778,9 @@ int i915_gem_init_memory_regions(struct drm_i915_private *i915)
 		case INTEL_STOLEN:
 			mem = i915_gem_stolen_setup(i915);
 			break;
+		case INTEL_LMEM:
+			mem = intel_setup_fake_lmem(i915);
+			break;
 		}
 
 		if (IS_ERR(mem)) {
drivers/gpu/drm/i915/intel_memory_region.h +6 -0
index 39d2c4ec3302..c74887b355ac 100644
@@ -10,6 +10,7 @@
 #include <linux/ioport.h>
 #include <linux/mutex.h>
 #include <linux/io-mapping.h>
+#include <drm/drm_mm.h>
 
 #include "i915_buddy.h"
 
@@ -71,6 +72,9 @@ struct intel_memory_region {
 	struct io_mapping iomap;
 	struct resource region;
 
+	/* For faking for lmem */
+	struct drm_mm_node fake_mappable;
+
 	struct i915_buddy_mm mm;
 	struct mutex mm_lock;
 
@@ -83,6 +87,8 @@ struct intel_memory_region {
 	unsigned int instance;
 	unsigned int id;
 
+	dma_addr_t remap_addr;
+
 	/* Protects access to objects and purgeable */
 	struct mutex obj_lock;
 	struct list_head objects;
drivers/gpu/drm/i915/intel_region_lmem.c +90 -0

108 lines not on this page · raw message

drivers/gpu/drm/i915/intel_region_lmem.h +5 -0
index ed2a3bab6443..213def7c7b8a 100644
@@ -6,6 +6,11 @@
 #ifndef __INTEL_REGION_LMEM_H
 #define __INTEL_REGION_LMEM_H
 
+struct drm_i915_private;
+
 extern const struct intel_memory_region_ops intel_region_lmem_ops;
 
+struct intel_memory_region *
+intel_setup_fake_lmem(struct drm_i915_private *i915);
+
 #endif /* !__INTEL_REGION_LMEM_H */
include/drm/i915_drm.h +3 -0
index 6722005884db..271980225deb 100644
@@ -39,6 +39,9 @@ bool i915_gpu_turbo_disable(void);
 /* Exported from arch/x86/kernel/early-quirks.c */
 extern struct resource intel_graphics_stolen_res;
 
+/* Exported from arch/x86/kernel/early-printk.c */
+extern struct resource intel_graphics_fake_lmem_res;
+
 /*
  * The Bridge device's PCI config space has information about the
  * fb aperture size and the amount of pre-reserved memory.
Signature · 6 lines
2.20.1

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

Re: [PATCH v3 18/21] drm/i915: Don't try to place HWS in non-existing mappable region

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:49)

Quoted 16 lines

From: Michal Wajdeczko <[email protected]>

HWS placement restrictions can't just rely on HAS_LLC flag.

---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
index 80fd072ac719..f6799ef9915a 100644

drivers/gpu/drm/i915/gt/intel_engine_cs.c static int pin_ggtt_status_page(struct intel_engine_cs *engine, · line 517

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -1
@@ -513,7 +513,8 @@ static int pin_ggtt_status_page(struct intel_engine_cs *engine,
        unsigned int flags;
 
        flags = PIN_GLOBAL;
-       if (!HAS_LLC(engine->i915))
+       if (!HAS_LLC(engine->i915) &&
+           i915_ggtt_has_aperture(&engine->i915->ggtt))

engine->gt->ggtt is the preferred abstracted route. -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#30 lore raw

✗ Fi.CI.CHECKPATCH: warning for LMEM basics (rev3)

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: LMEM basics (rev3)
URL : https://patchwork.freedesktop.org/series/67350/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
230ce2751c83 drm/i915/stolen: make the object creation interface consistent
-:89: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!obj"
#89: FILE: drivers/gpu/drm/i915/gem/i915_gem_stolen.c:602:
+	if (obj == NULL) {

total: 0 errors, 0 warnings, 1 checks, 150 lines checked
49d114bc9547 drm/i915: introduce intel_memory_region
-:59: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #59:
new file mode 100644

-:600: CHECK:UNCOMMENTED_DEFINITION: struct mutex definition without comment #600: FILE: drivers/gpu/drm/i915/intel_memory_region.h:44:
+ struct mutex mm_lock;

total: 0 errors, 1 warnings, 1 checks, 775 lines checked c846cb7cad7d drm/i915/region: support contiguous allocations -:317: WARNING:LINE_SPACING: Missing a blank line after declarations #317: FILE: drivers/gpu/drm/i915/selftests/intel_memory_region.c:130:
+ LIST_HEAD(holes);
+ I915_RND_STATE(prng);

total: 0 errors, 1 warnings, 0 checks, 393 lines checked
0339d6513672 drm/i915/region: support volatile objects
6c7235302062 drm/i915: Add memory region information to device_info
97b8c777c4d0 drm/i915: support creating LMEM objects
-:35: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #35:
new file mode 100644

-:137: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #137: FILE: drivers/gpu/drm/i915/intel_memory_region.c:10:
+#define REGION_MAP(type, inst) \
+ BIT((type) + INTEL_MEMORY_TYPE_SHIFT) | BIT(inst)

total: 1 errors, 1 warnings, 0 checks, 262 lines checked 94b66fcc5efd drm/i915: setup io-mapping for LMEM
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

total: 0 errors, 1 warnings, 0 checks, 34 lines checked aa7fd71d6788 drm/i915/lmem: support kernel mapping
-:200: WARNING:LINE_SPACING: Missing a blank line after declarations #200: FILE: drivers/gpu/drm/i915/selftests/intel_memory_region.c:282:
+ struct drm_i915_gem_object *obj;
+ I915_RND_STATE(prng);

total: 0 errors, 1 warnings, 0 checks, 273 lines checked 5e5781be3c3c drm/i915/selftests: add write-dword test for LMEM -:19: CHECK:LINE_SPACING: Please don't use multiple blank lines #19: FILE: drivers/gpu/drm/i915/selftests/intel_memory_region.c:10:

+

-:88: WARNING:LINE_SPACING: Missing a blank line after declarations #88: FILE: drivers/gpu/drm/i915/selftests/intel_memory_region.c:312:
+ struct intel_context *ce;
+ I915_RND_STATE(prng);

-:168: WARNING:LINE_SPACING: Missing a blank line after declarations #168: FILE: drivers/gpu/drm/i915/selftests/intel_memory_region.c:406:
+ struct drm_file *file;
+ I915_RND_STATE(prng);

total: 0 errors, 2 warnings, 1 checks, 198 lines checked 0dfe20962fb0 drm/i915/selftests: extend coverage to include LMEM huge-pages -:8: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

total: 0 errors, 1 warnings, 0 checks, 151 lines checked 2797cf97e640 drm/i915: enumerate and init each supported region 164771ef0b1f drm/i915: treat shmem as a region
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one

total: 0 errors, 1 warnings, 0 checks, 352 lines checked fe16f6f25391 drm/i915: treat stolen as a region a4c11ba258ec drm/i915: define i915_ggtt_has_aperture 955419c5d802 drm/i915: do not map aperture if it is not available. -:38: CHECK:SPACING: No space is necessary after a cast #38: FILE: drivers/gpu/drm/i915/i915_gem_gtt.c:3042:
+ (struct resource) DEFINE_RES_MEM(pci_resource_start(pdev, 2),

total: 0 errors, 0 warnings, 1 checks, 51 lines checked
69132ab6cb6e drm/i915: set num_fence_regs to 0 if there is no aperture
dacd250f584e drm/i915: error capture with no ggtt slot
bd4af504601f drm/i915: Don't try to place HWS in non-existing mappable region
eca4aec7ec7e drm/i915: don't allocate the ring in stolen if we lack aperture
625162b64039 drm/i915/selftests: check for missing aperture
9db91fb25dff HAX drm/i915: add the fake lmem region
-:49: WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... #49: FILE: arch/x86/kernel/early-quirks.c:624:
+ printk(KERN_INFO "Intel graphics fake LMEM starts at %pa\n",

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

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

#31 lore raw

✗ Fi.CI.SPARSE: warning for LMEM basics (rev3)

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: LMEM basics (rev3)
URL : https://patchwork.freedesktop.org/series/67350/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.6.0
Commit: drm/i915/stolen: make the object creation interface consistent
Okay!

Commit: drm/i915: introduce intel_memory_region
Okay!

Commit: drm/i915/region: support contiguous allocations Okay!

Commit: drm/i915/region: support volatile objects
Okay!

Commit: drm/i915: Add memory region information to device_info Okay!

Commit: drm/i915: support creating LMEM objects
Okay!

Commit: drm/i915: setup io-mapping for LMEM
Okay!

Commit: drm/i915/lmem: support kernel mapping
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:177:42: expected void [noderef] <asn:2> *vaddr
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:177:42: got void *[assigned] ptr
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:177:42: warning: incorrect type in argument 1 (different address spaces)
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:254:51: expected void *
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:254:51: got void [noderef] <asn:2> *
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:254:51: warning: incorrect type in return expression (different address spaces)
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:337:42: expected void [noderef] <asn:2> *vaddr
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:337:42: got void *[assigned] ptr
+drivers/gpu/drm/i915/gem/i915_gem_pages.c:337:42: warning: incorrect type in argument 1 (different address spaces)

Commit: drm/i915/selftests: add write-dword test for LMEM
-
+drivers/gpu/drm/i915/selftests/intel_memory_region.c:308:49: error: incompatible types in conditional expression (different address spaces)

Commit: drm/i915/selftests: extend coverage to include LMEM huge-pages Okay!

Commit: drm/i915: enumerate and init each supported region Okay!

Commit: drm/i915: treat shmem as a region
Okay!

Commit: drm/i915: treat stolen as a region
Okay!

Commit: drm/i915: define i915_ggtt_has_aperture
Okay!

Commit: drm/i915: do not map aperture if it is not available. Okay!

Commit: drm/i915: set num_fence_regs to 0 if there is no aperture Okay!

Commit: drm/i915: error capture with no ggtt slot
-
+drivers/gpu/drm/i915/i915_gpu_error.c:1027:55: expected void *src
+drivers/gpu/drm/i915/i915_gpu_error.c:1027:55: got void [noderef] <asn:2> *[assigned] s
+drivers/gpu/drm/i915/i915_gpu_error.c:1027:55: warning: incorrect type in argument 2 (different address spaces)

Commit: drm/i915: Don't try to place HWS in non-existing mappable region Okay!

Commit: drm/i915: don't allocate the ring in stolen if we lack aperture Okay!

Commit: drm/i915/selftests: check for missing aperture Okay!

Commit: HAX drm/i915: add the fake lmem region
Okay!

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

#32 lore raw

✓ Fi.CI.BAT: success for LMEM basics (rev3)

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: LMEM basics (rev3)
URL : https://patchwork.freedesktop.org/series/67350/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7011 -> Patchwork_14674
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

New tests
---------

New tests have been introduced between CI_DRM_7011 and Patchwork_14674:

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

* igt@i915_selftest@live_memory_region:
- Statuses : 43 pass(s)
- Exec time: [0.39, 2.59] s

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: [PASS][1] -> [INCOMPLETE][2] ([fdo#107718])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/fi-blb-e6850/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/fi-blb-e6850/igt@[email protected]

* igt@gem_exec_suspend@basic-s4-devices:
- fi-icl-u3: [PASS][3] -> [DMESG-WARN][4] ([fdo#107724])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/fi-icl-u3/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/fi-icl-u3/igt@[email protected]

#### Possible fixes ####

* igt@gem_mmap_gtt@basic-small-bo-tiledy:
- fi-icl-u3: [DMESG-WARN][5] ([fdo#107724]) -> [PASS][6] +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/fi-icl-u3/igt@[email protected]

[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724

Participating hosts (52 -> 44)
------------------------------

Missing (8): fi-ilk-m540 fi-hsw-4200u fi-hsw-peppy fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

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

* CI: CI-20190529 -> None
* Linux: CI_DRM_7011 -> Patchwork_14674

CI-20190529: 20190529
CI_DRM_7011: 7d13733c2a87909eef8bc945ecbf4d47e0b67133 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5212: d17a484b3c22706b2b004ef1577f367d79235e43 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14674: 9db91fb25dfffa036289696db0609e06a0b7a1ff @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

9db91fb25dff HAX drm/i915: add the fake lmem region
625162b64039 drm/i915/selftests: check for missing aperture eca4aec7ec7e drm/i915: don't allocate the ring in stolen if we lack aperture bd4af504601f drm/i915: Don't try to place HWS in non-existing mappable region dacd250f584e drm/i915: error capture with no ggtt slot 69132ab6cb6e drm/i915: set num_fence_regs to 0 if there is no aperture 955419c5d802 drm/i915: do not map aperture if it is not available. a4c11ba258ec drm/i915: define i915_ggtt_has_aperture
fe16f6f25391 drm/i915: treat stolen as a region
164771ef0b1f drm/i915: treat shmem as a region
2797cf97e640 drm/i915: enumerate and init each supported region 0dfe20962fb0 drm/i915/selftests: extend coverage to include LMEM huge-pages 5e5781be3c3c drm/i915/selftests: add write-dword test for LMEM aa7fd71d6788 drm/i915/lmem: support kernel mapping
94b66fcc5efd drm/i915: setup io-mapping for LMEM
97b8c777c4d0 drm/i915: support creating LMEM objects
6c7235302062 drm/i915: Add memory region information to device_info 0339d6513672 drm/i915/region: support volatile objects c846cb7cad7d drm/i915/region: support contiguous allocations 49d114bc9547 drm/i915: introduce intel_memory_region
230ce2751c83 drm/i915/stolen: make the object creation interface consistent

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [PATCH v3 02/21] drm/i915: introduce intel_memory_region

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:33)

drivers/gpu/drm/i915/gem/i915_gem_region.c line 115

Quoted 4 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +4 -0
+struct drm_i915_gem_object *
+i915_gem_object_create_region(struct intel_memory_region *mem,
+                             resource_size_t size,
+                             unsigned int flags)

Ok, while dma_addr_t can technically exceed resource_size_t (which itself is phys_add_t), that is off no practical value? I do worry about that for 4+G cards on pure 32b machines.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#33 lore raw

✗ Fi.CI.IGT: failure for LMEM basics (rev3)

In reply to Matthew Auld
== Series Details ==

== Series Details ==

Series: LMEM basics (rev3)
URL : https://patchwork.freedesktop.org/series/67350/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7011_full -> Patchwork_14674_full
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_14674_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_14674_full:

### IGT changes ###

#### Possible regressions ####

* igt@gem_ctx_isolation@vecs0-dirty-switch:
- shard-skl: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl8/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl3/igt@[email protected]

* igt@i915_selftest@live_hangcheck:
- shard-hsw: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-hsw7/igt@i915_selftest@live_hangcheck.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-hsw6/igt@i915_selftest@live_hangcheck.html

#### Suppressed ####

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

* igt@gem_ctx_isolation@vcs2-dirty-create:
- {shard-tglb}: NOTRUN -> [SKIP][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-tglb6/igt@[email protected]

New tests
---------

New tests have been introduced between CI_DRM_7011_full and Patchwork_14674_full:

### New IGT tests (2) ###

* igt@i915_selftest@live_memory_region:
- Statuses : 8 pass(s)
- Exec time: [0.36, 2.27] s

* igt@i915_selftest@mock_memory_region:
- Statuses : 8 pass(s)
- Exec time: [0.97, 15.48] s

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@rcs0-s3:
- shard-apl: [PASS][6] -> [DMESG-WARN][7] ([fdo#108566]) +7 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-apl3/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-apl6/igt@[email protected]

* igt@gem_exec_schedule@preempt-contexts-bsd2:
- shard-iclb: [PASS][8] -> [SKIP][9] ([fdo#109276]) +14 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb2/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb5/igt@[email protected]

* igt@gem_exec_schedule@preempt-queue-contexts-bsd:
- shard-iclb: [PASS][10] -> [SKIP][11] ([fdo#111325]) +1 similar issue
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb6/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb2/igt@[email protected]

* igt@gem_userptr_blits@map-fixed-invalidate-overlap-busy-gup:
- shard-snb: [PASS][12] -> [DMESG-WARN][13] ([fdo#111870])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-snb1/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-snb4/igt@[email protected]

* igt@kms_cursor_legacy@cursor-vs-flip-toggle:
- shard-hsw: [PASS][14] -> [FAIL][15] ([fdo#103355])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-hsw8/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-hsw6/igt@[email protected]

* igt@kms_cursor_legacy@pipe-c-single-bo:
- shard-iclb: [PASS][16] -> [INCOMPLETE][17] ([fdo#107713]) +1 similar issue
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb8/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb7/igt@[email protected]

* igt@kms_flip@dpms-vs-vblank-race-interruptible:
- shard-apl: [PASS][18] -> [INCOMPLETE][19] ([fdo#103927]) +2 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-apl7/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-apl1/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-pwrite:
- shard-iclb: [PASS][20] -> [FAIL][21] ([fdo#103167]) +1 similar issue
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb4/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-pwrite.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-indfb-draw-pwrite.html

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
- shard-skl: [PASS][22] -> [FAIL][23] ([fdo#108145])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl7/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl10/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [PASS][24] -> [FAIL][25] ([fdo#108145] / [fdo#110403]) +1 similar issue
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl7/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl9/igt@[email protected]

* igt@kms_psr2_su@page_flip:
- shard-iclb: [PASS][26] -> [SKIP][27] ([fdo#109642] / [fdo#111068])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb2/igt@kms_psr2_su@page_flip.html
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb6/igt@kms_psr2_su@page_flip.html

* igt@kms_psr@no_drrs:
- shard-iclb: [PASS][28] -> [FAIL][29] ([fdo#108341])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb7/igt@kms_psr@no_drrs.html
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb1/igt@kms_psr@no_drrs.html

* igt@kms_psr@psr2_cursor_plane_move:
- shard-iclb: [PASS][30] -> [SKIP][31] ([fdo#109441]) +1 similar issue
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb2/igt@kms_psr@psr2_cursor_plane_move.html
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb5/igt@kms_psr@psr2_cursor_plane_move.html

* igt@kms_setmode@basic:
- shard-apl: [PASS][32] -> [FAIL][33] ([fdo#99912])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-apl4/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-apl3/igt@[email protected]
- shard-skl: [PASS][34] -> [FAIL][35] ([fdo#99912])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl9/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl3/igt@[email protected]

* igt@perf@polling:
- shard-skl: [PASS][36] -> [FAIL][37] ([fdo#110728])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl5/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl1/igt@[email protected]

#### Possible fixes ####

* igt@gem_ctx_isolation@bcs0-dirty-create:
- shard-kbl: [FAIL][38] -> [PASS][39] +2 similar issues
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-kbl7/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-kbl2/igt@[email protected]

* igt@gem_ctx_isolation@bcs0-none:
- shard-skl: [FAIL][40] -> [PASS][41] +5 similar issues
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl8/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl2/igt@[email protected]
- shard-glk: [FAIL][42] -> [PASS][43]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-glk4/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-glk1/igt@[email protected]

* igt@gem_ctx_isolation@vecs0-none:
- shard-apl: [FAIL][44] -> [PASS][45]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-apl4/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-apl3/igt@[email protected]

* igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [SKIP][46] ([fdo#110841]) -> [PASS][47]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb4/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb5/igt@[email protected]

* igt@gem_eio@in-flight-contexts-immediate:
- shard-snb: [FAIL][48] -> [PASS][49]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-snb7/igt@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-snb2/igt@[email protected]

* igt@gem_exec_schedule@preempt-other-bsd:
- shard-iclb: [SKIP][50] ([fdo#111325]) -> [PASS][51] +2 similar issues
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb2/igt@[email protected]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb5/igt@[email protected]

* igt@gem_softpin@softpin:
- shard-skl: [TIMEOUT][52] ([fdo#111732 ]) -> [PASS][53]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl6/igt@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl2/igt@[email protected]

* igt@gem_userptr_blits@dmabuf-unsync:
- shard-snb: [DMESG-WARN][54] ([fdo#111870]) -> [PASS][55]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-snb2/igt@[email protected]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-snb2/igt@[email protected]

* igt@gem_userptr_blits@map-fixed-invalidate-overlap-busy:
- shard-hsw: [DMESG-WARN][56] ([fdo#111870]) -> [PASS][57]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-hsw2/igt@[email protected]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-hsw6/igt@[email protected]

* igt@gem_workarounds@suspend-resume-context:
- shard-apl: [DMESG-WARN][58] ([fdo#108566]) -> [PASS][59] +4 similar issues
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-apl6/igt@[email protected]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-apl4/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-skl: [FAIL][60] ([fdo#105363]) -> [PASS][61]
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl10/igt@[email protected]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl8/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-rgb565-draw-mmap-cpu:
- {shard-tglb}: [FAIL][62] ([fdo#103167]) -> [PASS][63] +8 similar issues
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-tglb2/igt@[email protected]
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-tglb2/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt:
- shard-iclb: [FAIL][64] ([fdo#103167]) -> [PASS][65] +5 similar issues
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb3/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html

* igt@kms_plane@plane-panning-bottom-right-pipe-b-planes:
- {shard-tglb}: [INCOMPLETE][66] -> [PASS][67] +1 similar issue
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-tglb2/igt@[email protected]
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-tglb6/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
- shard-skl: [FAIL][68] ([fdo#108145]) -> [PASS][69]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-skl10/igt@[email protected]
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-skl8/igt@[email protected]

* igt@kms_psr@psr2_sprite_mmap_gtt:
- shard-iclb: [SKIP][70] ([fdo#109441]) -> [PASS][71] +1 similar issue
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb8/igt@kms_psr@psr2_sprite_mmap_gtt.html
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html

* igt@kms_psr@psr2_suspend:
- {shard-tglb}: [INCOMPLETE][72] ([fdo#111832]) -> [PASS][73]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-tglb7/igt@kms_psr@psr2_suspend.html
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-tglb6/igt@kms_psr@psr2_suspend.html

* igt@prime_vgem@wait-bsd2:
- shard-iclb: [SKIP][74] ([fdo#109276]) -> [PASS][75] +13 similar issues
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb8/igt@[email protected]
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb4/igt@[email protected]

#### Warnings ####

* igt@gem_mocs_settings@mocs-reset-bsd2:
- shard-iclb: [FAIL][76] ([fdo#111330]) -> [SKIP][77] ([fdo#109276])
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb2/igt@[email protected]
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb5/igt@[email protected]

* igt@gem_mocs_settings@mocs-settings-bsd2:
- shard-iclb: [SKIP][78] ([fdo#109276]) -> [FAIL][79] ([fdo#111330]) +1 similar issue
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7011/shard-iclb7/igt@[email protected]
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/shard-iclb1/igt@[email protected]

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

[fdo# 111852 ]: https://bugs.freedesktop.org/show_bug.cgi?id= 111852 [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
[fdo#110548]: https://bugs.freedesktop.org/show_bug.cgi?id=110548
[fdo#110728]: https://bugs.freedesktop.org/show_bug.cgi?id=110728
[fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
[fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
[fdo#111597]: https://bugs.freedesktop.org/show_bug.cgi?id=111597
[fdo#111646]: https://bugs.freedesktop.org/show_bug.cgi?id=111646
[fdo#111732 ]: https://bugs.freedesktop.org/show_bug.cgi?id=111732
[fdo#111747]: https://bugs.freedesktop.org/show_bug.cgi?id=111747
[fdo#111832]: https://bugs.freedesktop.org/show_bug.cgi?id=111832
[fdo#111850]: https://bugs.freedesktop.org/show_bug.cgi?id=111850
[fdo#111870]: https://bugs.freedesktop.org/show_bug.cgi?id=111870
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (11 -> 11)
------------------------------

No changes in participating hosts

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

* CI: CI-20190529 -> None
* Linux: CI_DRM_7011 -> Patchwork_14674

CI-20190529: 20190529
CI_DRM_7011: 7d13733c2a87909eef8bc945ecbf4d47e0b67133 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5212: d17a484b3c22706b2b004ef1577f367d79235e43 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14674: 9db91fb25dfffa036289696db0609e06a0b7a1ff @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14674/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH v3 02/21] drm/i915: introduce intel_memory_region

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:33)

Quoted 36 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +36 -0
+int
+i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
+{
+       struct intel_memory_region *mem = obj->mm.region;
+       struct list_head *blocks = &obj->mm.blocks;
+       unsigned int flags = I915_ALLOC_MIN_PAGE_SIZE;
+       resource_size_t size = obj->base.size;
+       resource_size_t prev_end;
+       struct i915_buddy_block *block;
+       struct sg_table *st;
+       struct scatterlist *sg;
+       unsigned int sg_page_sizes;
+       unsigned long i;
+       int ret;
+
+       st = kmalloc(sizeof(*st), GFP_KERNEL);
+       if (!st)
+               return -ENOMEM;
+
+       if (sg_alloc_table(st, size >> ilog2(mem->mm.chunk_size), GFP_KERNEL)) {
+               kfree(st);
+               return -ENOMEM;
+       }
+
+       ret = __intel_memory_region_get_pages_buddy(mem, size, flags, blocks);
+       if (ret)
+               goto err_free_sg;
+
+       GEM_BUG_ON(list_empty(blocks));
+
+       sg = st->sgl;
+       st->nents = 0;
+       sg_page_sizes = 0;
+       i = 0;
+
+       list_for_each_entry(block, blocks, link) {

drivers/gpu/drm/i915/gem/i915_gem_region.c line 66

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+               u64 block_size, offset;
+
+               block_size = i915_buddy_block_size(&mem->mm, block);
+               offset = i915_buddy_block_offset(block);
+
+               GEM_BUG_ON(overflows_type(block_size, sg->length));
+
+               if (!i || offset != prev_end ||
+                   add_overflows_t(typeof(sg->length), sg->length, block_size)) {
+                       if (i) {

i is only being here to detect the start.
prev_end = (resource_size_t)-1;
Then I don't have to worry about i overflowing, although that seems harmless, and as ridiculous as that may be.

Quoted 38 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +37 -0
+                               sg_page_sizes |= sg->length;
+                               sg = __sg_next(sg);
+                       }
+
+                       sg_dma_address(sg) = mem->region.start + offset;
+                       sg_dma_len(sg) = block_size;
+
+                       sg->length = block_size;
+
+                       st->nents++;
+               } else {
+                       sg->length += block_size;
+                       sg_dma_len(sg) += block_size;
+               }
+
+               prev_end = offset + block_size;
+               i++;
+       };
+
+       sg_page_sizes |= sg->length;
+       sg_mark_end(sg);
+       i915_sg_trim(st);
+
+       __i915_gem_object_set_pages(obj, st, sg_page_sizes);
+
+       return 0;
+
+err_free_sg:
+       sg_free_table(st);
+       kfree(st);
+       return ret;
+}
 
+struct drm_i915_gem_object *
+i915_gem_object_create_region(struct intel_memory_region *mem,
+                             resource_size_t size,
+                             unsigned int flags)
+{

drivers/gpu/drm/i915/gem/i915_gem_region.c line 126

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+       struct drm_i915_gem_object *obj;
+
+       if (!mem)
+               return ERR_PTR(-ENODEV);
+
+       size = round_up(size, mem->min_page_size);
+
+       GEM_BUG_ON(!size);
+       GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_MIN_ALIGNMENT));
+

Put the FIXME here from the start

drivers/gpu/drm/i915/gem/i915_gem_region.c line 134

Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +8 -0
+       if (size >> PAGE_SHIFT > INT_MAX)
+               return ERR_PTR(-E2BIG);
+
+       if (overflows_type(size, obj->base.size))
+               return ERR_PTR(-E2BIG);
+
+       return mem->ops->create_object(mem, size, flags);
+}

I'm happy with this. But I would like a discussion on why resource_size_t was chosen and for that rationale to be captured in the code comments. At the end of the day, we need to bump obj->base.size to suit.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH v3 03/21] drm/i915/region: support contiguous allocations

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:34)

drivers/gpu/drm/i915/gem/i915_gem_region.c i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj) · line 111

Quoted 11 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c +3 -1
@@ -98,10 +103,12 @@ i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
 }
 
 void i915_gem_object_init_memory_region(struct drm_i915_gem_object *obj,
-                                       struct intel_memory_region *mem)
+                                       struct intel_memory_region *mem,
+                                       unsigned long flags)
 {
        INIT_LIST_HEAD(&obj->mm.blocks);
        obj->mm.region = intel_memory_region_get(mem);
+       obj->flags = flags;

This is odd as you don't necessarily have exclusive control of obj->flags

Looks like this may be a wart in the api.

Quoted 21 lines
drivers/gpu/drm/i915/selftests/intel_memory_region.c +21 -0
+static struct drm_i915_gem_object *
+igt_object_create(struct intel_memory_region *mem,
+                 struct list_head *objects,
+                 u64 size,
+                 unsigned int flags)
+{
+       struct drm_i915_gem_object *obj;
+       int err;
+
+       obj = i915_gem_object_create_region(mem, size, flags);
+       if (IS_ERR(obj))
+               return obj;
+
+       err = i915_gem_object_pin_pages(obj);
+       if (err)
+               goto put;
+
+       list_add(&obj->st_link, objects);
+       return obj;
+
+put:

drivers/gpu/drm/i915/selftests/intel_memory_region.c static int igt_mock_fill(void *arg) · line 120

Quoted 10 lines
drivers/gpu/drm/i915/selftests/intel_memory_region.c +10 -0
+       i915_gem_object_put(obj);
+       return ERR_PTR(err);
+}
+
+static void igt_object_release(struct drm_i915_gem_object *obj)
+{
+       i915_gem_object_unpin_pages(obj);
+       __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+       i915_gem_object_put(obj);
+       list_del(&obj->st_link);

Did you just put the object before operating on it? Did you have a spare reference lying around? :)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v3 4/21
#10 lore raw

Re: [PATCH v3 04/21] drm/i915/region: support volatile objects

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:35)

drivers/gpu/drm/i915/intel_memory_region.h struct intel_memory_region { · line 59

Quoted 13 lines
drivers/gpu/drm/i915/intel_memory_region.h +5 -0
index 29b86ca17dd9..323270a1ef67 100644
@@ -52,6 +52,11 @@ struct intel_memory_region {
        unsigned int type;
        unsigned int instance;
        unsigned int id;
+
+       /* Protects access to objects and purgeable */
+       struct mutex obj_lock;
+       struct list_head objects;
+       struct list_head purgeable;

Looks good. Minor suggestion would to be wrap this in a sub-struct,

	struct {
		struct mutex mutex; /* Protects access to objects */
		struct list_head list; /* yeah, not the best */
		struct list_head purgeable;
	} objects;

drivers/gpu/drm/i915/intel_memory_region.h struct intel_memory_region { · line 60

Quoted 1 line
drivers/gpu/drm/i915/intel_memory_region.h +0 -0
 };

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

#12 lore raw

Re: [PATCH v3 05/21] drm/i915: Add memory region information to device_info

In reply to Matthew Auld

Quoting Matthew Auld (2019-10-04 18:04:36)

Quoted 17 lines

From: Abdiel Janulgue <[email protected]>

Exposes available regions for the platform. Shared memory will always be available.

---
 drivers/gpu/drm/i915/i915_drv.h          | 2 ++
 drivers/gpu/drm/i915/intel_device_info.h | 2 ++
 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index dcbc6e6394fc..b7be46faef2d 100644

drivers/gpu/drm/i915/i915_drv.h IS_SUBPLATFORM(const struct drm_i915_private *i915, · line 2132

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2129,6 +2129,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
 
 #define HAS_IPC(dev_priv)               (INTEL_INFO(dev_priv)->display.has_ipc)
 
+#define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i))

HAS_REGION() is very unclear.

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

#5 lore raw

Re: [PATCH v3 02/21] drm/i915: introduce intel_memory_region

In reply to Chris Wilson
Quoted 104 lines · Chris Wilson

Quoting Matthew Auld (2019-10-04 18:04:33)

Quoted 36 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +36 -0
+int
+i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
+{
+       struct intel_memory_region *mem = obj->mm.region;
+       struct list_head *blocks = &obj->mm.blocks;
+       unsigned int flags = I915_ALLOC_MIN_PAGE_SIZE;
+       resource_size_t size = obj->base.size;
+       resource_size_t prev_end;
+       struct i915_buddy_block *block;
+       struct sg_table *st;
+       struct scatterlist *sg;
+       unsigned int sg_page_sizes;
+       unsigned long i;
+       int ret;
+
+       st = kmalloc(sizeof(*st), GFP_KERNEL);
+       if (!st)
+               return -ENOMEM;
+
+       if (sg_alloc_table(st, size >> ilog2(mem->mm.chunk_size), GFP_KERNEL)) {
+               kfree(st);
+               return -ENOMEM;
+       }
+
+       ret = __intel_memory_region_get_pages_buddy(mem, size, flags, blocks);
+       if (ret)
+               goto err_free_sg;
+
+       GEM_BUG_ON(list_empty(blocks));
+
+       sg = st->sgl;
+       st->nents = 0;
+       sg_page_sizes = 0;
+       i = 0;
+
+       list_for_each_entry(block, blocks, link) {

drivers/gpu/drm/i915/gem/i915_gem_region.c line 66

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+               u64 block_size, offset;
+
+               block_size = i915_buddy_block_size(&mem->mm, block);
+               offset = i915_buddy_block_offset(block);
+
+               GEM_BUG_ON(overflows_type(block_size, sg->length));
+
+               if (!i || offset != prev_end ||
+                   add_overflows_t(typeof(sg->length), sg->length, block_size)) {
+                       if (i) {

i is only being here to detect the start.
prev_end = (resource_size_t)-1;
Then I don't have to worry about i overflowing, although that seems harmless, and as ridiculous as that may be.

Quoted 38 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +37 -0
+                               sg_page_sizes |= sg->length;
+                               sg = __sg_next(sg);
+                       }
+
+                       sg_dma_address(sg) = mem->region.start + offset;
+                       sg_dma_len(sg) = block_size;
+
+                       sg->length = block_size;
+
+                       st->nents++;
+               } else {
+                       sg->length += block_size;
+                       sg_dma_len(sg) += block_size;
+               }
+
+               prev_end = offset + block_size;
+               i++;
+       };
+
+       sg_page_sizes |= sg->length;
+       sg_mark_end(sg);
+       i915_sg_trim(st);
+
+       __i915_gem_object_set_pages(obj, st, sg_page_sizes);
+
+       return 0;
+
+err_free_sg:
+       sg_free_table(st);
+       kfree(st);
+       return ret;
+}
 
+struct drm_i915_gem_object *
+i915_gem_object_create_region(struct intel_memory_region *mem,
+                             resource_size_t size,
+                             unsigned int flags)
+{

drivers/gpu/drm/i915/gem/i915_gem_region.c line 126

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+       struct drm_i915_gem_object *obj;
+
+       if (!mem)
+               return ERR_PTR(-ENODEV);
+
+       size = round_up(size, mem->min_page_size);
+
+       GEM_BUG_ON(!size);
+       GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_MIN_ALIGNMENT));
+

Put the FIXME here from the start

Quoted 13 lines

drivers/gpu/drm/i915/gem/i915_gem_region.c line 134

Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +8 -0
+       if (size >> PAGE_SHIFT > INT_MAX)
+               return ERR_PTR(-E2BIG);
+
+       if (overflows_type(size, obj->base.size))
+               return ERR_PTR(-E2BIG);
+
+       return mem->ops->create_object(mem, size, flags);
+}

I'm happy with this. But I would like a discussion on why resource_size_t was chosen and for that rationale to be captured in the code comments. At the end of the day, we need to bump obj->base.size to suit.

No good reason, I guess it just stems from using "struct resource region". Maybe for the object_create interface we should just use u64?

On that topic should we also stop using "struct resource" here, since that's starting to get confusing, maybe use u64 there also?

Quoted 2 lines

-Chris

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

#6 lore raw

Re: [PATCH v3 02/21] drm/i915: introduce intel_memory_region

Quoting Matthew Auld (2019-10-08 12:57:50)

Quoted 119 lines · Chris Wilson
Quoted 104 lines

Quoting Matthew Auld (2019-10-04 18:04:33)

Quoted 36 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +36 -0
+int
+i915_gem_object_get_pages_buddy(struct drm_i915_gem_object *obj)
+{
+       struct intel_memory_region *mem = obj->mm.region;
+       struct list_head *blocks = &obj->mm.blocks;
+       unsigned int flags = I915_ALLOC_MIN_PAGE_SIZE;
+       resource_size_t size = obj->base.size;
+       resource_size_t prev_end;
+       struct i915_buddy_block *block;
+       struct sg_table *st;
+       struct scatterlist *sg;
+       unsigned int sg_page_sizes;
+       unsigned long i;
+       int ret;
+
+       st = kmalloc(sizeof(*st), GFP_KERNEL);
+       if (!st)
+               return -ENOMEM;
+
+       if (sg_alloc_table(st, size >> ilog2(mem->mm.chunk_size), GFP_KERNEL)) {
+               kfree(st);
+               return -ENOMEM;
+       }
+
+       ret = __intel_memory_region_get_pages_buddy(mem, size, flags, blocks);
+       if (ret)
+               goto err_free_sg;
+
+       GEM_BUG_ON(list_empty(blocks));
+
+       sg = st->sgl;
+       st->nents = 0;
+       sg_page_sizes = 0;
+       i = 0;
+
+       list_for_each_entry(block, blocks, link) {

drivers/gpu/drm/i915/gem/i915_gem_region.c line 66

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+               u64 block_size, offset;
+
+               block_size = i915_buddy_block_size(&mem->mm, block);
+               offset = i915_buddy_block_offset(block);
+
+               GEM_BUG_ON(overflows_type(block_size, sg->length));
+
+               if (!i || offset != prev_end ||
+                   add_overflows_t(typeof(sg->length), sg->length, block_size)) {
+                       if (i) {

i is only being here to detect the start.
prev_end = (resource_size_t)-1;
Then I don't have to worry about i overflowing, although that seems harmless, and as ridiculous as that may be.

Quoted 38 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +37 -0
+                               sg_page_sizes |= sg->length;
+                               sg = __sg_next(sg);
+                       }
+
+                       sg_dma_address(sg) = mem->region.start + offset;
+                       sg_dma_len(sg) = block_size;
+
+                       sg->length = block_size;
+
+                       st->nents++;
+               } else {
+                       sg->length += block_size;
+                       sg_dma_len(sg) += block_size;
+               }
+
+               prev_end = offset + block_size;
+               i++;
+       };
+
+       sg_page_sizes |= sg->length;
+       sg_mark_end(sg);
+       i915_sg_trim(st);
+
+       __i915_gem_object_set_pages(obj, st, sg_page_sizes);
+
+       return 0;
+
+err_free_sg:
+       sg_free_table(st);
+       kfree(st);
+       return ret;
+}
 
+struct drm_i915_gem_object *
+i915_gem_object_create_region(struct intel_memory_region *mem,
+                             resource_size_t size,
+                             unsigned int flags)
+{

drivers/gpu/drm/i915/gem/i915_gem_region.c line 126

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +10 -0
+       struct drm_i915_gem_object *obj;
+
+       if (!mem)
+               return ERR_PTR(-ENODEV);
+
+       size = round_up(size, mem->min_page_size);
+
+       GEM_BUG_ON(!size);
+       GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_MIN_ALIGNMENT));
+

Put the FIXME here from the start

Quoted 13 lines

drivers/gpu/drm/i915/gem/i915_gem_region.c line 134

Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_region.c new file +8 -0
+       if (size >> PAGE_SHIFT > INT_MAX)
+               return ERR_PTR(-E2BIG);
+
+       if (overflows_type(size, obj->base.size))
+               return ERR_PTR(-E2BIG);
+
+       return mem->ops->create_object(mem, size, flags);
+}

I'm happy with this. But I would like a discussion on why resource_size_t was chosen and for that rationale to be captured in the code comments. At the end of the day, we need to bump obj->base.size to suit.

Quoted 2 lines

No good reason, I guess it just stems from using "struct resource region". Maybe for the object_create interface we should just use u64?

resource_size_t is definitely a better starting point than size_t, and afaik is the preferred type for this physical usage, even when dma_addr_t conflicts. But that just feels strange, and I couldn't find any definitive guide. So writing down why we chose the type will help the inevitable later discussions.

Quoted 2 lines

On that topic should we also stop using "struct resource" here, since that's starting to get confusing, maybe use u64 there also?

Well, I'm still looking at struct resource and thinking/hoping it may lead to us reusing more shared lib/ routines. So I'm ambivalent here. :)

My core objective here is supporting [in thought experiments at least] 4+GiB local memory on 32b platforms. To pull it off would need a bit more cleaning up (so that we never expose more than we have to) to stay within the dma budget -- and that has interesting ramifications onto iomem (we would need a mappable/non-mappable split again, or maybe the HW will only allow what can be mapped???)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx