From: Steve Carbonari <steven.carbon...@intel.com> Add check for zero usable stolen memory before calling drm_mm_init to support configurations where stolen memory exists but is fully reserved.
Also skip memory test in such case. v2: - convert stolen_usable_size to u64 so build do not break depending on PHYS_ADDR_T_64BIT config. Cc: Ville Syrjälä <ville.syrj...@linux.intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospu...@intel.com> Signed-off-by: José Roberto de Souza <jose.so...@intel.com> Signed-off-by: Steve Carbonari <steven.carbon...@intel.com> --- drivers/gpu/drm/i915/gem/i915_gem_stolen.c | 9 ++++++--- drivers/gpu/drm/i915/intel_memory_region.c | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c index 1de73a6449652..44972da1d4e95 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_stolen.c @@ -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); + (u64)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); diff --git a/drivers/gpu/drm/i915/intel_memory_region.c b/drivers/gpu/drm/i915/intel_memory_region.c index c70d7e286a512..329f46f71cdce 100644 --- a/drivers/gpu/drm/i915/intel_memory_region.c +++ b/drivers/gpu/drm/i915/intel_memory_region.c @@ -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); -- 2.35.1