@@ -496,13 +496,16 @@ static int i915_gem_init_stolen(struct intel_memory_region *mem)
* memory, so just consider the start. */
reserved_total = stolen_top - reserved_base;
+ i915->stolen_usable_size =
+ resource_size(&i915->dsm) - reserved_total;
+
drm_dbg(&i915->drm,
"Memory reserved for graphics device: %lluK, usable: %lluK\n",
(u64)resource_size(&i915->dsm) >> 10,
- ((u64)resource_size(&i915->dsm) - reserved_total) >> 10);
+ i915->stolen_usable_size >> 10);
- i915->stolen_usable_size =
- resource_size(&i915->dsm) - reserved_total;
+ if (i915->stolen_usable_size == 0)
+ return 0;
/* Basic memrange allocator for stolen space. */
drm_mm_init(&i915->mm.stolen, 0, i915->stolen_usable_size);
@@ -205,6 +205,11 @@ static int intel_memory_region_memtest(struct intel_memory_region *mem,
if (!mem->io_start)
return 0;
+ if ((mem->type == INTEL_MEMORY_STOLEN_LOCAL ||
+ mem->type == INTEL_MEMORY_STOLEN_SYSTEM) &&
+ !drm_mm_initialized(&i915->mm.stolen))
+ return 0;
+
if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) || i915->params.memtest)
err = iomemtest(mem, i915->params.memtest, caller);